【运维笔记】Centos 7.5 安装elasticsearch-7.4.0(压缩文件版本)

一、前言:

二、下载 & 解压 elasticsearch到指定目录:

[root@localhost opt]# cd /
[root@localhost /]# mkdir /opt/elasticsearch/
[root@localhost /]# cd /opt/elasticsearch/
[root@localhost elasticsearch]# wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.4.0-linux-x86_64.tar.gz 
[root@localhost elasticsearch]# ll
total 284792
-rw-r--r--. 1 root root 291625299 Oct  1  2019 elasticsearch-7.4.0-linux-x86_64.tar.gz
[root@localhost elasticsearch]# tar -zxvf elasticsearch-7.4.0-linux-x86_64.tar.gz
[root@localhost elasticsearch]# cd /opt/elasticsearch/elasticsearch-7.4.0
[root@localhost elasticsearch-7.4.0]# ll
total 552
drwxr-xr-x.  2 root root   4096 Sep 27  2019 bin
drwxr-xr-x.  2 root root    148 Sep 27  2019 config
drwxr-xr-x. 10 root root    119 Sep 27  2019 jdk
drwxr-xr-x.  3 root root   4096 Sep 27  2019 lib
-rw-r--r--.  1 root root  13675 Sep 27  2019 LICENSE.txt
drwxr-xr-x.  2 root root      6 Sep 27  2019 logs
drwxr-xr-x. 37 root root   4096 Sep 27  2019 modules
-rw-r--r--.  1 root root 523209 Sep 27  2019 NOTICE.txt
drwxr-xr-x.  2 root root      6 Sep 27  2019 plugins
-rw-r--r--.  1 root root   8500 Sep 27  2019 README.textile
[root@localhost elasticsearch-7.4.0]# 

三、备份 & 修改配置文件:

1、备份 & 修改 【elasticsearch.yml】文件:

[root@localhost elasticsearch-7.4.0]# cd /opt/elasticsearch/elasticsearch-7.4.0/config/
[root@localhost config]# cp /opt/elasticsearch/elasticsearch-7.4.0/config/elasticsearch.yml -d /opt/elasticsearch/elasticsearch-7.4.0/config/elasticsearch.yml.blk
[root@localhost config]# ll
total 36
-rw-rw----. 1 root root  2831 Sep 27  2019 elasticsearch.yml
-rw-rw----. 1 root root  2831 Sep 27  2019 elasticsearch.yml.blk
-rw-rw----. 1 root root  3593 Sep 27  2019 jvm.options
-rw-rw----. 1 root root 17545 Sep 27  2019 log4j2.properties
-rw-rw----. 1 root root   473 Sep 27  2019 role_mapping.yml
-rw-rw----. 1 root root   197 Sep 27  2019 roles.yml
-rw-rw----. 1 root root     0 Sep 27  2019 users
-rw-rw----. 1 root root     0 Sep 27  2019 users_roles
[root@localhost config]# 
[root@localhost config]# rm -rf /opt/elasticsearch/elasticsearch-7.4.0/config/elasticsearch.yml
[root@localhost config]# touch /opt/elasticsearch/elasticsearch-7.4.0/config/elasticsearch.yml
[root@localhost config]# vi /opt/elasticsearch/elasticsearch-7.4.0/config/elasticsearch.yml

2、将以下内容写入【elasticsearch.yml】文件中,内容如下:

http.port: 9200
network.host: 0.0.0.0
path.data: /opt/elasticsearch/elasticsearch-7.4.0/data
path.logs: /opt/elasticsearch/elasticsearch-7.4.0/logs
discovery.seed_hosts: ["127.0.0.1"]
cluster.initial_master_nodes: ["node-1"]

四、设置用户 & 赋予权限(因为es不允许直接使用root用户操作):

[root@localhost /]#    groupadd es                                       					// 添加用户组,组名:es
[root@localhost /]#    useradd es -g es                                  					// 添加用户,格式: 用户名 -g 组名
[root@localhost /]#    cchown -R es:es  /opt/elasticsearch/elasticsearch-7.4.0/				// 设置目录权限
[root@localhost /]#    passwd es                                         					// 设置es用户登陆密码,如:123456(提示过于简单继续确认)

五、启动脚本:

1、新建【start.sh】启动文件:

[root@localhost elasticsearch-7.4.0]# touch /opt/elasticsearch/elasticsearch-7.4.0/start.sh
[root@localhost elasticsearch-7.4.0]# vi /opt/elasticsearch/elasticsearch-7.4.0/start.sh 

2、将如下内容写入【start.sh】文件中,并保存:

./bin/elasticsearch -d
tailf /opt/elasticsearch/elasticsearch-7.4.0/logs/elasticsearch.log

3、启动es服务:

[root@localhost elasticsearch-7.4.0]# su es
[es@localhost elasticsearch-7.4.0]$ cd /opt/elasticsearch/elasticsearch-7.4.0
[es@localhost elasticsearch-7.4.0]$ sh start.sh 

4、启动成功提示:

[2022-05-10T22:17:55,946][INFO ][o.e.x.m.p.NativeController] [localhost.localdomain] Native controller process has stopped - no new native processes can be started

六、错误&解决方案::

1、future versions of Elasticsearch will require Java 11; your Java version from [/usr/java/jdk1.8.0_191-amd64/jre] does not meet this requirement:

  • 修改 elasticsearch-env 文件代码,命令:vi /opt/elasticsearch/elasticsearch-7.4.0/bin/elasticsearch-env,将代码 JAVA_HOME="/opt/elasticsearch/elasticsearch-7.4.0/jdk" 写入到 elasticsearch-env 文件中,:
#!/bin/bash

set -e -o pipefail

CDPATH=""

SCRIPT="$0"

JAVA_HOME="/opt/elasticsearch/elasticsearch-7.4.0/jdk"

......省略代码......

2、OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release:

  • 修改jvm.options文件配置,命令:vi /opt/elasticsearch/elasticsearch-7.4.0/config/jvm.options,将文件中-XX:+UseConcMarkSweepGC修改为-XX:+UseG1GC

3、max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
原因: 意思是说你的进程不够用了
解决方案: 切到root 用户:进入到security目录下的limits.conf;执行命令 vi /etc/security/limits.conf 在文件的末尾添加下面的参数值:

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

4、max number of threads [3803] for user [es] is too low, increase to at least [4096]
原因:意思就是说你的线程数不够用了
解决方案: 切到root 用户:执行命令 vi /etc/security/limits.d/20-nproc.conf 修改3803为4096:

*          soft    nproc     4096
root       soft    nproc     unlimited

如果还是失败(大多出现在 Centos7 以上),换下面这种:

#*          soft    nproc     4096
#root       soft    nproc     unlimited
* hard nproc 4096
* soft nproc 4096
elk soft nproc 4096
root soft nproc unlimited

5、max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
原因: 需要修改系统变量的最大值
解决方案:切换到 root 用户修改配置 vi /etc/sysctl.conf 增加配置值: vm.max_map_count=655360

执行命令 sysctl -p 这样就可以了,会显示如下信息

[root@localhost ~]#    sysctl -p
vm.max_map_count = 262144

6、system call filters failed to install; check the logs and fix your configuration or disable system call filters at your own risk
问题原因:因为Centos6不支持SecComp,而ES5.2.1默认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


























注:以上内容仅提供参考和交流,请勿用于商业用途,如有侵权联系本人删除!


持续更新中…

如有对思路不清晰或有更好的解决思路,欢迎与本人交流,QQ群:273557553,个人微信:
你遇到的问题是小编创作灵感的来源!


评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值