Quantcast
Channel: StackExchange Replication Questions
Viewing all 17268 articles
Browse latest View live

Replication Error - Pull Subscription

$
0
0

Is anyone familiar with this error?

enter image description here

Firstly, I am trying to set up a Pull Subscription Transactional replication where in server is outside of the firewall while the distributor and subscriber (both are on the same instance) is on our company.

I tried to create a test in my local PC wherein there are 2 instances, 1 will act as Publisher and 1 will act as Distributor and Subscriber (pull subscription type).

The first error I encountered was issue in synchronizing and the resolution was to create a login of the subscriber on the publisher then grant connect on the database of the publication.

The thing is, on the production I cannot the add the loging of the subscriber to the publisher since both server has no instance name so the default of the account was both NT SERVICE\MSSQLSERVER and NT SERVICE\SQLSERVERAGENT.

What is the solution/work around on this?

Note: My snapshot folder was in UNC format when set up. Below is the current permission on that folder.

enter image description here

Thank You.


SQL Server Merge replication - Applying the snapshot to the Subscriber manually and not via GUI

$
0
0

I am having issues finding material on how to send a snapshot to a subscriber server to apply the snapshot at a later stage.

My situation: Publisher is based in SA. Subscriber is based in Germany. To deliver a 8GB database snapshot takes almost a day and I have heard if you zip the snapshot and copy it to the subscriber server via google drive or FTP you can speed the process up. Has anyone dealt with this ? Using SQL Server 2014 Merge rep.

Transactional replication on sql server failover clusters (fci)

$
0
0

Is there a way to setup transactional replication on a sql server instance/resource setup on a failover cluster (fci).

When i open up sql server instance (using the virtual failover domain) in ssms and try to add a publication I get and error.

"SQL Server replication requires the actual server name to make a connection to the server. Specify the actual server name"

I'm assuming this is because the server name I am using is the virtual failover.

Note: I need the replication to continue regardless of which cluster node is active (I have 2 as of now).

I was unable to find any solid articals online, if you find any its appreciated.

What will happen if the column has unique constraint in merge replication

$
0
0

I have two different tables and both tables have unique column called EmpId. There is a high chance employee info exists in DB1 and DB2. When I do replication what will happen? Is it going to fail because of the unique constraint? Or is it going to skip and continue processing remaining records? Is there any way to skip the duplicates?

Execute xp_cmdshell using C#

$
0
0

We have created a Windows Forms application to synchronize databases using merge publication and merge pull subscription. We have created publication and subscription successfully. Now We want to start synchronize data.

For that we want to execute below SQL Command:

-- Declare the variables.  
DECLARE @publicationDB AS sysname;
DECLARE @Subscriber AS sysname;
DECLARE @Publisher AS sysname;
DECLARE @SubscriptionDB AS sysname;
DECLARE @Publication AS sysname;
DECLARE @sql VARCHAR(8000);
DECLARE @sqlDist VARCHAR(8000);
SET @Publisher = 'MSSQLSERVER2014';
SET @Subscriber = 'SQLEXPRESS2014'; 
SET @PublicationDB = 'ServerDB' ;
SET @SubscriptionDB = 'ClinetDB';
SET @Publication = 'ServerDB_PUBLICATION';

--Start the Merge Agent with concurrent upload and download processes.  
SET @sql = '"C:\Program Files\Microsoft SQL Server\130\COM\REPLMERG.EXE" -Publication ' + @Publication+ ' -Publisher ' + @Publisher + ' -Subscriber ' + @Subscriber +   ' -Distributor ' + @Publisher + ' -PublisherDB ' + @PublicationDB +   ' -SubscriberDB ' + @SubscriptionDB + ' -PublisherSecurityMode 0 -PublisherLogin sa -PublisherPassword Abc@1234  -OutputVerboseLevel 2  -SubscriberSecurityMode 1  -SubscriptionType 1 -DistributorSecurityMode 0   -DistributorLogin sa -DistributorPassword Abc@1234 -Validate 3  -ParallelUploadDownload 1'
EXEC master..xp_cmdshell @sql

How to execute above command in C#? We don't wont to use cmd or powershell.

We have tried below but get syntax error at @publication:

string SP_xp_cmdshell = "'C:\\Program Files\\Microsoft SQL Server\\130\\COM\\REPLMERG.EXE' -Publication " + mPublication + " -Publisher " + mPublisher + " -Subscriber " + mSubscriber + " -Distributor " + mPublisher + " -PublisherDB " + mPublicationDatabase + " -SubscriberDB " + mSubscriptionDatabase + " -PublisherSecurityMode 0 -PublisherLogin " + mLogin + " -PublisherPassword " + mPassword + " -OutputVerboseLevel 2 -SubscriberSecurityMode 1 -SubscriptionType 1 -DistributorSecurityMode 0 -DistributorLogin " + mLogin + " -DistributorPassword " + mPassword + " -Validate 3 -ParallelUploadDownload 1";
cmd.Connection = mConnection; //master connection
cmd.CommandText = "xp_cmdshell "+ SP_xp_cmdshell;
cmd.CommandType = CommandType.Text;
cmd.ExecuteNonQuery();

Could not find object 'sp_MSrepl_startup' or you do not have permission

$
0
0

I am trying to configure distribution for replication setup in SQL Server 2016 on execution of below script. Also I got the same error when I tried from SSMS wizards for configuration.

use master
exec sp_adddistributor @distributor = N'ServerName', @password = N'****'
GO

my sqlserver user account has sysadmin role. Wondering if I have missed some prerequisite for replication configuration.

Error message found.

Msg 15165, Level 16, State 1, Procedure sp_procoption, Line 40 [Batch Start Line 0] Could not find object 'sp_MSrepl_startup' or you do not have permission.

As I didn't find any clue on why this procedure is missing I took it over here to get help on this.

Appreciate your suggestion on this.

SQL Server Replication using SQL Login remote Subscriber in non-trusted domain

$
0
0

I have been researching and reading every document and article I can find, however every answer and document seem to link to the same three MS Replication articles - which are great but but none seem to directly address my exact question and scenario.

I am trying to configure SQL 2012 replication (Push, Transactional) where the Subscriber is remote and in a non-trusted domain, and we cannot use Windows "pass-through" authentication.

The Publisher, Distributor and Subscriber are all separate machines. The Publisher and the Distributor are on the same trusted network. The Distributor hosts only the Distribution database and the Agents.

So the question is - does there only need to be a common SQL Login on the Distributor and the Subscriber - or does the same SQL login need to exist on the Publisher ?

I thought that the login has to be added to the Publication PAL - which I was thinking meant it had to exist on all three machines...

Can anyone point me to a document or article which clearly defines the requirement ?

The standard documents referred to do not seem to answer the question (this and this and this one)

Data at the Publisher and Subscriber Do Not Match after synchronization

$
0
0

Even if the Replication Confict Viewer says "publisher wins" data still mismatch in the Publisher and Subscriber Tables. The scenario is a "Transactional Replication With Updatable Subscriptions"


merge replication sql server orphan constraints

$
0
0

We have recently migrated to a new server where first the database was restored and then the replication has been setup. The same Merge agent works with the existing server but not with the new one.Below is the error which pops up when the merge agent is run:

The schema script 'Subscribed_Userdb99ffc3_18.sch' could not be propagated to the subscriber. (Source: MSSQL_REPL, Error number: MSSQL_REPL-2147201001) Get help: http://help/MSSQL_REPL-2147201001 Could not drop object 'dbo.Subscribed_Users_Temp_Storage' because it is referenced by a FOREIGN KEY constraint. (Source: MSSQLServer, Error number: 3726) Get help: http://help/3726

When I am trying to drop the table it shows up table is being referenced by a foreign key.When i am trying to disable the foreign key it shows

Msg 3733, Level 16, State 2, Line 1 Constraint 'FK_Subscribed_User_Paypal_Details_Subscribed_Users_Temp_Storage' does not belong to table 'subscribed_users_temp_storage'. Msg 3727, Level 16, State 0, Line 1

And when I checked the schema of the table it shows the foreign key is there.

Does that means that foreign key is an orphan one,and if so then what is the possible solution to it. Could not drop constraint. See previous errors.

Merge Replication fails to replicate UD type

$
0
0

I have a DB that includes some User Defined Types. As I understand, Merge Replication will automatically include the UD types that are been used. One of those types is a table variable witch is used in a function. And on publisher site works fine but on the Subscriber site it fails to synchronize. Why is this happening?

  • I tried to replicate just the one function which uses the type, and succeed. After that the replication worked just fine.

  • When I tried to make the same configuration to another system it failed at the begin as the original try on the previous system, but now even if I try to replicate the one procedure, I still get the same Error.

The error is the following:

The schema script 'some name.sch' could not propagated to the subscriber.

And when I trace the error:

Cannot find data type dbo.someName

Restore Subscriber with a different DB Merge Replication

$
0
0

I have a Publisher and a Subscriber using pull subscription at Merge Replication. Let's say that the shared folder with the snapshot has 50GB size. I have a scenario in mind that aims to minimize bandwidth during transmission.

Can I take a backup from a subscriber and use it to create a new DB as new subscriber one on a different server?

And if this is possible, is the server going to download the whole 50GB of the shared folder or because of the already existing data, will save some bandwidth?

Bandwidth Usage between shared folders in merge replication

$
0
0

I have two servers (Server1 and Server2) involved in Merge Replication

The merge replication shared folder contains 50GB of snapshots for use in replication.

Will Server2 immediately download 50GB? If not, when will the server download the data?

SQLServer Error: 14516, Proxy (38) is not allowed for subsystem "Distribution" and user

$
0
0

I have just recently started to have a look at one particular server, after re-starting sql server I get the following message in the event log, as you can see on the picture below.

Date 02/03/2018 19:21:56 Log SQL Server Agent (Current - 02/03/2018 19:16:00)

Message [298] SQLServer Error: 14516, Proxy (38) is not allowed for subsystem "Distribution" and user "mycompany\myuser". Grant permission by calling sp_grant_proxy_to_subsystem or sp_grant_login_to_proxy. [SQLSTATE 42000]

enter image description here

any indication as to where to start troubleshooting this one?

I have replication in this server, publications and a distributor server, and I believe this message could be related to that...

When I run the following query by Sean Gallardy, I get the results below.

SELECT * 
FROM sysproxysubsystem sp 
INNER JOIN syssubsystems s 
        ON sp.subsystem_id = s.subsystem_id

enter image description here

pglogical library

$
0
0

I would like to try pglogical to set up an archive server from a live database, filtering with INSERT, UPDATE statements (DELETE statements will not be replicated in the archive server).
I follow the official documentation but when i set shared_preload_libraries = 'pglogical' in my configuration file (postgresql.conf) the server could not start.

There is no pglogical file in ./usr/pgsql-9.6/lib/ directory.

How setting up all prerequisites to start properly (with v9.5 and 9.6)?
I am using PostgreSQL v9.5 and v9.6 for POC on CentOS 7.

Many Thanks.

Two-step Replication between SQL 2008 and 2017

$
0
0

I am currently using transactional replication from several SQL 2008 publishers to a central 2014 subscriber/distributor. I need to replicate this data to a 2017 server, which would require a 2017 distributor.

Since 2008 -> 2017 transactional replication is not supported, I am trying to replicate in a second step from the 2014 server.

2008 -------------------> 2014 ------------------> 2017
         Dist: 2014                Dist: 2017

However, I cannot figure out how to get the 2014 server to recognize the 2017 server as the distributor for its publications, while still acting as the distributor for its subscriptions. Specifically, the 2014 server is configured as a publisher at the remote 2017 distributor, but when I try to enable a 2014 database for publication in the GUI, it asks me to first enable the server as a publisher on the local 2014 distributor.

So I want to know: 1. Is it possible to configure a local distributor for subscriptions and a remote distributor for publications? 2. Could I just use the 2017 distributor for both legs? Is 2017 supported to act as a distributor for the 2008 -> 2014 replication? 3. Is there some other best practice for transactional replication from 2008 -> 2017?


Merge Replication: Execute code after replication

$
0
0

I have two servers, a publisher and a subscriber using merge replication and pull subscription. Both ends can insert/update/delete a table. Is there any way that if a row is inserted from replication, it will trigger a query?

I know I can make a trigger not running on replication, but is there any way to make a trigger run only on replicated rows?

EDIT: Is there any way to distinguish the rows from logging table created by replication?

Unable to enable publishing on restored database

$
0
0

We have a production database (2008 R2) that is enabled for replication as a publisher and subscriber with a remote distributor (distributorA).

We restored a copy of this database onto a new 2016 server. Now we want to configure replication on the restored copy as a publisher to our new distributor (distributorB).

We configured distributorB with a new distribution database and configured the new 2016 server as a publisher to distributorB.

Back on the new 2016 server, we ran sp_adddistributor to point it to distributorB. Everything works as expected so far.

Now we run the following command on the restored db to enable replication sp_replicationdboption @dbname = 'restoreddb', @optname = 'publish', @value = 'true'. That completed successfully.

This is where the problem starts to manifest itself. When I tried to create a new publication now, at the end of the publishing wizard, it errored out saying it can't find dbo.syspublications.

I check the system tables on the restoredb and find that some of the tables required for replication have not been created (syspublications, sysarticles, syssubscriptions and etc), but some have (sysreplservers and MSPeer*). I can, however, see that this database has 'transactional' checked in publication databases under publisher properties. When I try to uncheck it and hit OK, it gives me the following error

Invalid object name 'dbo.syssubscriptions'.
Transaction count after EXECUTE indicates a mismatching number of BEGIN and COMMIT statements. Previous count = 0, current count = 1.
Transaction count after EXECUTE indicates a mismatching number of BEGIN and COMMIT statements. Previous count = 0, current count = 1.
Transaction count after EXECUTE indicates a mismatching number of BEGIN and COMMIT statements. Previous count = 0, current count = 1.
Transaction count after EXECUTE indicates a mismatching number of BEGIN and COMMIT statements. Previous count = 0, current count = 1.

I tried using sp_removedbreplication to cleanup any remnants of replication settings from the database to start afresh, but that didn't seem to help at all.

I think the problem here is somehow the remnant replication settings from the database's 'former self' is interfering with setting up replication again with a different distributor.

So my question is why some of the replication system tables were not created? How do we remedy this?

SQL Replication not working correctly.

$
0
0

I have a transactional SQL Server replication set up. Currently everything I have review seems to show that the replication is working. I have reviewed the Replication Monitoring and Sync State and both show that transactions are being pushed across correctly.

The problem I am having is that some of the replicated tables aren't even coming across while other are. Is there a better way to look deeper into Replication to find out why things aren't coming across?

How to replicate huge data table in SQL Server 2012

$
0
0

I have the same database on two servers and I am using merge replication for around 35 tables, and it is working fine.

But whenever I add 2-3 more tables with around 1 million records, the replication breaks after some time/days.

Can I do 2 replications on same database? Say 1 replication for those 35 tables and another one for 2-3 new tables?

Please suggest resolution for those bulk table data replication via merge method.

MSSQL Transactional Replication

$
0
0

I have an application that almost continuously works with inserting or updating data. Since multiple requests are handled asynchronous I wrote my queries like below. I used an example based on SO, but that's not what I'm actually doing.

DECLARE @rows int;
INSERT INTO [user] ([username],[reputation])
SELECT [username],[reputation]
FROM (
    SELECT [username]=:user,[reputation]=:rep
) A
WHERE A.[username] NOT IN (
  SELECT [username]
  FROM [user]
);
SET @rows = @@ROWCOUNT;

IF (@rows=0) BEGIN
  UPDATE [user]
  SET [reputation]=:rep, [updated]=GetDate()
  WHERE [username]=:user
END;

This is passed in total to the database with PHPPDO. Because of the amount of data and other processing factors it's heavy on the (cheap) VPS it's running on. It's not really a problem if these processes run slow or get delayed, but on the other hand this data should be available via a website and then the queries on the data should be quick.

I was thinking about replicating parts of the processed data to a second server and running the website on that database. But I'm wondering how that would actually work with a query like above.

I'm guessing the UPDATE query will only be in the transaction log when @rows=0, so that won't be a problem.

But would the first part only send INSERT INTO [user] ([username],[reputation]) VALUES ('Hugo Delsing', '10k') or the entire query with the WHERE NOT IN () query?

Most of the time a user would exists, so if it only runs the new inserts that won't be a problem. But if it would run the entire query each time the benefits would be small.

Obviously I could wrap the first part up in another check if exists(select 1 from [user] where [username] = :user) to make sure it only runs when there is no user, but I'm wondering if that is necessary.

Bonus question, but feel free to ignore because it's a bit broad: Would replicating be the way to go or does MS SQL offer other/better solutions for something like this?

Viewing all 17268 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>