升级 OpenResty Edge
我们建议您升级生产环境前,使用生产环境的数据构建一个与生产环境一样的测试环境进行升级测试,测试通过后再进行正式环境的升级。详细步骤见 克隆 OpenResty Edge 环境。
1. 升级 Log Server DB
注意
如果您的 Log Server 与 Edge Admin 部署在同一台机器,请先执行 3. 升级 Edge Node。如果您想要进行在线升级(推荐),可以直接下载安装器
curl -O https://openresty.com/client/oredge/openresty-edge-installer.sh
如果您想要用 bundle 包进行升级
请到下载中心 下载以下文件,如果没有请与我们联系:
a.
openresty-edge-bundle-VERSION.tar.gz
:包含 OpenResty Edge 的业务包、配置包及初始化数据等。旧名称是openresty-edge-bundle-VERSION.tar.gz
。解压
openresty-edge-bundle-VERSION.tar.gz
并进入解压后的目录tar xf openresty-edge-bundle-VERSION.tar.gz cd openresty-edge-bundle-VERSION
运行安装器
sudo /bin/bash openresty-edge-installer.sh
输入您要执行的操作
Upgrade
> Checking network... > Welcome to the OpenResty Edge Installer. [1] Install [2] Upgrade [3] Downgrade [4] Uninstall [5] Self Check [6] Get Default Info What would you like to do? 2 > You chose: Upgrade.
输入您想要升级的版本 (可以从 变更日志 获取最新的版本信息),如果使用安装器中的默认版本,可以直接回车
Which version would you like to upgrade to? (Default: 23.12.1, Press Enter to use the default version) [WARN] Using default version number: 23.12.1
输入您要升级的组件
Log Server DB
[WARN] If you haven't performed an upgrade test yet, we strongly recommend that you conduct one before proceeding. For details, please visit: https://doc.openresty.com/en/edge/edge-installation-upgrade/edge-env-clone/. [1] Edge Log Server Database [2] Edge Log Server [3] Edge Node [4] Edge Admin Database [5] Edge Admin [6] Edge Built-in WAF Rules [7] Rebuild [8] Clean database after upgrade [9] Exit What would you like to do? 1 > You chose: Edge Log Server Database
如果成功,最后会有如下提示
Great! update log-server database successfully.
2. 升级 Log Server
操作步骤相同,升级时组件选择
Log Server
[WARN] If you haven't performed an upgrade test yet, we strongly recommend that you conduct one before proceeding. For details, please visit: https://doc.openresty.com/en/edge/edge-installation-upgrade/edge-env-clone/. [1] Edge Log Server Database [2] Edge Log Server [3] Edge Node [4] Edge Admin Database [5] Edge Admin [6] Edge Built-in WAF Rules [7] Rebuild [8] Clean database after upgrade [9] Exit What would you like to do? 2 > You chose: Edge Log Server.
如果成功,最后会有如下提示
Great! Upgrade openresty-edge-log-server successfully.
在升级过程中,安装器会自动生成一个包含历史操作记录的目录。您将看到类似以下的提示信息:
This execution process will be saved in the /home/USER/openresty-edge-VERSION/oredge-history/2024-07-01-02-03-04
请注意,这个目录对于未来可能的降级操作至关重要。因此,我们强烈建议您保留此目录,不要删除它。
3. 升级 Edge Node
3.1 备份 Edge Node 数据库
如果你当前的 OpenResty Edge Admin 版本小于 1.3.0,则跳过此步骤。
- 登录 OpenResty Edge Admin 控制台
- 【网关集群】-【备份与还原】-【开始备份】
3.2 迁移流量(可选)
为避免影响业务,Edge Node 节点升级前,把该节点上的流量转移到其他未升级节点上。 此步骤为可选,但是强烈建议对最初升级的少数 Edge Node 执行此步骤:
- 迁移走流量
- 升级
- 验证
没问题后,再升级剩下的 Edge Node。另外,升级过程中请关注错误日志。
如果使用的 OpenResty Edge 的 DNS 控制流量,请按以下步骤把即将升级的 Edge Node 节点下线。
- 进入 OpenResty Edge 控制台
- 进入【网关集群】页面
- 对节点所在集群进行【编辑】
- 修改节点【状态】为【关闭 DNS,关闭集群缓存】
- 保存
等待节点不再有流量或只有少量流量。可通过查看访问日志确定:
tail -f /usr/local/oredge-node/logs/access.log
3.3 升级
操作步骤相同,升级时组件选择
Edge Node
[WARN] If you haven't performed an upgrade test yet, we strongly recommend that you conduct one before proceeding. For details, please visit: https://doc.openresty.com/en/edge/edge-installation-upgrade/edge-env-clone/. [1] Edge Log Server Database [2] Edge Log Server [3] Edge Node [4] Edge Admin Database [5] Edge Admin [6] Edge Built-in WAF Rules [7] Rebuild [8] Clean database after upgrade [9] Exit What would you like to do? 3 > You chose: Edge Node.
如果成功,最后会有如下提示
Great! Upgrade openresty-edge-node successfully.
在升级过程中,安装器会自动生成一个包含历史操作记录的目录。您将看到类似以下的提示信息:
This execution process will be saved in the /home/USER/openresty-edge-VERSION/oredge-history/2024-07-01-02-03-04
请注意,这个目录对于未来可能的降级操作至关重要。因此,我们强烈建议您保留此目录,不要删除它。
4. 升级 Edge Admin 数据库
操作步骤相同,升级时组件选择
Edge Admin DB
[WARN] If you haven't performed an upgrade test yet, we strongly recommend that you conduct one before proceeding. For details, please visit: https://doc.openresty.com/en/edge/edge-installation-upgrade/edge-env-clone/. [1] Edge Log Server Database [2] Edge Log Server [3] Edge Node [4] Edge Admin Database [5] Edge Admin [6] Edge Built-in WAF Rules [7] Rebuild [8] Clean database after upgrade [9] Exit What would you like to do? 4 > You chose: Edge Admin DB.
注意
执行备份命令前,请先检查磁盘空间是否足够。备份 Edge Admin 数据库
Do you want to backup db? [Y/N]: y
如果成功,最后会有如下提示
Great! update admin database successfully.
5. 升级 Edge Admin-web
操作步骤相同,升级时组件选择
Edge Admin
[WARN] If you haven't performed an upgrade test yet, we strongly recommend that you conduct one before proceeding. For details, please visit: https://doc.openresty.com/en/edge/edge-installation-upgrade/edge-env-clone/. [1] Edge Log Server Database [2] Edge Log Server [3] Edge Node [4] Edge Admin Database [5] Edge Admin [6] Edge Built-in WAF Rules [7] Rebuild [8] Clean database after upgrade [9] Exit What would you like to do? 5 > You chose: Edge Admin.
如果成功,最后会有如下提示
Great! Upgrade openresty-edge-admin successfully.
在升级过程中,安装器会自动生成一个包含历史操作记录的目录。您将看到类似以下的提示信息:
This execution process will be saved in the /home/USER/openresty-edge-VERSION/oredge-history/2024-07-01-02-03-04
请注意,这个目录对于未来可能的降级操作至关重要。因此,我们强烈建议您保留此目录,不要删除它。
6. (可选)升级 WAF 规则集
- 首先备份 WAF 规则集:
- 登录 Edge Admin 管理界面
- 进入 全局配置 > 全局 WAF > 导出 WAF 规则
接着升级 WAF 规则集,有两个方法,选择其中一个即可:
方法一:通过下载中心下载 WAF 规则集,然后在 进入 全局配置 > 全局 WAF > 导入 WAF 规则,进行升级。
方法二:与前面的操作步骤相同,升级时组件选择
Edge Built-in WAF Rules
[WARN] If you haven't performed an upgrade test yet, we strongly recommend that you conduct one before proceeding. For details, please visit: https://doc.openresty.com/en/edge/edge-installation-upgrade/edge-env-clone/. [1] Edge Log Server Database [2] Edge Log Server [3] Edge Node [4] Edge Admin Database [5] Edge Admin [6] Edge Built-in WAF Rules [7] Rebuild [8] Clean database after upgrade [9] Exit What would you like to do? 6 > You chose: Edge Built-in WAF Rules.
7. 重新编译
操作步骤相同,升级时组件选择
Rebuild
[WARN] If you haven't performed an upgrade test yet, we strongly recommend that you conduct one before proceeding. For details, please visit: https://doc.openresty.com/en/edge/edge-installation-upgrade/edge-env-clone/. [1] Edge Log Server Database [2] Edge Log Server [3] Edge Node [4] Edge Admin Database [5] Edge Admin [6] Edge Built-in WAF Rules [7] Rebuild [8] Clean database after upgrade [9] Exit What would you like to do? 7 > You chose: Rebuild.
先重新编译几个流量较少的不包含泛域名的 HTTP 应用,再编译几个大流量的不包含泛域名的 HTTP 应用
Do you want to rebuild one application for test? [Y/N]: y Please input the application id: 1 rebuild application 1
再继续根据提示进行编译
Do you want to rebuild upgrade config? [Y/N]: y rebuild upgrade config recompile upgrade configurations successfully Do you want to rebuild all wilecard apps? [Y/N]: y rebuild all wilecard apps Do you want to rebuild all apps? [Y/N]: y Do you want to compile concurrently? [Y/N]: n rebuild all apps Do you want to rebuild all http_proxy apps? [Y/N]: y rebuild all http_proxy apps Do you want to rebuild all socks5_apps? [Y/N]: y rebuild all sock5_proxy apps Do you want to rebuild global? [Y/N]: y rebuild global recompile global successfully Do you want to rebuild waf? [Y/N]: y rebuild waf recompiled all of the WAF rule sets successfully. Do you want to rebuild dns? [Y/N]: y rebuild dns recompile dns successfully. Do you want to rebuild global-action? [Y/N]: y rebuild global-action recompile global action successfully Do you want to rebuild gateway? [Y/N]: y rebuild gateway recompiled gateway successfully rebuild done!
如果业务指标都表现正常,升级完成!
如果 HTTP/HTTPS 应用数量很多,可能这一步的编译时间会比较长:
Do you want to rebuild all apps? [Y/N]: y
此时,接下来可以选择并发编译,将启动 4 个进程来编译:
Do you want to compile concurrently? [Y/N]: y
如果不够快,可以修改安装器指定更大的并发,但是不能超过 8,比如:
sudo /bin/bash utils/parallel-recompile.sh 8
8. (可选)升级完成后
在执行完前面的步骤并验证完成后,可以执行此步骤来清理不再需要的数据库字段或者对数据库字段增加约束。
操作步骤相同,升级时组件选择
Clean db after upgrade
[WARN] If you haven't performed an upgrade test yet, we strongly recommend that you conduct one before proceeding. For details, please visit: https://doc.openresty.com/en/edge/edge-installation-upgrade/edge-env-clone/. [1] Edge Log Server Database [2] Edge Log Server [3] Edge Node [4] Edge Admin Database [5] Edge Admin [6] Edge Built-in WAF Rules [7] Rebuild [8] Clean database after upgrade [9] Exit What would you like to do? 8 > You chose: Clean db after upgrade.
如果成功,最后会有如下提示
Great! upgrade admin database successfully.
有问题我们随时沟通 :)