centos7安装elasticsearch

时间:2022-03-19 07:22:17

[root@aaron tools]# wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.5.1.zip

unzip elasticsearch-5.5.1.zip

[root@aaron elasticsearch-5.5.1]# ./bin/elasticsearch

报错
[2017-12-08T15:09:05,826][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:127) ~[elasticsearch-5.5.1.jar:5.5.1]
at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:114) ~[elasticsearch-5.5.1.jar:5.5.1]
at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:67) ~[elasticsearch-5.5.1.jar:5.5.1]
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:122) ~[elasticsearch-5.5.1.jar:5.5.1]
at org.elasticsearch.cli.Command.main(Command.java:88) ~[elasticsearch-5.5.1.jar:5.5.1]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:91) ~[elasticsearch-5.5.1.jar:5.5.1]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:84) ~[elasticsearch-5.5.1.jar:5.5.1]
Caused by: java.lang.RuntimeException: can not run elasticsearch as root
at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:106) ~[elasticsearch-5.5.1.jar:5.5.1]
at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:194) ~[elasticsearch-5.5.1.jar:5.5.1]
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:351) ~[elasticsearch-5.5.1.jar:5.5.1]
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:123) ~[elasticsearch-5.5.1.jar:5.5.1]
... 6 more

解决方法:

[root@aaron ~]# chown -R Aaron:Aaron /home/Aaron/tools/elasticsearch-5.5.1
[root@aaron ~]# ls -la /home/Aaron/tools/elasticsearch-5.5.1/
total 236
drwxr-xr-x. 8 Aaron Aaron 4096 Dec 8 15:09 .
drwxrwxr-x. 3 Aaron Aaron 32 Dec 8 15:30 ..
drwxr-xr-x. 2 Aaron Aaron 4096 Jul 18 20:47 bin
drwxr-xr-x. 3 Aaron Aaron 86 Dec 8 15:47 config
drwxr-xr-x. 2 Aaron Aaron 4096 Jul 18 20:47 lib
-rw-r--r--. 1 Aaron Aaron 11358 Jul 18 20:42 LICENSE.txt
drwxr-xr-x. 2 Aaron Aaron 4096 Dec 8 15:09 logs
drwxr-xr-x. 13 Aaron Aaron 4096 Jul 18 20:47 modules
-rw-rw-r--. 1 Aaron Aaron 194187 Jul 18 20:46 NOTICE.txt
drwxr-xr-x. 2 Aaron Aaron 6 Jul 18 20:47 plugins
-rw-rw-r--. 1 Aaron Aaron 9548 Jul 18 20:42 README.textile
[root@aaron ~]# su - Aaron
Last login: Fri Dec 8 15:46:41 CST 2017 on pts/2

[Aaron@aaron ~]$ cd tools/elasticsearch-5.5.1/
[Aaron@aaron elasticsearch-5.5.1]$ bin/elasticsearch

[root@aaron ~]# curl http://localhost:9200/
{
"name" : "huxpDLG",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "71lMVm_SRJGOFOFkL23HCA",
"version" : {
"number" : "5.5.1",
"build_hash" : "19c13d0",
"build_date" : "2017-07-18T20:44:24.823Z",
"build_snapshot" : false,
"lucene_version" : "6.6.0"
},
"tagline" : "You Know, for Search"
}