In this post, I am going to outline my environment and then walk through the process of patching mirrored servers.
My test environment consists of two SQL Server 2005 SP2 servers named SSQL1 (principal) and SSQL2 (mirror) that contain eleven mirrored databases. The database mirroring operating mode is set to asynchronous and I’m upgrading to SP4.
Here is a look at the two mirrored instances.
Step 1
Always backup all system and user databases before applying patches.
Step 2
Remote Desktop into the “Mirror” server (SSQL2 in our example) and download/copy the patch to the server.
Step 3
Stop all SQL Services on the “Mirror” server.
Step 4
Run the patch on the “Mirror” server.
Step 5
Once the patch is complete, reboot the “Mirror” server.
Step 6 (optional)
If your database mirroring is set to asynchronous (High Performance mode), we will need to synchronize the databases first. To do this we will need to issue the following statement for every database on the “Principal” server that is mirrored.
ALTER DATABASE databasename SET SAFETY FULL
Here are the commands for the 11 databases on my server.
Step 7
The databases might change to “synchronizing” while the transactions catch up. Once all of the databases show “synchronized”, as shown below, we can perform the manual failover.
We can perform the failover using the following statement on the principal server for each database:
ALTER DATABASE databasename SET PARTNER FAILOVER
Here are the commands for the 11 databases on my server.
We can now see that the servers have switched roles.
Step 8 (optional)
Once the failover has taken place and all the databases have switched roles we
can set the operating mode back to asynchronous using the following statement
on the new principal server:
ALTER DATABASE databasename SET
SAFETY OFF
Here are the
commands for the 11 databases on my server.
Patch the New Mirror Server
Now that the roles
have been swapped, we will patch our "new" mirror server (SSQL1 in
our example).
Step 9
Remote Desktop into the "new" "Mirror" server (SSQL1 in our
example) and download/copy the patch to the server.
Step 10
Stop all SQL Services.
Step 11
Run the patch on the server.
Step 12
Once the patch is complete, reboot the server (SSQL1).
Step 13
Upon reboot and login, make sure all databases come online clean and
synchronized.
Step 14
You now have two choices, leave the databases alone and leave SSQL2 as the
principal and SSQL1 as the mirror or you can fail back to return the
environment back to how it was from the beginning.
Step 15 (optional)
If you want to failback again follow these steps.
If you are using
asynchronous mode issue this statement for each database:
ALTER DATABASE databasename SET
SAFETY FULL
Once the databases
are synchronized then run this statement for each database:
ALTER DATABASE databasename SET
PARTNER FAILOVER
If you need to turn
the asynchronous mode on again run this statement for each database:
ALTER DATABASE databasename SET
SAFETY OFF
Here is an example
of the commands to run on both servers.
No comments:
Post a Comment