SQL Database Mirroring setup
-
Upload
kamaljeet-singh-matharu -
Category
Documents
-
view
2.651 -
download
15
description
Transcript of SQL Database Mirroring setup
![Page 1: SQL Database Mirroring setup](https://reader031.fdocuments.us/reader031/viewer/2022012304/5541b12fb4c90589158b4569/html5/thumbnails/1.jpg)
1
Database Mirroring
![Page 2: SQL Database Mirroring setup](https://reader031.fdocuments.us/reader031/viewer/2022012304/5541b12fb4c90589158b4569/html5/thumbnails/2.jpg)
2
Preparation
• Minimum of two SQL servers
• Principal database/Mirror database
• “Witness” server (used for automatic failover)
• Will be done using SQL Server 2005 SP2
![Page 3: SQL Database Mirroring setup](https://reader031.fdocuments.us/reader031/viewer/2022012304/5541b12fb4c90589158b4569/html5/thumbnails/3.jpg)
3
Types of mirroring
• High availability:– Synchronized writes on principal and mirror– Automated failover– Requires witness server
• High Protection:– Synchronized writes on principal and mirror– Manual failover– No witness server required
• High performance:– Not synchronized (assumed writes will be completed on both
principal and mirror)– Forced failover only– Witness not required
![Page 4: SQL Database Mirroring setup](https://reader031.fdocuments.us/reader031/viewer/2022012304/5541b12fb4c90589158b4569/html5/thumbnails/4.jpg)
4
Implementation• Will be using high availability method• Requires at least three separate instances of SQL Server 2005 SP1
(Principal, Mirror, Witness)• Ensure BlackBerry services on all machines are stopped• Ensure the login credentials for all the SQL servers are the same• Run the errors.sql script on all SQL servers before proceeding (the Run the errors.sql script on all SQL servers before proceeding (the
errors.sql script can be found in the BES installation folder). You can errors.sql script can be found in the BES installation folder). You can also get rid of the final line in the script (the USE database line) as it also get rid of the final line in the script (the USE database line) as it may produce errors. may produce errors. -this is now an obsolete step. Running errors.sql is no longer required for DB mirroring.
• It does not matter which servers you use for which purpose (i.e. M1 can be principal, M2 can be mirror and M3 can be witness for DB1 while M3 can be principal, M1 can be mirror and M2 can be witness for DB2.)
![Page 5: SQL Database Mirroring setup](https://reader031.fdocuments.us/reader031/viewer/2022012304/5541b12fb4c90589158b4569/html5/thumbnails/5.jpg)
5
Implementation contd…
• Login to the SQL Server where your DB exists
• Right-click->Properties->Options page
• Select “Full” option under recovery model
![Page 6: SQL Database Mirroring setup](https://reader031.fdocuments.us/reader031/viewer/2022012304/5541b12fb4c90589158b4569/html5/thumbnails/6.jpg)
6
![Page 7: SQL Database Mirroring setup](https://reader031.fdocuments.us/reader031/viewer/2022012304/5541b12fb4c90589158b4569/html5/thumbnails/7.jpg)
7
Implementation contd…
• Backup the database– Right-click->Tasks->Backup– Ensure the backup type is “Full”– On the options screen select “Overwrite all
existing backup sets” to ensure you are not appending the backup set to an existing set
– Optionally you can also check “Verify backup when finished” or “Perform checksum before writing to media” for verification of data
![Page 8: SQL Database Mirroring setup](https://reader031.fdocuments.us/reader031/viewer/2022012304/5541b12fb4c90589158b4569/html5/thumbnails/8.jpg)
8
![Page 9: SQL Database Mirroring setup](https://reader031.fdocuments.us/reader031/viewer/2022012304/5541b12fb4c90589158b4569/html5/thumbnails/9.jpg)
9
![Page 10: SQL Database Mirroring setup](https://reader031.fdocuments.us/reader031/viewer/2022012304/5541b12fb4c90589158b4569/html5/thumbnails/10.jpg)
10
Implementation contd…
• Backup the transaction log– Right-click->Tasks->Backup– Ensure the backup type is “Transaction log”. When restoring on
the mirrored server, it may complain that no transaction log was found and may fail the database restoration on the mirrored server so this step is performed as a precaution
– On the options screen ensure that “Append to the existing backup set” is checked. This will add the transaction log to your previous full backup of the database so you only require to copy the one .bak file to the mirrored server
– Optionally you can also check “Verify backup when finished” or “Perform checksum before writing to media” for verification of data
![Page 11: SQL Database Mirroring setup](https://reader031.fdocuments.us/reader031/viewer/2022012304/5541b12fb4c90589158b4569/html5/thumbnails/11.jpg)
11
![Page 12: SQL Database Mirroring setup](https://reader031.fdocuments.us/reader031/viewer/2022012304/5541b12fb4c90589158b4569/html5/thumbnails/12.jpg)
12
![Page 13: SQL Database Mirroring setup](https://reader031.fdocuments.us/reader031/viewer/2022012304/5541b12fb4c90589158b4569/html5/thumbnails/13.jpg)
13
Implementation contd…
• Copy the backups to another SQL Server• Requires access to the SQL Server itself
(through remote desktop or VMware console). What you want to do is copy the backed up file you created in the previous steps to the SQL server where you want the database to be mirrored
• Where you place the backup files on the second SQL Server does not matter
![Page 14: SQL Database Mirroring setup](https://reader031.fdocuments.us/reader031/viewer/2022012304/5541b12fb4c90589158b4569/html5/thumbnails/14.jpg)
14
Implementation contd…
• Restore the database on second SQL Server– Login to the SQL Server where your DB was
copied to– Right-click on Database folder->Restore
backup– Type the same name as the original database
on the first SQL Server in the “To database” field
![Page 15: SQL Database Mirroring setup](https://reader031.fdocuments.us/reader031/viewer/2022012304/5541b12fb4c90589158b4569/html5/thumbnails/15.jpg)
15
![Page 16: SQL Database Mirroring setup](https://reader031.fdocuments.us/reader031/viewer/2022012304/5541b12fb4c90589158b4569/html5/thumbnails/16.jpg)
16
Implementation contd…
• Select “From device” and click the “…” button
• Click the add button and find the backup file of the database– Select the backed up database that you
copied from the principal SQL server
![Page 17: SQL Database Mirroring setup](https://reader031.fdocuments.us/reader031/viewer/2022012304/5541b12fb4c90589158b4569/html5/thumbnails/17.jpg)
17
![Page 18: SQL Database Mirroring setup](https://reader031.fdocuments.us/reader031/viewer/2022012304/5541b12fb4c90589158b4569/html5/thumbnails/18.jpg)
18
Implementation contd…
• The two backups will appear in the window
• Checkmark both backups
![Page 19: SQL Database Mirroring setup](https://reader031.fdocuments.us/reader031/viewer/2022012304/5541b12fb4c90589158b4569/html5/thumbnails/19.jpg)
19
![Page 20: SQL Database Mirroring setup](https://reader031.fdocuments.us/reader031/viewer/2022012304/5541b12fb4c90589158b4569/html5/thumbnails/20.jpg)
20
Implementation contd…
• Select the options page
• At the bottom under “Recovery state” select the second option (RESTORE WITH NORECOVERY)
![Page 21: SQL Database Mirroring setup](https://reader031.fdocuments.us/reader031/viewer/2022012304/5541b12fb4c90589158b4569/html5/thumbnails/21.jpg)
21
![Page 22: SQL Database Mirroring setup](https://reader031.fdocuments.us/reader031/viewer/2022012304/5541b12fb4c90589158b4569/html5/thumbnails/22.jpg)
22
Implementation contd…
• Your database should now be listed in the database folder on the second SQL server and it should be in the “Restoring…” state
• *Note*: The “Restoring…” state is indefinite for the mirrored database. You will not be able to access a database while it is in the restoring state.
![Page 23: SQL Database Mirroring setup](https://reader031.fdocuments.us/reader031/viewer/2022012304/5541b12fb4c90589158b4569/html5/thumbnails/23.jpg)
23
Setting up the mirroring
• Login to the first SQL Server:– Select the Principal database– Right-click->Properties– Select the “Mirroring page”– Click on “Configure security”
![Page 24: SQL Database Mirroring setup](https://reader031.fdocuments.us/reader031/viewer/2022012304/5541b12fb4c90589158b4569/html5/thumbnails/24.jpg)
24
![Page 25: SQL Database Mirroring setup](https://reader031.fdocuments.us/reader031/viewer/2022012304/5541b12fb4c90589158b4569/html5/thumbnails/25.jpg)
25
![Page 26: SQL Database Mirroring setup](https://reader031.fdocuments.us/reader031/viewer/2022012304/5541b12fb4c90589158b4569/html5/thumbnails/26.jpg)
26
Setting up the mirroring contd…
• On the Principal, Mirror and Witness Server Instance screens, settings may be grayed out due to the endpoint being setup already for use. If this is the case just select the appropriate server to connect to and use the default settings. If the endpoint has not been created yet, you can create a new endpoint that will be used for all database mirroring.
![Page 27: SQL Database Mirroring setup](https://reader031.fdocuments.us/reader031/viewer/2022012304/5541b12fb4c90589158b4569/html5/thumbnails/27.jpg)
27
![Page 28: SQL Database Mirroring setup](https://reader031.fdocuments.us/reader031/viewer/2022012304/5541b12fb4c90589158b4569/html5/thumbnails/28.jpg)
28
Setting up the mirroring contd…
• If creating a new endpoint, use the default port of 5022 and enter any name for the endpoint. Use the same name on the following servers for consistency although using different names does not affect the mirroring in any way.
![Page 29: SQL Database Mirroring setup](https://reader031.fdocuments.us/reader031/viewer/2022012304/5541b12fb4c90589158b4569/html5/thumbnails/29.jpg)
29
Setting up the mirroring contd…
• When selecting the Mirror and Witness Server Instances, you may be required to connect to these servers using some form of authentication before you are able to continue. For consistency use the same logins for all servers.
![Page 30: SQL Database Mirroring setup](https://reader031.fdocuments.us/reader031/viewer/2022012304/5541b12fb4c90589158b4569/html5/thumbnails/30.jpg)
30
![Page 31: SQL Database Mirroring setup](https://reader031.fdocuments.us/reader031/viewer/2022012304/5541b12fb4c90589158b4569/html5/thumbnails/31.jpg)
31
Setting up the mirroring contd…
• The next screen you may encounter will ask for service accounts. This screen is to grant CONNECT permissions for the accounts that are running the SQL services on each machine. Generally all the SQL Server should be run on the same account so you can just leave the fields blank.
![Page 32: SQL Database Mirroring setup](https://reader031.fdocuments.us/reader031/viewer/2022012304/5541b12fb4c90589158b4569/html5/thumbnails/32.jpg)
32
![Page 33: SQL Database Mirroring setup](https://reader031.fdocuments.us/reader031/viewer/2022012304/5541b12fb4c90589158b4569/html5/thumbnails/33.jpg)
33
• Click finish and the database mirroring should be setup successfully.
![Page 34: SQL Database Mirroring setup](https://reader031.fdocuments.us/reader031/viewer/2022012304/5541b12fb4c90589158b4569/html5/thumbnails/34.jpg)
34
![Page 35: SQL Database Mirroring setup](https://reader031.fdocuments.us/reader031/viewer/2022012304/5541b12fb4c90589158b4569/html5/thumbnails/35.jpg)
35
Setting up the mirroring contd…
• Ensure the settings are correct in the Mirroring window
• Synchronous operating mode should be selected
• Click on start mirroring
• Status should show the database is now mirrored correctly
![Page 36: SQL Database Mirroring setup](https://reader031.fdocuments.us/reader031/viewer/2022012304/5541b12fb4c90589158b4569/html5/thumbnails/36.jpg)
36
Setting up the mirroring contd…
• Your databases should now be in the following states
• Upon failover, the mirror database will become principal and the principal database will become the mirror (similar in function to a high availability BES with the active/standby states)