我使用docker-compose在我的本地计算机(mac)上创建了一个简单的elasticsearch“cluster”。配置如下所示
version: '2.2'
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:6.2.4
environment:
- cluster.name=elasticsearch
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
- "index.number_of_replicas: 1"
- "index.number_of_shards: 2"
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- esdata1:/usr/share/elasticsearch/data
ports:
- 9200:9200
networks:
- esnet
volumes:
esdata1:
driver: local
networks:
esnet:
现在我想向此群集添加一个新的es节点,但我不知道如何继续。我尝试使用以下命令运行docker容器:
docker run -e "cluster.name=elasticsearch" -e "bootstrap.memory_lock: true" -e "ES_JAVA_OPTS=-Xms512m -Xmx512m" -e "discovery.zen.ping.unicast.hosts=localhost:9200" -e "network.host: _local_" -v esdata2:/usr/share/elasticsearch/data docker.elastic.co/elasticsearch/elasticsearch:6.2.4
但这似乎创建了一个单独的群集/节点,因为当我尝试访问http://127.0.0.1:9200/_cluster/health?pretty
时,我仍然只看到一个节点:
{
"cluster_name" : "elasticsearch",
"status" : "green",
"timed_out" : false,
"number_of_nodes" : 1,
"number_of_data_nodes" : 1,
"active_primary_shards" : 1,
"active_shards" : 1,
"relocating_shards" : 0,
"initializing_shards" : 0,
"unassigned_shards" : 0,
"delayed_unassigned_shards" : 0,
"number_of_pending_tasks" : 0,
"number_of_in_flight_fetch" : 0,
"task_max_waiting_in_queue_millis" : 0,
"active_shards_percent_as_number" : 100.0
}
我不确定我应该如何创建新的es节点并将其添加到我的群集中。我是否需要再次使用docker-compose,或者我在docker run
中指定的标志是否错误?
答案 0 :(得分:0)
正如official doc of Elasticsearch
所述您需要在docker-compose.yml文件中指定节点,如下所示:
version: '2.2'
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:6.2.4
container_name: elasticsearch
environment:
- cluster.name=docker-cluster
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- esdata1:/usr/share/elasticsearch/data
ports:
- 9200:9200
networks:
- esnet
elasticsearch2:
image: docker.elastic.co/elasticsearch/elasticsearch:6.2.4
container_name: elasticsearch2
environment:
- cluster.name=docker-cluster
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
- "discovery.zen.ping.unicast.hosts=elasticsearch"
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- esdata2:/usr/share/elasticsearch/data
networks:
- esnet
volumes:
esdata1:
driver: local
esdata2:
driver: local
networks:
esnet:
答案 1 :(得分:0)
根据此https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html
弹性网站上的文章,您应该为每个弹性实例指定群集名称,发现种子主机的名称。
i=0
width = 0.25
gap = .02
cols = ['BKNG','MCD','YUM']
colors= ['b','g','r']
for col in cols:
ax.bar(df.index+(i*(width+gap)), df[col], color = colors[i], width = width, label=col)
i+=1