es安装
1.拉取es7.17.5
docker run -d \
--name elasticsearch \
--restart always \
-e "ES_JAVA_OPTS=-Xms1g -Xmx1g" \
-e "discovery.type=single-node" \
-e "bootstrap.memory_lock=true" \
--privileged \
-p 9200:9200 \
-p 9300:9300 \
elasticsearch:7.17.5
2.挂载es路径
docker cp elasticsearch:/usr/share/elasticsearch/data /opt/es
docker cp elasticsearch:/usr/share/elasticsearch/config /opt/es
docker cp elasticsearch:/usr/share/elasticsearch/plugins /opt/es
docker cp elasticsearch:/usr/share/elasticsearch/bin /opt/es
3.赋权
chmod 777 /opt/es/data
4.删除容器
docker rm -f elasticsearch
5.重新安装
docker run -d \
--name elasticsearch \
--restart always \
-e "ES_JAVA_OPTS=-Xms2g -Xmx2g" \
-e "discovery.type=single-node" \
-e "bootstrap.memory_lock=true" \
-v /opt/es/data:/usr/share/elasticsearch/data \
-v /opt/es/config:/usr/share/elasticsearch/config \
-v /opt/es/plugins:/usr/share/elasticsearch/plugins \
-v /opt/es/bin:/usr/share/elasticsearch/bin \
--privileged \
-p 9200:9200 \
-p 9300:9300 \
elasticsearch:7.17.5
kibana安装
1.拉取kibana7.17.5
docker run -d \
--name kibana \
--restart always \
-e "ELASTICSEARCH_URL=http://x.x.x.x:9200" \
-p 5601:5601 \
kibana:7.17.5
2.挂载kibana路径
docker cp kibana:/usr/share/kibana/data /opt/kibana
docker cp kibana:/usr/share/kibana/config /opt/kibana
docker cp kibana:/usr/share/kibana/plugins /opt/kibana
docker cp kibana:/usr/share/kibana/bin /opt/kibana
3.删除容器
docker rm -f kibana
4.重新安装
docker run -d \
--name kibana \
--restart always \
-e "ELASTICSEARCH_URL=http://x.x.x.x:9200" \
-p 5601:5601 \
-v /opt/kibana/data:/usr/share/kibana/data \
-v /opt/kibana/config:/usr/share/kibana/config \
-v /opt/kibana/plugins:/usr/share/kibana/plugins \
-v /opt/kibana/bin:/usr/share/kibana/bin \
--link elasticsearch:elasticsearch \
kibana:7.17.5
es与kibana加密
1.进入es容器
docker exec -it elasticsearch bash
cd config
2.在 elasticsearch.yml 中添加如下配置
配置X-Pack
echo "http.cors.enabled: true" >> elasticsearch.yml
echo "http.cors.allow-origin: "*"" >> elasticsearch.yml
echo "http.cors.allow-headers: Authorization" >> elasticsearch.yml
echo "xpack.security.enabled: true" >> elasticsearch.yml
echo "xpack.security.transport.ssl.enabled: true" >> elasticsearch.yml
3.查询elasticsearch的yml文件
cat elasticsearch.yml
查询结果如下:
http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-headers: Authorization
xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true
4.重启elasticsearch服务
docker restart elasticsearch
5.设置elasticsearch密码
docker exec -it elasticsearch bash
#继续执行
/usr/share/elasticsearch/bin/elasticsearch-setup-passwords interactive
#按提示输入密码
123456
6. 配置es账号密码设置kibana访问,修改kibana.yml配置对应账号密码
进入容器
docker exec -it kibana bash
cd config
在 kibana.yml 中添加如下配置
echo 'elasticsearch.username: "elastic"' >> kibana.yml
echo 'elasticsearch.password: "123456"' >> kibana.yml
查询kibana的yml文件
cat kibana.yml
查询结果如下:
elasticsearch.username: "elastic"
elasticsearch.password: "123456"
配置完成后访问测试
http://x.x.x.x:9200
http://x.x.x.x:5601