需要先安装好Docker和DockerCompose
安装的是单机版本的elasticsearch
一、安装elasticsearch 8.14.3
- 复制下面的内容到elasticsearch-compose.yaml中
services: elasticsearch: image: docker.elastic.co/elasticsearch/elasticsearch:8.14.3 container_name: elasticsearch environment: - node.name=elasticsearch - cluster.name=docker-cluster - discovery.type=single-node - bootstrap.memory_lock=true - "ES_JAVA_OPTS=-Xms512m -Xmx512m" - ELASTIC_PASSWORD=elastic - xpack.security.http.ssl.enabled=false ulimits: memlock: soft: -1 hard: -1 volumes: - esdata:/usr/share/elasticsearch/data ports: - "8800:9200" - "8801:9300" restart: unless-stopped network_mode: bridge volumes: esdata: driver: local
- 启动elasticsearch
docker-compose -f elasticsearch-compose.yaml up -d
- 创建kibana_system用户
192.168.21.101是我的ip,需要改成自己的ipcurl -u elastic:elastic -X POST http://192.168.21.101:8800/_security/user/kibana_system/_password -d '{"password":"kibana"}' -H 'Content-Type: application/json'
二、安装Kibana 8.14.3
- 复制下面的内容到kibana-compose.yaml中
192.168.21.101是我的ip,需要改成自己的ipservices: kibana: image: docker.elastic.co/kibana/kibana:8.14.3 container_name: kibana environment: - ELASTICSEARCH_HOSTS=http://192.168.21.101:8800 - ELASTICSEARCH_USERNAME=kibana_system - ELASTICSEARCH_PASSWORD=kibana ports: - 8802:5601 restart: unless-stopped network_mode: bridge
- 启动kibana
第一次启动较慢,等1到3分钟,可通过docker logs kibana -f 查看启动过程docker-compose -f kibana-compose.yaml up -d
- 修改页面为中文
- 进入到docker容器内
docker exec -it kibana /bin/bash
- 修改配置文件
第一个空行是为了强制换下行,要不会追加到最后一行的未尾echo "" >> /usr/share/kibana/config/kibana.yml echo "i18n.locale: \"zh-CN\"" >> /usr/share/kibana/config/kibana.yml
- 退出容器
exit
- 重启kibana
docker restart kibana
- 进入到docker容器内
三、登录Kibana
http://192.168.21.101:8802/
账号:elastic
密码:elastic
注意事项:
- 我本机ip是192.168.21.101,安装后elasticsearch的端口是8800,kibana的端口是8802,可以根据自己的喜好修改,但要注意上下文对应,如果elasticsearch端口改了,kibana-compose.yaml中ELASTICSEARCH_HOSTS也要改
- 因为是学习环境,因此关闭了https,因为htts证书配置比较麻烦,生产上应该开启
- 如果镜像拉不下来,可以用我的阿里云同步的镜像
- 替换docker.elastic.co/elasticsearch/elasticsearch:8.14.3为registry.cn-hangzhou.aliyuncs.com/mirror-sync/elasticsearch:8.14.3
- 替换docker.elastic.co/kibana/kibana:8.14.3为registry.cn-hangzhou.aliyuncs.com/mirror-sync/kibana:8.14.3