安裝步驟:
一菇绵、容器編排腳本
在你的目錄新建個(gè)文件夾 創(chuàng)建 docker-compose.yml
version: "3.1"
# 服務(wù)配置
services:
elasticsearch:
container_name: elasticsearch-8.8.1
image: docker.elastic.co/elasticsearch/elasticsearch:8.8.1
# 用來(lái)給容器root權(quán)限(不安全)可移除
privileged: true
# 在linux里ulimit命令可以對(duì)shell生成的進(jìn)程的資源進(jìn)行限制
ulimits:
memlock:
soft: -1
hard: -1
environment:
- "ES_JAVA_OPTS=-Xms1024m -Xmx1024m"
- "http.host=0.0.0.0"
- "node.name=elastic01"
- "cluster.name=cluster_elasticsearch"
- "discovery.type=single-node"
ports:
- "9200:9200"
- "9300:9300"
volumes:
# - ./elasticsearch/config:/usr/share/elasticsearch/config
- ./elasticsearch/data:/usr/share/elasticsearch/data
- ./elasticsearch/plugin:/usr/share/elasticsearch/plugins
networks:
- elastic_net
kibana:
container_name: kibana-8.8.1
image: docker.elastic.co/kibana/kibana:8.8.1
ports:
- "5601:5601"
# volumes:
# - ./kibana/config:/usr/share/kibana/config
networks:
- elastic_net
# 網(wǎng)絡(luò)配置
networks:
elastic_net:
driver: bridge
二滞谢、容器映射目錄配置
2.1 掛在卷 同步配置
# 啟動(dòng)服務(wù)
docker-compose up -d
# 在docker-compose 目錄中俐东,執(zhí)行容器文件拷貝到宿主機(jī)
# 1.創(chuàng)建 kibana 映射目錄
# 2.拷貝 elasticsearch 配置
# 3.拷貝 kibana 配置
mkdir kibana
docker cp elasticsearch-8.8.1:/usr/share/elasticsearch/config ./elasticsearch/config
docker cp kibana-8.8.1:/usr/share/kibana/config ./kibana/config
2.2 elasticsearch配置
# 集群節(jié)點(diǎn)名稱
node.name: "elastic01"
# 設(shè)置集群名稱為elasticsearch
cluster.name: "cluster_elasticsearch"
# 網(wǎng)絡(luò)訪問(wèn)限制
network.host: 0.0.0.0
# 以單一節(jié)點(diǎn)模式啟動(dòng)
discovery.type: single-node
# 是否支持跨域
http.cors.enabled: true
# 表示支持所有域名
http.cors.allow-origin: "*"
# 內(nèi)存交換的選項(xiàng)俺祠,官網(wǎng)建議為true
bootstrap.memory_lock: true
# 修改安全配置 關(guān)閉 證書(shū)校驗(yàn)
xpack.security.http.ssl:
enabled: false
xpack.security.transport.ssl:
enabled: false
2.3 kibana配置
# Default Kibana configuration for docker target
i18n.locale: zh-CN
server.host: "0.0.0.0"
server.shutdownTimeout: "5s"
elasticsearch.hosts: [ "http://elasticsearch:9200" ]
monitoring.ui.container.elasticsearch.enabled: true
#此處為新生成的kibana賬號(hào)和密碼
elasticsearch.username: "kibana_system"
elasticsearch.password: "Wgnm5flBNMi*xQW5yHww"
2.4 重啟服務(wù)加載配置
# 1\. 首先放開(kāi) docker-compose.yml 中的注釋
- ./elasticsearch/config:/usr/share/elasticsearch/config
- ./kibana/config:/usr/share/kibana/config
# 2\. 更新容器
docker-compose up -d
# 3.訪問(wèn)地址:
elastic:http://localhost:9200
kibana:http://localhost:5601
三、訪問(wèn)elasticsearch
重置 elastic 用戶密碼
# 重置 elastic 用戶密碼
docker exec -it elasticsearch-8.8.1 /usr/share/elasticsearch/bin/elasticsearch-reset-password -uelastic
# 提示如下 輸入 y:
This tool will reset the password of the [elastic] user to an autogenerated value.
The password will be printed in the console.
Please confirm that you would like to continue [y/N]
# 輸入后顯示結(jié)果 xxxxxx 即為密碼
Password for the [elastic] user successfully reset.
New value: xxxxxx
4.3 密碼kibana重置
# 重置 kibana_system 用戶密碼
docker exec -it elasticsearch-8.8.1 /usr/share/elasticsearch/bin/elasticsearch-reset-password -ukibana_system
# 提示如下 輸入 y:
This tool will reset the password of the [kibana_system] user to an autogenerated value.
The password will be printed in the console.
Please confirm that you would like to continue [y/N]
# 輸入后顯示結(jié)果 xxxxxx 即為密碼
Password for the [kibana_system] user successfully reset.
New value: xxxxxx
4.4 提示輸入驗(yàn)證碼
# 驗(yàn)證碼獲取
docker exec -it kibana-8.8.1 /usr/share/kibana/bin/kibana-verification-code
# 輸入結(jié)果
Your verification code is: xxx xxx
本地測(cè)試賬號(hào)密碼
本地elasticSearch賬號(hào)密碼:
賬號(hào):elastic
密碼:-KNVfdUof92By2WznPsi
本地kibana賬號(hào)密碼:
賬號(hào):kibana_system
密碼:Wgnm5flBNMi*xQW5yHww