您的位置:首页 > 其它

ElasticSearch 5.5.2安装和启动

2018-02-08 00:56 330 查看
安装环境 CentOS release 6.8

1、因Elasticsearch是基于java写的,所以它的运行环境中需要java的支持,在Linux下执行命令:java -version,检查Jar包是否安装

安装java版本至少是1.8以上

2、首先准备下载Elasticsearch5.5.2 安装包

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.2.2.tar.gz[/code] 
3、下载到/usr/local 目录下,解压

tar -zxvf  elasticsearch-5.2.2.tar.gz


4、因为Elasticsearch5.0之后,不能使用root账户启动,我们先创建一个elasticsearch组和账户

groupadd elasticsearch #创建elasticsearch用户组
useradd  elasticsearch -g elasticsearch -p elasticsearch #创建用户elasticsearch所属组为elasticsearch
chown -R elasticsearch:elasticsearch .#切换到elasticsearch-5.2.2同级目录,变更该文件夹拥有 .代表当前文件夹


5、启动elasticsearch

cd /usr/local/elasticsearch5.2.2/
su elasticsearch #更改用户为elasticsearch
./bin/elasticsearch


启动报错①

Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x0000000085330000, 2060255232, 0) failed; error='Cannot allocate memory' (errno=12)


由于elasticsearch5.0默认分配jvm空间大小为2g,修改jvm空间分配

vi config/jvm.options


将文件中

-Xms2g
-Xmx2g


修改为

-Xms512m
-Xmx512m


启动报错②

unable to install syscall filter:
java.lang.UnsupportedOperationException: seccomp unavailable: CONFIG_SECCOMP not compiled into kernel, CONFIG_SECCOMP and CONFIG_SECCOMP_FILTER are needed


因为Centos6不支持SecComp,而ES默认bootstrap.system_call_filter为true进行检测,所以导致检测失败,失败后直接导致ES不能启动。详见 :https://github.com/elastic/elasticsearch/issues/22899

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

bootstrap.memory_lock: false
bootstrap.system_call_filter: false


启动报错③

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


原因:无法创建本地文件问题,用户最大可创建文件数太小

解决方法:切换到root用户,编辑limits.conf配置文件, 添加类似如下内容:

<
bd84
pre class="prettyprint">
su root #切换到root用户 需要输入密码
vi /etc/security/limits.conf


添加如下内容:

* soft nofile 65536
* hard nofile 65536


然后用户切换到elasticsearch执行

ulimit -Hn


如果显示65536即可 否则重新登录或重启

启动报错④

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


原因:无法创建本地线程问题,用户最大可创建线程数太小

解决方法:

切换到root用户,编辑limits.conf配置文件, 添加类似如下内容

su root #切换到root用户 需要输入密码
vi /etc/security/limits.d/90-nproc.conf


修改如下内容:

* soft nproc 1024


修改为

* soft nproc 2048


启动报错⑤

max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]


解决方法:

[root@modelhost ~]# vi /etc/sysctl.conf


最下面添加

vm.max_map_count=262144


执行

sysctl -p


启动报错⑥

使用elasticsearch集群时 如果出现下面的错误

main ERROR Could not register mbeans java.security.AccessControlException:
access denied ("javax.management.MBeanTrustPermission" "register"


意思是当前用户没有这个文件夹的操作权限 给当前用户授权即可

[root@model es_slave]# chown -R elasticsearch:elasticsearch .


这时使用上面 的命令启动,出现下图则启动成功



打开另一个终端执行

curl http://localhost:9200[/code] 
返回:



至此,elasticsearch单个节点安装完成。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: