-
7.7 版本的重大变更
-
安全设置变更
- 必须配置
xpack.security.transport.ssl.enabled
才能启用传输层 SSL 功能。 - 必须配置
xpack.security.http.ssl.enabled
才能启用 HTTP 层 SSL 功能。 - 若要为传输接口启用 SSL,需要提供证书和密钥。
- 若要为 HTTP 层启用 SSL,需要提供证书和密钥。
-
索引弃用变更(无影响)
- 事务日志保留设置已被弃用。
index.translog.retention.age
和index.translog.retention.size
索引设置现已弃用。自 7.4 版本起,这些设置就已被忽略,转而使用软删除功能。为避免出现弃用警告,请停止使用这些设置。
-
日志记录变更(无影响)
org.elasticsearch.action
下的日志记录器默认以INFO
级别记录日志。大多数日志记录器的默认日志级别为INFO
,但在早期版本中,org.elasticsearch.action.*
层级的日志记录器默认以DEBUG
级别发出日志消息,这有时会产生大量不必要的日志噪声。从 7.7 版本开始,该层级日志记录器的默认日志级别与其他大多数日志记录器一致,均为INFO
。如果需要,可以通过调整日志配置恢复 7.7 版本之前的默认行为。
-
映射变更
- 动态模板验证:到目前为止,只有在索引包含未映射字段的文档时,才会发现动态模板配置错误。在 Elasticsearch 8.0 及更高版本中,动态映射在更新映射时会进行更严格的验证。无效的更新(如使用不正确的分析器设置或未知的字段类型)将失败。对于在 Elasticsearch 7.7 及更高版本中创建的索引,更新操作会成功,但会发出警告。
-
设置变更(无影响)
-
thread_pool.listener.size
和thread_pool.listener.queue_size
已被弃用。Elasticsearch 内部不再使用监听器线程池,因此这些设置已被弃用。可以安全地从节点配置中移除这些设置。 -
cluster.remote.connect
已被弃用,建议使用node.remote_cluster_client
。以前,该设置用于配置本地节点是否能够在跨集群搜索和跨集群复制中充当远程集群客户端。此设置已被弃用,node.remote_cluster_client
具有相同的用途,并将本地节点标识为具有remote_cluster_client
角色。 -
认证领域的
order
配置在 8.0.0 版本中将成为必需项。在 8.0.0 版本中,任何类型的认证领域配置都需要order
配置。如果某个领域缺少此配置,节点将无法启动。 -
认证领域的
order
配置在 8.0.0 版本中将强制要求唯一。在 8.0.0 版本中,认证领域的order
配置必须唯一。如果为任何类型的多个领域配置了相同的order
,节点将无法启动。 -
不安全的监控密码设置已被弃用。监控 HTTP 导出器的
auth.password
设置已被弃用,并将在 8.0.0 版本中移除。请使用auth.secure_password
设置代替。 -
用于在一定数量的主节点就绪前推迟集群恢复的设置已被弃用。以下集群设置现已弃用:
gateway.expected_nodes
gateway.expected_master_nodes
gateway.recover_after_nodes
gateway.recover_after_master_nodes
只要大多数有资格成为主节点的节点加入集群,就可以安全地恢复集群。等待额外的有资格成为主节点的节点启动并无益处。为避免出现弃用警告,请停止使用这些已弃用的设置。如有需要,可以使用 gateway.expected_data_nodes
或 gateway.recover_after_data_nodes
在一定数量的数据节点就绪前推迟集群恢复。
-
搜索变更
- 日期范围字段范围查询的一致舍入:目前,
date_range
字段的范围查询边界可能与纯date
字段的等效查询略有不同。例如,在使用日期数学或未精确到最后一毫秒的日期时就可能出现这种情况。虽然date
字段的查询会将gt
和lt
边界向上舍入到最新的毫秒,但date_range
字段的相同查询不会这样做。现在,这两种字段类型的行为与日期数学和舍入 文档中描述的一致。 - 管道聚合验证错误:管道聚合验证已移至协调节点。以前返回 HTTP 500/内部服务器错误的错误现在返回 400/错误请求,并且现在返回验证错误列表,而不是只返回遇到的第一个错误。
-
高亮显示变更(无影响)
- 忽略关键字值不再高亮显示:如果关键字值在索引时因其长度(应用了
ignore_above
参数)而被忽略,Elasticsearch 将不再尝试对其进行高亮显示,这意味着不会为被忽略的值生成高亮显示结果。
-
升级步骤
滚动升级
-
备份elasticsearch.yml,jvm.option 文件
echo y | cp /etc/elasticsearch/elasticsearch.yml /data/elasticsearch.yml.20250326
echo y | cp /etc/elasticsearch/jvm.options /data/jvm.options.20250326
-
上传7.10.1版本es,ik,kibana
-
禁用副本分配
curl -X PUT "localhost:9200/_cluster/settings" -H 'Content-Type: application/json' -d'
{
"persistent": {
"cluster.routing.allocation.enable": "none"
}
}'
-
刷新索引
curl -X POST "localhost:9200/_flush/synced"
-
备份,创建快照
cp /data/elasticsearch /data/elasticsearch_20250326
创建快照仓库
curl -X PUT "localhost:9200_snapshot/mybackup" -H 'Content-Type: application/json' -d'
{
"type": "fs",
"settings": {
"location": "/data/es/snapshot"
}
}'
拍摄快照
curl-X PUT "localhost:9200/_snapshot/ecopherebbs/snapshot_20250326" -H 'Content-Type: application/json' -d'
{
"ignore_unavailable": true,
"include_global_state": true
}'
-
确认当前版本
curl http://127.0.0.1:9200/ | grep number
-
卸载ik分词器
/usr/share/elasticsearch/bin/elasticsearch-plugin remove analysis-ik
-
停止es服务
systemctl stop elasticsearch
-
卸载7.6.2版本es
rpm -qa | grep elasticsearch
rpm -e elasticsearch-7.6.2-1.x86_64
-
安装7.7.1版本
rpm -qa | grep elasticsearch
rpm -i elasticsearch-7.7.1-x86_64.rpm
-
安装ik分词器
echo y | /usr/share/elasticsearch/bin/elasticsearch-plugin install file:///data/elasticsearch-analysis-ik-7.7.1.zip
-
还原配置
echo y |cp /data/jvm.options.20250326 /etc/elasticsearch/jvm.options
echo y |cp /data/elasticsearch.yml.20250326 /etc/elasticsearch/elasticsearch.yml
-
启动es服务
cd /usr/share;chown -R elasticsearch:elasticsearch elasticsearch
systemctl start elasticsearch
-
检查当前节点升级状态
curl http://127.0.0.1:9200/_cat/nodes?v
curl http://127.0.0.1:9200/ | grep number
-
启用副本分配
curl -X PUT "localhost:9200/_cluster/settings" -H 'Content-Type: application/json' -d'
{
"persistent": {
"cluster.routing.allocation.enable": "all"
}
}'
#查看集群是否恢复正常
watch -n 5 'curl -s "localhost:9200/_cluster/health?pretty"'
备份kibana配置
cp /etc/kibana/kibana.yml /data/kibana.yml.20250326
升级kibana
systemctl stop kibana
rpm -qa | grep kibana
rpm -e kibana-7.6.2-1.x86_64
rpm -i kibana-7.7.1-x86_64.rpm
cp /data/kibana.yml.20250326 /etc/kibana/kibana.yml
-
回滚方案
-
禁用副本分配
curl -X PUT "localhost:9200/_cluster/settings" -H 'Content-Type: application/json' -d'
{
"persistent": {
"cluster.routing.allocation.enable": "none"
}
}'
-
刷新索引
curl -X POST "localhost:9200/_flush/synced"
-
回滚7.7.1版本ES,IK分词器,kibana
rpm -qa | grep elastic
/usr/share/elasticsearch/bin/elasticsearch-plugin remove analysis-ik
systemctl stop elasticsearch
rpm -e elasticsearch-7.7.1-1.x86_64
rpm -qa | grep elasticsearch
rpm -i elasticsearch-7.6.2-x86_64.rpm
echo y |/usr/share/elasticsearch/bin/elasticsearch-plugin install file:///data/es/elasticsearch-analysis-ik-7.6.2.zip
cd /usr/share;chown -R elasticsearch:elasticsearch elasticsearch
echo y |cp /data/jvm.options.20250326 /etc/elasticsearch/jvm.options
echo y |cp /data/elasticsearch.yml.20250326 /etc/elasticsearch/elasticsearch.yml
rpm -e kibana-7.7.1-1.x86_64
rpm -i kibana-7.6.2-x86_64.rpm
cp /data/kibana.yml.20250326 /etc/kibana/kibana.yml
-
清空数据目录(回退后无法启动)
-
使用快照回滚数据
curl -X POST "localhost:9200/_snapshot/bak_test/snapshot_20250326/_restore" -H 'Content-Type: application/json' -d'
{
"indices": "*",
"ignore_unavailable": true,
"include_global_state": false
}'
-
开启副本分配,验证数据完整性
systemctl start elasticsearch
curl -X PUT "localhost:9200/_cluster/settings" -H 'Content-Type: application/json' -d'
{
"persistent": {
"cluster.routing.allocation.enable": "all"
}
}'
#查看集群是否恢复正常
watch -n 5 'curl -s "localhost:9200/_cluster/health?pretty"'