Docker installation Elasticsearch 5.6.3 cluster and head 5 plug-in

Environment Introduction

Centos 7.2 + Docker 17.09.0-ce + Elasticsearch 5.6.3 + elasticsearch-head 5

Mirror Pull

docker pull docker.elastic.co/elasticsearch/elasticsearch:5.6.3
docker pull mobz/elasticsearch-head:5

Profiles

elsasticsearch

es1.yml

cluster.name: "dali"
node.name: node1
node.master: true
node.data: true
# head插件设置
http.cors.enabled: true
http.cors.allow-origin: "*"
# 关闭X-Pack
xpack.security.enabled: false
network.host: 0.0.0.0
discovery.zen.minimum_master_nodes: 1

es2.yml

cluster.name: "dali"
node.name: node2
node.master: false
node.data: true
# head插件设置
http.cors.enabled: true
http.cors.allow-origin: "*"
# 关闭X-Pack
xpack.security.enabled: false
network.host: 0.0.0.0
discovery.zen.minimum_master_nodes: 1
discovery.zen.ping.unicast.hosts: es1

app.js

/* 修改localhost为elasticsearch集群地址,本机部署可不改 */
this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http://localhost:9200";

Gruntfile.js

    connect: {
            server: {
                options: {
                    /* 默认监控:127.0.0.1,修改为:0.0.0.0 */
                    hostname: '0.0.0.0',
                    port: 9100,
                    base: '.',
                    keepalive: true
                }
            }

Create a container

 # es1
docker run -d --name es1 -p 9200:9200 -p 9300:9300 -v /root/es_docker/es1.yml:/usr/share/elasticsearch/config/elasticsearch.yml -v /root/es_docker/esdata1:/usr/share/elasticsearch/data docker.elastic.co/elasticsearch/elasticsearch:5.6.2
 # es2
docker run -d --name es2 --link es1:es1 -p 9201:9200 -p 9301:9300 -v /root/es_docker/es2.yml:/usr/share/elasticsearch/config/elasticsearch.yml -v /root/es_docker/esdata2:/usr/share/elasticsearch/data docker.elastic.co/elasticsearch/elasticsearch:5.6.2
 # head
docker run -d --name head -p 9100:9100 --network esdocker_esnet -v /root/es_docker/head/Gruntfile.js:/usr/src/app/Gruntfile.js -v /root/es_docker/head/app.js:/usr/src/app/_site/app.js mobz/elasticsearch-head:5

View cluster status

curl http://192.168.56.101:9200/_cat/health?v

View Head cluster status

http://192.168.56.101:9100/

Management container

# 停止
docker stop head es1 es2
# 启动
docker start head es1 es2
# 重启
docker restart head es1 es2
# 停止并删除所有容器
docker rm -f $(docker ps -aq)

Reference Documents

https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html
https://github.com/mobz/elasticsearch-head

Released four original articles · won praise 0 · Views 7080

Guess you like

Origin blog.csdn.net/jlh21/article/details/78319947