yum -y install epel-release
yum -y install python-pip
// 更新pip
pip install --upgrade pip
// 安装docker-compoes,如已安装,跳过
pip install docker-compose
// 下载elasticsearch,logstash,kibana, 自es5开始,一般三个软件的版本都保持一致了。
docker pull docker.elastic.co/elasticsearch/elasticsearch:7.1.1 && docker pull docker.elastic.co/logstash/logstash:7.1.1 && docker pull docker.elastic.co/kibana/kibana:7.1.1
Configuration
- (Use docker-compose starting a set of choreographed container) we create a directory used to store files yml
mkdir -p /lizheng/elk
cd /lizheng/elk
vim docker-compose.yml
- docker-compose.yml document reads as follows
version: '3'
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:7.1.1
container_name: elasticsearch7.1.1
environment:
- node.name=node-40
- network.publish_host=172.168.50.41
- network.host=0.0.0.0
- discovery.seed_hosts=172.168.50.40,172.168.50.240,172.168.50.41
- cluster.initial_master_nodes=172.168.50.40,172.168.50.240,172.168.50.41
- cluster.name=es-cluster
#- http.cors.enabled=true
#- http.cors.allow-origin="*"
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
#- discovery.type=single-node
volumes:
- esdata:/usr/share/elasticsearch/data
- /root/elk/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
hostname: elasticsearch
restart: always
ports:
- 9200:9200
- 9300:9300
kibana:
image: docker.elastic.co/kibana/kibana:7.1.1
container_name: kibana7.1.1
environment:
- elasticsearch.hosts=http://elasticsearch:9200
hostname: kibana
depends_on:
- elasticsearch
restart: always
ports:
- 5601:5601
logstash:
image: docker.elastic.co/logstash/logstash:7.1.1
container_name: logstash7.1.1
hostname: logstash
restart: always
depends_on:
- elasticsearch
ports:
- 9600:9600
- 5044:5044
volumes:
esdata:
driver: local
- In the current directory, start elk
docker-compose up -d
Appears done for success, docker-compose logs to view the log (output log elk are three services) execution docker ps can see the operating status of the three services
Enter your browser to http: // IP: 5601 /
- Es can be used to monitor head
// 拉取镜像
docker pull mobz/elasticsearch-head:5
// 启动
docker run -d --name es_admin -p 9100:9100 mobz/elasticsearch-head:5
- In the browser input http: // IP: 9100
Note, IP address to use in your server's address es, then click the link, the instructions that appear similar display, no problem, I have here is three nodes, you should have only one node.
- If you click the link does not respond, F12 to view the network is 403, or 200, but the console prompt cross-domain, you need to set up cross-domain, said the following two methods
方法1: 直接进入容器中,使用 docker exec -it 容器ID /bin/bash ,进入后修改/usr/share/elasticsearch/config/elasticsearch.yml文件,
加入以下两行:
http.cors.enabled: true
http.cors.allow-origin: "*"
方法2:将容器中的es配置文件映射到宿主机,然后加入以上两行配置重启即可,映射文件就不说了,如果不会,参考 https://www.cnblogs.com/lz0925/p/12011026.html
- Refer to the original address: https://blog.51cto.com/13555423/2442499?source=dra