9.10 升级InnoDB ReplicaSet

2024年 3月 21日 50.0k 0

要升级 InnoDB ReplicaSet 中的实例,请完成以下步骤:

升级MySQL路由器。

升级 MySQL Shell。

升级MySQL服务器。

升级后状态检查。

检查已安装的二进制文件的版本:

mysqlrouter --version:检查安装的 MySQL Router 的版本。

mysqlsh --version:检查安装的 MySQL Shell 版本。

mysqld --version:检查安装的 MySQL 服务器的版本。

升级 MySQL 路由器。
要升级 MySQL Router,请完成以下步骤:

停止 MySQL 路由器。

在 Unix 系统上,如果您使用了可选的引导选项,则会在您引导 路由器 --directory时选择的位置创建一个独立的安装,其中包含所有生成的目录和文件 。这些文件包括. 导航到该目录并发出以下命令: stop.sh

./stop.sh
在 Microsoft Windows 上,如果您使用了可选的 引导选项,则会在您引导 路由器–directory时选择的位置创建一个独立的安装,其中包含所有生成的目录和文件 。这些文件包括. 导航到该目录并发出以下命令: stop.ps1

.\stop.ps1
或者在 Linux 系统上使用systemd,通过发出以下命令来停止 MySQL Router 服务:

systemctl stop mysqlrouter.service
否则,杀死关联的mysqlrouter进程的 进程 ID (PID)。

获取并安装最新版本的 MySQL Router。

启动 MySQL 路由器。

在 Unix 系统上,如果您使用可选的 - -directorybootstrap 选项,则会在您选择的位置创建一个独立的安装,其中包含所有生成的目录和文件。这些文件包括 start.sh. 导航到该目录并发出以下命令:

./start.sh
如果新路由器的路径已更改,则必须更新start.shshell 脚本以反映该路径。

#!/bin/bash
basedir=/tmp/myrouter
ROUTER_PID=$basedir/mysqlrouter.pid /usr/bin/mysqlrouter -c $basedir/mysqlrouter.conf &
disown %-
如果您手动升级 MySQL Router,而不是使用包管理,则可以更新basedir=. 再次引导路由器也会重新生成 start.shshell 脚本。

或者在 Linux 系统上使用systemd,通过发出以下命令启动 MySQL Router 服务:

systemctl start mysqlrouter.service
在 Microsoft Windows 上,如果您使用了可选的 - -directorybootstrap 选项,则会在您选择的位置创建一个独立的安装,其中包含所有生成的目录和文件。这些文件包括 start.ps1. 导航到该目录并发出以下命令:

.\start.ps1
使用新的路由器二进制文件启动 MySQL Router 时,路由器的版本会升级:

mysqlrouter --version
升级 MySQL Shell
通过安装新的二进制文件并停止和启动 MySQL Shell 来升级 MySQL Shell:

获取并安装最新版本的 MySQL Shell。

通过发出以下命令来停止并退出 MySQL Shell:

\q
通过发出以下命令从命令行重新启动 MySQL Shell:

mysqlsh
升级 InnoDB ReplicaSet 元数据:

要升级 InnoDB ReplicaSet,请将 MySQL Shell 的全局会话连接到您的 ReplicaSet,并使用该 dba.upgradeMetadata()操作将 ReplicaSet 的元数据升级到新的元数据。

该dba.upgradeMetadata()函数将已安装的元数据模式的版本与此 Shell 支持的元数据模式的版本进行比较。如果安装的元数据版本较低,则启动升级过程。

元数据升级
如果 ReplicaSet 已经使用最新版本,则元数据升级可能不会执行任何操作。

升级MySQL服务器
通过在升级主实例之前升级所有辅助实例来升级 MySQL Server。

升级 MySQL 服务器是可选的
升级 MySQL 服务器是可选的。服务器升级比升级 MySQL Shell 和 MySQL Router 产生的影响更大。另外,你应该始终将 MySQL Shell 和 MySQL Router 保持在最新版本,即使服务器不是;对于 InnoDB Cluster 和 ReplicaSet 来说也是如此。

通过发出以下命令之一停止 MySQL 服务器:

如果 MySQL 服务器使用 systemd问题:

systemctl stop mysqld
如果 MySQL 服务器正在使用 init.d问题:

/etc/init.d/mysql stop
如果MySQL Server正在使用 服务问题:

service mysql stop
如果您在 Microsoft Windows 上部署 MySQL Server 问题:

mysqladmin -u root -p shutdown
获取并安装最新版本的 MySQL Server。

通过发出以下命令之一启动 MySQL 服务器:

如果 MySQL 服务器使用 systemd问题:

systemctl start mysqld
如果 MySQL 服务器正在使用 init.d问题:

/etc/init.d/mysql start
如果MySQL Server正在使用 服务问题:

service mysql start
如果您在 Microsoft Windows 上部署 MySQL Server 问题:

mysqld
当您升级完所有辅助实例后,升级主实例以完成升级过程。

InnoDB ReplicaSet 中没有自动主切换。升级主实例前,您需要将主实例设置为已升级的成员。

将升级后的辅助实例设置为主实例:

.setPrimaryInstance(’:

’)
使用该.setPrimaryInstance() 操作可以安全地将 ReplicaSet 的主实例更改为另一个实例。当前主实例将降级为辅助实例并设为只读,而升级后的实例将成为新的主实例并设为读写。所有其他辅助实例都会更新为从新的主实例进行复制。您针对 ReplicaSet 引导的 MySQL Router 实例会自动开始将读写客户端重定向到新的主实例。

升级old主实例。升级后,您可以用来 .setPrimaryInstance()将此升级后的实例恢复为主实例。有关更多信息,请参阅 第 9.6 节 “更改主实例”。

升级后状态检查
升级 MySQL Router 后,MySQL Shell 和 MySQL Server 都会升级:

通过发出 来检查 ReplicaSet 的状态 .status()。在以下示例中,.status()返回一个 instanceErrors:

mysqlsh> .status();
{
“replicaSet”: {
“name”: “myReplicaSet”,
“primary”: “example-el7-1644251369:30014”,
“status”: “AVAILABLE”,
“statusText”: “All instances available.”,
“topology”: {
“example-el7-1644251369:30011”: {
“address”: “example-el7-1644251369:30011”,
“instanceErrors”: [
“NOTE: The required parallel-appliers settings are not enabled on the instance.
Use dba.configureReplicaSetInstance() to fix it.”
],
“instanceRole”: “SECONDARY”,
“mode”: “R/O”,
“replication”: {
“applierStatus”: “APPLIED_ALL”,
“applierThreadState”: “Waiting for an event from Coordinator”,
“applierWorkerThreads”: 4,
“receiverStatus”: “ON”,
“receiverThreadState”: “Waiting for source to send event”,
“replicationLag”: null
},
“status”: “ONLINE”
},
“example-el7-1644251369:30014”: {
“address”: “example-el7-1644251369:30014”,
“instanceErrors”: [
“NOTE: The required parallel-appliers settings are not enabled on the instance.
Use dba.configureReplicaSetInstance() to fix it.”
],
“instanceRole”: “PRIMARY”,
“mode”: “R/W”,
“status”: “ONLINE”
},
“example-el7-1644251369:30017”: {
“address”: “example-el7-1644251369:30017”,
“instanceErrors”: [
“NOTE: The required parallel-appliers settings are not enabled on the instance.
Use dba.configureReplicaSetInstance() to fix it.”
],
“instanceRole”: “SECONDARY”,
“mode”: “R/O”,
“replication”: {
“applierStatus”: “APPLIED_ALL”,
“applierThreadState”: “Waiting for an event from Coordinator”,
“applierWorkerThreads”: 4,
“receiverStatus”: “ON”,
“receiverThreadState”: “Waiting for source to send event”,
“replicationLag”: null
},
“status”: “ONLINE”
},
“example-el7-1644251369:30021”: {
“address”: “example-el7-1644251369:30021”,
“instanceErrors”: [
“NOTE: The required parallel-appliers settings are not enabled on the instance.
Use dba.configureReplicaSetInstance() to fix it.”
],
“instanceRole”: “SECONDARY”,
“mode”: “R/O”,
“replication”: {
“applierStatus”: “APPLIED_ALL”,
“applierThreadState”: “Waiting for an event from Coordinator”,
“applierWorkerThreads”: 4,
“receiverStatus”: “ON”,
“receiverThreadState”: “Waiting for source to send event”,
“replicationLag”: null
},
“status”: “ONLINE”
}
},
“type”: “ASYNC”
}
}
它instanceError告诉我们发出 dba.configureReplicaSetInstance()问题来修复错误。

dba.configureReplicaSetInstance(instance) 配置您想要在 ReplicaSet 中使用的每个实例。MySQL Shell 可以连接到实例然后对其进行配置,也可以传入名称 instance来配置特定的远程实例。有关更多信息,请参阅 第 6.2.4 节 “持久设置”。

.status()以下示例显示了如果 PRIMARY成员具有read_only 或super_read_only设置为 的 输出 ON:

mysqlsh > .status();
replicaset.status();
{
“replicaSet”: {
“name”: “myReplicaSet”,
“primary”: “example-el7-1644251369:30014”,
“status”: “UNAVAILABLE”,
“statusText”: “PRIMARY instance is not available, but there is at least one SECONDARY
that could be force-promoted.”,
“topology”: {
“example-el7-1644251369:30011”: {
“address”: “example-el7-1644251369:30011”,
“instanceErrors”: [
“NOTE: The required parallel-appliers settings are not enabled on the instance.
Use dba.configureReplicaSetInstance() to fix it.”
],
“instanceRole”: “SECONDARY”,
“mode”: “R/O”,
“replication”: {
“applierStatus”: “APPLIED_ALL”,
“applierThreadState”: “Waiting for an event from Coordinator”,
“applierWorkerThreads”: 4,
“receiverStatus”: “ON”,
“receiverThreadState”: “Waiting for source to send event”,
“replicationLag”: null
},
“status”: “ONLINE”
},
“example-el7-1644251369:30014”: {
“address”: “example-el7-1644251369:30014”,
“fenced”: true,
“instanceErrors”: [
“ERROR: Instance is a PRIMARY but is READ-ONLY: read_only=ON, super_read_only=ON”,
“NOTE: The required parallel-appliers settings are not enabled on the instance.
Use dba.configureReplicaSetInstance() to fix it.”
],
“instanceRole”: “PRIMARY”,
“mode”: “R/O”,
“status”: “ERROR”
},
“example-el7-1644251369:30017”: {
“address”: “example-el7-1644251369:30017”,
“instanceErrors”: [
“NOTE: The required parallel-appliers settings are not enabled on the instance.
Use dba.configureReplicaSetInstance() to fix it.”
],
“instanceRole”: “SECONDARY”,
“mode”: “R/O”,
“replication”: {
“applierStatus”: “APPLIED_ALL”,
“applierThreadState”: “Waiting for an event from Coordinator”,
“applierWorkerThreads”: 4,
“receiverStatus”: “ON”,
“receiverThreadState”: “Waiting for source to send event”,
“replicationLag”: null
},
“status”: “ONLINE”
},
“example-el7-1644251369:30021”: {
“address”: “example-el7-1644251369:30021”,
“instanceErrors”: [
“NOTE: The required parallel-appliers settings are not enabled on the instance.
Use dba.configureReplicaSetInstance() to fix it.”
],
“instanceRole”: “SECONDARY”,
“mode”: “R/O”,
“replication”: {
“applierStatus”: “APPLIED_ALL”,
“applierThreadState”: “Waiting for an event from Coordinator”,
“applierWorkerThreads”: 4,
“receiverStatus”: “ON”,
“receiverThreadState”: “Waiting for source to send event”,
“replicationLag”: null
},
“status”: “ONLINE”
}
},
“type”: “ASYNC”
}
}
有关更多信息,请参见 第 9.9 节 “检查 InnoDB ReplicaSet 的状态”。。

相关文章

Oracle如何使用授予和撤销权限的语法和示例
Awesome Project: 探索 MatrixOrigin 云原生分布式数据库
下载丨66页PDF,云和恩墨技术通讯(2024年7月刊)
社区版oceanbase安装
Oracle 导出CSV工具-sqluldr2
ETL数据集成丨快速将MySQL数据迁移至Doris数据库

发布评论