本篇文章為大家展示了docker如何搭建elasticsearch集群,內(nèi)容簡明扼要并且容易理解,絕對(duì)能使你眼前一亮,通過這篇文章的詳細(xì)介紹希望你能有所收獲。
為隴縣等地區(qū)用戶提供了全套網(wǎng)頁設(shè)計(jì)制作服務(wù),及隴縣網(wǎng)站建設(shè)行業(yè)解決方案。主營業(yè)務(wù)為成都網(wǎng)站設(shè)計(jì)、做網(wǎng)站、隴縣網(wǎng)站設(shè)計(jì),以傳統(tǒng)方式定制建設(shè)網(wǎng)站,并提供域名空間備案等一條龍服務(wù),秉承以專業(yè)、用心的態(tài)度為用戶提供真誠的服務(wù)。我們深信只要達(dá)到每一位用戶的要求,就會(huì)得到認(rèn)可,從而選擇與我們長期合作。這樣,我們也可以走得更遠(yuǎn)!
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文件內(nèi)容為:
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文件內(nèi)容為:
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文件內(nèi)容為:
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
執(zhí)行下面命令
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
在宿主機(jī)解壓
unzip elasticsearch-analysis-ik-5.6.8.zip
并改文件夾名為ik
mv elasticsearch ik
復(fù)制解壓后的ik到docker鏡像目錄
docker cp ik es-node1:/usr/share/elasticsearch/plugins
docker restart 容器id
如果要單點(diǎn)運(yùn)行 ,可以把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要寫容器內(nèi)部的ip,查看容器內(nèi)部的ip命令
docker inspect
上述內(nèi)容就是docker如何搭建elasticsearch集群,你們學(xué)到知識(shí)或技能了嗎?如果還想學(xué)到更多技能或者豐富自己的知識(shí)儲(chǔ)備,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。