docker centos7 installed under a cluster es

1> Pull mirror

docker pull elasticsearch:5.6.8

2> Create Data hanging in the directory, and to configure the cluster configuration file ElasticSearch

mkdir /docker/ES

mkdir /docker/ES/data1

mkdir /docker/ES/data2

mkdir /docker/ES/data3

mkdir /docker/ES/config

Create a configuration file in the config folder

touch es1.yml es2.yml es3.yml

Edit es1.yml file

vi es1.yml

cluster.name: elasticsearch-cluster // cluster name
node.name: es-node1 // node name
network.bind_host: 0.0.0.0
network.publish_host: your IP // external IP
http.port: 9200 // access port
transport.tcp.port: 9300 // this parameter indicates forwarded to the 9300 through 9200
http.cors.enabled: to true
http.cors.allow-Origin: "*"
node.master: // to true whether it is the primary cluster
node. data: true // whether to store data
discovery.zen.ping.unicast.hosts: [ "your IP: 9300", "your IP: 9301", "your IP: 9302"]
discovery.zen.minimum_master_nodes: 1 // this parameter indicates the number of master

vi es2.yml

cluster.name: elasticsearch-cluster
node.name: es-node2
network.bind_host: 0.0.0.0
network.publish_host: 47.112.214.91
http.port: 9201
transport.tcp.port: 9301
http.cors.enabled: true
http.cors.allow-origin: "*"
node.master: false
node.data: true
discovery.zen.ping.unicast.hosts: ["你的IP:9300","你的IP:9301","你的IP:9302"]
discovery.zen.minimum_master_nodes: 1

vi es3.yml

cluster.name: elasticsearch-cluster
node.name: es-node3
network.bind_host: 0.0.0.0
network.publish_host: 47.112.214.91
http.port: 9202
transport.tcp.port: 9302
http.cors.enabled: true
http.cors.allow-origin: "*"
node.master: false
node.data: true 
discovery.zen.ping.unicast.hosts: ["你的IP:9300","你的IP:9301","你的IP:9302"]
discovery.zen.minimum_master_nodes: 1

Add a firewall:

firewall-cmd --add-port=9300/tcp

firewall-cmd --add-port=9301/tcp

firewall-cmd --add-port=9302/tcp

Change file created folder permissions:

chmod 777 data1 data2 data3

3> Start ElasticSearch cluster container

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:5.6.8

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:5.6.8

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:5.6.8

 

4> View es Launch OK

curl 127.0.0.1:9200

Or enter in your browser to http: // your ip: 9200, the figure below displays the content is successful

 

5> View cluster health status

curl '127.0.0.1:9200/_cat/health?pretty=true'

Or type in the browser http: // your ip: 9200 / _cat / health pretty = true?

 

6> using elasticsearch-head front end frame

Pulling mirror docker pull mobz / elasticsearch-head: 5

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

Browser access http://192.168.9.219:9100/, the following figure shows

 

(If Ali is the cloud server, remember to add port policies open the appropriate port number in the security group)

 

Guess you like

Origin www.cnblogs.com/caihuaxing/p/11025013.html