Docker 启动 Elasticsearch 7.4.2闪退问题的解决

问题:启动之后,在docker ps 命令下面找不到我们的启动的容器只有在docker ps -a才看的到我们启动的容器

可能的原因:虚拟机内存不足。可通过-e ES_JAVA_OPTS限制占用内存大小

具体配置:

docker run --name elasticsearch -p 9200:9200 -p 9300:9300 
-e "discovery.type=single-node" 
-e ES_JAVA_OPTS="-Xms512m -Xmx512m" 
-v/mydata/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/
elasticsearch.yml 
-v /mydata/elasticsearch/data:/usr/share/elasticsearch/data 
-v /mydata/elasticsearch/plugins:/usr/share/elasticsearch/plugins 
-d elasticsearch:7.4.2

修改完后还是启动闪退,可通过 docker logs elasticsearch命令查看日志,

常见错误
错误 1:
Caused by: java.lang.RuntimeException: can not run elasticsearch as root

原因:出于对root用户的安全保护,需要用其他用户组用户来启动。
解决方法:需要对elasticsearch安装目录进行用户授权。
chown -R es:es /opt/elasticsearch/

错误2:
Exception in thread "main" 2017-11-12 12:17:55,776 main ERROR No log4j2 configuration file found. Using default configuration: logging only errors to the console. Set system property ‘log4j2.debug‘ to show Log4j2 internal initialization logging.
2017-11-12 12:17:56,319 main ERROR Could not register mbeans java.security.AccessControlException: access denied ("javax.management.MBeanTrustPermission" "register")
原因:elasticsearch.yml中的配置项的格式有问题
解决方案:请尽量保持冒号前面没空格,后面一个空格,不要用tab键
 

你可能感兴趣的:(Docker 启动 Elasticsearch 7.4.2闪退问题的解决)