Docker部署elk全流程指令
时间: 2024-03-15 08:35:38 浏览: 74
以下是Docker部署ELK的全流程指令:
1. 安装Docker和Docker Compose
2. 创建一个新的目录,将以下文件分别放入该目录下:
- elasticsearch.yml
- logstash.conf
- kibana.yml
- docker-compose.yml
3. 在elasticsearch.yml中配置Elasticsearch:
```
cluster.name: "my-cluster"
network.host: 0.0.0.0
http.port: 9200
```
4. 在logstash.conf中配置Logstash:
```
input {
beats {
port => 5044
}
}
output {
elasticsearch {
hosts => ["elasticsearch:9200"]
index => "%{[@metadata][beat]}-%{[@metadata][version]}-%{+YYYY.MM.dd}"
}
}
```
5. 在kibana.yml中配置Kibana:
```
server.name: kibana
server.host: "0"
elasticsearch.hosts: ["http://elasticsearch:9200"]
```
6. 在docker-compose.yml中定义容器:
```
version: '2.2'
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:7.9.3
container_name: elasticsearch
environment:
- discovery.type=single-node
volumes:
- ./elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
- esdata:/usr/share/elasticsearch/data
ports:
- 9200:9200
networks:
- elk
logstash:
image: docker.elastic.co/logstash/logstash:7.9.3
container_name: logstash
volumes:
- ./logstash.conf:/usr/share/logstash/pipeline/logstash.conf
ports:
- 5044:5044
networks:
- elk
kibana:
image: docker.elastic.co/kibana/kibana:7.9.3
container_name: kibana
volumes:
- ./kibana.yml:/usr/share/kibana/config/kibana.yml
ports:
- 5601:5601
networks:
- elk
volumes:
esdata:
driver: local
networks:
elk:
driver: bridge
```
7. 运行以下命令启动容器:
```
docker-compose up -d
```
8. 访问Kibana的Web界面:http://localhost:5601
现在你已经成功地使用Docker部署了ELK!
阅读全文