centos7下的docker安装ES集群
docker pull elasticsearch:7.6.2
2>创建数据挂在目录,以及配置ElasticSearch集群配置文件
mkdir /docker/ES
mkdir /docker/ES/data1
mkdir /docker/ES/data2
mkdir /docker/ES/data3
mkdir /docker/ES/config
在config文件夹下创建配置文件
touch es1.yml es2.yml es3.yml
编辑es1.yml文件
vi es1.yml
cluster.name: hzmt-es-cluster
node.name: es-node1
network.bind_host: 0.0.0.0
network.publish_host: 192.168.10.122
http.port: 9200
transport.tcp.port: 9300
http.cors.enabled: true
http.cors.allow-origin: "*"
node.master: true
node.data: true
discovery.zen.minimum_master_nodes: 2
discovery.seed_hosts: ["192.168.10.122:9300","192.168.10.122:9301","192.168.10.122:9302"]
cluster.initial_master_nodes: ["es-node1","es-node2","es-node3"]
vi es2.yml
cluster.name: hzmt-es-cluster
node.name: es-node1
network.bind_host: 0.0.0.0
network.publish_host: 192.168.10.122
http.port: 9200
transport.tcp.port: 9300
http.cors.enabled: true
http.cors.allow-origin: "*"
node.master: true
node.data: true
discovery.zen.minimum_master_nodes: 2
discovery.seed_hosts: ["192.168.10.122:9300","192.168.10.122:9301","192.168.10.122:9302"]
cluster.initial_master_nodes: ["es-node1","es-node2","es-node3"]
vi es3.yml
cluster.name: hzmt-es-cluster
node.name: es-node1
network.bind_host: 0.0.0.0
network.publish_host: 192.168.10.122
http.port: 9200
transport.tcp.port: 9300
http.cors.enabled: true
http.cors.allow-origin: "*"
node.master: true
node.data: true
discovery.zen.minimum_master_nodes: 2
discovery.seed_hosts: ["192.168.10.122:9300","192.168.10.122:9301","192.168.10.122:9302"]
cluster.initial_master_nodes: ["es-node1","es-node2","es-node3"]
添加防火墙:
firewall-cmd --add-port=9300/tcp
firewall-cmd --add-port=9301/tcp
firewall-cmd --add-port=9302/tcp
改变创建的文件夹权限:
chmod 777 data1 data2 data3
3>启动ElasticSearch集群容器
docker run -e ES_JAVA_OPTS="-Xms256m -Xmx256m" -d -p 9200:9200 -p 9300:9300 -v /docker/ES/config/es1.yml:/usr/share/elasticsearch/config/elasticsearch.yml -v /docker/ES/data1:/usr/share/elasticsearch/data --name ES01 elasticsearch:7.6.2
docker run -e ES_JAVA_OPTS="-Xms256m -Xmx256m" -d -p 9201:9201 -p 9301:9301 -v /docker/ES/config/es2.yml:/usr/share/elasticsearch/config/elasticsearch.yml -v /docker/ES/data2:/usr/share/elasticsearch/data --name ES02 elasticsearch:7.6.2
docker run -e ES_JAVA_OPTS="-Xms256m -Xmx256m" -d -p 9202:9202 -p 9302:9302 -v /docker/ES/config/es3.yml:/usr/share/elasticsearch/config/elasticsearch.yml -v /docker/ES/data3:/usr/share/elasticsearch/data --name ES03 elasticsearch:7.6.2
4>查看es是否启动成功
curl 127.0.0.1:9200
或者在你浏览器输入 http://你的ip:9200,显示下图内容则是成功
5>查看集群健康状态
curl ‘127.0.0.1:9200/_cat/health?pretty=true‘
或者在浏览器输入 http://你的ip:9200/_cat/health?pretty=true
6>使用elasticsearch-head前端框架
拉取镜像 docker pull mobz/elasticsearch-head:5
启动容器 docker run -d -p 9100:9100 --name es-manager mobz/elasticsearch-head:5
浏览器访问http://自己的ip:9100/,如下图表示
(如果是阿里云服务器,记得在安全组中加端口策略开放相应的端口号)
白驹过隙,当看到比你优秀的人比你还努力的时候,你也会越来越优秀,相信越努力越幸运!