一、docker 安装es
docker run --name elasticsearch -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -e ES_JAVA_OPTS="-Xms512m -Xmx512m" -e "ES_JAVA_OPTS=-Xms512m -Xmx512m" -e xpack.ml.enabled=false -d elasticsearch:7.8.0
cd /home/dockers
docker cp elasticsearch:/usr/share/elasticsearch .
docker stop elasticsearch && docker rm elasticsearch
##修改config目录下elasticsearch.yml 文件 最下方添加 xpack.ml.enabled: false
docker run --restart=always -d -p 9200:9200 -p 9300:9300 --name elasticsearch -e ES_JAVA_OPTS="-Xms512m -Xmx512m" -e "discovery.type=single-node" -v /home/dockers/elasticsearch:/usr/share/elasticsearch docker.io/elasticsearch:7.8.0
es设置密码
1、修改config目录下elasticsearch.yml 文件
cluster.name: "docker-cluster"
network.host: 0.0.0.0
xpack.ml.enabled: false
xpack.security.enabled: true
xpack.license.self_generated.type: basic
xpack.security.transport.ssl.enabled: true
2、重启elaseticsearch
docker restart elasticsearch
3、进入容器
docker exec -it elasticsearch bash
#执行设置用户名和密码的命令,这里需要为4个用户分别设置密码,elastic, kibana, logstash_system,beats_system
bin/elasticsearch-setup-passwords interactive
4、修改密码命令如下
curl -H "Content-Type:application/json" -XPOST -u elastic 'http://127.0.0.1:9200/_xpack/security/user/elastic/_password' -d '{ "password" : "123456" }'
二、docker安装kibana
docker run -d -p 5601:5601 -e ELASTICSEARCH_URL=http://127.0.0.1:9200 --name kibana docker.io/kibana:7.8.0
docker cp kibana:/usr/share/kibana .
docker stop kibana && docker rm kibana
## 修改config 目录下elasticsearch.hosts: [ "http://192.168.3.78:9200" ] 为 es地址
docker run -d -p 5601:5601 --restart=always -v /home/dockers/kibana:/usr/share/kibana --name kibana docker.io/kibana:7.8.0
kibana 设置密码
1、修改config目录下 kibana.yml 文件
#
# ** THIS IS AN AUTO-GENERATED FILE **
#
# Default Kibana configuration for docker target
server.name: kibana
server.host: "0"
i18n.locale: "zh-CN"
elasticsearch.hosts: [ "http://192.168.3.78:9200" ]
monitoring.ui.container.elasticsearch.enabled: true
elasticsearch.username: kibana_system
elasticsearch.password: *****
2、重启kibana
docker restart kibana
三、docker 安装logstash
docker run -d -p 5044:5044 -p 5045:5045 --name logstash logstash:7.8.0docker cp logstash:/usr/share/logstash /home/dockersdocker stop logstash && docker rm logstashdocker run -d --restart=always -p 5044:5044 -p 9600:9600 --name logstash -v /home/dockers/logstash:/usr/share/logstash logstash:7.8.0
logstash.yml
http.host: "0.0.0.0"
logstash.conf
input { tcp { port => 9600 }}filter { kv { source => "message" } json { source => "message" remove_field => ["port","level_value","tags","log.path","logstash_address"] }}output { stdout { codec => rubydebug } elasticsearch { hosts => ["http://192.168.3.78:9200"] index => "springboot_%{+YYYY.MM}" codec => json user => "elastic" password => "*****" }}