elasticsearch-6.2.2安装错误解决方案

新买了个1核1G的服务器没事玩玩,安装一下elasticsearch来学学,结果刚安装就出现了各种的问题,搜索了很久找到了解决方案,记录一下,备忘

1、刚安装完成启动就出错了:error='Cannot allocate memory'

[root@centos7.4-64 elasticsearch-6.2.2]# ./bin/elasticsearch -d
Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x00000000c5330000, 986513408, 0) failed; error='Cannot allocate memory' (errno=12)

看来是我这1G的内存太小了啊,elasticsearch使用java的jvm默认是使用1G的内存的,这里我们修改一下内存,直接把内存改到200m

[root@centos7.4-64 elasticsearch-6.2.2]# vim ./config/jvm.options
#修改内容
-Xms200m
-Xmx200m

2、修改之后再启动试一下,结果又提示:can not run elasticsearch as root,这是不能使用root用户操作,添加一个其他的用户再试试

[root@centos7.4-64 elasticsearch-6.2.2]# adduser elastic
[root@centos7.4-64 elasticsearch-6.2.2]# passwd elastic
Changing password for user elastic.
New password: 
Retype new password: 
passwd: all authentication tokens updated successfully.
3、继续启动elasticsearch,又提示:Exception in thread "main" java.nio.file.AccessDeniedException: /usr/local/elasticsearch-6.2.2/config/jvm.options,没有jvm文件的权限,改一下所属的用户
[root@centos7.4-64 elasticsearch-6.2.2]# chown elastic /usr/local/elasticsearch-6.2.2/ -R

4、登录刚才新建的elastic用户,并启动elasticsearch,OK

5、尝试安装kibana,结果又出现下列错误:

[elastic@centos7.4-64 ~]$ /usr/local/elasticsearch-6.2.2/bin/elasticsearch
。。。。。。省略其他启动信息
ERROR: [3] bootstrap checks failed
[1]: max file descriptors [65535] for elasticsearch process is too low, increase to at least [65536]
[2]: max number of threads [3895] for user [elastic] is too low, increase to at least [4096]
[3]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
[2018-03-08T19:29:32,233][INFO ][o.e.n.Node               ] [s3f1uD4] stopping ...
[2018-03-08T19:29:32,397][INFO ][o.e.n.Node               ] [s3f1uD4] stopped
[2018-03-08T19:29:32,397][INFO ][o.e.n.Node               ] [s3f1uD4] closing ...
[2018-03-08T19:29:32,412][INFO ][o.e.n.Node               ] [s3f1uD4] closed

可以看到这里出现了三个错误,提示的也很清楚了,登录到root用户,修改如下:

【1】修改/etc/security/limits.conf,修改到提示值即可

[root@centos7.4-64 ~]# vim /etc/security/limits.conf
* hard nofile 65536

【2】修改/etc/security/limits.d/90-nproc.conf 文件

[root@centos7.4-64 ~]# vim /etc/security/limits.conf 
修改或添加
* hard nproc 4096
切换用户,如果还是不行则修改:/etc/security/limits.d/20-nproc.conf,其他文章上写的都是修改90-nproc.conf
不过我这个安装之后没有这个文件,只有一个20-nproc.conf,我的修改这个就行,刚开始学不知道什么原因
[root@centos7.4-64 ~]# vim /etc/security/limits.d/20-nproc.conf 

将内容改为:
*          soft    nproc     4096

【3】修改/etc/sysctl.conf

[root@centos7.4-64 ~]# vim /etc/sysctl.conf 
添加配置:vm.max_map_count=262144,然后执行命令
[root@centos7.4-64 ~]# sysctl -p

如果是使用xshell开两个窗口的话修改完成之后一定要断开重新登录一下哦

展开阅读全文

没有更多推荐了,返回首页