1>拉取鏡像 docker pull elasticsearch:7.6.2 2>創建數據掛在目錄,以及配置ElasticSearch集群配置文件 mkdir /docker/ES mkdir /docker/ES/data1 mkdir /docker/ES/data2 mkdir /docker ...
1>拉取鏡像
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/,如下圖表示
(如果是阿裡雲伺服器,記得在安全組中加埠策略開放相應的埠號)
白駒過隙,當看到比你優秀的人比你還努力的時候,你也會越來越優秀,相信越努力越幸運!