我是靠谱客的博主 痴情大雁,这篇文章主要介绍linux 安装elasticsearch步骤以及入的坑,现在分享给大家,希望可以做个参考。

linux 安装elasticsearch步骤以及入的坑

最近在做一些微服务的项目要求在站内搜索,所以选择使用的elasticsearch,话不多说上安装步骤:

一、首先去官网下载linux tar.gz版本 我这里是5.6.8版本网址如下
https://www.elastic.co/cn/downloads/past-releases/elasticsearch-5-6-8

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# 创建用户名为 es 的用户 useradd es # 设置 es 用户的密码 passwd es # 创建 es 的 data 和 logs 目录 mkdir elasticsearch-5.6.8/data mkdir elasticsearch-5.6.8/logs #解压 tar -zxvf /elasticsearch-5.6.8.tar.gz # 将 /usr/local/elasticsearch/elasticsearch-5.6.8 的拥有者设置为 es chown -R es:es /usr/local/elasticsearch/elasticsearch-5.6.8 #编辑配置文件config/elasticsearch.yml 添加如下两句 network.host: 0.0.0.0 http.port: 9200

以为在5.0以后版本el不支持root用户启动 所以要切换到刚刚创建的用户 es下面

复制代码
1
2
3
4
su es #将目录切换到目录bin目录 前台启动 是否报错 ./elasticsearch

如遇以下问题

复制代码
1
2
3
4
5
6
[2018-01-28T23:51:35,180][INFO ][o.e.t.TransportService ] [qR5cyzh] publish_address {172.19.26.110:9300}, bound_addresses {172.19.26.110:9300} [2018-01-28T23:51:35,204][INFO ][o.e.b.BootstrapChecks ] [qR5cyzh] bound or publishing to a non-loopback address, enforcing bootstrap checks 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]

第一个可以max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]

如下解决 原因是因为操作系统vm.max_map_count参数设置太小导致的,至于设置多大的数值,我这里就直接参照报错信息的建议直接设置为262144

解决方案一:

复制代码
1
2
3
4
5
6
7
8
#切换到root用户下,执行以下命令: sysctl -w vm.max_map_count=262144 #检查配置是否生效 [root@localhost elasticsearch-6.1.2]# sysctl -a | grep "vm.max_map_count" vm.max_map_count = 262144 [root@localhost elasticsearch-6.1.2]#

解决方案二:

复制代码
1
2
3
4
5
6
7
8
9
10
11
#切换到root用户,备份原有配置 [root@localhost elasticsearch-6.1.2]# cd /etc [root@localhost etc]# cp sysctl.conf sysctl.conf.bak #编辑sysctl.conf,增加如下内容 [root@localhost etc]# vim sysctl.conf # elasticsearch config start vm.max_map_count=262144 # elasticsearch config end

如果正常输出262144,则说明修改成功,然后再次启动elasticsearch,输出如下

复制代码
1
2
3
4
5
```java ERROR: [1] bootstrap checks failed [1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
复制代码
1
2
3
4
5
6
7
8
9
10
这个时候发现只有一个错了 报错max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]是因为操作系统安全检测配置影响的,我们需要切换到root用户下做如下配置: 先做一个配置备份 ```java [root@localhost elasticsearch-6.1.2]# cd /etc/security/ [root@localhost security]# cp limits.conf limits.conf.bak

limits.conf文件配置如下:

复制代码
1
2
3
4
5
6
7
# elasticsearch config start * soft nofile 65536 * hard nofile 131072 * soft nproc 2048 * hard nproc 4096 # elasticsearch config end

执行启动命令 ./bin/elasticsearch ,会发现指定IP已经配置好了,也正常启动。

ip:9200访问结果如下:

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
{ "name" : "OYJ_I0B", "cluster_name" : "elasticsearch", "cluster_uuid" : "U5JHdDL8SECLAr2qVHZXbw", "version" : { "number" : "5.6.8", "build_hash" : "688ecce", "build_date" : "2018-02-16T16:46:30.010Z", "build_snapshot" : false, "lucene_version" : "6.6.1" }, "tagline" : "You Know, for Search" }

后台启动命令:

复制代码
1
2
./elasticsearch -d

安装的时候就是遇到这些
ps 如遇一下问题

复制代码
1
2
java.lang.UnsupportedOperationException: seccomp unavailable: CONFIG_SECCOMP not compiled into kernel, CONFIG_SECCOMP and CONFIG_SECCOMP_FILTER are needed

错误描述:
  ElasticSearch集群启动错误,错误的原因是:因为Centos6不支持SecComp,而ES默认bootstrap.system_call_filter为true进行检测,所以导致检测失败,失败后直接导致ES不能启动解决:修改elasticsearch.yml
问题解决:
在所有节点的elasticsearch.yml配置文件中加入:

复制代码
1
2
3
 bootstrap.memory_lock: false  bootstrap.system_call_filter: false

最后

以上就是痴情大雁最近收集整理的关于linux 安装elasticsearch步骤以及入的坑的全部内容,更多相关linux内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(76)

评论列表共有 0 条评论

立即
投稿
返回
顶部