Elasticsearch2.X升级至5.X问题汇总


问题描述

Elasticsearch 5.0已正式发布一段时间

1. Lucene升级到了6.2,搜索方面会有巨大的性能提升

2. 优化Indexing过程,性能会更加稳定

3. 新增Ingest Node,用于数据转换,相当于Elastic Search里内置了一个Logstash。或许有比bulk更好的Indexing性能

排查思路

启动过程一直失败,通过查看错误日志,发现如下问题总结在解决方案中

解决方案

首先贴上完整升级流程:

1、按顺序关闭kibana logstash elasticsearch

2、由于新版本ES不支持任何插件,所以清除该目录下的所有插件/usr/share/elasticsearch/plugins

3、备份es kibana 等配置文件

4、更新es

执行rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
增加yum源
[elasticsearch-5.x]
name=Elasticsearch repository for 5.x packages
baseurl=https://artifacts.elastic.co/packages/5.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md

5、ES变更三处

用最新的启动程序覆盖:/etc/init.d/elasticsearch
修改内存:/etc/elasticsearch/jvm.options
切记用最新的配置文件,并在其基础上恢复旧的配置:/etc/elasticsearch/elasticsearch.yml

6、更新部署kibana,实为直接解压最新安装包即可,并修改yml配置

7、修改limits.conf的相关参数,详情在问题集里

8、按顺序启动 elasticsearch logstash kibana ,进行数据索引加载完成更新



问题集合

解决方法

1

Unable to lock JVM Memory: error=12, reason=Cannot allocate memory
This can result in part of the JVM being swapped out.
Increase RLIMIT_MEMLOCK, soft limit: 65536, hard limit: 65536
These can be adjusted by modifying /etc/security/limits.conf

/etc/security/limits.conf
elasticsearch soft memlock unlimited
elasticsearch hard memlock unlimited

2

Since elasticsearch 5.x index level settings can NOT be set on the nodes
configuration like the elasticsearch.yaml, in system properties or command line
arguments.In order to upgrade all indices the settings must be updated via the
/${index}/_settings API. Unless all settings are dynamic all indices must be closed
in order to apply the upgradeIndices created in the future should use index templates
to set default values.

解决方法:
注释主配置文件里面的,官方建议生成索引时再设置
# index.number_of_shards: 5
# index.number_of_replicas: 1

Please ensure all required values are updated on all indices by executing:curl -XPUT 'http://localhost:9200/_all/_settings?preserve_existing=true' -d '{

"index.number_of_replicas" : "1",
"index.number_of_shards" : "10"
}'

3

[2016-11-07T12:26:05,957][ERROR][o.e.b.Bootstrap ] Exception
java.lang.IllegalArgumentException: unknown setting [script.indexed] did you mean any of [script.inline, script.ingest]?

目前我注释了,这个应该是语法错误,后续再查官网
#script.inline: true
#script.indexed: true

4

max file descriptors [65535] for elasticsearch process likely too low, increase to at least [65536]
max number of threads [1024] for user [elasticsearch] likely too low, increase to at least [2048]

报错信息直接提示了修改limits.conf的相关参数
elasticsearch soft nofile 65536
elasticsearch hard nofile 131072
elasticsearch soft nproc 2048
elasticsearch hard nproc 4096

5


Copy2.X的elasticsearch.yml到5.0里,大量报错

1)踩了个"node settings must not contain any index level settings",报错提示是所有index配置(例如 index.mapper.dynamic)都需要在ES启动之后通过接口来改。
2)script开头的配置项也没了。
3)一些配置项的名字改了,例如 bootstrap.mlockall 改成了 bootstrap.memory_lock。

建议直接在5.0的elasticsearch.yml上面改配置!
另外./config/ 里面新增了 jvm.options 和 log4j2.properties,取消了logging.yml。关于内存的配置可以直接在 jvm.options 里面设,不需要折腾环境变量了。

6

动报错,提示调高JVM线程数限制
bootstrap checks failed
max virtual memory areas vm.max_map_count [65530] likely too low, increase to at least [262144]

vim /etc/sysctl.conf

vm.max_map_count=262144 #添加这一行

7 搜索报错,默认Scripting语言从groovy改成了painless

这个坑藏得好深,困惑了一段时间...最后改query的lang字段为painless就过了

8

5.x的es,不再使用索引名称作为目录了,而是hash值

原来:Feb 7 00:05 logstash-www-2017.02.07
现在:Feb 7 11:24 ZpSCDUgGR2KfaHmu_fgx_A

9



关于ES插件的问题

现在ES所有插件都不能安装了,否则会导致启动报错

现在必须使用官方推荐的X-Pack作为集成在kibana上的web展示管理插件

一直以来,Elastic Search团队提供的付费插件与服务都感觉不痛不痒。新发布的X-Pack把所有付费痛点打包到一起了,包括权限控制、更好的数据可视化系统、经常被提出的报表系统等,这是Elastic Search商业化非常重要的一步(另一步是Elastic Cloud)

但X-Pack需要进行注册认证,否则只能使用1个月,目前推荐的做法是在es配置文件添加 xpack.security.enabled: false