ELK docker 安装elasticsearch 集群之二

ELK docker 安装elasticsearch 集群之一

与之一样,也在一个节点的docker启动3个容器。

// 在创建容器时,就指定IP
172.19.0.10
172.19.0.11
172.19.0.12

 

配置文件

文件es00.yml
cluster.name: elasticsearch-cluster
node.name: es00
node.master: true
node.data: true
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
network.bind_host: 0.0.0.0
network.publish_host: 172.19.0.10
http.port: 9200
transport.tcp.port: 9300
http.cors.enabled: true
http.cors.allow-origin: "*"
discovery.seed_hosts: ["172.19.0.10:9300","172.19.0.11:9301","172.19.0.12:9302"]
cluster.initial_master_nodes: ["172.19.0.10:9300"]
discovery.zen.minimum_master_nodes: 2

 

文件es01.yml
cluster.name: elasticsearch-cluster
node.name: es01
node.master: true
node.data: true
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
network.bind_host: 0.0.0.0
network.publish_host: 172.19.0.11
http.port: 9201
transport.tcp.port: 9301
http.cors.enabled: true
http.cors.allow-origin: "*"
discovery.seed_hosts: ["172.19.0.10:9300","172.19.0.11:9301","172.19.0.12:9302"]
cluster.initial_master_nodes: ["172.19.0.10:9300"]
discovery.zen.minimum_master_nodes: 2

 

文件es02.yml
cluster.name: elasticsearch-cluster
node.name: es02
node.master: true
node.data: true
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
network.bind_host: 0.0.0.0
network.publish_host: 172.19.0.12
http.port: 9202
transport.tcp.port: 9302
http.cors.enabled: true
http.cors.allow-origin: "*"
discovery.seed_hosts: ["172.19.0.10:9300","172.19.0.11:9301","172.19.0.12:9302"]
cluster.initial_master_nodes: ["172.19.0.10:9300"]
discovery.zen.minimum_master_nodes: 2

 

启动命令

docker run -e ES_JAVA_OPTS="-Xms128m -Xmx128m" -d --net esnetwork --ip 172.19.0.10 -p 9200:9200 -p 9300:9300 -v /home/soft/ES/config/es00.yml:/usr/share/elasticsearch/config/elasticsearch.yml -v /home/soft/ES/data/data00:/usr/share/elasticsearch/data -v /home/soft/ES/logs/logs00:/usr/share/elasticsearch/logs --name es00 elasticsearch:7.1.1

docker run -e ES_JAVA_OPTS="-Xms128m -Xmx128m" -d --net esnetwork --ip 172.19.0.11 -p 9201:9201 -p 9301:9301 -v /home/soft/ES/config/es01.yml:/usr/share/elasticsearch/config/elasticsearch.yml -v /home/soft/ES/data/data01:/usr/share/elasticsearch/data  -v /home/soft/ES/logs/logs01:/usr/share/elasticsearch/logs --name es01 elasticsearch:7.1.1

docker run -e ES_JAVA_OPTS="-Xms128m -Xmx128m" -d --net esnetwork --ip 172.19.0.12 -p 9202:9202 -p 9302:9302 -v /home/soft/ES/config/es02.yml:/usr/share/elasticsearch/config/elasticsearch.yml -v /home/soft/ES/data/data02:/usr/share/elasticsearch/data  -v /home/soft/ES/logs/logs02:/usr/share/elasticsearch/logs --name es02 elasticsearch:7.1.1

 

测试访问结果:

其中我部署服务器机器IP为 

192.168.89.137
[root@localhost ~]# curl http://192.168.89.137:9200/_cat/nodes?pretty
172.19.0.11 55 93 70 3.28 3.58 1.95 mdi - es01
172.19.0.10 67 93 70 3.28 3.58 1.95 mdi * es00
172.19.0.12 54 93 69 3.28 3.58 1.95 mdi - es02
[root@localhost ~]# curl http://192.168.89.137:9201/_cat/nodes?pretty
172.19.0.11 56 93 10 1.40 3.00 1.85 mdi - es01
172.19.0.12 53 93  9 1.40 3.00 1.85 mdi - es02
172.19.0.10 73 93  9 1.40 3.00 1.85 mdi * es00
[root@localhost ~]# curl http://192.168.89.137:9202/_cat/nodes?pretty
172.19.0.11 60 93 24 1.29 2.95 1.84 mdi - es01
172.19.0.12 59 93 24 1.29 2.95 1.84 mdi - es02
172.19.0.10 76 93 24 1.29 2.95 1.84 mdi * es00

 

网页访问:

 

备注:

这里很奇怪,可能是版本问题。es7与es6有一定的区别。

我本想通过192.168.89.137:9300 ,192.168.89.137:9301,192.168.89.137:9302 做集群,一致提示如下错误,意思是它一直找不到相应的节点。。

master not discovered yet, this node has not previously joined a bootstrapped (v7+) cluster, and this node must discover master-eligible nodes [192.168.89.137:9300, 192.168.89.137:9301, 192.168.89.137:9302] to bootstrap a cluster: have discovered []; discovery will continue using [192.168.89.137:9300, 192.168.89.137:9302] from hosts providers and [{es01}{KB-xJrQtRduGTCgf8DxPxw}{w6rmCqwZQ3K00Udg6Wx8bw}{192.168.89.137}{192.168.89.137:9301}{ml.machine_memory=1019629568, xpack.installed=true, ml.max_open_jobs=20}] from last-known cluster state; node term 0, last-accepted version 0 in term 0"

 

参考:https://blog.csdn.net/belonghuang157405/article/details/83301937

 

posted on 2020-02-13 14:29  陈惟鲜的博客  阅读(1584)  评论(0编辑  收藏  举报

导航