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