这篇文章主要讲解了“Elasticsearch 5.1.1如何升级到6.7.2”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“Elasticsearch 5.1.1如何升级到6.7.2”吧!
因为我们的ES版本低于5.6,所以需要通过全集群重启的方式来升级,升级过程主要参考官方文档:
https://www.elastic.co/guide/en/elasticsearch/reference/6.0/setup-upgrade.html
因为es的shard分片,包含主从分片,而主从分片一般在不同的节点。如果一台节点挂了(当然,升级过程中是我们主动关机),es会进行分片的重分配,因为全部是网络IO,慢到爆炸。所以我们首先要关闭shard片重分配。
方法很简单:
PUT _cluster/settings { "persistent": { "cluster.routing.allocation.enable": "none" } }
刷一下shard片:
POST _flush/synced
关闭Elasticsearch服务,注意,要一台一台关:
sudo systemctl stop elasticsearch.service
注意,这一步坑很多,我一条一条记录。
首先参考官网文档
https://www.elastic.co/guide/en/elasticsearch/reference/6.0/rpm.html
因为我们的服务器不能连接Internet,所以需要下载以下几个文件,特别是 elasticsearch-6.7.2.rpm.sha512 GPG-KEY-elasticsearch,这两个文件一定不能少。
其中GPG-KEY-elasticsearch可以通过以下来下载
wget https://artifacts.elastic.co/GPG-KEY-elasticsearch
下载完成之后包含以下文件:
$ ls elasticsearch-6.7.2.rpm elasticsearch-6.7.2.rpm.sha512 GPG-KEY-elasticsearch kibana-6.7.2-x86_64.rpm
然后引入es的公钥,因为我们是在本地的,需要改一下路径:
rpm --import ./GPG-KEY-elasticsearch
引入公钥之后,需要校验rpm包的完整性,这里采用sha512的方式。如果没有安装相关工具会报错,需要先安装sha校验工具:
sudo yum install perl-Digest-SHA
校验:
shasum -a 512 -c elasticsearch-6.7.2.rpm.sha512
然后第一个坑来了,按照官网的教程安装
sudo rpm --install elasticsearch-6.7.2.rpm
会出现文件冲突报错,原因是已经安装过老版本的es了。
file /etc/init.d/elasticsearch from install of elasticsearch-0:6.7.2-1.noarch conflicts with file from package elasticsearch-0:5.1.1-1.noarch file /etc/sysconfig/elasticsearch from install of elasticsearch-0:6.7.2-1.noarch conflicts with file from package elasticsearch-0:5.1.1-1.noarch file /usr/share/elasticsearch/bin/elasticsearch from install of elasticsearch-0:6.7.2-1.noarch conflicts with file from package elasticsearch-0:5.1.1-1.noarch ...
再此我们使用来安装
sudo rpm --Uvh elasticsearch-6.7.2.rpm
装一半又报错了,可以看到elasticsearch.keystore不存在,我就创建了一个elasticsearch.keystore,安装即可成功。注意,这里是一个大坑,后面详说。
Preparing... ################################# [100%] Updating / installing... 1:elasticsearch-0:6.7.2-1 warning: /etc/elasticsearch/elasticsearch.yml created as /etc/elasticsearch/elasticsearch.yml.rpmnew warning: /etc/sysconfig/elasticsearch created as /etc/sysconfig/elasticsearch.rpmnew warning: /usr/lib/systemd/system/elasticsearch.service created as /usr/lib/systemd/system/elasticsearch.service.rpmnew ################################# [ 50%] Cleaning up / removing... 2:elasticsearch-0:5.1.1-1 warning: /etc/elasticsearch/scripts saved as /etc/elasticsearch/scripts.rpmsave ################################# [100%] ES_PATH_CONF must be set to the configuration path chown: cannot access ‘/etc/elasticsearch/elasticsearch.keystore’: No such file or directory chmod: cannot access ‘/etc/elasticsearch/elasticsearch.keystore’: No such file or directory md5sum: /etc/elasticsearch/elasticsearch.keystore: No such file or directory warning: %posttrans(elasticsearch-0:6.7.2-1.noarch) scriptlet failed, exit status 1
创建之后,就安装成功啦:
Preparing... ################################# [100%] package elasticsearch-0:6.7.2-1.noarch is already installed
安装成功之后,我们就该启动elasticsearch集群了:
sudo service elasticsearch start
但不幸的是启动失败,elasticsearch的9200端口无响应,查看启动状态,可以看到Active: failed。
[yuliangwang@LPT0268 ~]$ systemctl status elasticsearch.service ● elasticsearch.service - Elasticsearch Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; disabled; vendor preset: disabled) Active: failed (Result: exit-code) since Fri 2019-06-28 16:50:18 CST; 24s ago Docs: http://www.elastic.co Process: 11905 ExecStart=/usr/share/elasticsearch/bin/elasticsearch -p ${PID_DIR}/elasticsearch.pid --quiet -Edefault.path.logs=${LOG_DIR} -Edefault.path.data=${DATA_DIR} -Edefault.path.conf=${CONF_DIR} (code=exited, status=1/FAILURE) Process: 13440 ExecStartPre=/usr/share/elasticsearch/bin/elasticsearch-systemd-pre-exec (code=exited, status=203/EXEC) Main PID: 11905 (code=exited, status=1/FAILURE)
感谢各位的阅读,以上就是“Elasticsearch 5.1.1如何升级到6.7.2”的内容了,经过本文的学习后,相信大家对Elasticsearch 5.1.1如何升级到6.7.2这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是亿速云,小编将为大家推送更多相关知识点的文章,欢迎关注!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。