说明:
准备2台机器,我这里有192.168.0.170 和 192.168.0.169
192.168.0.170 作为master 192.168.0.169 作为普通node一、环境
1.docker 环境 2.Elasticsearch5.6.13 3.Elasticsearch-head:5 插件二、下载
head 只需要在一台机器上装就行了、我直接和master节点装在170上docker pull docker.io/elasticsearch:5.6.13
docker pull docker.io/mobz/elasticsearch-head:5三、设置elasticsearch 配置环境1、master[192.168.0.170] 配置mkdir -p /usr/local/elasticsearch/conf
touch es1.yml
es1.yml:#集群名称 所有节点要相同
cluster.name: "nova_es"#本节点名称node.name: master#作为master节点node.master: true#是否存储数据node.data: true# head插件设置http.cors.enabled: truehttp.cors.allow-origin: "*"#设置可以访问的ip 这里全部设置通过network.bind_host: 0.0.0.0#设置节点 访问的地址 设置master所在机器的ipnetwork.publish_host: 192.168.0.170 2、启动master我的配置文件 和 data所在目录都设置在物理机器上,这里-v 映射下就可以了
docker run -d --name es5_6_13master -p 9200:9200 -p 9300:9300 --privileged=true -v /usr/local/elasticsearch/conf/es1.yml:/usr/share/elasticsearch/config/elasticsearch.yml -v /usr/local/elasticsearch/data:/usr/share/elasticsearch/data elasticsearch:5.6.13
启动的时候如果报错
ERROR: [1] bootstrap checks failed
[1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
解决办法:
1、切换到root用户修改配置sysctl.confvi /etc/sysctl.conf
添加下面配置:
vm.max_map_count=655360
并执行命令:
sysctl -p
然后再执行docker start es5_6_13master 启动成功
3、node2[192.168.0.169] 配置mkdir -p /usr/local/elasticsearch/conf
touch es2.yml
es2.ymlcluster.name: "nova_es"
#子节点名称node.name: node2#不作为master节点node.master: falsenode.data: truehttp.cors.enabled: truehttp.cors.allow-origin: "*"network.bind_host: 0.0.0.0network.publish_host: 192.168.0.169#设置master地址discovery.zen.ping.unicast.hosts: [192.168.0.170] 4、启动node2docker run -d --name es5_6_13node2 -p 9200:9200 -p 9300:9300 --privileged=true -v /usr/local/elasticsearch/conf/es2.yml:/usr/share/elasticsearch/config/elasticsearch.yml -v /usr/local/elasticsearch/data:/usr/share/elasticsearch/data elasticsearch:5.6.13
5、node3[192.168.0.168] 配置
mkdir -p /usr/local/elasticsearch/conf
touch es3.yml
es3.ymlcluster.name: "nova_es"
#子节点名称node.name: node3#不作为master节点node.master: falsenode.data: truehttp.cors.enabled: truehttp.cors.allow-origin: "*"network.bind_host: 0.0.0.0network.publish_host: 192.168.0.168#设置master地址discovery.zen.ping.unicast.hosts: [192.168.0.170] 6、启动node3docker run -d --name es5_6_13node3 -p 9200:9200 -p 9300:9300 --privileged=true -v /usr/local/elasticsearch/conf/es3.yml:/usr/share/elasticsearch/config/elasticsearch.yml -v /usr/local/elasticsearch/data:/usr/share/elasticsearch/data elasticsearch:5.6.13
四、开启head查看docker run -p 9100:9100 mobz/elasticsearch-head:5打开链接 http://192.168.0.170:9100/ 查看节点状态