LISTENER_URL = 'tcp://ag1-listener.contoso.com:5022'or'tcp://IPADDRESS:5022' ,
LISTENER_URL = 'tcp://ag1-listener.contoso.com:5022'or'tcp://IPADDRESS:5022' ,
below query should run on Global forwarder
ALTER AVAILABILITY GROUP [distributedag]
JOIN
AVAILABILITY GROUP ON
'ag1' WITH
(
LISTENER_URL = 'tcp://ag1-listener.contoso.com:5022'or'tcp://IPADDRESS:5022' ,
AVAILABILITY_MODE = ASYNCHRONOUS_COMMIT,
FAILOVER_MODE = MANUAL,
SEEDING_MODE = AUTOMATIC
),
'ag2' WITH
(
LISTENER_URL = 'tcp://ag1-listener.contoso.com:5022'or'tcp://IPADDRESS:5022' ,
AVAILABILITY_MODE = ASYNCHRONOUS_COMMIT,
FAILOVER_MODE = MANUAL,
SEEDING_MODE = AUTOMATIC
);
GO
After executing the above queries if databases are not added at Global forwarder run below query forwarder
ALTER AVAILABILITY GROUP [ag2] GRANT CREATE ANY DATABASE
Modify availability mode of the Distributed Availability Group (Dist_AG01_AG02) in the primary Availability Group (AG01)
:CONNECT TDPRD071
--Modify availability mode of the primary and secondary AGs in a Distributed Availability Group
--Run this on the primary replica of the primary AG – TDPRD071
ALTER AVAILABILITY GROUP [Dist_AG01_AG02]
MODIFY
AVAILABILITY GROUP ON
'AG01' WITH
(
AVAILABILITY_MODE = SYNCHRONOUS_COMMIT
),
'AG02' WITH
(
AVAILABILITY_MODE = SYNCHRONOUS_COMMIT
);
Modify availability mode of the Distributed Availability Group (Dist_AG01_AG02) in the secondary Availability Group (AG02)
:CONNECT TDDR071
--Modify availability mode of the primary and secondary AGs in a Distributed Availability Group
--Run this on the primary replica of the secondary AG – TDDR071
ALTER AVAILABILITY GROUP [Dist_AG01_AG02]
MODIFY
AVAILABILITY GROUP ON
'AG01' WITH
(
AVAILABILITY_MODE = SYNCHRONOUS_COMMIT
),
'AG02' WITH
(
AVAILABILITY_MODE = SYNCHRONOUS_COMMIT
);
Before proceeding with Step #3, verify that both the primary and secondary Availability Groups are in SYNCHRONOUS COMMIT and synchronization_health_desc value of HEALTHY. Use the queries below to verify.
:CONNECT TDPRD071
SELECT r.replica_server_name, r.endpoint_url,
rs.connected_state_desc, rs.role_desc, rs.operational_state_desc,
rs.recovery_health_desc,rs.synchronization_health_desc,
r.availability_mode_desc, r.failover_mode_desc
FROM sys.dm_hadr_availability_replica_states rs
INNER JOIN sys.availability_replicas r
ON rs.replica_id=r.replica_id
ORDER BY r.replica_server_name
GO
SELECT ag.name, ag.is_distributed, ar.replica_server_name, ar.availability_mode_desc, ars.connected_state_desc, ars.role_desc,
ars.operational_state_desc, ars.synchronization_health_desc FROM sys.availability_groups ag
JOIN sys.availability_replicas ar on ag.group_id=ar.group_id
LEFT JOIN sys.dm_hadr_availability_replica_states ars
ON ars.replica_id=ar.replica_id
WHERE ag.is_distributed=1
GO
SELECT ag.name
, drs.database_id
, drs.group_id
, drs.replica_id
, drs.synchronization_state_desc
, drs.end_of_log_lsn
FROM sys.dm_hadr_database_replica_states drs,
sys.availability_groups ag
WHERE drs.group_id = ag.group_id
The Distributed Availability Group is ready for failover when the last_hardened_lsn value for all of the databases on both Availability Groups are the same. Use the T-SQL query below to verify if both Availability Groups are ready for failover.
:CONNECT TDPRD071
SELECT ag.name,
drs.database_id,
db_name(drs.database_id) as database_name,
drs.group_id,
drs.replica_id,
drs.last_hardened_lsn
FROM sys.dm_hadr_database_replica_states drs
INNER JOIN sys.availability_groups ag ON drs.group_id = ag.group_id;
:CONNECT TDDR071
SELECT ag.name,
drs.database_id,
db_name(drs.database_id) as database_name,
drs.group_id,
drs.replica_id,
drs.last_hardened_lsn
FROM sys.dm_hadr_database_replica_states drs
INNER JOIN sys.availability_groups ag ON drs.group_id = ag.group_id;
Set the Distributed Availability Group role on the primary Availability Group (AG01) to SECONDARY
:CONNECT TDPRD071
ALTER AVAILABILITY GROUP [Dist_AG01_AG02] SET (ROLE = SECONDARY);
Failover the Distributed Availability Group to the secondary Availability Group (AG02)--We should run on primary of global forwarder
:CONNECT TDDR071
ALTER AVAILABILITY GROUP [Dist_AG01_AG02] FORCE_FAILOVER_ALLOW_DATA_LOSS;
if we have large size databases we have to restore on all nodes with norecovery and then we have to add in AG
Comments
Post a Comment