千家信息网

docker中怎么搭建elastatic集群

发表于:2025-02-01 作者:千家信息网编辑
千家信息网最后更新 2025年02月01日,这篇文章给大家介绍docker中怎么搭建elastatic集群,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。cd /roottouch node1/config/elastic
千家信息网最后更新 2025年02月01日docker中怎么搭建elastatic集群

这篇文章给大家介绍docker中怎么搭建elastatic集群,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。

cd /roottouch  node1/config/elasticsearch.ymltouch  node2/config/elasticsearch.ymlchmod 775 /root/node1/config/elasticsearch.ymlchmod 775 /root/node2/config/elasticsearch.yml

/root/node1/config/elasticsearch.yml配置如下:

http.host: 0.0.0.0cluster.name: elastic-ckynode.name: es1node.master: truenode.data: truebootstrap.system_call_filter: falsetransport.host: 0.0.0.0discovery.zen.minimum_master_nodes: 1http.cors.enabled: truehttp.cors.allow-origin: "*"


/root/node2/config/elasticsearch.yml配置如下:

http.host: 0.0.0.0cluster.name: elastic-ckynode.name: es2node.master: truenode.data: truebootstrap.system_call_filter: falsetransport.host: 0.0.0.0discovery.zen.minimum_master_nodes: 1discovery.zen.ping.unicast.hosts: ["es1:9300"]http.cors.enabled: truehttp.cors.allow-origin: "*"

说明:

跨域请求http.cors.enabled: true  http.cors.allow-origin: "*"


启动如下:

cd /rootdocker run --name es1 -p 9201:9200 -p 9301:9300 -v "$PWD/node1/config/elasticsearch.yml":/usr/share/elasticsearch/config/elasticsearch.yml --ulimit nofile=65536:131072  -e "ES_JAVA_OPTS=-Xms512m -Xmx512m" -d elasticsearch  docker run --name es2 -p 9202:9200 -p 9302:9300 -v "$PWD/node2/config/elasticsearch.yml":/usr/share/elasticsearch/config/elasticsearch.yml --ulimit nofile=65536:131072 --link es1:es1  -e "ES_JAVA_OPTS=-Xms512m -Xmx512m" -d elasticsearch

检测是否成功

docker exec -it es2 /bin/bashcurl http://localhost:9200/_cat/health

效果:

root@1256b78663ef:/usr/share/elasticsearch# curl http://localhost:9200/_cat/health 1563959266 09:07:46 elastic-cky green 1 1 0 0 0 0 0 0 - 100.0%

插件elasticsearch-head 浏览器访问

docker run -d --name es-head -p 9100:9100 mobz/elasticsearch-head:5

浏览器访问:xxx:9100

关于docker中怎么搭建elastatic集群就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。

0