您好,登錄后才能下訂單哦!
本篇文章為大家展示了docker如何搭建elasticsearch集群,內容簡明扼要并且容易理解,絕對能使你眼前一亮,通過這篇文章的詳細介紹希望你能有所收獲。
docker pull docker.io/elasticsearch:5.6.8
mkdir -p /docker/es/config mkdir -p /docker/es/data1 mkdir -p /docker/es/data2 mkdir -p /docker/es/data3
touch /docker/es/config/es1.yml touch /docker/es/config/es2.yml touch /docker/es/config/es3.yml
es1.yml文件內容為:
cluster.name: elasticsearch-cluster node.name: es-node1 network.bind_host: 0.0.0.0 network.publish_host: 192.168.100.102 http.port: 9200 transport.tcp.port: 9300 http.cors.enabled: true http.cors.allow-origin: "*" node.master: true node.data: true discovery.zen.ping.unicast.hosts: ["192.168.100.102:9300","192.168.100.102:9301","192.168.100.102:9302"] discovery.zen.minimum_master_nodes: 2
es2.yml文件內容為:
cluster.name: elasticsearch-cluster node.name: es-node2 network.bind_host: 0.0.0.0 network.publish_host: 192.168.100.102 http.port: 9201 transport.tcp.port: 9301 http.cors.enabled: true http.cors.allow-origin: "*" node.master: true node.data: true discovery.zen.ping.unicast.hosts: ["192.168.100.102:9300","192.168.100.102:9301","192.168.100.102:9302"] discovery.zen.minimum_master_nodes: 2
es3.yml文件內容為:
cluster.name: elasticsearch-cluster node.name: es-node3 network.bind_host: 0.0.0.0 network.publish_host: 192.168.100.102 http.port: 9202 transport.tcp.port: 9302 http.cors.enabled: true http.cors.allow-origin: "*" node.master: true node.data: true discovery.zen.ping.unicast.hosts: ["192.168.100.102:9300","192.168.100.102:9301","192.168.100.102:9302"] discovery.zen.minimum_master_nodes: 2
在 /etc/sysctl.conf文件最后添加一行
vm.max_map_count=262144
執行下面命令
sysctl -w vm.max_map_count=262144
docker run -e ES_JAVA_OPTS="-Xms256m -Xmx256m" -d -p 9200:9200 -p 9300:9300 --privileged=true -v /docker/es/config/es1.yml:/usr/share/elasticsearch/config/elasticsearch.yml -v /docker/es/data1:/usr/share/elasticsearch/data --name es-node1 elasticsearch:5.6.8
docker run -e ES_JAVA_OPTS="-Xms256m -Xmx256m" -d -p 9201:9201 -p 9301:9301 --privileged=true -v /docker/es/config/es2.yml:/usr/share/elasticsearch/config/elasticsearch.yml -v /docker/es/data2:/usr/share/elasticsearch/data --name es-node2 elasticsearch:5.6.8
docker run -e ES_JAVA_OPTS="-Xms256m -Xmx256m" -d -p 9202:9202 -p 9302:9302 --privileged=true -v /docker/es/config/es3.yml:/usr/share/elasticsearch/config/elasticsearch.yml -v /docker/es/data3:/usr/share/elasticsearch/data --name es-node3 elasticsearch:5.6.8
docker pull mobz/elasticsearch-head:5 docker run -di --name=es-head -p 9100:9100 docker.io/mobz/elasticsearch-head:5
下載分詞器插件:https://github.com/medcl/elasticsearch-analysis-ik/releases/tag/v5.6.8
在宿主機解壓
unzip elasticsearch-analysis-ik-5.6.8.zip
并改文件夾名為ik
mv elasticsearch ik
復制解壓后的ik到docker鏡像目錄
docker cp ik es-node1:/usr/share/elasticsearch/plugins
docker restart 容器id
如果要單點運行 ,可以把es-node2 es-node3 停掉 并且注釋掉es1.yml配置文件中的部分配置
cluster.name: elasticsearch-cluster node.name: es-node1 network.bind_host: 0.0.0.0 http.port: 9200 transport.tcp.port: 9300 http.cors.enabled: true http.cors.allow-origin: "*" node.data: true #network.publish_host: 192.168.100.102 #node.master: true #discovery.zen.ping.unicast.hosts: ["192.168.100.102:9300","192.168.100.102:9301","192.168.100.102:9302"] #discovery.zen.minimum_master_nodes: 2
docker run -it -d -e ELASTICSEARCH_URL=http://172.17.0.2:9200 --name kibana -p 5601:5601 kibana:5.6.8
es 的 URL要寫容器內部的ip,查看容器內部的ip命令
docker inspect <container id>
上述內容就是docker如何搭建elasticsearch集群,你們學到知識或技能了嗎?如果還想學到更多技能或者豐富自己的知識儲備,歡迎關注億速云行業資訊頻道。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。