Thursday, August 02, 2007

Converting the database mirroring from High Availability to High Performance

In the previous article i showed you how to configure database mirroring using the high availability configuration through a SQLCMD master script.
What if we want to change the configuration from high availability mode to high performance mode,we will need to clean the configuration and reconfigure it again?
The answer is no,we can convert the configuration.
All what we need to do is to set both the witness and the safety off


-- ConvertToHighPerf.sql

/*========================================================
File: ConvertToHighPerf.sql

Summary: Change the High Availability configuration
over to High Performance.
Turn off the witness, turn off safety!

Date: August 2007
==========================================================*/


:SETVAR PrincipalServer MSHEHADEHVPC\SQLDev01
:SETVAR MirrorServer MSHEHADEHVPC\SQLDev02
:SETVAR Database2Mirror AdventureWorksDW
go

:ON ERROR EXIT
go

:CONNECT $(PrincipalServer)

ALTER DATABASE $(Database2Mirror)
SET WITNESS OFF
go

ALTER DATABASE $(Database2Mirror)
SET SAFETY OFF
go

SELECT DATABASEPROPERTYEX(N'$(Database2Mirror)', N'Status')
-- Returns ONLINE
SELECT db_name(sd.[database_id]) AS [Database Name],
sd.mirroring_guid,
sd.mirroring_state,
sd.mirroring_state_desc,
sd.mirroring_partner_name,
sd.mirroring_witness_name,
sd.mirroring_witness_state,
sd.mirroring_witness_state_desc,
sd.mirroring_role,
sd.mirroring_role_desc,
sd.mirroring_role_sequence,
sd.mirroring_safety_level,
sd.mirroring_safety_level_desc,
sd.mirroring_safety_sequence,
sd.mirroring_failover_lsn
FROM sys.database_mirroring AS sd
WHERE sd.[database_id] = db_id(N'$(Database2Mirror)')
go

:CONNECT $(MirrorServer)
SELECT DATABASEPROPERTYEX(N'$(Database2Mirror)', N'Status') -- Returns RESTORING
SELECT db_name(sd.[database_id]) AS [Database Name],
sd.mirroring_guid,
sd.mirroring_state,
sd.mirroring_state_desc,
sd.mirroring_partner_name,
sd.mirroring_witness_name,
sd.mirroring_witness_state,
sd.mirroring_witness_state_desc,
sd.mirroring_role,
sd.mirroring_role_desc,
sd.mirroring_role_sequence,
sd.mirroring_safety_level,
sd.mirroring_safety_level_desc,
sd.mirroring_safety_sequence,
sd.mirroring_failover_lsn
FROM sys.database_mirroring AS sd
WHERE sd.[database_id] = db_id(N'$(Database2Mirror)')
go

No comments: