Effective Usage of SQL Server 2005  Database Mirroring by Satya Shyam K Jayanty SQL Server MVP www.sqlserver-qa.net [email...
Topics <ul><li>Introduction </li></ul><ul><li>Today’s Goals </li></ul><ul><li>SQL Server 2005 High Availability features <...
Introduction - Speaker <ul><li>Webmaster of  www.sqlserver-qa.net  &  www.sqloogle.co.uk </li></ul><ul><li>Been in the IT ...
Today’s Goals <ul><li>Focus on what you can do, as a DBA, to ensure the highest availability of your mission-critical, pro...
SQL Server 2005 High Availability features <ul><li>SQL Server 2005 High Availability is a set of best practices and techno...
SQL Server 2005 High Availability features <ul><li>Failover clustering  and  Database mirroring  both provide the followin...
SQL Server 2005 High Availability features <ul><li>Database Mirroring  - What is the advantage over Failover Clustering? <...
SQL Server 2005 High Availability features <ul><li>Log shipping  – this can be used as a supplement or an alternative to d...
SQL Server 2005 High Availability features <ul><li>Replication involves the Publisher, Distributor, and Subscriber Metapho...
Database Mirroring concepts <ul><li>What is  - Database mirroring transfers transaction log records directly from one serv...
Database Mirroring concepts <ul><li>Terms involved: </li></ul><ul><ul><li>Principal  – the server that holds a copy of dat...
Database Mirroring concepts <ul><li>Terms involved: </li></ul><ul><ul><li>System databases  cannot be a part of mirroring....
Database Mirroring concepts <ul><li>Database Mirroring configuration: </li></ul><ul><ul><li>High Availability </li></ul></...
Database Mirroring concepts 09th March 2007,  SQL Server Open World Effective Usage of SQL Server 2005 Database Mirroring ...
Database Mirroring concepts <ul><li>The mode is dependant on setting of Transaction Safety and Witness Server. </li></ul><...
Usage and Practices <ul><li>Depending on the transaction safety level and whether you have a witness, you can have automat...
Usage and Practices <ul><li>Safety levels and failover options sequence: </li></ul><ul><ul><li>Redo process on mirror </li...
Usage and Practices <ul><li>Things to take care </li></ul><ul><ul><li>From the server perspective, the database failover t...
Usage and Practices <ul><li>Things to take care </li></ul><ul><ul><li>The database might contain changes made by transacti...
Usage and Practices <ul><li>Things to take care </li></ul><ul><ul><li>Ensure TCP/IP is enabled from SQL Configuration Mana...
Usage and Practices <ul><ul><li>Things to take care </li></ul></ul><ul><ul><ul><li>If the principal fails, the failover sc...
Failover & Failback implementation <ul><li>Preparing  the Mirror for Failover </li></ul><ul><ul><li>It is better to use id...
Failover & Failback implementation <ul><li>If there are multiple databases in an instance, you need to mirror each databas...
Failover & Failback implementation <ul><li>Security  of mirroring sessions can be controlled by configuring the listener p...
Failover & Failback implementation <ul><li>Initiating  Failover  using SQL Server  Management Studio : </li></ul><ul><ul><...
Failover & Failback implementation <ul><li>W ith and  W ithout  W itness </li></ul><ul><ul><li>Witness is  not  the most i...
Monitoring Mirroring Performance <ul><li>In addition to using the Database Mirroring Monitor and dbmmonitor, you can use s...
Monitoring Mirroring Performance <ul><ul><li>Rolling upgrade </li></ul></ul><ul><ul><ul><li>Upgrade the mirror first </li>...
Monitoring Mirroring Performance <ul><li>Troubleshooting </li></ul><ul><li>Database mirroring does not regularly check the...
Monitoring Mirroring Performance <ul><li>Account under which the SQL Server instance is running has the necessary CONNECT ...
Conclusion <ul><li>Measures & Practices </li></ul><ul><li>The operational tasks related to the data center span the full l...
Conclusion <ul><li>The performance of database mirroring is very closely associated with the type of application, transact...
Frequently Asked Questions <ul><li>Support for Database Mirroring prior to SQL Server 2005 SP1. </li></ul><ul><li>Can I mi...
Questions & Answers <ul><li>I’ll do my best to answer your questions. </li></ul><ul><li>If you don’t get your questions an...
Thank you and have a great day ahead . <ul><li>Feedback : </li></ul><ul><ul><li>Please fill out evaluation forms </li></ul...
Upcoming SlideShare
Loading in...5
×

Effective Usage of SQL Server 2005 Database Mirroring

3,023

Published on

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
3,023
On Slideshare
0
From Embeds
0
Number of Embeds
30
Actions
Shares
0
Downloads
70
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide
  • 09th March 2007, SQL Server Open World www.sqlserver-qa.net Effective Usage of SQL Server 2005 Database Mirroring
  • 09th March 2007, SQL Server Open World www.sqlserver-qa.net Effective Usage of SQL Server 2005 Database Mirroring
  • 09th March 2007, SQL Server Open World www.sqlserver-qa.net Effective Usage of SQL Server 2005 Database Mirroring
  • 09th March 2007, SQL Server Open World www.sqlserver-qa.net Effective Usage of SQL Server 2005 Database Mirroring
  • 09th March 2007, SQL Server Open World www.sqlserver-qa.net Effective Usage of SQL Server 2005 Database Mirroring
  • 09th March 2007, SQL Server Open World www.sqlserver-qa.net Effective Usage of SQL Server 2005 Database Mirroring
  • 09th March 2007, SQL Server Open World www.sqlserver-qa.net Effective Usage of SQL Server 2005 Database Mirroring
  • 09th March 2007, SQL Server Open World www.sqlserver-qa.net Effective Usage of SQL Server 2005 Database Mirroring
  • 09th March 2007, SQL Server Open World www.sqlserver-qa.net Effective Usage of SQL Server 2005 Database Mirroring
  • 09th March 2007, SQL Server Open World www.sqlserver-qa.net Effective Usage of SQL Server 2005 Database Mirroring
  • 09th March 2007, SQL Server Open World www.sqlserver-qa.net Effective Usage of SQL Server 2005 Database Mirroring
  • Transaction safety is a mirroring-specific database property that determines whether a database mirroring session operates synchronously or asynchronously. There are two safety levels: FULL and OFF. SAFETY FULL Full transaction safety causes the session to operate synchronously in high-safety mode. If a witness is present, a session supports automatic failover. When you establish a session using ALTER DATABASE statements, the session begins with the SAFETY property set to FULL; that is, the session begins in high-safety mode. After the session begins, you can add a witness. SAFETY OFF Turning off transaction safety causes the session to operate asynchronously, in high-performance mode. If the SAFETY property is set to OFF, the WITNESS property should also be set to OFF (the default). For information about the impact of the witness in high-performance mode, see &amp;quot;The State of the Witness,&amp;quot; later in this topic. For more information about running with transaction safety turned off, see Asynchronous Database Mirroring (High-Performance Mode) . Transport security in SQL Server 2005 involves authentication and, optionally, encryption of messages exchanged between the databases. In some situations, such as when server instances are not in trusted domains or when SQL Server is running as a local service, Windows Authentication is unavailable. In such cases, instead of user credentials, certificates are required to authenticate connection requests. The mirroring endpoint of each server instance must be configured with its own locally created certificate. 09th March 2007, SQL Server Open World www.sqlserver-qa.net Effective Usage of SQL Server 2005 Database Mirroring
  • In learning how to setup and configure Database Mirroring, there are many new and important concepts to master. If possible, you may want to follow a very specific process to setting up and learning Database Mirroring. It is recommended that you first learn the High Performance configuration and then move to the High Protection configuration. Then, if desired, you can move to the High Availability configuration. Starting with High Performance allows you to test mirroring with the least impact to your production environment. The High Performance configuration allows you to setup a Mirror database that has very little latency behind your Principal database, effectively setting up a form of real-time log shipping. Once you feel comfortable with the setup and configuration of Database Mirroring in the asynchronous form, you can then move to a synchronous form. Moving to a synchronous form will allow you to test the actual performance impact of Database Mirroring in your environment. There are many factors which impact performance: network speed and distance, speed of the mirror database/server, and transaction load. By moving to the synchronous High Protection configuration next, you can test the impact to performance without the possibility of an automated (and possibly unexpected) failover. Once the performance is deemed acceptable and you determine that automatic detection/failover is desired, you can add the required witness to the High Protection configuration to convert to the High Availability configuration. 09th March 2007, SQL Server Open World www.sqlserver-qa.net Effective Usage of SQL Server 2005 Database Mirroring
  • 09th March 2007, SQL Server Open World www.sqlserver-qa.net Effective Usage of SQL Server 2005 Database Mirroring
  • Effective Usage of SQL Server 2005 Database Mirroring 09th March 2007, SQL Server Open World www.sqlserver-qa.net
  • 09th March 2007, SQL Server Open World www.sqlserver-qa.net Effective Usage of SQL Server 2005 Database Mirroring
  • Effective Usage of SQL Server 2005 Database Mirroring 09th March 2007, SQL Server Open World www.sqlserver-qa.net
  • 09th March 2007, SQL Server Open World www.sqlserver-qa.net Effective Usage of SQL Server 2005 Database Mirroring
  • 09th March 2007, SQL Server Open World www.sqlserver-qa.net Effective Usage of SQL Server 2005 Database Mirroring
  • Effective Usage of SQL Server 2005 Database Mirroring 09th March 2007, SQL Server Open World www.sqlserver-qa.net
  • 09th March 2007, SQL Server Open World www.sqlserver-qa.net Effective Usage of SQL Server 2005 Database Mirroring
  • 09th March 2007, SQL Server Open World www.sqlserver-qa.net Effective Usage of SQL Server 2005 Database Mirroring
  • 09th March 2007, SQL Server Open World www.sqlserver-qa.net Effective Usage of SQL Server 2005 Database Mirroring
  • 09th March 2007, SQL Server Open World www.sqlserver-qa.net Effective Usage of SQL Server 2005 Database Mirroring
  • 09th March 2007, SQL Server Open World www.sqlserver-qa.net Effective Usage of SQL Server 2005 Database Mirroring
  • 09th March 2007, SQL Server Open World www.sqlserver-qa.net Effective Usage of SQL Server 2005 Database Mirroring
  • 09th March 2007, SQL Server Open World www.sqlserver-qa.net Effective Usage of SQL Server 2005 Database Mirroring
  • 09th March 2007, SQL Server Open World www.sqlserver-qa.net Effective Usage of SQL Server 2005 Database Mirroring
  • 09th March 2007, SQL Server Open World www.sqlserver-qa.net Effective Usage of SQL Server 2005 Database Mirroring
  • 09th March 2007, SQL Server Open World www.sqlserver-qa.net Effective Usage of SQL Server 2005 Database Mirroring
  • 09th March 2007, SQL Server Open World www.sqlserver-qa.net Effective Usage of SQL Server 2005 Database Mirroring
  • 09th March 2007, SQL Server Open World www.sqlserver-qa.net Effective Usage of SQL Server 2005 Database Mirroring
  • Disable DB Mirroring: Database mirroring requires AUTO_CLOSE OFF. 09th March 2007, SQL Server Open World www.sqlserver-qa.net Effective Usage of SQL Server 2005 Database Mirroring
  • 09th March 2007, SQL Server Open World www.sqlserver-qa.net Effective Usage of SQL Server 2005 Database Mirroring
  • 09th March 2007, SQL Server Open World www.sqlserver-qa.net Effective Usage of SQL Server 2005 Database Mirroring
  • Effective Usage of SQL Server 2005 Database Mirroring

    1. 1. Effective Usage of SQL Server 2005 Database Mirroring by Satya Shyam K Jayanty SQL Server MVP www.sqlserver-qa.net [email_address] Lalandia, Denmark - March 09 th 2007
    2. 2. Topics <ul><li>Introduction </li></ul><ul><li>Today’s Goals </li></ul><ul><li>SQL Server 2005 High Availability features </li></ul><ul><li>Database Mirroring concepts </li></ul><ul><li>Usage and Practices </li></ul><ul><li>Failover & Failback implementation </li></ul><ul><li>Monitoring Mirroring Performance </li></ul><ul><li>Conclusion </li></ul><ul><li>Frequently Asked Questions </li></ul><ul><li>Q & A </li></ul>
    3. 3. Introduction - Speaker <ul><li>Webmaster of www.sqlserver-qa.net & www.sqloogle.co.uk </li></ul><ul><li>Been in the IT field over 15 years </li></ul><ul><li>SQL Server DBA for over 10 years (since ver. 4.2) </li></ul><ul><li>Contributing Editor, Writer & Moderator for www.sql-server-performance.com </li></ul><ul><li>Currently, working full-time as Sr. DBA at a large Financial Enterprise focusing on SQL Server high availability, clustering, disaster recovery, and performance tuning. </li></ul><ul><li>SQL Server MVP ( www.microsoft.com/mvp /) </li></ul><ul><li>Participation in assorted forums such as MSDN, SQL Server magazine, dbforums and so on </li></ul>09th March 2007, SQL Server Open World Effective Usage of SQL Server 2005 Database Mirroring - www.sqlserver-qa.net
    4. 4. Today’s Goals <ul><li>Focus on what you can do, as a DBA, to ensure the highest availability of your mission-critical, production SQL Servers. </li></ul><ul><li>How better Database Mirroring can help you to achieve the High Availability to the databases. </li></ul><ul><li>Look at a series of configuration & best practices that every DBA should follow to help insure high SQL Server availability. </li></ul><ul><li>Industry best practices & implementation. </li></ul><ul><ul><li>Prevention & Practices </li></ul></ul><ul><li>Selecting a HA Solution that suits the business needs. </li></ul><ul><li>IT costs – planning, budget approval & implementation. </li></ul>09th March 2007, SQL Server Open World Effective Usage of SQL Server 2005 Database Mirroring - www.sqlserver-qa.net
    5. 5. SQL Server 2005 High Availability features <ul><li>SQL Server 2005 High Availability is a set of best practices and technologies designed to increase database availability through backups that help recover from catastrophic disasters, redundant database components engineered to prevent downtime, and redundant server implementation designed to minimize downtime. </li></ul><ul><ul><li>High Availability (HA) solutions: </li></ul></ul><ul><ul><ul><li>Failover Clustering </li></ul></ul></ul><ul><ul><ul><li>Database Mirroring (supported from Service Pack 1 onwards) </li></ul></ul></ul><ul><ul><ul><li>Log Shipping and </li></ul></ul></ul><ul><ul><ul><li>Replication </li></ul></ul></ul><ul><li>SQL Server 2005 database engine features (database mirroring) </li></ul><ul><ul><li>Enterprise Edition - Fully supported (failover partners must use the same edition) </li></ul></ul><ul><ul><li>Standard Edition - Safety full only </li></ul></ul><ul><ul><li>Workgroup Edition, SQL Express & SQL Express with Advanced services – Only as witness </li></ul></ul><ul><ul><li>SQL Express and the Workgroup Edition can be used as a witness server, but they cannot be used as a partner server in database mirroring. </li></ul></ul>09th March 2007, SQL Server Open World Effective Usage of SQL Server 2005 Database Mirroring - www.sqlserver-qa.net
    6. 6. SQL Server 2005 High Availability features <ul><li>Failover clustering and Database mirroring both provide the following: </li></ul><ul><ul><li>Automatic detection and failover, Manual failover and Transparent client redirect </li></ul></ul><ul><li>Constraints in Failover Clustering </li></ul><ul><ul><li>Operates at the server instance scope </li></ul></ul><ul><ul><li>Requires certified hardware (HAL) </li></ul></ul><ul><ul><li>Has no reporting on standby </li></ul></ul><ul><ul><li>Utilizes a single copy of the database </li></ul></ul><ul><ul><li>Does not protect against disk failure </li></ul></ul><ul><li>Database Mirroring benefits for the constraints above: </li></ul><ul><ul><li>Operates at the database scope </li></ul></ul><ul><ul><li>Uses a single, duplicate copy of the database </li></ul></ul><ul><ul><li>Uses standard servers </li></ul></ul><ul><ul><li>Provides limited reporting on the mirror server by using database snapshots </li></ul></ul><ul><ul><li>When operating synchronously, provides for zero work loss through delayed commit on the principal database. </li></ul></ul>09th March 2007, SQL Server Open World Effective Usage of SQL Server 2005 Database Mirroring - www.sqlserver-qa.net
    7. 7. SQL Server 2005 High Availability features <ul><li>Database Mirroring - What is the advantage over Failover Clustering? </li></ul><ul><ul><li>You can mix & match database mirroring with a failover clustering. </li></ul></ul><ul><ul><li>Database mirroring works easily between failover clusters and also between a failover cluster and a nonclustered host. </li></ul></ul><ul><ul><li>Database mirroring & log shipping with Notification Services </li></ul></ul><ul><ul><ul><li>This combination can be used to provide high availability for your notification applications, you can maintain a standby server that you can bring online after failures or during server maintenance. </li></ul></ul></ul><ul><ul><li>Benefits of – increased data protection, increased availability of databases during any hardware or software patching. </li></ul></ul><ul><ul><li>Configuration - High Protection & High Performance. </li></ul></ul><ul><ul><li>No licensing cost to setup witness server. </li></ul></ul><ul><ul><li>It is recommended that you first learn the High Performance configuration and then move to the High Protection configuration. </li></ul></ul>09th March 2007, SQL Server Open World Effective Usage of SQL Server 2005 Database Mirroring - www.sqlserver-qa.net
    8. 8. SQL Server 2005 High Availability features <ul><li>Log shipping – this can be used as a supplement or an alternative to database mirroring. </li></ul><ul><ul><li>A key difference as compared to database mirroring. </li></ul></ul><ul><ul><li>Capable to support multiple secondary databases with a single primary database. </li></ul></ul><ul><ul><li>Can be useful only if data is accidentally changed on the primary database. </li></ul></ul><ul><ul><li>Dependant upon the transaction log and shared backup location. </li></ul></ul><ul><ul><li>Manual intervention is required in order to failover the primary database in the event of any failure on primary server. </li></ul></ul><ul><ul><li>With SQL Server Management Studio you can view the Transaction Log Shipping status report at a monitor server, primary server, or secondary server. To see the most complete information about your log shipping configuration, view the report at the monitor server instance. </li></ul></ul><ul><ul><li>An upgrade from a SQL Server 2000 log shipping configuration to SQL Server 2005 cannot be achieved as the Database Maintenance Plan Wizard, which was integral to log shipping in SQL Server 2000, is not used as part of the log shipping configuration in SQL Server 2005. </li></ul></ul>09th March 2007, SQL Server Open World Effective Usage of SQL Server 2005 Database Mirroring - www.sqlserver-qa.net
    9. 9. SQL Server 2005 High Availability features <ul><li>Replication involves the Publisher, Distributor, and Subscriber Metaphor. </li></ul><ul><li>Replication Scenarios – </li></ul><ul><ul><ul><li>Central Publisher and with Remote Distributor. </li></ul></ul></ul><ul><ul><ul><li>Publishing Subscriber & Central Subscriber. </li></ul></ul></ul><ul><ul><ul><li>Multiple Publishers or Multiple Subscribers. </li></ul></ul></ul><ul><li>Subscriptions. </li></ul><ul><ul><ul><li>Pull, Push & Anonymous Subscriptions. </li></ul></ul></ul><ul><li>Replication Agents. </li></ul><ul><ul><ul><li>Snapshot, Log Reader, Distribution, Merge Agents. </li></ul></ul></ul><ul><li>Timing, Latency, and Autonomy of Data with the methods of data distribution. </li></ul><ul><li>SQL Server Replication Types. </li></ul><ul><ul><ul><li>Snapshot Replication, Transactional Replication & Merge Replication. </li></ul></ul></ul><ul><li>Backup and Recovery in a Replication Configuration. </li></ul><ul><li>  Alternate Synchronization Partners. </li></ul><ul><li>  Worldwide Sales and Marketing-Scenario with Data Replication. </li></ul>09th March 2007, SQL Server Open World Effective Usage of SQL Server 2005 Database Mirroring - www.sqlserver-qa.net
    10. 10. Database Mirroring concepts <ul><li>What is - Database mirroring transfers transaction log records directly from one server to another and can quickly fail over to the standby server. </li></ul><ul><ul><li>An originating SQL Server 2005 instance continuously sends a database's transaction log records to a copy of the database on another standby SQL Server instance. </li></ul></ul><ul><li>Client connections - can code client applications to automatically redirect their connection information, and in the event of a failover, automatically connect to the standby server and database. </li></ul><ul><li>Fast failover - with minimal data loss has traditionally involved higher hardware cost and greater software complexity. </li></ul><ul><li>No dependency on proprietary hardware (cost and complexity), and easy to setup and manage. </li></ul><ul><li>SQL Server 2005 supports database mirroring between 64 bit & 32 bit editions. </li></ul>09th March 2007, SQL Server Open World Effective Usage of SQL Server 2005 Database Mirroring - www.sqlserver-qa.net
    11. 11. Database Mirroring concepts <ul><li>Terms involved: </li></ul><ul><ul><li>Principal – the server that holds a copy of database that is accessible to client applications at any given time. </li></ul></ul><ul><ul><li>Mirror – the server that holds copy of database that is always in restoring state that is not accessible to the applications. </li></ul></ul><ul><ul><li>Witness – the optional server that is useful to provide an automatic failover mechanism in case of any failure on principal server. </li></ul></ul><ul><ul><li>Send Queue - a queue (principal) that builds up when the log records can’t be sent at the rate at which they are generated from principal to mirror. It is a part of the log that has not yet been sent to mirror server. </li></ul></ul><ul><ul><li>Redo Queue – a queue (mirror) that builds up when the log records can’t be applied at the rate at which they are received from principal server. It is a part of log that remains to be applied to the mirror database to roll it forward. </li></ul></ul><ul><ul><li>Endpoint : A SQL Server object that enables Principal, Mirror & Witness servers to communicate over the network. It encapsulates a transport protocol and a port number. </li></ul></ul>09th March 2007, SQL Server Open World Effective Usage of SQL Server 2005 Database Mirroring - www.sqlserver-qa.net
    12. 12. Database Mirroring concepts <ul><li>Terms involved: </li></ul><ul><ul><li>System databases cannot be a part of mirroring. </li></ul></ul><ul><ul><li>Snapshot on mirror is possible for read-only purpose that is ideal for reporting requirements. </li></ul></ul><ul><ul><li>Mixture – An instance can serve as the principal for one database, the mirror for another database, and the witness for yet another database. </li></ul></ul><ul><ul><li>Encryption - Data between the principal and the mirror is transferred encrypted by default. </li></ul></ul><ul><ul><li>Transaction safety level – that determines whether the changes on the principal database are applied to the mirror database synchronously or asynchronously. Two safety levels—OFF and FULL. </li></ul></ul><ul><ul><li>Synchronous - the mirror server must synchronize the mirror database with the principal database. Speeds up the writes all of the incoming log records to disk as quickly as possible. </li></ul></ul><ul><ul><li>Asynchronous – this sets up database mirroring with high performance. With safety OFF, the transaction is committed as soon as the principal server writes the log record to the local log and sends the log record to the mirror, without waiting for an acknowledgement from the mirror server. </li></ul></ul>09th March 2007, SQL Server Open World Effective Usage of SQL Server 2005 Database Mirroring - www.sqlserver-qa.net
    13. 13. Database Mirroring concepts <ul><li>Database Mirroring configuration: </li></ul><ul><ul><li>High Availability </li></ul></ul><ul><ul><ul><li>Supports automatic detection and automatic failover in the event of a disaster by requiring a third instance to act as a Witness server. </li></ul></ul></ul><ul><ul><ul><li>“ full safety” form - If the Principal Database fails then the Witness will coordinate with the Mirror to have the Mirror database come online automatically to service client requests. </li></ul></ul></ul><ul><ul><li>High Protection </li></ul></ul><ul><ul><ul><li>Does not support automatic detection or automatic failover in the event of a disaster and it does not require or use a Witness. </li></ul></ul></ul><ul><ul><ul><li>Still uses “full safety” - steps to configure High Protection are identical to the High Availability configuration with the exception of the setup of the Witness server. </li></ul></ul></ul><ul><ul><ul><li>This should be used when automatic failover is not required and when more control on the failover scenario is desired. </li></ul></ul></ul><ul><ul><li>High Performance </li></ul></ul><ul><ul><ul><li>Does not support automatic detection or automatic failover in the event of a disaster and it does not require or use a Witness. </li></ul></ul></ul><ul><ul><ul><li>Uses an asynchronous (“full safety off”) form of mirroring. With full safety off, changes are not required to be sent immediately to the Mirror Database. </li></ul></ul></ul><ul><ul><ul><li>This allows the Principal Database to focus on client requests without the need to immediately and synchronously send the changes. </li></ul></ul></ul>09th March 2007, SQL Server Open World Effective Usage of SQL Server 2005 Database Mirroring - www.sqlserver-qa.net
    14. 14. Database Mirroring concepts 09th March 2007, SQL Server Open World Effective Usage of SQL Server 2005 Database Mirroring - www.sqlserver-qa.net <ul><ul><li>Another configuration mode (possible) asynchronous mode with no witness server – although this is possible to setup it is not recommended because it combines the risk of data loss and split-brain scenario. </li></ul></ul>Operating Mode Transaction Safety Transfer Mechanism Quorum Required Witness Server Failover type High Availability FULL Synchronous Yes Yes Automatic or Manual High Protection FULL Synchronous Yes No Manual High Performance OFF Asynchronous No No Forced
    15. 15. Database Mirroring concepts <ul><li>The mode is dependant on setting of Transaction Safety and Witness Server. </li></ul><ul><li>The impact of the transaction safety level on performance is application dependent. </li></ul><ul><li>It is recommended that you first learn the High Performance configuration and then move to the High Protection configuration. Then, if desired, you can move to the High Availability configuration. </li></ul><ul><li>Standard Edition allows only the FULL transaction safety level. </li></ul><ul><li>Configuration must be chosen depending upon the business requirement </li></ul>09th March 2007, SQL Server Open World Effective Usage of SQL Server 2005 Database Mirroring - www.sqlserver-qa.net
    16. 16. Usage and Practices <ul><li>Depending on the transaction safety level and whether you have a witness, you can have automatic failover, manual failover, or both. </li></ul><ul><li>Safety levels and failover options sequence: </li></ul><ul><ul><li>Failure occurs </li></ul></ul><ul><ul><ul><li>may be caused by hardware, storage, network, or power failure on the principal server. </li></ul></ul></ul><ul><ul><li>Failure is detected by mirror and witness </li></ul></ul><ul><ul><ul><li>Failure due to power loss are detected quickly within 1 second. </li></ul></ul></ul><ul><ul><ul><li>Failure due to hardware issues such as storage disks will take bit longer to detect, as dependant upon the ping process between principal, mirror and witness servers. Default timeout is 10 seconds and can be changed using ALTER DATABASE SET PARTNER TIMEOUT statement. </li></ul></ul></ul>09th March 2007, SQL Server Open World Effective Usage of SQL Server 2005 Database Mirroring - www.sqlserver-qa.net
    17. 17. Usage and Practices <ul><li>Safety levels and failover options sequence: </li></ul><ul><ul><li>Redo process on mirror </li></ul></ul><ul><ul><ul><li>Remaining log in the redo queue of the mirror at the time of failure of the principal is applied on the mirror database to completely recover it. </li></ul></ul></ul><ul><ul><li>Decision to fail over (1 second) </li></ul></ul><ul><ul><ul><li>A coordination process with the witness and decides that the database should now fail over to the mirror. </li></ul></ul></ul><ul><ul><li>Mirror becomes principal </li></ul></ul><ul><ul><ul><li>Once remaining redo log is applied the mirror database is brought online and assumes the role of principal, that is available for application connections. </li></ul></ul></ul><ul><ul><li>Undo </li></ul></ul><ul><ul><ul><li>All uncommitted transactions in the transaction log are rolled back. </li></ul></ul></ul><ul><ul><li>Database state: SYNCHRONIZING, SYNCHRONIZED, SUSPENDED, PENDING_FAILOVER & DISCONNECTED. </li></ul></ul>09th March 2007, SQL Server Open World Effective Usage of SQL Server 2005 Database Mirroring - www.sqlserver-qa.net
    18. 18. Usage and Practices <ul><li>Things to take care </li></ul><ul><ul><li>From the server perspective, the database failover time is the amount of time that it takes from the time the failure of the principal is detected to the time the mirror assumes the role of the principal. </li></ul></ul><ul><ul><li>A major component of the database failover time can be the redo phase. </li></ul></ul><ul><ul><li>Time to apply the redo records depends on the redo queue length and the redo rate on the mirror. </li></ul></ul><ul><ul><li>SYSMON counters Redo Queue KB and Redo Bytes/sec to measure this performance. </li></ul></ul><ul><ul><li>To accomplish roll forward, the SQL Server Database Engine processes log backups as they are restored, starting with the log that is contained in full backups, so the log backups after full backups is most important to reduce the redo phase time. </li></ul></ul>09th March 2007, SQL Server Open World Effective Usage of SQL Server 2005 Database Mirroring - www.sqlserver-qa.net
    19. 19. Usage and Practices <ul><li>Things to take care </li></ul><ul><ul><li>The database might contain changes made by transactions that are uncommitted at the recovery point. So it is better to keep the transactions in smaller batches to avoid lengthy time during failover time for a mission-critical database. </li></ul></ul><ul><ul><li>If redoing fails, the mirror server pauses the session by putting the database into the SUSPENDED state. The database owner must resolve the cause of the failure before resuming the session. </li></ul></ul><ul><ul><li>Client connection string supplied by the client contains information that the data access provider uses to connect to the database. </li></ul></ul><ul><ul><li>Connection string should contain the Network attribute to specify the network protocol. This ensures that the specified network protocol persists between connections to different partners. </li></ul></ul><ul><ul><li>Recommended protocol for connecting to a mirrored database is TCP/IP {Network=dbmssocn;} </li></ul></ul>09th March 2007, SQL Server Open World Effective Usage of SQL Server 2005 Database Mirroring - www.sqlserver-qa.net
    20. 20. Usage and Practices <ul><li>Things to take care </li></ul><ul><ul><li>Ensure TCP/IP is enabled from SQL Configuration Manager all the instances in database mirroring. </li></ul></ul><ul><ul><li>Named pipes can also be used, but a drawback is it does not use the TCP/IP retry algorithm, in many cases, a named pipes connection attempt may time out before connecting to a mirrored database. </li></ul></ul><ul><ul><li>When Database Mirroring appears to be running smoothly – don’t let yourself get a false sense of security. Things may be running smoothly but this is when you’ll want to be on the highest alert. </li></ul></ul><ul><ul><li>One way to measure the actual failover time is to use SQL Server Profiler [ Database Mirroring State Change event] on the principal and the mirror. </li></ul></ul><ul><ul><li>The name of an endpoint is changed when the port changes. If SQL Server is listening on dynamic ports, the port can change, changing the endpoint name, and dropping the associated endpoint permissions. </li></ul></ul><ul><ul><li>To avoid this security risk, do not set custom permissions on endpoints associated with dynamic ports, and do not change the order in which a TCP/IP endpoint occurs in the registry. </li></ul></ul>09th March 2007, SQL Server Open World Effective Usage of SQL Server 2005 Database Mirroring - www.sqlserver-qa.net
    21. 21. Usage and Practices <ul><ul><li>Things to take care </li></ul></ul><ul><ul><ul><li>If the principal fails, the failover scenario depends on the transaction safety level and whether you have a witness. </li></ul></ul></ul><ul><ul><ul><li>The length of the failover time depends upon the type of failure and the load on the database. </li></ul></ul></ul><ul><ul><ul><li>For a given failure type (synchronous mirroring with witness) , it takes longer to complete the failover under load as compared to the no-load scenario. </li></ul></ul></ul><ul><ul><ul><li>Changes in Recovery Model may be necessary </li></ul></ul></ul><ul><ul><li>Log Shipping supports Bulk-logged model </li></ul></ul><ul><ul><ul><li>If Log Shipped copy used as a safety store for recovering from erroneous user changes </li></ul></ul></ul><ul><ul><li>Create periodic Database Snapshots instead of delaying the application of log backups </li></ul></ul>09th March 2007, SQL Server Open World Effective Usage of SQL Server 2005 Database Mirroring - www.sqlserver-qa.net
    22. 22. Failover & Failback implementation <ul><li>Preparing the Mirror for Failover </li></ul><ul><ul><li>It is better to use identical servers (in terms of CPU, memory, storage, and network capacity) as principal and mirror partners. </li></ul></ul><ul><ul><li>Same service pack and patch levels for the operating system and SQL Server on both partners. </li></ul></ul><ul><ul><li>Depending upon the rolling upgrades the service pack levels can be different between principal and mirror, but for steady state they must be identical. </li></ul></ul><ul><ul><li>Ensuring that both servers have the same directory structure and SQL Server configuration eliminates the need for changes to these during or after the failover to the mirror partner. </li></ul></ul><ul><ul><li>Ensure that all active SQL Server logins (and their permissions) on the principal server are also present on the mirror server. </li></ul></ul><ul><ul><li>Ensure that all SQL Server Agent jobs, alerts, linked server definitions & SSIS packages are present in mirror server (disabled) and you may need them to enable in the event of a failover. </li></ul></ul><ul><ul><li>TCP Endpoint on each server and configure authentication on endpoint with CONNECT permission appropriately. </li></ul></ul><ul><li>The above preparation lists are applicable to the system databases between the principal and mirror servers. </li></ul>09th March 2007, SQL Server Open World Effective Usage of SQL Server 2005 Database Mirroring - www.sqlserver-qa.net
    23. 23. Failover & Failback implementation <ul><li>If there are multiple databases in an instance, you need to mirror each database individually. </li></ul><ul><li>The recommended limit of 10 databases in 1 SQL instance is only approximate and not an exact number. The limit (memory and threads) can vary depending upon your application and workload. </li></ul><ul><li>If your application consists of multiple databases, develop an alert mechanism to detect if one database fails over while others don’t. In this case you might need a manual failover of other databases. </li></ul><ul><li>In some cases (High Availability mode) failover can occur automatically while in others it must be forced. </li></ul><ul><li>To test the automatic failover you will shutdown the principal server and watch how the mirror server automatically comes online to handle requests. </li></ul><ul><li>High Performance is the best configuration with which to start as it has the least impact to your production workload yet still offers a secondary database that’s close to current. </li></ul><ul><li>Enable ALL of the threshold warnings for BOTH the principal and the mirror instance. </li></ul><ul><li>Database Mirroring has a single WMI Event to which all changes are logged. </li></ul><ul><ul><ul><ul><li>To understand how the system works without the option of automatically failing over, try using database mirroring without a witness for a time. </li></ul></ul></ul></ul>09th March 2007, SQL Server Open World Effective Usage of SQL Server 2005 Database Mirroring - www.sqlserver-qa.net
    24. 24. Failover & Failback implementation <ul><li>Security of mirroring sessions can be controlled by configuring the listener ports used for communication between mirrored partners. </li></ul><ul><li>Transaction Safety (SET TRANSACTION SAFETY) </li></ul><ul><ul><li>FULL : Transactions are forwarded synchronously (High Protection) </li></ul></ul><ul><ul><li>OFF: Transactions are forwarded asynchronously </li></ul></ul><ul><li>Removing Witness Server (SET WITNESS OFF) </li></ul><ul><ul><li>Behavior of mirroring session after the witness is removed depends on the transaction safety level. </li></ul></ul><ul><li>Testing Failover procedure </li></ul><ul><ul><li>Using the SQL Server Management Studio is simple – a single click of the “Failover” button in the mirroring dialog and if you say yes to “failing over and disconnecting currently connected users”, then the failover occurs very easily. </li></ul></ul><ul><ul><li>In similar using TSQL procedures is another straight forward solution that includes the catalog views, changing roles. Additionally, in High Protection, failover is not automatic and instead – must be forced. </li></ul></ul><ul><ul><ul><li>Initiate manual failover from principal database in order to switch partner roles. </li></ul></ul></ul><ul><ul><ul><ul><li>ALTER DATABASE <PrincipalDatabaseName> </li></ul></ul></ul></ul><ul><ul><ul><ul><li>SET PARTNER FAILOVER </li></ul></ul></ul></ul><ul><ul><li>Using the High Protection mode as the first implementation probably makes testing easier than jumping right into the High Availability mode. </li></ul></ul>09th March 2007, SQL Server Open World Effective Usage of SQL Server 2005 Database Mirroring - www.sqlserver-qa.net
    25. 25. Failover & Failback implementation <ul><li>Initiating Failover using SQL Server Management Studio : </li></ul><ul><ul><li>In the Object Explorer window, right-click on the PrincipalDB (Principal, Synchronized) database and choose P r operties . </li></ul></ul><ul><ul><li>On the Database Properties - PrincipalDB dialog, select Mirroring from the Select a page pane. </li></ul></ul><ul><ul><li>On the Mirroring page of the Database Properties - PrincipalDB window, click on the F ailover button to initiate the failover. </li></ul></ul><ul><ul><li>On selection, a Database Properties message box will appear stating: </li></ul></ul><ul><ul><ul><li>Failing over Database Mirroring will swap the roles of the mirror and principal databases. The mirror database will become the principal database, and the current principal will become inaccessible. If you have just modified any properties in the Database Properties dialog box, those changes will be lost. In addition, SQL Server must close all other connections to the current principal database. </li></ul></ul></ul><ul><ul><ul><li>Are you sure you want to fail over Database Mirroring to the mirror database and close all connections to the current principal database? </li></ul></ul></ul><ul><ul><li>Select Y es to confirm the failover. </li></ul></ul><ul><ul><li>In the Object Explorer window, expand the Databases list (under the GALAXY1EARTH connection). </li></ul></ul><ul><ul><li>Right-click on Databases and select Re f resh . The PrincipalDB database on the former principal server should be listed as the mirror database after failover: PrincipalDB (Mirror, Synchronized / Restoring…) </li></ul></ul><ul><ul><li>Expand the Databases list under the GALAXY1MARS connection. </li></ul></ul><ul><ul><li>Right-click on Databases and select Re f resh . The PrincipalDB database on the new principal server should be listed as: PrincipalDB (Principal, Synchronized) </li></ul></ul><ul><ul><li>Return to the Database Monitor and notice the titles now – during the failover, the client application detected the network timeout and reconnected to the NEW principal. </li></ul></ul>09th March 2007, SQL Server Open World Effective Usage of SQL Server 2005 Database Mirroring - www.sqlserver-qa.net
    26. 26. Failover & Failback implementation <ul><li>W ith and W ithout W itness </li></ul><ul><ul><li>Witness is not the most important member of the database mirroring session. </li></ul></ul><ul><ul><li>Witness server assists Principal or Mirror server in forming a quorum. </li></ul></ul><ul><ul><li>If Principal server cannot connect to mirror server, still the quorum consists with Witness to keep up the database in service. </li></ul></ul><ul><ul><li>In case Principal server is down then Witness initiates failover where the Mirror can take on the role of new principal server. </li></ul></ul><ul><ul><li>When the partner servers cannot see each other, the partner servers contact the witness to see whether the witness can contact the other partner and verify that a failure has occurred. </li></ul></ul><ul><ul><li>Witness is not a single point of failure. </li></ul></ul><ul><ul><li>The location of Witness is dependant upon your network availability to avoid losing two different servers, and therefore quorum, if the power system fails. </li></ul></ul><ul><ul><li>General recommendation of Witness location is to accompany Principal. </li></ul></ul>09th March 2007, SQL Server Open World Effective Usage of SQL Server 2005 Database Mirroring - www.sqlserver-qa.net
    27. 27. Monitoring Mirroring Performance <ul><li>In addition to using the Database Mirroring Monitor and dbmmonitor, you can use stored procedures to monitor a mirrored database and set up alerts on monitored performance variables. </li></ul><ul><li>SYSMON counters on each partner server helps you to monitor the performance of database mirroring, few of them are important to watch: </li></ul><ul><ul><li>SQLServer:Database Mirroring </li></ul></ul><ul><ul><li>Databases - Transactions/sec </li></ul></ul><ul><ul><li>On Principal server </li></ul></ul><ul><ul><ul><li>Log Bytes Sent/sec </li></ul></ul></ul><ul><ul><ul><li>Log Send Queue KB </li></ul></ul></ul><ul><ul><ul><li>Log Bytes Flushed/sec </li></ul></ul></ul><ul><ul><ul><li>Disk Write Bytes/sec </li></ul></ul></ul><ul><ul><li>On Mirror server </li></ul></ul><ul><ul><ul><li>Redo Bytes/sec </li></ul></ul></ul><ul><ul><ul><li>Redo Queue KB </li></ul></ul></ul><ul><ul><ul><li>Disk Write Bytes/sec </li></ul></ul></ul><ul><ul><ul><li>Other Logical Disk counters </li></ul></ul></ul>09th March 2007, SQL Server Open World Effective Usage of SQL Server 2005 Database Mirroring - www.sqlserver-qa.net
    28. 28. Monitoring Mirroring Performance <ul><ul><li>Rolling upgrade </li></ul></ul><ul><ul><ul><li>Upgrade the mirror first </li></ul></ul></ul><ul><ul><ul><li>Failover </li></ul></ul></ul><ul><ul><ul><li>Upgrade the new mirror </li></ul></ul></ul><ul><ul><ul><li>Failover again </li></ul></ul></ul><ul><ul><li>If using asynchronous mirroring </li></ul></ul><ul><ul><ul><li>Upgrade the mirror first </li></ul></ul></ul><ul><ul><ul><li>Wait for a low activity window </li></ul></ul></ul><ul><ul><ul><li>Switch to synchronous, and wait till SYNCHRONIZED </li></ul></ul></ul><ul><ul><ul><li>Follow process similar to one above </li></ul></ul></ul><ul><ul><ul><li>Switch back to asynchronous </li></ul></ul></ul><ul><li>SQL Server Profiler trace: </li></ul><ul><ul><li>Database Mirroring State Change event class </li></ul></ul><ul><ul><li>Audit Database Mirroring Login event class </li></ul></ul>09th March 2007, SQL Server Open World Effective Usage of SQL Server 2005 Database Mirroring - www.sqlserver-qa.net
    29. 29. Monitoring Mirroring Performance <ul><li>Troubleshooting </li></ul><ul><li>Database mirroring does not regularly check the components on which Sqlservr.exe relies to verify whether they are functioning correctly or have failed. </li></ul><ul><ul><li>Failures in databases other than the mirrored database are not detectable in a database mirroring session. Moreover, a data disk failure is unlikely to be detected, unless the database is restarted because of a data disk failure. </li></ul></ul><ul><li>If database mirroring is not working, check the following to make sure the configuration is correct: </li></ul><ul><ul><ul><li>Look at the column STATE_DESC in the catalog view sys.database_mirroring_endpoints . </li></ul></ul></ul><ul><ul><ul><li>Endpoints compatible encryption settings </li></ul></ul></ul><ul><ul><ul><ul><li>Look at the column IS_ENCRYPTION_ENABLED in the catalog view sys.database_mirroring_endpoints </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Look at the columns TYPE_DESC and ROLE_DESC respectively of the catalog view sys.database_mirroring_endpoints for the correct type and roles. </li></ul></ul></ul></ul><ul><ul><li>Ensure port numbers of the endpoints are the same as the corresponding port numbers specified in the SET PARTNER statements. </li></ul></ul>09th March 2007, SQL Server Open World Effective Usage of SQL Server 2005 Database Mirroring - www.sqlserver-qa.net
    30. 30. Monitoring Mirroring Performance <ul><li>Account under which the SQL Server instance is running has the necessary CONNECT permissions. </li></ul><ul><ul><li>If SQL Server runs under a different user on one or more of these servers, then you need to grant CONNECT permission on the endpoint of a server to the login account of the other servers. </li></ul></ul><ul><ul><li>Make sure the port that is used for database mirroring endpoints is opened through the firewall, if used. </li></ul></ul><ul><li>Critical - speed of error detection and, therefore, the reaction time of the mirroring session to a failure, depends on whether the error is hard or soft. </li></ul><ul><ul><li>Few network components and some IO subsystems, have their own time-outs to determine failures. </li></ul></ul><ul><ul><li>Mirroring does not protect against problems specific to client accessing the servers, such as public network adapter on any partner server. </li></ul></ul><ul><li>Database mirroring failover and failback procedures are dependant on the network components and server hardware in addition to the server/database configuration. </li></ul>09th March 2007, SQL Server Open World Effective Usage of SQL Server 2005 Database Mirroring - www.sqlserver-qa.net
    31. 31. Conclusion <ul><li>Measures & Practices </li></ul><ul><li>The operational tasks related to the data center span the full life-cycle of the data services it helps to provide, from planning, through building and deployment, to operation. </li></ul><ul><li>Managed data stores use database mirroring and therefore when performance becomes an issue, the IT operations team can add new higher specification servers. </li></ul><ul><li>What’s new for DBA: </li></ul><ul><li>Role of the database administrator is changing, thoughts on the relevance of 64-bit and Itanium with respect to Business Intelligence (BI), and the very on-topic advances in High Availability, such as Database Mirroring and Log Shipping technology in SQL Server 2005 and its implications for disaster recovery. </li></ul><ul><li>Database Mirroring can be set to fail-over and recover automatically. Indeed, db mirroring offers a substantial increase in availability over standard log shipping, by maintaining a hot-standby server where changes are reflected real-time, and applications can recover quickly with minimal, if any, intervention. </li></ul>09th March 2007, SQL Server Open World Effective Usage of SQL Server 2005 Database Mirroring - www.sqlserver-qa.net
    32. 32. Conclusion <ul><li>The performance of database mirroring is very closely associated with the type of application, transaction safety level, and network performance. </li></ul><ul><li>The network plays a very important role in a database mirroring environment. </li></ul><ul><li>When used with a high-bandwidth and low-latency network, database mirroring can provide a reliable high-availability solution against planned and unplanned downtime. </li></ul><ul><li>Across geographically distant data centers, database mirroring can provide the foundation for a disaster-recovery solution. </li></ul><ul><li>Do not forget to test and plan for any sort of new introduction to your High Availability ranch, even changes in Database Mirroring mode. </li></ul>09th March 2007, SQL Server Open World Effective Usage of SQL Server 2005 Database Mirroring - www.sqlserver-qa.net
    33. 33. Frequently Asked Questions <ul><li>Support for Database Mirroring prior to SQL Server 2005 SP1. </li></ul><ul><li>Can I mirror between multiple virtual servers in a cluster? </li></ul><ul><li>What is the slowest network that I can use with mirroring? </li></ul><ul><li>What and Why don’t some technologies work seamlessly after a failover? </li></ul><ul><li>How to disable database mirroring for a particular database, is it possible? </li></ul><ul><li>What is the usage of WITNESS instance in Database Mirroring setup? </li></ul><ul><li>Is it recommended to use 32-bit server as Witness for a 64-bit Database Mirroring Partner server? </li></ul>09th March 2007, SQL Server Open World Effective Usage of SQL Server 2005 Database Mirroring - www.sqlserver-qa.net
    34. 34. Questions & Answers <ul><li>I’ll do my best to answer your questions. </li></ul><ul><li>If you don’t get your questions answered today, post them at: SSP Forums & MSDN Forums or view Blogs </li></ul><ul><li>Additional Database Mirroring Resources </li></ul><ul><ul><li>Database Mirroring in SQL Server 2005 by Ron Talmage - Whitepaper </li></ul></ul><ul><ul><li>Implementing Database Mirroring, series for IT Professionals, presented by Kimberly L. Tripp, SQLskills.com – Webcast </li></ul></ul><ul><ul><li>SQL Server 2005 Books Online Refresh, February 2007 – Link </li></ul></ul><ul><ul><li>High Availability resources – SSP & SSQA </li></ul></ul>09th March 2007, SQL Server Open World Effective Usage of SQL Server 2005 Database Mirroring - www.sqlserver-qa.net
    35. 35. Thank you and have a great day ahead . <ul><li>Feedback : </li></ul><ul><ul><li>Please fill out evaluation forms </li></ul></ul>09th March 2007, SQL Server Open World Effective Usage of SQL Server 2005 Database Mirroring - www.sqlserver-qa.net
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×