Docker----基于docker搭建es三节点集群

测试环境搭建es集群

服务名称 IP地址 端口
es-node1 172.17.3.135 9200,9300
es-node2 172.17.3.123 9200,9300
es-node3 172.17.3.99 9200,9300

连接的是客户端节点,内网连接172.17.3.135:9300(java),172.17.3.135:9200 (node)

docker搭建es-node1

1.先创建一个简单的容器,首先将es的配置文件拷贝至本地
docker run -p 9200:9200 -p 9300:9300 --restart=always --name es -d registry.cn-beijing.aliyuncs.com/qianjia2018/qianjia_dev:es-ik-pinyin
docker cp es:/usr/share/elasticsearch/config  /qj/es-node1/config
docker cp es:/usr/share/elasticsearch/logs  /qj/es-node1/logs
docker cp es:/usr/share/elasticsearch/data  /qj/es-node1/data

- 注:需要将config目录 、logs目录和 data目录拷贝出至宿主机。并设置775权限

2.修改es-node1配置文件
配置文件目录:/qj/es-node1

/config目录下的elasticsearch.yml文件

cluster.name: elasticsearch

node.name: es-node1
node.master: false
node.data: false

network.bind_host: 0.0.0.0
network.publish_host: 172.17.3.135

http.port: 9200
transport.tcp.port: 9300

http.cors.enabled: true
http.cors.allow-origin: "*"

discovery.zen.ping.unicast.hosts: ["172.17.3.135:9300", "172.17.3.99:9300", "172.17.3.123:9300"]
discovery.zen.minimum_master_nodes: 1

indices.query.bool.max_clause_count: 10000

docker启动命令:

docker run -d -p 9200:9200 -p 9300:9300 --name es -v /qj/es-node1/config/:/usr/share/elasticsearch/config -v /qj/es-node1/data/:/usr/share/elasticsearch/data -v/qj/es-node1/logs:/usr/share/elasticsearch/logs -v /etc/localtime:/etc/localtime -v /etc/timezone:/etc/timezone --restart=always registry.cn-beijing.aliyuncs.com/qianjia2018/qianjia_dev:es-ik-pinyin

3.修改es-node2配置文件
配置文件目录:/qj/es-node2
cluster.name: elasticsearch

node.name: es-node2
node.master: true
node.data: true

network.bind_host: 0.0.0.0
network.publish_host: 172.17.3.123

http.port: 9200
transport.tcp.port: 9300

http.cors.enabled: true
http.cors.allow-origin: "*"

discovery.zen.ping.unicast.hosts: ["172.17.3.135:9300", "172.17.3.99:9300", "172.17.3.123:9300"]
discovery.zen.minimum_master_nodes: 1

indices.query.bool.max_clause_count: 10000

docker启动命令:

docker run -d -p 9200:9200 -p 9300:9300 --name es-node2 -v /qj/es-node2/config/:/usr/share/elasticsearch/config -v /qj/es-node2/data/:/usr/share/elasticsearch/data -v/qj/es-node2/logs:/usr/share/elasticsearch/logs -v /etc/localtime:/etc/localtime -v /etc/timezone:/etc/timezone --restart=always registry.cn-beijing.aliyuncs.com/qianjia2018/qianjia_dev:es-ik-pinyin

4.修改es-node3配置文件
配置文件目录:/qj/es-node3
cluster.name: elasticsearch

node.name: es-node3
node.master: true
node.data: true

network.bind_host: 0.0.0.0
network.publish_host: 172.17.3.99

http.port: 9200
transport.tcp.port: 9300

http.cors.enabled: true
http.cors.allow-origin: "*"

discovery.zen.ping.unicast.hosts: ["172.17.3.135:9300","172.17.3.99:9300","172.17.3.123:9300"]
discovery.zen.minimum_master_nodes: 1

indices.query.bool.max_clause_count: 10000

docker启动命令:

docker run -d -p 9200:9200 -p 9300:9300 --name es-node3 -v /qj/es-node3/config/:/usr/share/elasticsearch/config -v /qj/es-node3/data/:/usr/share/elasticsearch/data -v/qj/es-node3/logs:/usr/share/elasticsearch/logs -v /etc/localtime:/etc/localtime -v /etc/timezone:/etc/timezone --restart=always registry.cn-beijing.aliyuncs.com/qianjia2018/qianjia_dev:es-ik-pinyin

你可能感兴趣的:(Docker----基于docker搭建es三节点集群)