High Availability of SQL server SQL Mirror HA

Source: Internet
Author: User

This article describes the basic configuration and installation of Mirror for SQL Server 2008.

Preparations

1. The Principal, Mirror, and Witness instances are installed in the same version. Currently, they are in SQL Server 2008 SP1.

2. you need to add a domain account to the Administrators group and SQL Server-related groups of the servers where the three database instances are located. The specific group functions are unclear, therefore, we recommend that you add this domain account to all groups to ensure that the permission runs properly.

3. Set the domain account in step 2 to the SQL Server service, the SQL Server Agent Startup account, and restart the service.

4. Ensure that the data and logs on the Principal and Miroor instances are the same. The backup mode is full backup, and the recovery mode is full. You must select the NoRecovery mode when restoring the database to the Mirror instance.

Create an EndPoint

1. Create an EndPoint on the Principal and Mirror instances and run the script:

 
 
  1. Create EndPoint On Principal and Mirror Instance
  2. Create endpoint paiing_ep
  3. STATE = STARTED
  4. As tcp (LISTENER_PORT = 5022)
  5. FOR database_grouping ing
  6. (ROLE = PARTNER, ENCRYPTION = SUPPORTED)
  7. -- Or create endpoint cmding_ep
  8. STATE = STARTED
  9. As tcp (LISTENER_PORT = 5022)
  10. FOR database_grouping ing
  11. (AUTHENTICATION = windows ntlm, ROLE = PARTNER)

2. Create an EndPoint on the Witness instance and run the script:

 
 
  1. Create EndPoint On Witness Instance
  2. Create endpoint paiing_ep
  3. STATE = STARTED
  4. As tcp (LISTENER_PORT = 5022)
  5. FOR database_grouping ing
  6. (ENCRYPTION = SUPPORTED, ROLE = WITNESS );
  7. -- Or
  8. Create endpoint paiing_ep
  9. STATE = STARTED
  10. As tcp (LISTENER_PORT = 5022)
  11. FOR database_grouping ing
  12. (AUTHENTICATION = windows ntlm, ROLE = WITNESS)

View the EndPoint and delete the EndPoint script:

 
 
  1. Select * From Sys.database_mirroring_endpoints  
  2. Select * From sys.database_mirroring  
  3. Drop Endpoint endpoint_mirroring 

Create Mirror Session

1. Create a Session on the Mirror instance and run the script:

 
 
  1. ALTER DATABASE  DataBaseName  
  2. SET PARTNER = 'TCP://PrincipalServerName:5022'; 

2. Create a Session on the Principal instance and run the script:

 
 
  1. ALTER DATABASE  DataBaseName  
  2. SET PARTNER = 'TCP://MirrorServerName:5022'; 

3. Specify Witness on the Principal instance and run the script:

 
 
  1. ALTER DATABASE  HB2008_Gome  
  2. SET WITNESS = 'TCP://WitnessServerName:5022'; 

Note:

1. This error may occur when you create a Session on the Principal instance. The error message is as follows:

The transaction log data contained in the Image Database "dbName" is insufficient, and the log backup chain of the main database cannot be retained. This situation may occur if log backup is not performed from the primary database or the backup is not restored from the backup database.

The solution is to back up the log on the Principal instance and restore it to the Mirror instance in NoRecovery mode.

The reason is that logs are interrupted and logs may be generated during full backup.

2. Test FailOver

 
 
  1. ALTER DATABASE DataBase  
  2. SET PARTNER FAILOVER 

3. Related query tables:

 
 
  1. Sys.database_mirroring   
  2. Sys.database_mirroring_endpoints   
  3. Sys.database_mirroring_witnesses  

4. scheduled task backup in advance:

You can generate scripts for scheduled tasks on Principal in advance and execute the scripts on the Mirror instance after the Mirror configuration is complete.

5. Image Running Mode

High Security Mode: supports synchronous operations. When a transaction is committed on both the subject and the image, the transaction latency is prolonged.

High-performance mode: supports asynchronous operation, and the backup storage may lag behind the master database.

It is worth noting that, in the high security mode, because the subject and the image are synchronous operations, the image is not submitted, causing the subject to not submit, which may have a great impact.

For example, DBServerA and DBServerB databases are mutually mirrored, DBServerA is the subject, and DBServerB is the image;

At the same time, DBServerA is the Publishing Server, and DBServerC subscribes from DBServerA. The application system queries on DBServerC.

If DBServerB fails, DBServerA cannot be submitted. Therefore, DBServerC cannot query data in a timely manner.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.