启动订户同步的脚本 [英] Script to start subscribers synchronizing

查看:133
本文介绍了启动订户同步的脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我想强制更新我的合并复制发布的订阅者时,我可以进入复制监视器,右键单击订阅,然后选择开始同步。我想能够脚本(使用vba / vbscript或命令行)。我也希望用户能够运行脚本(需要什么权限?)。

When I want to force an update of the subscribers to my merge replication publication, I can go into the Replication Monitor, right click on the subscription, and choose Start Synchronizing. I'd like to be able to script this (using vba/vbscript or a command line). I'd also like users to be able to run the script (what permissions would be required, if any?).

我确定已经提出并回答了

I'm sure this has been asked and answered many times before, but my Googling attempts came up empty.

推荐答案

假设发布已经存在(并且有效的快照可用一个有效的文件夹),这里是T-SQL和命令行指令,您需要启动和维护发布商和订阅者的订阅。我们使用此代码从头开始Web复制(订户端没有数据库)。一旦通过存储过程在两端声明了订阅,您必须(在定期的基础上)在订阅者端运行同步命令行指令(见下文)。

Assuming the publication already exists (and a valid snapshot is available on a valid folder), here are the T-SQL and command line instructions that you need to initiate and maintain a subscription on both publisher and subscriber. We use this code to start a web replication from scratch (no database on the subscriber's side). Once the subscription declared on both sides through stored procedures, you have to run (on a regular basis) the synchronization command-line instruction on the subscriber's side (see below).

由于此代码特定于Web复制,请检查在服务器上组织此类复制的其他参考,包括发布参数等。您可以在相应的文档中找到所有与安全相关的内容。当然,同步命令行参数与特定订阅及其参数严格相关。如果您的订阅不是通过网络(如本例中),您将不得不调整发布,订阅和同步参数。请注意,这里的许多参数反映了我们的具体情况,例如发布商也是订阅者。您可能需要根据情况进行调整。

As this code is specific to web replication, please check additional references on organizing such a replication on your server, including publication parameters, etc. You'll find all the stuff related to security in the corresponding docs. Of course, synchronization command-line parameters are strictly related to the specific subscription and its parameters. In case your subscription is not done through web (like in this example), you 'll have to adjust publication, subscription and synchronization parameters consequently. Please be aware that many parameters here reflects our specific situation, where for example the publisher is also the subscriber. You might have to adapt depending on your situation.

PS:SQLEXPRESS服务器不能是发布商。您必须获取完整版本的SQL才能发布数据库。 SQLEXPRESS服务器可以是订阅服务器。

PS: SQLEXPRESS server cannot be a publisher. You'll have to get the complete version of SQL to publish your database. SQLEXPRESS servers can be Subscribers.


  1. 发布商代码:one sp

  1. Publisher code: one sp

exec sp_addmergesubscription 
    @publication = N'myPublication', 
    @subscriber = N'mySuscriber\SQLEXPRESS', 
    @subscriber_db = N'myDatabaseOnMySubscriber', 
    @subscription_type = N'pull', 
    @subscriber_type = N'local', 
    @subscription_priority = 0, 
    @sync_type = N'Automatic'
go


  • 用户代码:两个sp

  • Subscriber code: two sp's

    exec sp_addmergepullsubscription 
        @publisher = N'myServerName', 
        @publication = N'myPublicationName', 
        @publisher_db = N'myMainDatabase', 
        @subscriber_type = N'Local', 
        @subscription_priority = 0, 
        @description = N'', 
        @sync_type = N'Automatic'
    
    exec sp_addmergepullsubscription_agent
        @publisher = N'myServername', 
        @publisher_db = N'myMainDatabase', 
        @publication = N'myDatabaseOnMySubscriber', 
        @distributor = N'myServerName', 
        @distributor_security_mode = 1, 
        @distributor_login = N'', 
        @distributor_password = N'', 
        @enabled_for_syncmgr = N'True', 
        @frequency_type = 4, 
        @frequency_interval = 1, 
        @frequency_relative_interval = 1, 
        @frequency_recurrence_factor = 0, 
        @frequency_subday = 8, 
        @frequency_subday_interval = 1, 
        @active_start_time_of_day = 0, 
        @active_end_time_of_day = 235959, 
        @active_start_date = 0, 
        @active_end_date = 0, 
        @alt_snapshot_folder = N'', 
        @working_directory = N'', 
        @use_ftp = N'True', 
        @job_login = null, 
        @job_password = null, 
        @publisher_security_mode = 1, 
        @publisher_login = N'', 
        @publisher_password = N'', 
        @use_interactive_resolver = N'False', 
        @dynamic_snapshot_location = N'', 
        @use_web_sync = 1, 
        @internet_url = N'https://mySecuredWebPage:myOpenPort/myPublicationName/replisapi.dll',
        @internet_login = N'myDomain\myUserName', 
        @internet_password = null, 
        @internet_security_mode = 0, 
        @internet_timeout = 300
    go
    


  • 用户同步BAT文件

  • Subscriber BAT file for synch

    "C:\Program Files\Microsoft SQL Server\90\COM\replmerg.exe"
        -Publisher [myServerName]  
        -PublisherDB [myMainDatabase]  
        -Publication [myPublicationName] 
        -Distributor [myServerName] 
        -Subscriber [mySubscriber\SQLEXPRESS] 
        -SubscriptionType 1 
        -SubscriberSecurityMode 1 
        -SubscriberDB [myDatabaseOnMySubscriber] 
        -InternetURL [https://mySecuredWebPage:myOpenPort/myPublicationName/replisapi.dll] 
        -InternetLogin [myDomain\myUserName] 
        -InternetPassword [myPassword]
    


  • 这篇关于启动订户同步的脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆