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;


在升級完所有的服務器後,你可以按需將主副本切換回來。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章