部署ES
1、安装docker-compose
sudo curl -L "https://github.com/docker/compose/releases/download/1.24.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
docker-compose --version
2、elasticsearch
docker pull docker.elastic.co/elasticsearch/elasticsearch:6.4.0
vim /etc/sysctl.conf
vm.max_map_count=262144
vim /etc/security/limits.conf
soft nofile 65536
hard nofile 65536
3、创建文件和目录
mkdir /home/docker/elasticsearch -p
cd /home/docker/elasticsearch
mkdir config
vim elasticsearch.yml
cd /home/docker/elasticsearch
vim docker-compose.yml
mkdir data
4、elasticsearch.yml
cluster.name: "docker-cluster"
node.name: "search-node1"
network.host: 0.0.0.0
network.publish_host: 172.16.3.64
# minimum_master_nodes need to be explicitly set when bound on a public IP
# # set to 1 to allow single node clusters
# # Details: https://github.com/elastic/elasticsearch/pull/17288
discovery.zen.minimum_master_nodes: 1
discovery.zen.ping.unicast.hosts: ["172.16.3.63:9300", "172.16.3.64:9300"]
5、docker-compose.yml
version: '2.2'
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:6.4.0
container_name: elasticsearch
environment:
- cluster.name=docker-cluster
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ulimits:
memlock:
soft: -1
hard: -1
network_mode: host
volumes:
- /home/docker/elasticsearch/data:/usr/share/elasticsearch/data
- /home/docker/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
6、在每个服务器的docker-compose.yml 同级目录下同时执行 docker-compose up –d 命令,根据服务器性能,大概等待1分钟左右,两个节点的集群就创建成功了,当然可以通过执行以下命令查看启动状态:
docker-compose up –d
docker logs elasticsearch -f
7、查看集群的所有节点:
curl 172.16.232.107:9200/_cat/nodes?v
Last updated