Merge replication deleting data on the subscriber - sql

I have two servers with Sql Server 2012, and with Merge replication configured. They were working correctly, but because a network problem, the Subscriber was some days off line, and when the connection returned, the Publisher is deleting the data that was saved on the Subscriber during the off line period. I tried to delete and reconfigure the Replication, but not working.
Can someone help me?
Thanks!

The publisher might be marking records to be deleted on the subscriber because they don't exist on the publisher anymore. If this is not the case, reinitialize the subscription to the publisher on the client machine, and see if it starts replicating successfully.

Related

Best way to syncing two different database

I have two database(SQL Server) one database has 2.5 million records and the other one is empty, i want to transfer data from first one to the second one and after that every time first database has been changed the second database must sync. And we must do it in offline way with excel file for example(there is no online way between them) , Can anyone show me a guideline to do this?
There is only one out-of-the-box solution for offline replication, ie that doesn't require a network connection from the the distributor to the publisher and from the subscriber to the distributor or distributor to subscriber.
Snapshot Replication with Alternate Snapshot Location. You take a snapshot of the published tables, copy the snapshot somehow to a location visible to the subscriber, and then apply the snapshot from the new location.
There are different ways to do that but I think the easiest could be replication, you can use Transactional replication or snapshot replication.
https://learn.microsoft.com/en-us/sql/relational-databases/replication/transactional/transactional-replication?view=sql-server-ver15

How do I temporarily disable SQL Server Replication

I have a SQL Server (distributor and publisher) 2008 which is replicating using both snapshot and transactional replication to replicate to a couple of subscribers. There is plenty of information here https://learn.microsoft.com/en-us/sql/relational-databases/replication/disable-publishing-and-distribution on how to permanently disable replication.
I don't want to permanently disable replication, just temporarily for a network outage that is scheduled for later this week.
I have learned my lesson that when things go amuck it's a complete disable, remove, and re-setup to get everything working again, and there are too many publications to make this an option just to temporarily disable this.
It depends on whether there's going to be a network split between publisher and distributor or distributor and subscriber. Both of the below scenarios deal with transactional replication.
publisher and distributor - the log reader agent will not be able to mark records as delivered to the distribution database and so will stay in the transaction log of the publisher longer than normal. This may cause log growth (depending on how much free space is in your log file currently).
distributor and subscriber - assuming that the network outage is shorter than the minimum retention period for the distribution database, you should be able to just suspend the distribution jobs and everything should pick back up once the network is back online. Depending on the size of the backlog, it may be easier to re-initialize some (or all!) of your articles.
For snapshot replication, you shouldn't need to do much since the only time there's activity is when a snapshot is being created and delivered to the subscriber. You can just disable those jobs for the duration of your event and re-enable them when you're done.

Pull subscription running on subscriber anonymously. Determine when replication has ended

I created a publication (snapshot or transaction) on a Server-A. I'm trying to set up pull replication on Server-B.
I'm able to use replication properly but my snapshot is very big & the complete transaction takes around 1 hr to complete.
When I check my subscription status on subscriber, it says Job agent is already started & running. On publisher server I get status is "No replication transaction". Even when I know replication is working in the background on Subscriber.
I end up starting SQL Profiler on subscriber server to watch when replication has ending. Is there any other way to watch this?
I'm using SQL Server 2008 R2.
Based on my understanding of your question, what you are looking for is not really possible with snapshot replication and here is why; the publisher has a job that creates a snapshot of the database and saves it to your chosen folder. On the secondary (subscriber) there is a job that goes out to the publisher's folder and processes it. For instance, you can have the publisher set to run the job at 6 am and have your subscriber later process the file at 8 am. The only purpose of the publisher is to save a snapshot file and doesn't care when the subscriber processes it.
However, transactional replication is different from snapshot where both the publisher and subscriber can be monitored for latency (what I believe you are expecting for snapshot); reason, the publisher has a log reader job that is continuously sending changes to the distributor database. While that is happening, the subscriber has a job that continuously processes those changes from the distributor.
Here is a link to Microsoft TechNet explaining the various flavors of replication.
Hope this helps!

SQL Replication Error (On Server Agent)

I have created the new replication. Now what is issue I am facing:
When I go to ​start the 'View Agent Snapshot Status' Its just start working and First line shows "Starting Agent" and just keep working, working and continuously working.
..
After sometime it show the following message:
"The replication agent has not logged a progress message in 10 minutes. This might indicate an unresponsive agent or high system activity. Verify that records are being replicated to the destination and that connections to the Subscriber, Publisher, and Distributor are still active."
I try the following solution that I found, I have increased the value of #HeartBeat_interval property of distributor from 10 to 30 but no success.
I have Sql Server 2008 R2.
any help will be appreciated really.
May be this will help to someone else:
I did the following changes and my replication is working perfect.
1 - Job username and Job password must have full access and permission of windows.
2 - You must be logged In to user that you will use in the replication script to create replication.
That's all.
Thanks!!
I had the same behavior.
some of my articals are huge. while the replica's synch was over, the agent hanged up with the same message as yours.
after ~20 minutes it began running as expected.
I thought it is not not normal behavior, but after creating my second subscription, the error appeared again. it was gone approximately after 20 minutes.
I believe it is encounters high load of data (in case it is) and hangs up for while.
hope it helps

NServiceBus: How to configure a subscriber when using DB subscription storage

I have a logical publication which is basically a bunch of MT servers, who all access a DB subscription storage. These MTs are typically upgraded by taking 1/2 out of rotation, installing the new MT version, bringing them back online, and then repeating for the other half.
I am confused how a subscriber would subscribes to such a publication. In all of the examples I have seen, a subscriber needs to have a publisher's InputQueue specified in configuration in order for the subscription request to be received. But what InputQueue would I specify in this situation? I don't want subscription to fail if some of my publisher MT's happen to be down. Would I just subscribe manually by adding a record to the DB subscription storage?
Publishers usually publish as a result of processing some command from a client, and as such, you usually use a distributor to scale them out, as well as using the DB subscription storage. Subscribers are another kind of client so you would configure them to point to the distributor as well.