logstash+elasticsearch 错误摘记
[2017-09-17T06:00:22,511][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [] uncaught exception in thread [main] org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:136) ~[elasticsearch-5.6.0.jar:5.6.0] at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:123) ~[elasticsearch-5.6.0.jar:5.6.0] at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:67) ~[elasticsearch-5.6.0.jar:5.6.0] at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:134) ~[elasticsearch-5.6.0.jar:5.6.0] at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-5.6.0.jar:5.6.0] at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:91) ~[elasticsearch-5.6.0.jar:5.6.0] at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:84) ~[elasticsearch-5.6.0.jar:5.6.0] Caused by: java.lang.RuntimeException: can not run elasticsearch as root at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:106) ~[elasticsearch-5.6.0.jar:5.6.0] at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:195) ~[elasticsearch-5.6.0.jar:5.6.0] at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:342) ~[elasticsearch-5.6.0.jar:5.6.0] at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:132) ~[elasticsearch-5.6.0.jar:5.6.0] ... 6 more
如上错误解决办法:
创建普通用户,和用户组,并需要更改属组,属主
[root@vm1 elasticsearch-5.6.0]# useradd elsearch -g elsearch -p elasticsearch [root@vm1 app]# chown -R elsearch:elsearch elasticsearch-5.6.0
./bin/logstash -f /etc/logstash/conf.d/ela.conf --verbose 测试Logstash与ela连通性报错“503”
{ "error" : { "root_cause" : [ ], "type" : "search_phase_execution_exception", "reason" : "all shards failed", "phase" : "query", "grouped" : true, "failed_shards" : [ ] }, "status" : 503 }
解决办法:
这个错误是elasticsearch的问题,更改一下elasticsearch的启动默认文件配置
vi config/elasticsearch.yml
在配置文件里添加:
network.host: 0.0.0.0 http.cors.allow-origin: "/.*/" http.cors.enabled: true
然后重新启动elasticsearch即可解决
好记性不如烂笔头-_-