- 安装 Docker
安装Docker步骤参考: https://www.jianshu.com/p/80e3fd18a17e
解决libltdl7版本过低Docker安装失败参考:https://www.jianshu.com/p/92205963ce23
- 安装 docker-compose
curl -L https://github.com/docker/compose/releases/download/{版本号}/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
版本信息可以访问https://github.com/docker/compose/releases获取
添加执行权限
chmod +x /usr/local/bin/docker-compose
安装成功,查看版本
docker-compose --version
- 安装ELK Elasticsearch、Logstash、Kibana
// 获取ES镜像:
docker pull docker.elastic.co/elasticsearch/elasticsearch:{版本号}
// 获取kibana镜像:
docker pull docker.elastic.co/kibana/kibana:{版本号}
// 获取logstash镜像:
docker pull docker.elastic.co/logstash/logstash:{版本号}
版本信息可以访问https://www.docker.elastic.co/#获取
- 部署ELK
在home下创建elkDocker目录,创建 docker-compose.yml 文件。(路径可以自由选择,需要注意权限问题)
yml内容可以参考以下模板
version: '2.2'
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:7.6.2
container_name: elasticsearch
environment:
- discovery.type=single-node
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
volumes:
- esdata:/ELKData/ELK/elasticsearch/data
hostname: elasticsearch
restart: always
ports:
- 9200:9200
- 9300:9300
kibana:
image: docker.elastic.co/kibana/kibana:7.6.2
container_name: kibana
environment:
- elasticsearch.hosts=http://elasticsearch:9200
hostname: kibana
depends_on:
- elasticsearch
restart: always
ports:
- "5601:5601"
logstash:
image: docker.elastic.co/logstash/logstash:7.6.2
container_name: logstash
volumes:
- ./logstash/logstash.conf:/usr/share/logstash/config/logstash.conf
hostname: logstash
command: logstash -f /usr/share/logstash/config/logstash.conf
restart: always
depends_on:
- elasticsearch
- redis
ports:
- 9600:9600
- 5044:5044
nginx:
image: nginx:latest
container_name: nginx
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf
- ./nginx/htpasswd.users:/etc/nginx/htpasswd.users
ports:
- "80:80"
restart: always
depends_on:
- kibana
redis:
image: redis:latest
container_name: redis
ports:
- "6379:6379"
restart: always
command: redis-server --requirepass ProdELK2020
networks: {stack: {}}
# use docker volume to persist ES data outside of a container.
volumes:
esdata:
由于我在部署的时候用到了 nginx 和 redis ,所有 docker-compose.yml 中包含了nginx,redis的部署节点,如有需要,可以参考。
- 启动ELK
docker-compose up -d
执行上面命令后,ELK就启动了,可以通过浏览器访问。
评论