docker安装elk8
时间: 2023-11-16 11:01:28 浏览: 175
要在Docker上安装ELK8,您可以按照以下步骤进行操作:
1. 首先,您需要安装Docker和Docker Compose。
2. 创建一个名为docker-compose.yml的文件,并将以下内容复制到该文件中:
```
version: '3'
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:7.8.0
container_name: elasticsearch
environment:
- node.name=elasticsearch
- discovery.seed_hosts=elasticsearch
- cluster.initial_master_nodes=elasticsearch
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- esdata1:/usr/share/elasticsearch/data
ports:
- 9200:9200
networks:
- elk
kibana:
image: docker.elastic.co/kibana/kibana:7.8.0
container_name: kibana
ports:
- 5601:5601
environment:
ELASTICSEARCH_URL: http://elasticsearch:9200
ELASTICSEARCH_HOSTS: http://elasticsearch:9200
networks:
- elk
logstash:
image: docker.elastic.co/logstash/logstash:7.8.0
container_name: logstash
volumes:
- ./logstash/config/logstash.yml:/usr/share/logstash/config/logstash.yml
- ./logstash/pipeline:/usr/share/logstash/pipeline
ports:
- 5000:5000
- 9600:9600
environment:
LS_JAVA_OPTS: "-Xmx256m -Xms256m"
ELASTICSEARCH_HOST: "http://elasticsearch:9200"
networks:
- elk
volumes:
esdata1:
driver: local
networks:
elk:
```
3. 在终端中导航到包含docker-compose.yml文件的目录,并运行以下命令以启动ELK8容器:
```
docker-compose up -d
```
4. 等待一段时间,直到所有容器都启动并运行。您可以使用以下命令检查容器的状态:
```
docker ps
```
5. 现在,您可以通过浏览器访问Kibana Web界面,该界面位于http://localhost:5601。您可以使用以下命令登录到Elasticsearch:
```
docker exec -it elasticsearch /bin/bash
```
6. 最后,您可以使用Logstash将日志数据发送到Elasticsearch。要使用Logstash,请将您的配置文件放在logstash/pipeline目录中,并在docker-compose.yml文件中指定该目录的路径。
阅读全文