Quantcast
Channel: SQL Server Replication forum
Viewing all articles
Browse latest Browse all 4054

Issue with TX replication with DB Mirroring

$
0
0
I am trying to setup TX replication with DB mirroring in SQL 2012. 

Server1: Test-DB01
Windows 2012 Data Center Edition
SQL 2012 EE

On TEST-DB01 I have 2 databases engine,reports. I am replicating(Tx replication) data from engine database to reports database. I configured the distributor for this replication on a different server TEST-DB02. I have also setup mirroring for engine and reports databases on TEST-DB01 to TEST-DB02. Publication name is 10272014.

Server2: Test-DB02
Windows 2012 Data Center Edition
SQL 2012 EE
This server is a distributor with 2 publishers TEST-DB01 and TEST-DB02. It is also being used as a mirror for both engine and reports database from TEST-DB01.

I executed the below statements to ensure that the databases on TEST-DB02 are the failover partners when a failover occurs:

exec sp_add_agent_parameter @profile_id = 1, @parameter_name = N'-PublisherFailoverPartner', @parameter_value = N'TEST-DB02'
exec sp_add_agent_parameter @profile_id = 2, @parameter_name = N'-PublisherFailoverPartner', @parameter_value = N'TEST-DB02'
exec sp_add_agent_parameter @profile_id = 3, @parameter_name = N'-PublisherFailoverPartner', @parameter_value = N'TEST-DB02'
exec sp_add_agent_parameter @profile_id = 9, @parameter_name = N'-PublisherFailoverPartner', @parameter_value = N'TEST-DB02'


I failed over engine from TEST-DB01 to TEST-DB02 and ran few update statements and then reflect in the reports database in TEST-DB01. No issues there. Then I wanted to failover reports database from TEST-DB01 to TEST-DB02 which is the subscriber database. I failover the subscriber database and its done. I executed DBCC Traceon(1448,-1). I then ran a few update statements on engine database which is new publisher on TEST-DB02 but I dont see them reflect in new subscriber which is reports in TEST-DB02. I see the errors:
The process could not access database 'reports' on server 'TEST-DB01'. (Source: MSSQL_REPL, Error number: MSSQL_REPL20052)
Get help: http://help/MSSQL_REPL20052
Cannot open database "reports" requested by the login. The login failed. (Source: MSSQLServer, Error number: 4060)
Get help: http://help/4060
Login failed for user 'domain\svc_testdb02'. (Source: MSSQLServer, Error number: 18456)
Get help: http://help/18456

 Per Pauls white paper on replication with database mirroring I executed the below query to make a note of the LSN:
SELECT transaction_timestamp, * FROM dbo.MSreplication_subscriptions WHERE publisher     = 'TEST-DB01'   AND publisher_db = 'engine'   AND publication  = '10272014';

After noting down the LSN I tried to run the next set of statements as shown below:

 EXEC sp_subscription_cleanup 
@publisher    = 'TEST-DB01',
@publisher_db = 'engine',
@publication  = '10272014';

and I get the error. Error:The specified publication does not allow subscriptions to be initialized from a backup. To allow initialization from a backup, use sp_changepublication: set ‘allow_initialize_from_backup’ to ‘true’.

So I did this

EXEC sp_changepublication 
  @Publication=10272014,
  @property = N'allow_initialize_from_backup',  
  @value = True 

Now when I run the below query per pauls paper

EXEC sp_addsubscription
@publication       = N'10272014', 
@subscriber        = N'TEST-DB02', 
@destination_db    = N'reports', 
@subscription_type = N'push', 
@sync_type         = N'initialize from LSN', 
@article           = N'all', 
@update_mode       = N'read only', 
@subscriber_type   = 0,
@subscriptionlsn   = 0x00001FEA000003D00024000000000000;

I am getting the forllowing error:

The transactions required for synchronizing the subscription with the specified log sequence number (LSN) are unavailable at the Distributor. Specify a higher LSN.

Can someone tell me if I am doing wrong any where. I am kind of stuck right now. I have already set the Distribution transaction period t0 at least: 12 hours and not more than 24 hours and I started working the entire setup just a couple of hours back.



Viewing all articles
Browse latest Browse all 4054

Trending Articles