High availability with sqlserver database replication

  • need:

Project operating system windows server2008, database sql sever2012. A high-availability scenario for the database is required. We provide a ha scheme using the real-time replication feature of the database. Specifically, the "transactional replication" method is used to actively push the primary database to the backup database in real time. When the main database fails, manually modify the database connection address to the standby database, and the system starts to run normally. Then delete the original replication and change to real-time replication from the backup repository to the primary repository.

A database fault finder is required. When a failure occurs, the switch can be performed manually, which takes more than ten minutes; or it can be performed automatically, requiring a program to modify the database url.

  • Please refer to Baidu for the principle and basic operation of the sqlserver replication function, which is omitted here.
  • Verify the environment:

主:window server2008+sqlserver 2012

Preparation :window 10+sqlserver 2012.

Firewalls are all turned off for convenience

  • step:

Install the database on 2 machines. Check the "Copy" and "Management" functions according to the time.

Open SQLServer Management Studio and connect to 2 databases.

 

The proxy service of the master server must be started:

 

 

  • To establish replication, just operate on the main server,

1) "Copy" menu, configure the distributor, note that the "distributor" and "publisher" are on the same machine, the steps are omitted.

2) "Local Publishing" menu, create a " transactional publishing " type of publishing. be careful:

Snapshots folder, don't use the default location, which can cause "path unreachable" errors, use a different folder instead.

 

3) After the release is created, it will be displayed under "My Release". Click "View Snapshot Status" to make sure the published snapshot is error-free:

 

4) Find the created publication under "My Publications", right-click, and select "New Subscription" to start creating a subscription for this publication. Pay attention to the setting of the "Security" property. In this example, because the two machines for publishing and subscribing do not have the same Windows login account, the "Subscriber Connection" uses the sa user authentication.

 

5) Check the backup database, the tables and data are the same as the main database. Do some data modification in the main database and check whether it is synchronized in the backup database.

 

 

 

 

 

 

 

 

 

 

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326296528&siteId=291194637