ElasticSearch安装常见错误

[复制链接]
feng 发表于 2022-6-6 19:58:09 | 显示全部楼层 |阅读模式
本帖最后由 feng 于 2022-6-6 20:50 编辑

ElasticSearch安装常见错误


[root@node2 ~]# yum install  -y *jdk   安装java环境
[root@node2 ~]# cd /usr/local/src/
[root@node2 src]# wget https://artifacts.elastic.co/dow ... search-5.6.3.tar.gz
##官网下载5.6以上的版本


[root@node2 ~]# java -version  ###查看java版本
openjdk version "1.8.0_151"
OpenJDK Runtime Environment (build 1.8.0_151-b12)
OpenJDK 64-Bit Server VM (build 25.151-b12, mixed mode)  ###可以看到已经安装java的最新版本了。
##解压安装 ElasticSearch


[root@node2 src]# tar -xf elasticsearch-5.6.3.tar.gz   ##解压
[root@node2 src]# cd elasticsearch-5.6.3
[root@node2 elasticsearch-5.6.3]# ls
bin  config  lib  LICENSE.txt  modules  NOTICE.txt  plugins  README.textile
[root@node2 elasticsearch-5.6.3]# vim config/
elasticsearch.yml  jvm.options        log4j2.properties  
[root@node2 elasticsearch-5.6.3]# vim config/elasticsearch.yml  ###修改下面两项
network.host: 172.25.0.30    ###为本地ip,监听主机
discovery.zen.minimum_master_nodes: 1   ###我这里只有一台,所以修改为1
接下来我们启动看看


错误一:
我们会发现启动错误。会弹出下面的报错,抱错如下图:


主要原因是已经有提示了:Caused by: java.lang.RuntimeException: can not run elasticsearch as root,说是不能在root用户下运行,接下来我们换个用户来运行。


[root@node2 bin]# useradd dashuju
[root@node2 bin]# su - dashuju
[dashuju@node2 ~]$ cd /usr/local/src/elasticsearch-5.6.3/
错误二:


启动后我们发现了错误
[dashuju@node2 bin]$ ./elasticsearch
Exception in thread "main" 2017-11-12 12:17:55,776 main ERROR No log4j2 configuration file found. Using default configuration: logging only errors to the console. Set system property ‘log4j2.debug‘ to show Log4j2 internal initialization logging.
2017-11-12 12:17:56,319 main ERROR Could not register mbeans java.security.AccessControlException: access denied ("javax.management.MBeanTrustPermission" "register")
这也是根据问题原因去解决,解决方法如下:


[root@node2 ~]# yum install -y log4j*    ###安装log4j包
[root@node2 ~]# chown dashuju:dashuju -R  /usr/local/src/elasticsearch-5.6.3  ###给予elasticsearch权限
错误三:

继续启动:
[dashuju@node2 bin]$ ./elasticsearch
ERROR: [2] bootstrap checks failed   ##还有错误,这个是要改文件数,这个因为太多我就不放图了。
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
我们改一下限制的文件数就可以了


[root@node1 src]# cat /etc/sysctl.conf
vm.max_map_count=655360
[root@node2 src]# cat /etc/security/limits.conf
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096
[root@node2 ~]# sysctl -p
vm.max_map_count = 655360
注:###最好重启一下,然后执行一遍


[dashuju@node2 bin]$ ./elasticsearch   
[root@node2 ~]# netstat -ntpl   ###查看一下服务,可以看到elasticsearch已经起来了,端口9200和9300
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name   
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      1/systemd           
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1178/sshd           
tcp        0      0 0.0.0.0:873             0.0.0.0:*               LISTEN      847/rsync           
tcp6       0      0 :::111                  :::*                    LISTEN      1/systemd           
tcp6       0      0 172.25.0.30:9200        :::*                    LISTEN      1650/java           
tcp6       0      0 :::2224                 :::*                    LISTEN      866/ruby            
tcp6       0      0 172.25.0.30:9300        :::*                    LISTEN      1650/java           
tcp6       0      0 :::22                   :::*                    LISTEN      1178/sshd           
tcp6       0      0 :::873                  :::*                    LISTEN      847/rsync           
tcp6       0      0 :::3306                 :::*                    LISTEN      1436/mysqld
再访问以下我们9200端口,也已经成功了,可以看到elasticsearch的信息了。        


[root@node2 ~]# curl 172.25.0.30:9200
{
  "name" : "XjOLC6R",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "45286kMyRMqEsjgH04lQCg",
  "version" : {
    "number" : "5.6.3",
    "build_hash" : "1a2f265",
    "build_date" : "2017-10-06T20:33:39.012Z",
    "build_snapshot" : false,
    "lucene_version" : "6.6.1"
  },
  "tagline" : "You Know, for Search"
}


问题一:警告提示
[2016-11-06T16:27:21,712][WARN ][o.e.b.JNANatives ] unable to install syscall filter:
java.lang.UnsupportedOperationException: seccomp unavailable: requires kernel 3.5+ with CONFIG_SECCOMP and CONFIG_SECCOMP_FILTER compiled in
at org.elasticsearch.bootstrap.Seccomp.linuxImpl(Seccomp.java:349) ~[elasticsearch-5.0.0.jar:5.0.0]
at org.elasticsearch.bootstrap.Seccomp.init(Seccomp.java:630) ~[elasticsearch-5.0.0.jar:5.0.0]


报了一大串错误,其实只是一个警告。
解决:使用心得linux版本,就不会出现此类问题了。



问题一:警告提示


[2016-11-06T16:27:21,712][WARN ][o.e.b.JNANatives ] unable to install syscall filter:
java.lang.UnsupportedOperationException: seccomp unavailable: requires kernel 3.5+ with CONFIG_SECCOMP and CONFIG_SECCOMP_FILTER compiled in
at org.elasticsearch.bootstrap.Seccomp.linuxImpl(Seccomp.java:349) ~[elasticsearch-5.0.0.jar:5.0.0]
at org.elasticsearch.bootstrap.Seccomp.init(Seccomp.java:630) ~[elasticsearch-5.0.0.jar:5.0.0]


报了一大串错误,其实只是一个警告。

解决:使用心得linux版本,就不会出现此类问题了。


问题二:ERROR: bootstrap checks failed


Last login: Mon Jun  6 20:41:01 2022 from 192.168.111.253
[root@lognode2 ~]# su elastic -c "/usr/local/elasticsearch/bin/elasticsearch -d"
[root@lognode2 ~]# ERROR: [1] bootstrap checks failed. You must address the points described in the following [1] lines before starting Elasticsearch.
bootstrap check failure [1] of [1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
ERROR: Elasticsearch did not exit normally - check the logs at /data/logs/elasticsearch/glog.log

解决:切换到root用户,编辑limits.conf 添加类似如下内容


vi /etc/security/limits.conf


添加如下内容:


* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096

问题三:max number of threads [1024] for user [lish] likely too low, increase to at least [2048]

解决:切换到root用户,进入limits.d目录下修改配置文件。

vi /etc/security/limits.d/90-nproc.conf
修改如下内容:
* soft nproc 1024
#修改为
* soft nproc 2048


问题四:max virtual memory areas vm.max_map_count [65530] likely too low, increase to at least [262144]


解决:切换到root用户修改配置sysctl.conf


vi /etc/sysctl.conf

添加下面配置:
vm.max_map_count=655360
并执行命令:
sysctl -p

问题五:max file descriptors [4096] for elasticsearch process likely too low, increase to at least [65536]


解决:修改切换到root用户修改配置limits.conf 添加下面两行

命令:vi /etc/security/limits.conf
*        hard    nofile           65536
*        soft    nofile           65536
切换到es的用户。
然后,重新启动elasticsearch,即可启动成功。


六、后台运行
最后还有一个小问题,如果你在服务器上安装Elasticsearch,而你想在本地机器上进行开发,这时候,你很可能需要在关闭终端的时候,让Elasticsearch继续保持运行。最简单的方法就是使用nohup。先按Ctrl + C,停止当前运行的Elasticsearch,改用下面的命令运行Elasticsearch

nohup./bin/elasticsearch&

这样,你就可以放心地关闭服务器终端,而不用担心Elasticsearch也跟着关闭了。
ERROR: bootstrap checks failed
system call filters failed to install; check the logs and fix your configuration or disable system call filters at your own risk


解决:
在elasticsearch.yml中配置bootstrap.system_call_filter为false,注意要在Memory下面:
bootstrap.memory_lock: false
bootstrap.system_call_filter: false


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|手机版|小黑屋|RuZhuo ( 鄂ICP备16015978号-8 )

GMT+8, 2024-5-19 01:35 , Processed in 0.028704 second(s), 28 queries .

Powered by RuZhuo

快速回复 返回顶部 返回列表