You are on page 1of 4

Rolling Upgrade to SQL Server Database Mirroring

Server 1 - Principal / Server 2 - Mirror / Server 3 - Witness


SELECT database_id,

mirroring_witness_name

FROM sys.database_mirroring

GO

1. Run DBCC CHECKDB on all databases on Server 1.


DBCC CHECKDB -- Check the current database.

GO

2. Perform full backup of all databases on Server 1.


3. If running mirroring in High-Performance mode, switch to High-Safety.
ALTER DATABASE DatabaseName

SET PARTNER SAFETY FULL

GO

4. Remove Witness from mirroring session - Disable the Witness when you are using Automatic Failovers.
ALTER DATABASE DatabaseName

SET WITNESS OFF

GO

5. Perform upgrade / Install the Service Pack on Server 2.


6. Failover all databases to Server 2 (upgraded Mirror  new Principal).
ALTER DATABASE DatabaseName

SET PARTNER FAILOVER

GO

7. Run DBCC CHECKDB on all databases on Server 2 (upgraded Mirror  new Principal).
DBCC CHECKDB -- Check the current database.

GO

8. Perform upgrade / Install the Service Pack on Server 1 (original Principal  new Mirror).
9. Failover all database to Server 1 (new Mirror  upgraded Principal).
ALTER DATABASE DatabaseName

SET PARTNER FAILOVER

GO

10. Run DBCC CHECKDB on all database on Server 1 (upgraded Principal).


DBCC CHECKDB DatabaseName

GO

11. Perform full backup of all databases on Server 1 (upgraded Principal).


12. If mirroring was initially set to High- Performance mode, switch mirroring modes.
ALTER DATABASE DatabaseName

SET PARTNER SAFETY OFF

GO
13. Perform upgrade / Install the Service Pack on Server 3 (Witness - actually you can do it any time).
14. Add Witness back to mirroring session. ALTER DATABASE <資料庫名稱> SET WITNESS =<伺服器網路位址>
ALTER DATABASE DatabaseName

SET WITNESS = 'TCP://<system-address>:<* port>'

GO

15. Resume the database mirroring session.


ALTER DATABASE DatabaseName

SET PARTNER RESUME

GO

Example Demonstrations

 Upgrading High-Performance Mode


1. Run the SQL Server 2008 installation to upgrade the mirror server.
2. Change the operating mode to high-safety mode without a witness and wait for the mirror database to
synchronize. You can change the database to high-safety mode by running the following command from the
master database on the principal server.
ALTER DATABASE [DatabaseName]

SET PARTNER SAFETY FULL

3. Fail over the principal database to the new SQL Server 2008 instance. SQL Server will now suspend mirroring
because the servers are at two different build levels. You will be able to resume mirroring once you have
completed the upgrade on the original principal server. To fail over to the database to the mirror server, issue
the following command from the master database on the principal server.
ALTER DATABASE [DatabaseName]

SET PARTNER FAILOVER

4. Change the operating mode back to high-performance. You can change the database to high-performance mode
by running the following command from the master database on the principal server.
ALTER DATABASE [DatabaseName]

SET PARTNER SAFETY OFF

5. Run the SQL Server 2008 installation to upgrade the original principal server (now acting as the mirror).
6. Resume the database mirroring session. To resume database mirroring run the following command on either
partner.
ALTER DATABASE [DatabaseName]

SET PARTNER RESUME

 Upgrading High-Safety Mode without a Witness


1. Change the operating mode to high-performance mode. This is only applicable if you are running SQL Server
Enterprise Edition. You can change the database to high-performance mode by running the following command
from the master database on the principal server.
ALTER DATABASE [DatabaseName]
SET PARTNER SAFETY OFF

2. Run the SQL Server 2008 installation to upgrade the mirror server.
3. Change the operating mode back to high-safety mode without a witness and wait for the mirror database to
synchronize. You will only need to do this if you changed the operating mode in step 1. You can change the
database to high-safety mode by running the following command from the master database on the principal
server.
ALTER DATABASE [DatabaseName]

SET PARTNER SAFETY FULL

4. Fail over the principal database to the new SQL Server 2008 instance. SQL Server will now suspend mirroring
because the servers are at two different build levels. You will be able to resume mirroring once you have
completed the upgrade on the original principal server. To fail over to the database to the mirror server, issue
the following command from the master database on the principal server.
ALTER DATABASE [DatabaseName]

SET PARTNER FAILOVER

5. Run the SQL Server 2008 installation to upgrade the original principal server (now acting as the mirror).
6. Resume the database mirroring session. To resume database mirroring run the following command on either
partner.
ALTER DATABASE [DatabaseName]

SET PARTNER RESUME

 Upgrading High-Safety Mode with a Witness


1. Take note of the witness server’s full network address. You will need this information when you add the
witness server back in to the mirroring session. You can get the full network address of the witness server by
running the following command on either partner.
SELECT mirroring_witness_name

FROM sys.database_mirroring

WHERE database_id = DB_ID('DatabaseName')

2. Remove the witness server to disable automatic failover. To remove the witness issue the following command
on either partner.
ALTER DATABASE [DatabaseName]

SET WITNESS OFF

3. Change the operating mode to high-performance mode. This is only applicable if you are running SQL Server
Enterprise Edition. You can change the database to high-performance mode by running the following command
from the master database on the principal server.
ALTER DATABASE [DatabaseName]

SET PARTNER SAFETY OFF

4. Run the SQL Server 2008 installation to upgrade the mirror server.
5. Change the operating mode back to high-safety mode without a witness and wait for the mirror database to
synchronize. You will only need to do this if you changed the operating mode in step 3. You can change the
database to high-safety mode by running the following command from the master database on the principal
server.
ALTER DATABASE [DatabaseName]

SET PARTNER SAFETY FULL

6. Fail over the principal database to the new SQL Server 2008 instance. SQL Server will now suspend mirroring
because the servers are at two different build levels. You will be able to resume mirroring once you have
completed the upgrade on the original principal server. To fail over to the database to the mirror server, issue
the following command from the master database on the principal server.
ALTER DATABASE [DatabaseName]

SET PARTNER FAILOVER

7. Run the SQL Server 2008 installation to upgrade the original principal server (now acting as the mirror).
8. Resume the database mirroring session. To resume database mirroring run the following command on either
partner.
ALTER DATABASE [DatabaseName]

SET PARTNER RESUME

9. Run the SQL Server 2008 installation to upgrade the witness server. You can do this step at any time after you
have removed the witness server from the mirroring session in step 2.
10. Add the witness server back to database mirroring session to enable automatic failover. To add the witness
server back issue the following command on the principal server with the appropriate network address for the
witness server.
ALTER DATABASE [DatabaseName]

SET WITNESS = 'TCP://<Server>:<Port>'

You might also like