浅学
Published on 2017-09-02 11:31 in 暂未分类 with 做个俗人、贪财好色

单实例安装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参照之前的随笔

进入官网页面之后

复制链接地址之后到linux中创建elastic目录,在elastic目录中使用命令 wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.5.2.tar.gz 下载

安装

解压 tar -zxvf elasticsearch-5.5.2.tar.gz 

启动

解压之后进入bin目录,直接使用命令sh elasticsearch启动即可

此时如果用的是root用户会报如下错误,因为elastic search不能用root用户启动,解决办法有很多种,我用的是创建用户的方法

[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

解决办法:

#创建用户

adduser elastic  

#修改密码(输入要修改的密码,第二次输入是确定密码)

passwd elastic

#elastic文件夹权限赋给elastic用户

chown -R elastic elastic

#切换用户启动

su elastic

sh elasticsearch

看到如下信息说明启动完成,浏览器访问页面即可,默认监听9200端口

 

posted @ 2019-08-29 10:23  不帅你打我  阅读(273)  评论(0编辑  收藏  举报