您好,登錄后才能下訂單哦!
今天就跟大家聊聊有關Docker中怎么部署elasticsearch,可能很多人都不太了解,為了讓大家更加了解,小編給大家總結了以下內容,希望大家根據這篇文章可以有所收獲。
version: '2' services: elasticsearch: image: elasticsearch:7.12.0 container_name: es01 environment: - "discovery.type=single-node" - "ES_JAVA_OPTS=-Xmx256m -Xms256m" - xpack.security.enabled=true - xpack.license.self_generated.type=basic - xpack.security.transport.ssl.enabled=true volumes: - /opt/docker/elasticsearch/data:/usr/share/elasticsearch/data:rw - /opt/docker/elasticsearch/plugins:/usr/share/elasticsearch/plugins - /opt/docker/elasticsearch/logs:/usr/share/elasticsearch/logs ports: - "9200:9200" - "9300:9300" networks: - elk networks: elk: driver: bridge
繼部署單機,快速使用后,設置密碼只需要加上xpack相關配置即可
重啟容器(docker-compose restart)后,進入容器生成密碼
# 進入容器 root# docker exec -it es01 /bin/bash # 在容器內,執行自動生成密碼命令 [root@8b97a00d4223 elasticsearch]# bin/elasticsearch-setup-passwords auto Initiating the setup of passwords for reserved users elastic,apm_system,kibana,kibana_system,logstash_system,beats_system,remote_monitoring_user. The passwords will be randomly generated and printed to the console. Please confirm that you would like to continue [y/N]y Changed password for user apm_system PASSWORD apm_system = *** Changed password for user kibana_system PASSWORD kibana_system = *** Changed password for user kibana PASSWORD kibana = *** Changed password for user logstash_system PASSWORD logstash_system = *** Changed password for user beats_system PASSWORD beats_system = *** Changed password for user remote_monitoring_user PASSWORD remote_monitoring_user = *** Changed password for user elastic PASSWORD elastic = ***
至此密碼已經設置成功,可以使用對應用戶名和密碼訪問了,***為自動生成的密碼,記住即可。
若要重置密碼,修改配置,注釋掉這一行配置后重啟容器:
#- xpack.security.enabled=true
然后訪問
curl -XGET "http://localhost:9200/_cat/indices?pretty" -H 'Content-Type: application/json'
會出現一個索引: .security-7 ,刪除即可
curl -XDELETE http://localhost:9200/.security-7
看完上述內容,你們對Docker中怎么部署elasticsearch有進一步的了解嗎?如果還想了解更多知識或者相關內容,請關注億速云行業資訊頻道,感謝大家的支持。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。