我正在使用SQL Server 2012并尝试实现事务复制。我使用系统存储过程来创建发布和订阅。我成功创建了这些东西,但是当我检查复制监视器时,它显示“未初始化的订阅”。
当我检查订阅的同步状态时,我找到了这个日志
Date 6/20/2012 7:36:33 PM
Log Job History (HYDHTC0131320D-PublisherDB-PublicationOne-HYDHTC0131320D\MSS-ReplicationSubscri-7C1D7509-C8A6-4073-A901-0433A2B6D2D3)
Step ID 1
Server HYDHTC0131320D\MSSQLSERVER2
Job Name HYDHTC0131320D-PublisherDB-PublicationOne-HYDHTC0131320D\MSS-ReplicationSubscri-7C1D7509-C8A6-4073-A901-0433A2B6D2D3
Step Name Run agent.
Duration 00:07:41
Sql Severity 0
Sql Message ID 0
Operator Emailed
Operator Net sent
Operator Paged
Retries Attempted 0
Message
2012-06-20 14:14:13.986 Copyright (c) 2008 Microsoft Corporation
2012-06-20 14:14:13.986 Microsoft SQL Server Replication Agent: distrib
2012-06-20 14:14:13.986
2012-06-20 14:14:13.986 The timestamps prepended to the output lines are expressed in terms of UTC time.
2012-06-20 14:14:13.986 User-specified agent parameter values:
-Publisher HYDHTC0131320D
-PublisherDB PublisherDB
-Publication PublicationOne
-Distributor HYDHTC0131320D
-SubscriptionType 2
-Subscriber HYDHTC0131320D\MSSQLSERVER2
-SubscriberSecurityMode 1
-SubscriberDB ReplicationSubscriberDB
-Continuous
-XJOBID 0xDFE51AEC7F9E3F42A450CE8874B662CD
-XJOBNAME HYDHTC0131320D-PublisherDB-PublicationOne-HYDHTC0131320D\MSS-ReplicationSubscri-7C1D7509-C8A6-4073-A901-0433A2B6D2D3
-XSTEPID 1
-XSUBSYSTEM Distribution
-XSERVER HYDHTC0131320D\MSSQLSERVER2
-XCMDLINE 0
-XCancelEventHandle 000005F8
-XParentProcessHandle 00000560
2012-06-20 14:14:13.986 Startup Delay: 619 (msecs)
2012-06-20 14:14:14.606 Connecting to Subscriber 'HYDHTC0131320D\MSSQLSERVER2'
2012-06-20 14:14:14.656 Connecting to Distributor 'HYDHTC0131320D'
2012-06-20 14:14:14.671 Parameter values obtained from agent profile:
-bcpbatchsize 2147473647
-commitbatchsize 100
-commitbatchthreshold 1000
-historyverboselevel 1
-keepalivemessageinterval 300
-logintimeout 15
-maxbcpthreads 1
-maxdeliveredtransactions 0
-pollinginterval 5000
-querytimeout 1800
-skiperrors
-transactionsperhistory 100
2012-06-20 14:14:14.683 Agent message code 21040. Publication '' does not exist.
如何解决此问题?
答案 0 :(得分:3)
我收到了同样的错误。我的解决方法是明确定义Job_login和job_password,我将其作为null开始。
EXEC sp_addpullsubscription_agent
@publisher = @publisher,
@publisher_db = @publicationDB,
@publication = @publication,
@distributor = @publisher,
@job_login = $(Login),
@job_password = $(Password);
答案 1 :(得分:1)
您的复制设置脚本中似乎存在错误。
我怀疑错误是在sp_addpushsubscription_agent(如果是推送订阅)或sp_addpullsubscription_agent(如果是pull订阅)的调用中。具体而言, @publication 参数错误,因为分发代理声明指定的发布“不存在。
请检查您的脚本,然后重试。
答案 2 :(得分:1)
我面临同样的问题并通过以下方式解决:
-Subscriber作业所有者与发布用户
-Subscriber User已添加到订户用户列表中并添加 到sysadmin服务器角色
答案 3 :(得分:0)
只需几个笔记,因为我设法通过备份初始化获得拉动用户并运行:
sp_addsubscription
)上创建发布组件,并确保您拥有@sync_type = N'replication support only'
。希望这有助于任何人仍然根据备份初始化努力与拉用户...请注意,我没有在复制配置中使用任何备份配置。同时声明,pull订阅不得初始化(@immediate_sync = 0
)。
以下是脚本:
-----------------BEGIN: Script to be run at Publisher 'DB001\OLTP'-----------------
use [DB1]
go
exec sp_addsubscription @publication = N'DB1', @subscriber = N'DB002\OLTP', @destination_db = N'DB1', @sync_type = N'replication support only', @subscription_type = N'pull', @update_mode = N'read only'
GO
-----------------END: Script to be run at Publisher 'DB001\OLTP'-----------------
-----------------BEGIN: Script to be run at Subscriber 'DB002\OLTP'-----------------
use [DB1]
exec sp_addpullsubscription @publisher = N'DB001\OLTP', @publication = N'DB1', @publisher_db = N'DB1', @independent_agent = N'True', @subscription_type = N'pull', @description = N'', @update_mode = N'read only', @immediate_sync = 0
exec sp_addpullsubscription_agent @publisher = N'DB001\OLTP', @publisher_db = N'DB1', @publication = N'DB1', @distributor = N'DB003\DIST', @distributor_security_mode = 1, @distributor_login = N'', @distributor_password = null, @enabled_for_syncmgr = N'False', @frequency_type = 64, @frequency_interval = 0, @frequency_relative_interval = 0, @frequency_recurrence_factor = 0, @frequency_subday = 0, @frequency_subday_interval = 0, @active_start_time_of_day = 0, @active_end_time_of_day = 235959, @active_start_date = 20170327, @active_end_date = 99991231, @alt_snapshot_folder = N'\\DB001\Replication', @working_directory = N'', @use_ftp = N'False', @job_login = null, @job_password = null, @publication_type = 0
GO
-----------------END: Script to be run at Subscriber 'DB002\OLTP'-----------------