單實例安裝elastic和啓動報錯解決

下載

先到官網https://www.elastic.co/cn/downloads/past-releases/elasticsearch-5-5-2下載,我安裝的是5.5.2的版本,其餘版本直接訪問官網elastic.co下載須要的版本。注意:5.2.2版本使用的jdk是1.8,其餘elastic版本要適當調整jdk版本,怎麼安裝jdk參照以前的隨筆java

進入官網頁面以後node

複製連接地址以後到linux中建立elastic目錄,在elastic目錄中使用命令 wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.5.2.tar.gz 下載linux

安裝

解壓 tar -zxvf elasticsearch-5.5.2.tar.gz bootstrap

啓動

解壓以後進入bin目錄,直接使用命令sh elasticsearch啓動便可瀏覽器

此時若是用的是root用戶會報以下錯誤,由於elastic search不能用root用戶啓動,解決辦法有不少種,我用的是建立用戶的方法elasticsearch

[root@localhost bin]# ./elasticsearch
[2017-12-20T17:01:47,922][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [node-1] 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:125) ~[elasticsearch-6.1.1.jar:6.1.1]
    at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:112) ~[elasticsearch-6.1.1.jar:6.1.1]
    at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-6.1.1.jar:6.1.1]
    at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) ~[elasticsearch-cli-6.1.1.jar:6.1.1]
    at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-6.1.1.jar:6.1.1]
    at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92) ~[elasticsearch-6.1.1.jar:6.1.1]
    at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:85) ~[elasticsearch-6.1.1.jar:6.1.1]
Caused by: java.lang.RuntimeException: can not run elasticsearch as root
    at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:104) ~[elasticsearch-6.1.1.jar:6.1.1]
    at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:171) ~[elasticsearch-6.1.1.jar:6.1.1]
    at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:322) ~[elasticsearch-6.1.1.jar:6.1.1]
    at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:121) ~[elasticsearch-6.1.1.jar:6.1.1]
    ... 6 more

解決辦法:

#建立用戶spa

adduser elastic  code

#修改密碼(輸入要修改的密碼,第二次輸入是肯定密碼)blog

passwd elasticget

#elastic文件夾權限賦給elastic用戶

chown -R elastic elastic

#切換用戶啓動

su elastic

sh elasticsearch

看到以下信息說明啓動完成,瀏覽器訪問頁面便可,默認監聽9200端口

相關文章
相關標籤/搜索