1、ES部署(docker方式)
1、部署elaseticsearch
1.1、docker下载
docker pull elasticsearch
docker images
mkdir -p /usr/local/elasticsearch/{config,logs/{node0,node1,node2},data/{node0,node1,node2}}
cd /usr/local/elasticsearch/config
touch es0.yml es1.yml es2.yml
chmod -R 777 /usr/local/elasticsearch/data/*
chmod -R 777 /usr/local/elasticsearch/logs/*
chmod -R 777 /usr/local/elasticsearch/config/*
echo vm.max_map_count=221 >> /etc/sysctl.conf
sysctl -p
1.2、es配置
vi es0.yml
cluster.name: elasticsearch-cluster
node.name: es-node1 node.master: true node.data: true
network.bind_host: 0.0.0.0 network.publish_host: 192.168.30.128
http.port: 9200 transport.tcp.port: 9300
http.cors.enabled: true http.cors.allow-origin: "*"
discovery.zen.ping.unicast.hosts: ["192.168.30.128:9300","192.168.30.128:9301","192.168.30.128:9302"] discovery.zen.minimum_master_nodes: 2
|
vi es1.yml
uster.name: elasticsearch-cluster
node.name: es-node2 node.master: true node.data: true
network.bind_host: 0.0.0.0 network.publish_host: 192.168.30.128
http.port: 9201 transport.tcp.port: 9301
http.cors.enabled: true http.cors.allow-origin: "*"
discovery.zen.ping.unicast.hosts: ["192.168.30.128:9300","192.168.30.128:9301","192.168.30.128:9302"] discovery.zen.minimum_master_nodes: 2
|
vi es2.yml
cluster.name: elasticsearch-cluster
node.name: es-node3 node.master: true node.data: true
network.bind_host: 0.0.0.0 network.publish_host: 192.168.30.128
http.port: 9202 transport.tcp.port: 9302
http.cors.enabled: true http.cors.allow-origin: "*"
discovery.zen.ping.unicast.hosts: ["192.168.30.128:9300","192.168.30.128:9301","192.168.30.128:9302"] discovery.zen.minimum_master_nodes: 2 |
1.3、ES容器启动
docker run -e ES_JAVA_OPTS="-Xms256m -Xmx256m" -d -p 9200:9200 -p 9300:9300 -v /usr/local/elasticsearch/config/es0.yml:/usr/share/elasticsearch/config/elasticsearch.yml -v /usr/local/elasticsearch/data/node0:/usr/share/elasticsearch/data --name ES01 elasticsearch
docker run -e ES_JAVA_OPTS="-Xms256m -Xmx256m" -d -p 9201:9201 -p 9301:9301 -v /usr/local/elasticsearch/config/es1.yml:/usr/share/elasticsearch/config/elasticsearch.yml -v /usr/local/elasticsearch/data/node1:/usr/share/elasticsearch/data --name ES02 elasticsearch
docker run -e ES_JAVA_OPTS="-Xms256m -Xmx256m" -d -p 9202:9202 -p 9302:9302 -v /usr/local/elasticsearch/config/es2.yml:/usr/share/elasticsearch/config/elasticsearch.yml -v /usr/local/elasticsearch/data/node2:/usr/share/elasticsearch/data --name ES03
1.4、查看集群状态:
http://192.168.30.128:9200/_cat/nodes?pretty
2、安装elasticsearch-head
docker pull mobz/elasticsearch-head:5
docker run -d -p 9100:9100 --name es-manager mobz/elasticsearch-head:5
2.2、访问es: