Install ElasticSearch cluster through Docker under Mac

1. Install ElasticSearch

Use docker to directly obtain the es image. After executing the command docker pull elasticsearch:7.7.0
, execute docker images to see the image pulled in the previous step.

2. Create data to hang in the directory, and configure the ElasticSearch cluster configuration file

Create a data file mount directory
mkdir -p /home/soft/ES
mkdir -p /home/soft/ES/config
cd /home/soft/ES
Create a mount directory
mkdir data1 data2 data3
Enter the config file and create an es configuration file
cd ES/config/

3. Create an ElasticSearch configuration file

Create es1.yml, es2.yml, and es3.yml in the ES/config/ directory
and insert the picture description here
Edit
es1.yml

cluster.name: elasticsearch-cluster
node.name: es-node1
network.bind_host: 0.0.0.0
network.publish_host: 宿主ip
http.port: 9200
transport.tcp.port: 9300
http.cors.enabled: true
http.cors.allow-origin: "*"
node.master: true
node.data: true
discovery.zen.ping.unicast.hosts: ["宿主ip:9300","宿主ip:9301","宿主ip:9302"]
discovery.zen.minimum_master_nodes: 2
cluster.initial_master_nodes: ["es-node1"]

Execute the ip address command to view your own host ip, find es33
insert image description here
for example: 192.168.15.129

es2.yml
cluster.name: elasticsearch-cluster
node.name: es-node2
network.host: 0.0.0.0
network.publish_host: 宿主ip
http.port: 9201
transport.tcp.port: 9301
http.cors.enabled: true
http.cors.allow-origin: “*”
node.master: true
node.data: true
discovery.zen.ping.unicast.hosts: [“宿主ip:9300”,“宿主ip:9301”,“宿主ip:9302”]
discovery.zen.minimum_master_nodes: 2
cluster.initial_master_nodes: [“es-node1”]

es3.yml
cluster.name: elasticsearch-cluster
node.name: es-node3
network.host: 0.0.0.0
network.publish_host: 宿主ip
http.port: 9202
transport.tcp.port: 9302
http.cors.enabled: true
http.cors.allow-origin: “*”
node.master: true
node.data: true
discovery.zen.ping.unicast.hosts: [“宿主ip:9300”,“宿主ip:9301”,“宿主ip:9302”]
discovery.zen.minimum_master_nodes: 2
cluster.initial_master_nodes: [“es-node1”]

4. Start the ElasticSearch cluster container

In the centos window, execute the following command:

docker run -e ES_JAVA_OPTS="-Xms256m -Xmx256m" -d -p 9200:9200 -p 9300:9300 \
-v /home/soft/ES/config/es1.yml:/usr/share/elasticsearch/config/elasticsearch.yml \
-v /home/soft/ES/data1:/usr/share/elasticsearch/data \
--name elasticsearch01 elasticsearch:7.7.0 
 docker run -e ES_JAVA_OPTS="-Xms256m -Xmx256m" -d -p 9201:9201 -p 9301:9301 \
-v /home/soft/ES/config/es2.yml:/usr/share/elasticsearch/config/elasticsearch.yml \
-v /home/soft/ES/data2:/usr/share/elasticsearch/data \
--name elasticsearch02  elasticsearch:7.7.0
 docker run -e ES_JAVA_OPTS="-Xms256m -Xmx256m" -d -p 9202:9202 -p 9302:9302 \
-v /home/soft/ES/config/es3.yml:/usr/share/elasticsearch/config/elasticsearch.yml \
-v /home/soft/ES/data3:/usr/share/elasticsearch/data \
--name elasticsearch03 elasticsearch:7.7.0

5. Verify whether the build is successful

Visit http://192.168.xx,xx:9200/_cat/nodes?pretty in the browser address bar to view the node status
Insert picture description here

insert image description here

6. Use the elasticsearch-head front-end framework

Pull the image
docker pull mobz/elasticsearch-head:5
start the container
docker create --name es-head -p 9100:9100 mobz/elasticsearch-head:5
visit http://192.168.xx.xx:9100
insert image description here
and a rectangular frame appears Even if the three nodes are built successfully, there is no need to close the inside of the ellipse. That is the established index. After your cluster is successfully built, you can also create an index, which is displayed here.

Solution:

1.启动elasticsearch-head
2.进入head安装目录_site/vendor.js修改
①. 6886行 contentType: “application/x-www-form-urlencoded”
         改成
         contentType: “application/json;charset=UTF-8”

②. 7573var inspectData = s.contentType === “application/x-www-form-urlencoded”
        改成
       var inspectData = s.contentType === “application/json;charset=UTF-8

Guess you like

Origin blog.csdn.net/chuige2013/article/details/131040678