1、下载官网镜像
因为要在外网隔离环境部署,所以需要将image下载后再搬迁过去
docker pull docker.elastic.co/elasticsearch/elasticsearch:8.14.2
docker pull docker.elastic.co/kibana/kibana:8.14.2
docker image ls
docker save da0e65225d10 -o es8.14.2.tar
docker save 0456bfa956a9 -o kibana8.14.2.tar
目标环境机器上导入镜像:
docker load -i es8.14.2.tar
docker load -i kibana8.14.2.tar
docker tag da0e65225d10 es:8.14.2
docker tag 0456bfa956a9 kibana:8.14.2
配置环境变量
export ELASTIC_PASSWORD="Admin1234" # password for "elastic" username
export KIBANA_PASSWORD="Admin1234" # Used _internally_ by Kibana, must be at least 6 characters long
2、安装es
docker network create elastic-net
启动es容器:
docker run -p 0.0.0.0:9200:9200 -d --name elasticsearch --network elastic-net \
-e ELASTIC_PASSWORD=$ELASTIC_PASSWORD \
-e "discovery.type=single-node" \
-e "xpack.security.http.ssl.enabled=false" \
-e "xpack.license.self_generated.type=trial" \
es:8.14.2
3、安装kibana
# 给es添加kibana用户密码
curl -u elastic:$ELASTIC_PASSWORD \
-X POST \
http://localhost:9200/_security/user/kibana_system/_password \
-d '{"password":"'"$KIBANA_PASSWORD"'"}' \
-H 'Content-Type: application/json'
启动kibana容器:
docker run -p 0.0.0.0:8081:5601 -d --name kibana --network elastic-net \
-e ELASTICSEARCH_URL=http://9.8.173.221:9200 \
-e ELASTICSEARCH_HOSTS=http://9.8.173.221:9200 \
-e ELASTICSEARCH_USERNAME=kibana_system \
-e ELASTICSEARCH_PASSWORD=$KIBANA_PASSWORD \
-e "xpack.security.enabled=false" \
-e "xpack.license.self_generated.type=trial" \
kibana:8.14.2
4、登陆kibana
用户名和密码:elastic/Admin1234
5、问题记录
问题1: WARNING: IPv4 forwarding is disabled. Networking will not work
vim /etc/sysctl.conf
net.ipv4.ip_forward=1
systemctl restart network
sysctl net.ipv4.ip_forward
6、其他
6.1、kibana上查询数据
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
POST /test_index/_search?pretty { "size": "30", "query": { "match_all": {} }, "sort": [ { "timestamp": { "order": "desc" } } ] } |