One, the pit that was stepped on
1. You cannot start the elasticsearch cluster with the root account
The root account is used when installing docker. When starting the elasticsearch cluster, an error will be reported.
2. ssh cannot connect to the server
After tossing himself for a long time, he finally raised the work order, and Brother Ali helped to solve it. He must praise him and respond quickly and solve quickly. If you encounter problems with the server and cannot solve them for more than 2 hours, don't do it yourself, unless your purpose is to toss the server. The purpose like me is to learn elasticsearch, so don't spend too much time in other areas and be targeted.
3. Kibana cannot connect to the es cluster
The configuration file is incorrect, you need to specify the master node.
environment:
- ELASTICSEARCH_HOSTS=http://es01:9200
# 需要将Kibana配置文件中的小写转换成大写,然后这个才能用于变量,才能被设置到
- I18N_LOCALE=zh-CN
- xpack.monitoring.ui.container.elasticsearch.enabled=false
4. Install docker-compose
I tried to install through python-pip, but python-pip could not be installed. After an hour of tossing, I gave up decisively.
curl -L https://github.com/docker/compose/releases/download/1.24.1/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
Second, the configuration file
1. Directory structure
/usr/local/elasticsearch
docker-compose.yml
data
es01
es02
es03
config
es01
elasticsearch.yml
es02
elasticsearch.yml
es03
elasticsearch.yml
logs
es01
es02
es03
2 , docker-compose.yml
version: '2'
services:
cerebro:
image: lmenezes/cerebro:0.8.4
container_name: cerebro
ports:
- "9000:9000"
command:
- -Dhosts.0.host=http://elasticsearch:9200
networks:
- esnet
kibana:
image: kibana:7.3.0
container_name: kibana
environment:
- ELASTICSEARCH_HOSTS=http://es01:9200
# 需要将Kibana配置文件中的小写转换成大写,然后这个才能用于变量,才能被设置到
- I18N_LOCALE=zh-CN
- xpack.monitoring.ui.container.elasticsearch.enabled=false
ports:
- 5601:5601
networks:
- esnet
es01:
image: docker.elastic.co/elasticsearch/elasticsearch:7.3.0
container_name: es01
restart: always
environment:
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- ./data/es01:/usr/share/elasticsearch/data
- ./config/es01/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
- ./logs/es01:/usr/share/elasticsearch/logs
ports:
- 9200:9200
- 9300:9300
networks:
- esnet
es02:
image: docker.elastic.co/elasticsearch/elasticsearch:7.3.0
container_name: es02
restart: always
environment:
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- ./data/es02:/usr/share/elasticsearch/data
- ./config/es02/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
- ./logs/es02:/usr/share/elasticsearch/logs
depends_on:
- es01
networks:
- esnet
es03:
image: docker.elastic.co/elasticsearch/elasticsearch:7.3.0
container_name: es03
restart: always
environment:
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- ./data/es03:/usr/share/elasticsearch/data
- ./config/es03/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
- ./logs/es03:/usr/share/elasticsearch/logs
depends_on:
- es01
networks:
- esnet
networks:
esnet:
3. The configuration file elasticsearch.yml of the master node of es0
cluster.name: es-cluster
node.name: es01
node.master: true
node.data: false
path.data: /usr/share/elasticsearch/data
path.logs: /usr/share/elasticsearch/logs
bootstrap.memory_lock: true
network.host: 0.0.0.0
http.port: 9200
transport.tcp.port: 9300
discovery.zen.ping.unicast.hosts: ["es01", "es02", "es03"]
cluster.initial_master_nodes: ["es01","es02","es03"]
http.cors.enabled: true
http.cors.allow-origin: "*"
xpack.security.enabled: false
xpack.security.transport.ssl.enabled: false
4. The configuration file elasticsearch.yml of the data node
```clike
cluster.name: es-cluster
node.name: es02
node.master: false
node.data: true
path.data: /usr/share/elasticsearch/data
path.logs: /usr/share/elasticsearch/logs
bootstrap.memory_lock: true
network.host: 0.0.0.0
http.port: 9200
transport.tcp.port: 9300
discovery.zen.ping.unicast.hosts: ["es01", "es02", "es03"]
cluster.initial_master_nodes: ["es01", "es02", "es03"]
http.cors.enabled: true
http.cors.allow-origin: "*"
xpack.security.enabled: false
xpack.security.transport.ssl.enabled: false
5. Start the cluster
docker-compose up