SQL Server 2017 AlwaysOn on Linux 配置和维护(14)

2.5 操作

2.5.1可用性组升级

在升级之前,可以参考升级AG副本实例的模型和实践。

升级实例的顺序依赖于角色是否为辅助副本和他们是同步或异步副本。首先升级承载异步副本的实例,然后升级承载同步副本的实例。

注意:如果一个AG只有异步副本,为了避免数据丢失,修改一个副本为同步,等待直到同步后,然后升级该副本。


以下为AG在Linux上执行滚动升级SQL Server实例。


备份每个数据库


停止即将升级的目标辅助副本节点上的资源

pcs constraint location ag_cluster-master avoids nodeName1


在辅助副本上升级SQL Server

sudo yum update mssql-server
sudo yum update mssql-server-ha


移除位置约束

pcs constraint remove location-ag_cluster-master-rhel1--INFINITY


验证升级后资源启动、辅助副本已连接并同步

pcs status


在所有辅助副本升级后,手工故障转移到一个同步副本。

对于AG为EXTERNAL类型,使用群集管理工具来故障转移;

对于AG为NONE类型,使用Transact-SQL来故障转移。

sudo pcs resource move ag_cluster-master <targetReplicaName> --master

重要:以下步骤仅适用于AG没有群集管理器的情况。


如果AG为NONE类型,手动故障转移。按以下顺序完成。

1.设置主副本为辅助

ALTER AVAILABILITY GROUP [ag1] SET (ROLE = SECONDARY);

2.设置同步辅助副本为主

ALTER AVAILABILITY GROUP [ag1] FAILOVER;


在故障转移后,在旧的主副本上升级SQL Server

# add constraint for the resource to stop on the upgraded node
# replace 'nodename2' with the name of the cluster node targeted for upgrade
pcs constraint location ag_cluster-master avoids nodeName2
# upgrade mssql-server and mssql-server-ha packages
sudo yum update mssql-server
sudo yum update mssql-server-ha
# remove the constraint; make sure the resource is started and replica is connected and synchronized
pcs constraint remove location-ag_cluster-master-rhel1--INFINITY


对于AG类型为EXTERNAL,清理手动故障转移导致的位置约束

sudo pcs constraint remove cli-prefer-ag_cluster-master


对于新升级的辅助副本(即旧的主副本)恢复数据移动

ALTER DATABASE database_name SET HADR RESUME;


在升级完所有的服务器后,你可以按需将主副本切换回来。

猜你喜欢

转载自blog.51cto.com/ultrasql/2173392
今日推荐