docker 安裝es 問題


chown -R 1000:1000 /data/es/data-b/
chmod -R 777 /data/es/data-b/

最近想弄一個docker 環境,docker-composer 內容為 nginx,php,mysql,redis,elasticsearch.

但是在安裝es的時候出錯了,在網上找了幾天原因也沒找到,問題為:只要做持久化就會報錯,報錯內容如下

java.lang.IllegalStateException: failed to obtain node locks, tried [/usr/share/elasticsearch/data]; maybe these locations are not writable or multiple nodes were started on the same data path?

原來是 es鏡像的用戶是1000,所以在宿主機給改用戶賦權

chown -R 1000:1000 /data/es/data-b/
chmod -R 777 /data/es/data-b/

oK,這下不報這個錯了,但是又報內存不足的錯誤

max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

解決方案:

在/etc/sysctl.conf文件最后添加一行

vm.max_map_count=262144

執行/sbin/sysctl -p 立即生效

然后再啟動試試!!!!

注意,es8.0以上啟動的時候會默認開始用戶認證,用普通方式無法訪問!

一般都在啟動的時候會顯示密碼,但是docker的話就不知道怎么看密碼了 - -

所以我只能把es的配置文件映射出來,修改配置文件如下

 1 cluster.name: "docker-cluster"
 2 network.host: 0.0.0.0
 3 
 4 #----------------------- BEGIN SECURITY AUTO CONFIGURATION -----------------------
 5 #
 6 # The following settings, TLS certificates, and keys have been automatically      
 7 # generated to configure Elasticsearch security features on 15-03-2022 03:00:53
 8 #
 9 # --------------------------------------------------------------------------------
10 
11 # Enable security features
12 # 這里兩個設置成false
13 xpack.security.enabled: false
14 
15 xpack.security.enrollment.enabled: false
16 
17 
18 # Enable encryption for HTTP API client connections, such as Kibana, Logstash, and Agents
19 xpack.security.http.ssl:
20 enabled: true
21 keystore.path: certs/http.p12
22 
23 # Enable encryption and mutual authentication between cluster nodes
24 xpack.security.transport.ssl:
25 enabled: true
26 verification_mode: certificate
27 keystore.path: certs/transport.p12
28 truststore.path: certs/transport.p12
29 # Create a new cluster with the current node only
30 # Additional nodes can still join the cluster later
31 # 刪除或注釋這里的 cluster.initial_master_nodes: ["docker容器ID"]
32 
33 #----------------------- END SECURITY AUTO CONFIGURATION -------------------------                                                                

到此可以訪問成功了!


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM