Solve the error of running Elasticsearch by root in centos.
Run Elasticsearch 6.5 on CentOS 2.3. The exception is as follows:
Exception in thread "main" java.lang.RuntimeException: don't run elasticsearch as root. at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:93) at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:144) at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:270) at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35)Refer to the log for complete error details.
Exception Description: Elasticsearch cannot be run with the root permission. The solution is to add a parameter during the runtime:
bin/elasticsearch -Des.insecure.allow.root=true
Or modify bin/elasticsearch with the ES_JAVA_OPTS attribute:
ES_JAVA_OPTS="-Des.insecure.allow.root=true"
Then restart Elasticsearch.