elasticsearch-7.3.1安装注意事项
一、背景
因要使用信创环境,原A环境停止使用改用B环境,所以A环境的ES不可用需要重新部署到B环境,此处注意无安装包,只有A环境已经部署的ES配置文件等供参考。
二、步骤
因为B环境基本上完全copy A环境,所以elasticsearch的路径等均不变,默认安装生成路径不指定。设B环境ip:100.100.100.1
(1)路径记录:
bin执行路径:/usr/share/elasticsearch
logs路径:/var/log/elasticsearch
data路径:/var/lib/elasticsearch
config路径:/etc/elasticsearch
(2)ES数据导出:将/var/lib/elasticsearch/nodes的数据文件下载保存nodes.tar.gz
(3)用户:esuser
1、查看原ES版本
假设A环境为100.100.100.1,在终端输入以下命令,查看version中的number信息:
curl -uelastic -X GET “http://100.100.100.1:9200/”
显示为7.3.1
到ES官网下载此版本。
链接: https://www.elastic.co/cn/downloads/elasticsearch
2、新环境服务器
2.1、是否有elasticsearch
(1)查看是否有elasticsearch进程;
ps -ef|grep elasticsearch
(2)查看是否有elasticsearch安装包;
rpm -qa |grep elastic
(3)删除elasticsearch安装包。
yum remove elasticsearch
2.2、安装elasticsearch
(1)安装elasticsearch;
rpm -ivh elasticsearch-7.3.1-x86_64.rpm
如果安装有问题,卸载重新安装。
rpm -e elasticsearch-7.3.1-x86_64.rpm
(2)添加用户并到相关路径进行授权;
先用root账户
useradd esuser
chown -R esuser:root /etc/sysconfig/elasticsearch
chown -R esuser:root /usr/share/elasticsearch
chown -R esuser:root /var/log/elasticsearch
chown -R esuser:root /var/lib/elasticsearch
chown -R esuser:root /etc/elasticsearch
(3)环境变量;
su - esuser
cd /home/esuser
ll -als
vi .bash_profile
export JAVA_HOME=/usr/share/elasticsearch/jdk
export ES_HOME=/usr/share/elasticsearch/jdk
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/usr/share/elasticsearch/jdk/bin
source ~/.bash_profile
2.3、配置参数
将数据文件复制到指定路径
cd /var/lib/elasticsearch
mv nodes nodes.old
tar -zxvf nodes.tar.gz
vi /etc/sysconfig/elasticsearch
ES_home=/usr/share/elasticsearch/jdk
JAVA_HOME=/usr/share/elasticsearch/jdk
ES_PATH_CONF=/etc/elasticsearch
cd /etc/elasticsearch
vi jvm.options
-Xms1g
-Xmx1g
此处注意,如以下参数有则释放#并修改值,注意值前要先留个空格。没有就直接添加。
vi /etc/elasticsearch/elasticsearch.yml
cluster.name: my-application
node.max_local_storage_nodes: 2
path.data: /var/lib/elasticsearch
#可以通过逗号分隔指定多个目录
path.logs: /var/log/elasticsearch
network.host: 100.100.100.1
http.port: 9200
discovery.seed_hosts: [100.100.100.1]
cluster.initial_master_nodes: ["node-1"]
xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true
2.4、启动elasticsearch
cd /usr/share/elasticsearch/bin
./elasticsearch
或者
./elasticsearch -d
区别在于第一种日志直接打印在页面,如果当前页面关掉则elasticsearch停掉。第二种属于后台启动,日志打印在/var/log/elasticsearch/elasticsearch.log
2.5、设置密码
cd /usr/share/elasticsearch/bin
./elasticsearch-setup-passwords interactive
三、报错-问题总结
以下问题本次部署启动时均遇到,因为事后整理且无法看到执行记录,凭印象记录乱序排列。
1、jdk不适用
启动时显示jdk版本不适用,那就用ES自带的jdk,更新环境变量。
/usr/share/elasticsearch/jdk
2、bootstrap checks failed
执行时报错:
[ERROR][o.e.b.Bootstrap][i-z5rlfm6d] node validation exception
[1] bootstrap checks failed
[1] the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts,discovery.seed_providers, cluster.initial_master_nodes] must be configured
解决方法:vi /etc/elasticsearch/elasticsearch.yml增加修改以下两个参数:
discovery.seed_hosts: [100.100.100.1]
cluster.initial_master_nodes: [“node-1”]
3、Address already in use
端口还是ip,停止进程,重启。
ps -ef|grep elasticsearch
kill -9 进程号
lsof -i:9200|more或netstat -ulntp|grep 9200
kill -9 进程号
4、can not run elasticsearch as root
[ERROR][o.e.b.Bootstrap][i-z5rlfm6d] Exception
java.lang.RuntimeException:can not run elasticsearch as root
不用root启动elasticsearch,换其他用户。
5、modules] not found
两个错误都出来了,一开始modules在/usr/share/elasticsearch路径下,我看包第一个错误,就mv到jdk路径下,结果原路径也开始报错找不到文件,所以我又复制了一遍。相当于modules在两个路径下都存在且文件一致。
[ERROR][o.e.b.Bootstrap][i-z5rlfm6d] Exception
java.lang.illegalStateException:modules directory [/usr/share/elasticsearch/jdk/modules] not found
[ERROR][o.e.b.Bootstrap][i-z5rlfm6d] Exception
java.lang.illegalStateException:modules directory [/usr/share/elasticsearch/modules] not found
将/usr/share/elasticsearch路径下的modules同步到/usr/share/elasticsearch/jdk/路径下
cp -r /usr/share/elasticsearch/modules /usr/share/elasticsearch/jdk/
6、Event loop shut down?
[ERROR][i.n.u.c.D.rejectedExecution][i-z5rlfm6d]Failed to submit a listener notification task.Event loop shut down?
类问题3.3,杀掉进程重启。