SQL Server 2008 R2 from the master database synchronization (log shipping way Log Shipping)

Precautions:

    1, mainly to add new users of the system and set your password from the server;

    2, both main open SQL Server Agent service from a server, and set to automatic startup

    3, in the configuration management database in which to set up SQL Server login information for service and the SQL Server Agent service is added on top of system users, and set your password. (Master and slave servers need to remember this setting, do not forget, I always forget how to get will not work)

    4, users share files directory, you need shared access password, remember that first visit and remember to share documents, or will be prompted to fail.

    5, SQL Server backups, database backup of the database server automatically main library, backup file is generated, when the sub-interval, and then generate a backup log files (files .trn) further from the library according to the log file acquired from the main library restore operation, thus ensuring consistent master data from the database. But, if there is no data update, or will generate a log file (.trn), and data synchronization, network bandwidth.

    6, try not to separate from the library, because the process of being restored and sometimes isolated, additional time again after the separation, there will be "Can not attach database being restored (Microsoft SQL Server, Error: 1824)." Mistakes.

 

 

First, the preparatory work:

The primary database server:

Operating System: Windows Server 2008 R2    

Database: SQL Server 2008 R2

IP Address: 192.168.1.61

From the database server:

Operating System: Windows Server 2008 R2    

Database: SQL Server 2008 R2

IP Address: 192.168.1.62

 

 

Primary database server has WebDB, WebDB is what we want to synchronize the database, only one table WebDB test, as shown below:

wKioL1iuZini1LQyAABknghryQs592.png-wh_50

 

No WebDB database from the server database, WebDB database that we have to synchronize the database, as shown below:

wKiom1iuZlLTW5cJAABkno3QR0M731.png-wh_50

Second, create an administrator user and shared folder permissions to the SQL Server database, set the SQL Server service and SQL Server Agent logon user sqladmin

1. created on the server where the primary database WebDB user sqladmin, click Start - Run (or press the shortcut keys Win + R), type the command lurmgr.msc, hit Enter, pop-up Local Users and Groups window, new by user:

wKioL1iuZnDgkuacAAA-KqP7lcQ147.png-wh_50

  The new user interface as shown below:

wKiom1iuZpLw8IsCAAAd2KAErjY808.png-wh_50

Set sqladmin authority belongs to the Administrators

wKioL1iuZqyBFOgLAAAkUU80xLg887.png-wh_50

2. In the same need to create a user sqladmin from the database and added to the administrators group, others are deleted!

3. were created master from the master database server for storing backup log file from the shared files and shared folders SQLDataBack and NTFS permissions, as shown below:

wKioL1iuZtiAhRGzAABak-JHsvQ577.png-wh_50

wKiom1iuZvLyRmy0AAA21ENbvl4184.png-wh_50

4. SQLServer respectively open Configuration Manager from the database server on the primary database server, the SQL Server, and SQL Server Agent service and services "for the Log On" and the start SQLAdmin user mode: automatic, as shown below:

wKiom1iuZxWT50tNAAAilS_WSC4787.png-wh_50

wKiom1iuZ0Wyx7UvAAAh98hycP0034.png-wh_50

  General SQL Server server startup mode is self-starting, SQL Server Agent service is started manually, you need to choose Custom to start the service in.

wKioL1iuZ3XBrpoiAAAgKhlWXZw941.png-wh_50

Third, the log shipping configuration SQLServer

1 disposed on the primary database server

Sqladmin connection to the local SQL Server database server (I tried here, with the Administrator user login also possible)

wKiom1iuZ5KQ2NnzAABjshCDsqM818.png-wh_50

  In the database instance (database instance I have here is SQL2008, that is, \ Right-click on SQL2008.) Right-click - properties - security, configuration server authentication mode and proxy server accounts, correspondent account is set up in front of us sqladmin account.

wKioL1iuZ6zgNGFxAABtmf6BOIs414.png-wh_50

2. Set the attribute information WebDB database in the primary database server.

  Right-click on the database WebDB - Properties to open the Database Properties window, select the Options tab, select the resume mode is "complete" (the default is complete), as shown below

wKioL1iuZ8fAq6GdAABpra_WQug325.png-wh_50

  Then select "Transaction Log Shipping" option in the Properties window of the database, check the "Enable this database is the primary database log shipping configuration", then click "Backup Settings" button:

wKiom1iuZ-HjcDoDAAB0gwRiWmg744.png-wh_50

  Disposed below the transaction log backup settings window:

wKiom1iua_fgWO0MAAI8hoRm_48525.jpg-wh_50

  In the figure above, click on the "Program" button, pop-up as shown below:

wKiom1iuaB-QNHNqAABtMZvhPjM945.png-wh_50

  If you need to have synchronized, in duration, to select No end date. Continue to click OK, see the following figure so far!

wKiom1iuaDzz8sO9AACaNhhdd24853.png-wh_50

  上图中上一个箭头指向的是我们刚才备份设置中,设置的备份计划,点击箭头指向的“添加”按钮,连接到从服务器的辅助数据库实例。(注意:此时要是连接不上从服务器,应该把从服务器的防火墙关闭)

wKioL1iuaJ3zhL-XAABiaw_nIEU102.png-wh_50

   连接后,可以看到辅助数据库实例和辅助数据库名称。辅助数据库可以选择现有数据库,也可以输入一个名称,新建一个数据库,默认的辅助数据库名称,和需要同步的主数据库名称一致。

wKiom1iuaMPQJFKfAABMzegwQgI813.png-wh_50

   在初始化辅助数据库选项卡中,点击“还原选项”按钮,弹出还原选项窗口,如下图:

wKiom1iuaNihXqcPAAAZ7syAgRQ761.png-wh_50

   注意:该文件夹为从服务器的本地文件夹,即辅助数据库(同步库)的数据文件和日志文件需要存放的文件夹。不填写的话,则使用从服务器上的数据库实例默认的数据存放路径。

   点击“复制文件”选项卡,输入从服务器复制文件的目标文件夹(注意是从服务器上的本地文件夹,也是我们前面在从服务器上设置的共享文件夹)。其中的删除时间,也需要跟我们的同步频率进行设置,同步频率越频繁,则删除复制文件的间隔也越短。

wKioL1iuaPqjVPOyAABJ1EP5ovA361.png-wh_50

  点击上图中的计划按钮,弹出“作业计划属性”窗口,设置从服务器同步间隔和是否有结束日期,点击确定即可。

wKiom1iuaRfRBtaQAABPoBakc3o092.png-wh_50

   选择“还原事务”日志选项卡,选择“备用模式”,如下图:

wKiom1iuaS3ScIaBAABLH01O9Jk981.png-wh_50

   同时点击“计划”按钮,弹出“作业计划属性”,根据需要选择相应信息,点击确定即可。

wKioL1iuaUeD_8xZAABOAOqHAq8841.png-wh_50

  将我们以上的配置信息导出到文件,如下图:

wKiom1iuaVqwHYSWAACq91H8QA0612.png-wh_50

  保存完配置脚本后,点击确定按钮,就开始保存日志并传送配置,成功的话, 你就可以看到如下界面。

wKioL1iuaW7BmdwPAAA40pUvdt8360.png-wh_50

  注意:如果失败的话,会提示相应的错误信息,可以查看错误信息后。出现错误信息后,点击确定后,数据库属性的窗口就会关闭,我们再次在属性中打开,在“事务日志传送”就看不到我们配置的主从数据配置信息,我们可以重新配置。但是,我们还可以通过我们保存的脚本信息,在新建查询窗口中,执行我们保存的脚本。执行脚本后,就可以在数据库属性中的“事务日志传送”选项中看到我们设置的主从备份信息,改正错误,重新确定执行即可。

三、验证SQL Server 2008 R2主从数据库是否同步

1. We go from the server to see if there WebDB database, as shown in the figure below, showing a success!

wKioL1iuaYTyVF3-AABC5kAvcCI236.png-wh_50

2. Now we go to the primary database server to add a database WebDB table shown below:

Create a table named Sys_News

wKiom1iuaaPBS7auAABZTQTieIw866.png-wh_50

3. Now if we go from there WebDB database server database table Sys_News, as shown below:

wKiom1iuacHzqZMpAABSPz-zslQ571.png-wh_50

  I did not see, because the scheduled task we set is 15 minutes, 15 minutes not to, so there is no sync up. Wait 15 minutes after have. So when synchronized, time synchronization must be planned. 

  Note: How to Remove WebDB (standby / read only) database

    On the Database Right - Properties - Options - Status - database is read-only, can be modified to False!

Guess you like

Origin www.cnblogs.com/SyncNavigator8-4-1/p/10974104.html