早上好,伙计们,
我按照以下官方说明开始使用docker elasticsearch 5.0.1实例:
https://www.elastic.co/guide/en/elasticsearch/reference/5.0/settings.html
为了配置elasticsearch.yml和log4j2.properties文件,这些文件位于:
$ pwd
/system/mesos/elasticsearchf/config
$ ls
elasticsearch.yml log4j2.properties
包含这些配置文件:
$cat elasticsearch.yml
path:
data: /usr/share/elasticsearch/data
logs: /usr/share/elasticsearch/data
shared_data: /usr/share/elasticsearch/data
config: /usr/share/elasticsearch/config
node.add_lock_id_to_custom_path: false
index.number_of_shards: 2
cluster.name: elasticcluster
discovery.zen.ping.unicast.hosts: ["10.120.1.190", "10.120.1.191"]
$cat log4j2.properties
appender.rolling.type = RollingFile
appender.rolling.name = rolling
appender.rolling.fileName = ${sys:es.logs}.log
appender.rolling.layout.type = PatternLayout
appender.rolling.layout.pattern = [%d{ISO8601}][%-5p][%-25c] %.10000m%n
appender.rolling.filePattern = ${sys:es.logs}-%d{yyyy-MM-dd}.log
appender.rolling.policies.type = Policies
appender.rolling.policies.time.type = TimeBasedTriggeringPolicy
appender.rolling.policies.time.interval = 1
appender.rolling.policies.time.modulate = true
当我运行命令时:
$ docker -D -H unix:///var/run/docker.sock run --cpu-shares 1024 --memory 2634022912 -e ES_JAVA_OPTS="-Xms2G -Xmx2G" -v /system/mesos/elasticsearchf/data:/usr/share/elasticsearch/data/:rw -v /system/mesos/elasticsearchf/config:/usr/share/elasticsearch/config/:rw --net bridge -p 9200:9200/tcp -p 9300:9300/tcp docker.elastic.co/elasticsearch/elasticsearch:5.0.1
我收到了与log4j2消息相关的错误消息,您可以在下面看到
欢迎任何帮助
亲切的问候
DEBU[0001] framesize: 81
2016-12-01 10:37:15,526 main ERROR Unable to locate plugin type for RollingFile
DEBU[0001] framesize: 90
2016-12-01 10:37:15,554 main ERROR Unable to locate plugin for TimeBasedTriggeringPolicy
DEBU[0001] framesize: 2223
2016-12-01 10:37:15,555 main ERROR Unable to invoke factory method in class class org.apache.logging.log4j.core.appender.rolling.CompositeTriggeringPolicy for element Policies. java.lang.NullPointerException
at org.apache.logging.log4j.core.config.plugins.visitors.PluginElementVisitor.visit(PluginElementVisitor.java:52)
at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.generateParameters(PluginBuilder.java:243)
at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:131)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:918)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:858)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:850)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:850)
at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:479)
at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:219)
at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:231)
at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:496)
at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:249)
at org.elasticsearch.common.logging.LogConfigurator.configure(LogConfigurator.java:116)
at org.elasticsearch.common.logging.LogConfigurator.configure(LogConfigurator.java:83)
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:249)
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:112)
at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:103)
at org.elasticsearch.cli.SettingCommand.execute(SettingCommand.java:54)
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:96)
at org.elasticsearch.cli.Command.main(Command.java:62)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:80)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:73)
DEBU[0001] framesize: 76
2016-12-01 10:37:15,557 main ERROR Unable to locate plugin for RollingFile
DEBU[0001] framesize: 1974
2016-12-01 10:37:15,558 main ERROR Unable to invoke factory method in class class org.apache.logging.log4j.core.config.AppendersPlugin for element Appenders. java.lang.NullPointerException
at org.apache.logging.log4j.core.config.plugins.visitors.PluginElementVisitor.visit(PluginElementVisitor.java:52)
at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.generateParameters(PluginBuilder.java:243)
at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:131)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:918)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:858)
at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:479)
at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:219)
at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:231)
at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:496)
at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:249)
at org.elasticsearch.common.logging.LogConfigurator.configure(LogConfigurator.java:116)
at org.elasticsearch.common.logging.LogConfigurator.configure(LogConfigurator.java:83)
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:249)
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:112)
at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:103)
at org.elasticsearch.cli.SettingCommand.execute(SettingCommand.java:54)
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:96)
at org.elasticsearch.cli.Command.main(Command.java:62)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:80)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:73)
DEBU[0002] Corrupted prefix: []
DEBU[0002] [hijack] End of stdout
答案 0 :(得分:12)
尝试在Docker上运行Elasticsearch 5.3时遇到了完全相同的错误,我使用的是Elasticsearch日志配置部分中提到的类似属性。 我花了一段时间才弄清楚为什么我会收到这个错误。这是因为在定义类型属性时,行末尾有一个空格。在行的末尾不应该有任何空格。
appender.rolling.type = RollingFile
appender.rolling.policies.time.type = TimeBasedTriggeringPolicy
删除空格后(使用上面提到的配置)你的Elasticsearch会出现,但是你仍然会得到没有日志,因为它会覆盖在控制台中显示错误的默认设置,而且还没有添加滚动appender到根记录器。 要查看生成的日志信息,您还需要将以下两行添加到log4j2.properties中
rootLogger.level = info
rootLogger.appenderRef.rolling.ref = rolling
答案 1 :(得分:0)
如Elasticsearch文档所述:
Log4j的配置解析会被任何无关的内容弄糊涂 空格;如果您在此页面上复制并粘贴任何Log4j设置,或者 通常输入任何Log4j配置,请确保修剪所有前导 和尾随空格。
https://www.elastic.co/guide/en/elasticsearch/reference/6.8/logging.html