2026/5/19 0:53:27
网站建设
项目流程
专业网站制作公司教程,长沙 学校网站建设,参观互联网之光博览会,短网址生成算法建议先阅读这篇博客#xff0c;本文中只描述了关键信息#xff0c;整体流程可以看下面文章中间件升级-CSDN博客
说明#xff1a;
检索文档#xff0c;jdk1.8客户端最高支持到elasticsearch-rest-client7.17.x。不推荐进行升级#xff0c;如升级后使用需充分验证当前使用…建议先阅读这篇博客本文中只描述了关键信息整体流程可以看下面文章中间件升级-CSDN博客说明检索文档jdk1.8客户端最高支持到elasticsearch-rest-client7.17.x。不推荐进行升级如升级后使用需充分验证当前使用功能是否正常。es原始版本 8.1.3Kibana 等版本需同步升级。springboot版本2.7.18 , 默认elasticsearch-rest-client 7.17.15平台指定 elasticsearch-rest-client 8.1.3升级后推荐指定elasticsearch-rest-client 8.15.3下载地址https://www.elastic.co/downloads/elasticsearch服务安装Docker 安装详见 https://www.elastic.co/guide/en/elasticsearch/reference/8.15/docker.htmldocker pull docker.elastic.co/elasticsearch/elasticsearch:8.15.3docker run -d --name elasticsearch-8.15.3 -p 9200:9200 docker.elastic.co/elasticsearch/elasticsearch:8.15.3linux安装包下载# 下载地址 https://www.elastic.co/downloads/past-releases/elasticsearch-8-15-3 # 进入目录 cd /opt/easy-cloud # 下载文件arm框架请自行调整当前标记的为centos7版本其它版本请自行调整 wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.15.3-linux-x86_64.tar.gz # 解压文件 tar --no-same-owner -zxvf elasticsearch-8.15.3-*.tar.gz # 创建用户 useradd elastic passwd elastic # 赋权限给elastic用户 chown -R elastic:elastic /opt/easy-cloud/elasticsearch-8.15.3 # 进入目录 cd elasticsearch-8.15.3 # 备份配置文件 cp config/elasticsearch.yml config/elasticsearch.yml.bak # 核实内存是否更改本文设置为2g默认是4g如果服务内存充足可不进行修改 # vim config/jvm.options # 推荐更改-xms2g -xmx2gwindows安装包下载载地址https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.15.3-windows-x86_64.zip服务升级数据备份数据备份1. 进入文件夹cd /opt/easy-cloud2. 历史安装文件备份tar -zcvf elasticsearch-8.1.3.tar.gz elasticsearch-8.1.3 /3. 创建路径并授权mkdir -p /data/es/backup_repochown -R elastic:elastic /data/es/backup_repo-- 报错mkdir: cannot create directory /data: Permission denied 使用docker exec -u root -it xxx bash 进入容器4. 设置备份路径(先查看是否存在 cat config/elasticsearch.yml |grep path.repo)echo path.repo: [/data/es/backup_repo] config/elasticsearch.yml5. 重启当前es服务systemctl restart elasticsearch6. 创建快照仓库curl -k -u elastic:elastic -XPUT https://localhost:9200/_snapshot/my_local_repo -H Content-Type: application/json -d {type: fs,settings: {location: /data/es/backup_repo,compress: true,chunk_size: 100mb}}7. 验证快照仓库创建是否成功curl -k -u elastic:elastic -XGET https://localhost:9200/_snapshot/my_local_repo?pretty8. 真实创建快照curl -k -u elastic:elastic -XPUT https://localhost:9200/_snapshot/my_local_repo/upgrade_backup_8.1.3?wait_for_completiontrue -H Content-Type: application/json -d {indices: *,include_global_state: true}9. 验证快照有效性curl -k -u elastic:elastic -XGET https://localhost:9200/_snapshot/my_local_repo/upgrade_backup_8.1.3?pretty新服务启动1. 停止历史服务pgrep -f -u elastic elasticsearch | xargs -r kill -152. 进入目录cd /opt/easy-cloud/elasticsearch-8.15.33. 配置文件检查是否替换为了期望的配置文件cat config/elasticsearch.yml4. JVM内存检查。cat config/jvm.options |grep -E Xms|Xmx5. 系统内存检查sysctl -p-- 如果输出没有vm.max_map_count262144-- 执行指令追加配置到文件echo vm.max_map_count262144 /etc/sysctl.conf6. 默认文件数检查ulimit -Hnulimit -Sn--期望 65535,否则执行以下指令vim /etc/security/limits.conf 在 #End of file之前写入以下信息* hard nofile 65536* soft nofile 655367. 最后再次重新授权一下chown -R elastic:elastic /opt/easy-cloud/elasticsearch-8.15.38. 启动新服务su - elasticcd /opt/easy-cloud/elasticsearch-8.15.3 ./bin/elasticsearch -d9. 生成并重置默认密码bin/elasticsearch-reset-password -u elastic -ibin/elasticsearch-users useradd easy-es -p easyES123 -r superuser10. 验证服务是否启动curl -k -XGET -u elastic:elastic -k https://127.0.0.1:9200-- 看到版本号8.15.3输出说明正常生成。11. copy配置文件到目录(空环境easy-cloud-linux\es-config\elasticsearch.yml对比给出配置文件和当前配置文件config/elasticsearch.yml(验证先更改配置文件对应的证书无法生成12. 停止服务pgrep -f -u elastic elasticsearch | xargs -r kill -1513. 重新启动./bin/elasticsearch -d数据恢复此时不要启动业务服务不要让业务服务连接es并创建索引否则索引相同会导致恢复失败。1. 创建快照仓库curl -k -u elastic:elastic -XPUT https://localhost:9200/_snapshot/my_local_repo -H Content-Type: application/json -d {type: fs,settings: {location: /data/es/backup_repo,compress: true,chunk_size: 100mb}}2. 从快照恢复指定索引恢复前建议关闭目标索引恢复后重新打开curl -k -u elastic:elastic -XPOST https://localhost:9200/_snapshot/es_backup_repo/upgrade_backup_8.1.3/_restore?wait_for_completiontrue -H Content-Type: application/json -d {indices: *,include_global_state: true,ignore_unavailable: true,partial: false}3. 报错cannot restore index [hs_log_trace_20251205] because an open index with same name already exists in the cluster. Either close or delete the existing index or restore the index under a different name by providing a rename pattern and replacement name如果已经产生了索引可以进行索引的删除或者关闭。curl -k -XDELETE -u elastic:elastic -k https://127.0.0.1:9200/[需要删除的索引id]?pretty-- 示例curl -k -XDELETE -u elastic:elastic -k https://127.0.0.1:9200/hs_log_trace_20251205?pretty功能验证数据恢复后数据条数验证。程序是否可以正常构建新的索引。数据能正常写入版本回退1. 停止新服务pgrep -f -u elastic elasticsearch | xargs -r kill -152. 进入文件夹cd /opt/hussar-cloud3. 解压老版本数据如果原始文件夹未删除可忽略tar -zxvf elasticsearch-8.1.3.tar.gz4. 启动老服务cd /opt/hussar-cloud/elasticsearch-8.1.3 ./bin/elasticsearch -d5. 验证服务正常启动返回版本号8.1.3curl -k -XGET -u elastic:elastic -k https://127.0.0.1:92006. 风险点新版本的快照老版本加载较慢需要删除所有索引重新创建。新版本运行期间数据丢失。备注1. 启动报错java.nio.file.AccessDeniedException没有权限root账号执行chown -R elastic:elastic /opt/hussar-cloud/elasticsearch-8.15.32. 启动报错config/certs/transport.p12 because the file does not exist缺少证书从之前项目copyconfig/certs目录或者以下命令重新生成。./bin/elasticsearch-certutil cert --self-signed -out config/certs/transport.p12 -pass elastic./bin/elasticsearch-keystore add xpack.security.transport.ssl.keystore.secure_password3. 如果https 访问报错时 可以更改curl 的地址为http