ElasticSearch-安装以及常见错误

 ElasticSearch安装常见错误 

[root@node2 ~]# yum install  -y *jdk   安装java环境
[root@node2 ~]# cd /usr/local/src/
[root@node2 src]# wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-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

max file descriptors [4096] for elasticsearch process likely too low, increase to at least [65536]
max number of threads [1024] for user [lishang] likely too low, increase to at least [2048]

解决:切换到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

业务驱动技术,技术是手段,业务是目的。

个人总结:elasticsearch的安装使用并不难,我们在使用是只要是注意它启用时,所提示的错误,然后针对性的解决就可以。以上是我在安装使用elasticsearch所遇到问题,希望能帮到大家。


  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值