sqlserver summary of the publication's subscription replication_subscription

(Reprint) sqlserver summary of the publication's subscription replication_subscription

 

From "ITPUB blog", the original address: http: //blog.itpub.net/30126024/viewspace-2639648/, For reprint, please indicate the source, otherwise it will be held liable.

 

Official documents https://docs.microsoft.com/zh-cn/sql/relational-databases/replication/subscribe-to-publications?view=sql-server-2017

 

1, if the operation publish subscribed clients SSMS version is lower than the server version, being given such service is sqlserver2016, ssms use sqlserver2014 will complain 

2, only the establishment of distribution, will add seven related job; at the same time establish the initial release of the establishment of distribution, will add nine related job

3, behind each new release a name, posted job on the server will add two release follows former is a non-stop generating data release, the job non-stop running, after a release is initialized data (generated unc directory documents and files), run it once

TESTDB1-replicate2-2

TESTDB1-replicate2-pub_replicate2-2

Posted instance name - Database name - the name of the publication number

Posted instance name - Database name - Post name - the name of the publication number

4, Publisher - copy - local publishing - Post name - Right - Properties -snapshot, select put files in the following folder, you can put the files on the shared path

5, subscriptions can be established at the subscriber, the publisher can also be established, Publisher - copy - a local publication - the publication name, right click and choose new subscriptions

6, each behind a new subscription, if the subscription is pushed, a master library job increase, if the subscription is a request to increase a job from the library

TESTDB1-replicate2-replicate2-TESTDB2-6 (push subscriptions, publication instance name - the name of the publication database - name of the publication - subscription instance name - number)

TESTDB1-replicate1-pub_replicate1-TESTDB2-replicate_01-CD7A365E-2DE7-47A3-B31E-70F785FA71F2 (subscription request)

7, subscribe or publish job job, scheduler can be modified as needed

8, local post or local subscription Subscribe icon below a small circle to indicate in the current instance, is the other party take the initiative instead of the current instance of the initiative, subscriptions job over there in the other

Push subscription, in the main library released the following subscription icon does little blue circle, there is a small blue circle in the following subscription from libraries subscribe icon

Pull subscriptions, publication in the master library following subscription icon has a small blue circle, no small blue circle in the following subscription from libraries subscribe icon

- also applies to the local release is the case of local subscribers, such as a local library information to another local library, the local publish or subscribe below are local subscription, if it is a push subscription, the subscription icon does not release the following blue color small circle, subscribe to the following subscription icon blue small circle, if it is requested subscription, the subscription icon has issued the following small blue circle, following the subscription icon does not subscribe to the little blue circle

9, subscribe to delete, according to the push and pull subscriptions are different, have different mode of operation, uniform method of operation is to directly delete the master library following publication subscriptions.

In the case of a push subscription, if only remove a subscriber from a library, then released the following subscription information is still the main library, subscriptions job on the main library is also still (but the information will not be synchronized to the subscription library), you also need main library and then delete it again

In the case of a push subscription, in the main library, then delete subscriptions, subscriptions job is not in the main library, and subscribe to information from the library automatically deleted

In the case of a subscription request, delete subscriptions in the main library, then from the subscription on the job is not in the library, from the library's subscription information is automatically deleted

In the case of a subscription request, the subscription from the library, then deleted, gone, issued following the main library from the subscription on the job is not in the database subscription information

- also applies to the local release is the case of local subscribers, such as a local library information to another local library, the local publish or subscribe below have local subscriptions

10, published in msdb.dbo.sysjobs normal job record, but these job running Microsoft SQL Server are displayed in sysprocesses.program_name, does not appear as a specific job name, the following statement to query job, does not apply to subscription copy

select * from msdb.dbo.sysjobs where name='jobname'

select a.program_name,a.* from master..sysprocesses a where a.program_name like '%0D1CE57E8AC5%'

11, subscription job properly recorded in msdb.dbo.sysjobs, but the job is running in sysprocesses.program_name are displayed as empty

12, when you delete a subscription database, the following occurs, the solution is to subscribe to a job and then stopped the subscription database offline, and then delete

Cannot drop the database ‘XXX’because it is being used for replication

13, delete the publication, if time publish below subscription, delete the publication, subscription becomes ineffective

In the case of a subscription request, as well as subscription and subscribe the following job from a local library, but ineffective, but also about the need to manually delete subscription will automatically be deleted job

In the case of push subscriptions, publication of the main library and the job are deleted, the following subscription from the local library as well as a subscription, but fails, you also need to manually delete it

- also applies to the local release is the case of local subscribers, such as a local library information to another local library, the local publish or subscribe below have local subscriptions

14, subscription library, you can execute DML, execute delete will not have any consequences, perform update or insert words, if the library receives a publication pass over the data behind that may conflict

15, the stored procedure subscribe to publish relevant

EXEC distribution.dbo.sp_replmonitorhelppublisher - perform the Publisher libraries, posted on the local situation checking Publisher

16, after the release is set up, there is a publication linked sever point to the distribution server on the server name is the repl_distributor, after disable publishing and distribution, the linked server will be automatically deleted

When you subscribe to establish (whether it is a request to subscribe or push subscription), it will automatically create a linked server pointing to the subscriber at the publisher. To delete a publication or disable publishing and distribution, the linked server are not automatically deleted

17, if the job of the subscription schedules not specified, just start automaticaly when SQL Server Agent starts, then once this job is stopped, the back will not be synchronized, see this subscription status in the Replication Monitor is inside the Subscription Watch List not running

18, push subscription: Publisher to publish a local following - name - Subscribe to name, select the right view Synchronization Status you can see subscription status

Request Subscribe: Subscribe to the following local server Subscription - Subscribe to name, right to subscribe, select view Synchronization Status can see subscription status, and you can see the operation of subscription job

19. Copy - local subscription - subscribe to the name, select the right view Synchronization Status to view the status is No replicated transactions are available, then the publishing side, copy - a local publication - the publication name, right-released, select the following two check job status is start running, and if yes, count (*) from table master data is consistent, if consistent, indicating that at this time does not generate new data DML affairs

View Snapshot Agent Status View Snapshot Agent Status, the corresponding job is actually "instance name - the name of the publication database - name - published number", usually run only once, stored in unc generate initialization data

View Log Reader Agent Status View Log Reader Agent status, the corresponding job is actually "instance name - the name of the publication database - published number", the general has been running

20, the so-called distribution services, is to create a distribution database default distribution, and create a snapshot directory, if not distribute create, for the first time to establish when released, will automatically create a distribution service, when the second release build, it will use the original distribution services. When you create a publication, you must first have a distribution, or publication of data stored where? Is the distribution of these stored data to be published in the local

21, distribution server is publishing a bridge between the server and the subscriber, plays the role of the storage area, is responsible for copying specific data server associated with one or more release. Each publication server with a single database on the distribution server (called a distribution database) is associated. Distribution database to obtain the data will be published data storage replication status and role of metadata publishing, and in some cases to move from the publisher to the subscriber data is queued to play from the publisher. In most cases, a database server instance acts as Publisher and Distributor two roles. When the publisher and the distributor in the same database server instance, referred to as "local Distributor." When the Publisher and Distributor according to their database server instance configuration, the distribution server called "remote Distributor"

22. When not creating excessive hair, when you right-replication, have configure distribution, select configure distribution represents a distribution configuration only, not other actions, in the process If you check the publisher and distribution database at the Publishers page, right-replication, the Without configure distribution, replaced by a publisher properties, distributor properties, disable publishing and distribution; if not checked, publisher and distribution database in Publishers pages, when you right-replication, there is no configure distribution, replaced by a Distributor Properties, Disabled Publishing and Distribution Wizard. In fact, check the right choice when replication distribution configure the publisher and distribution database, which is to choose the publisher can use this distribution server (enable servers to use this distributor when they become publishers), in which the distribution database did not have a choice, that is, the distribution of the database, The default is distribution

23, right Replicattion select Disabled Publishing and Distribution Wizard, disable subscriptions to the publication, all subscriptions to the publication of information is lost, including system databases in the distribution database also includes all the directories and files in the unc directory, you need to subscribe to release information prior to execution backup or screenshots

24, to initialize the subscription, that is, to re-publish the data pushed to the end of the subscription ends, you can choose to push this single subscription (released end - name - Subscribe to name - Right --reinitialize) release, you can also choose to push the release of all subscriptions (released end - name - right --reinitialize all subscriptions). In another publisher - copy - a local publication - the publication name, right click and choose View Snapshot Agent Status selection start, or run job "instance name - the name of the publication database - name - Post No."

25, at the end of the first subscription table manually insert a statement released back end as a synchronous data over time, the subscription will end error

Violation of PRIMARY KEY constraint 'PK_XX'. Cannot insert duplicate key in object 'dbo.TXX'. The duplicate key value is (33583).

26, bug issues: Right Replicattion After selecting Disabled Publishing and Distribution Wizard, the final step will complain, but it does publish and distribute all deleted

27, Export subscribe to script replication method: Right Replication select Generate Scripts (export script there are comments in the release-side execution or subscribe to end execution) 
above will be exported to distribute under the current server, publish, subscribe, if out of the Generate Scripts of check the distributor properties interface will export distribution; check the publications in the following data sources will be exported released; if you select the subscriptions in the following data sources will be exported to subscribe.

28, Publish-Subscribe monitoring whether there is an exception, in the end released the following statement to 5

select * from [distribution].[dbo].[MSlogreader_history] WHERE error_id != 0 AND [time] >= DATEADD(HOUR, -1, GETDATE()) 
select * from [distribution].[dbo].[MSdistribution_history] WHERE error_id != 0 AND [time] >= DATEADD(HOUR, -1, GETDATE()) 
select * from [distribution].[dbo].[MSsnapshot_history] WHERE error_id != 0 AND [time] >= DATEADD(HOUR, -1, GETDATE()) 
select * from [distribution].[dbo].MSrepl_errors order by 2 desc

select * from msdb.dbo.sysreplicationalerts order by 7 desc

29 2 methods, query a publisher XX, published database objects

29.1, posted perform (data sources These three tables on the database, distribution.dbo.MSpublications view of the query publication name,

distribution.dbo.MSarticles view objects such as tables queries issued, sysarticlecolumns view query published table which was released field)  

select a.article,a.source_object,a.destination_object,b.colid from 

(select article,article_id,source_object,destination_object 

from [distribution].[dbo].MSarticles where publication_id in 

( select publication_id from 

[distribution].[dbo].MSpublications where publication='XX' 

) a 

inner join 

(select * from replicate1.dbo.sysarticlecolumns) b 

on a.article_id=b.artid order by a.article 

29.2, perform the subscription database  

select distinct article  from MSreplication_objects where publication='XX'

30, XX missing a publisher, but the request is still subscribe to the processing method

Subscribe to execute end, find the database object is published, and then create a publication on the publishing side, and then rebuild subscription, feasible method 2

select distinct article  from MSreplication_objects where publication='XX'

Not a method

Restoring the publication database to see if I can recover lost before publishing information, perform the following publication database found error

select * from sysarticlecolumns

Invalid object name 'sysarticlecolumns'.

31, publish subscribe to need to add a table, just right-name items selected articles inside checked need to add to the table, then right name --view snapshot agent status - start can, in publishing end of the log reader job (right name --view log reader agent status) under normal operation, subscriptions job (right subscription name --view sysnchronization status) is also normal operation, the subscriber can immediately see the new database table

32, SSMS graphical interface, the new release when the fourth step articles or items already existing right choice when publishing articles project, has been very slow interface does not display properly view the database objects such as tables stored procedures, etc., indicating a blockage, SSMS open a number of points after the interface is actually a select action, find the source of blockage kill, you can normally shows

33, examples --replication - Local Subscriptions-- subscription name - Right --View Synchronization Status error: An error occurred connecting to server '  XX'.SQL Server repliaction requires the actual server name to nake a connection to the server.
cause: You modify the computer name, SSMS connected computer name is new, but the database is not modified Servername, resulting in this error, SSMS connection uses the old computer name or modify the database modifications Servername for the new computer name to

34, data A server ADB1 library made replication to the B server ADB1 database, server A and A1 servers built AG, and the ADB1 joined AG, but the AG corresponding database ADB1 the A1 is not normal, right A server ADB1 corresponding name --View log Reader Agent Status discovery ADB1 release error: replicated transaction are waiting for next log backup or for mirror partner ( or wait for a log backup mirroring partner update replicated transactions awaiting next) to catch up 
solutions 
    1, to ensure the normal ADB1 AG in A1 (the preferred method) 
    method 2, to the database on the server a ADB1 removed from the AG 
    3. a method executed on the server a 
DBCC TRACEON (1448, -1) - undesirable replication is affected alwayson other node of 
reasons: 
    we know always on secondary replica is to obtain a primary secondary log information redo actions carried out to achieve the synchronization of the database. When the secondary abnormal downtime, in order to be able to continue to ensure that the last place to do redo log read operation when the secondary up, db's transaction log will not be backed up, and has been increased, the worst case lead to disk full, can not be used . If the current 01 primary, 02 for the secondary, to avoid after failover, 02 switching the primary copy, but did not get to this node and 01 as new information replication, leading to abnormal. So all always on node must know the situation synchronized, otherwise do not continue to synchronize. That is, after all node will get replication information before allowing replication to continue

 

 

Establish distribution

Copy - Right - Configuring Distribution

1, select the distribution servers

2. Select the snapshot directory

3, create a distribution database (default database name for the distribution, database files, database log name)

4, to choose which publisher can use this distribution server, enable servers to use this distributor when they become publishers, where the distribution database did not have a choice, that is, the distribution of the database, the default is distribution

- Check if the fourth step above the publisher and distribution database, right-Replicattion have Publisher Properties, Distributor Properties, Disabled Publishing and Distribution Wizard. If not checked, there is no right Replicattion Publisher Properties, have Distributor Properties, Disabled Publishing and Distribution Wizard

After the distribution is set up, the following job

1、Agent history clean up: distribution

2、Distribution clean up: distribution

3、Expired subscription clean up

4、Monitor and sync replication agent jobs

5、Reinitialize subscriptions having data validation failures

6、Replication agents checkup

7、Replication monitoring refresher for distribution.

 

 

Building publishing

Copy - Local publishing - Right - New Publication

 

Establish Release 1: When not distribute, distribution Establishment released at the same time (steps 3 and 4 above, although there is no "established distribution", but also create a default database distribution)

Right local publications (local publication) - Select new publication (new release)

1, select the distribution servers

2. Select the snapshot directory

3. Select the database you want to publish

4, select the type of publication

5, select the object you want to publish, such as tables, views, stored procedures,

6, select the snapshot agent, snapshot is created immediately or on a regular basis to create a security snapshot agent is to use the user name and password or use sqlserver agent services, snapshot agents how to connect the published server, OS is a domain account or DB account

7, create a publication name

After the publication is set up, the following job

1、Agent history clean up: distribution

2、Distribution clean up: distribution

3、Expired subscription clean up

4、Monitor and sync replication agent jobs

5、Reinitialize subscriptions having data validation failures

6、Replication agents checkup

7、Replication monitoring refresher for distribution.

8、WONCNTESTDB1-replicate1-1

9、WONCNTESTDB1-replicate1-pub_replicate1-1

 

Published establish 2: the distribution has been established, only the establishment of release

1. Select the database you want to publish

2, select the type of publication

3, select the object you want to publish, such as tables, views, stored procedures,

4. Select the snapshot agent, snapshot is created immediately or regularly create, snapshot agent security using user name or password using sqlserver agent services, snapshot agents how to connect the published server, OS is a domain account or DB account

5, create a publication name

After the publication is set up, the following job

1、WONCNTESTDB1-replicate1-1

2、WONCNTESTDB1-replicate1-pub_replicate1-1

 

 

Subscribe to establish

1. Select the publisher, select Publish

2. Select push subscriptions or pull subscriptions

3. Select the subscriber, choose the subscription database

4, choose to subscribe to a proxy server, the Distribution Agent how to use the connection, OS is a domain account or DB account, how to use the distribution server connections, the OS DB domain account or accounts, how subscribers use the connection, OS is the domain account or the account DB

5, synchronization is continuing or subscription on demand

6, whether immediately initialize the subscription target

After the subscription is set up, the following job, this job the same name and the first half of the subscription name that is WONCNTESTDB1-replicate1-pub_replicate1

WONCNTESTDB1-replicate1-pub_replicate1-WONCNTESTDB2-replicate_01-CD7A365E-2DE7-47A3-B31E-70F785FA71F2

 

Guess you like

Origin www.cnblogs.com/jimsfriend/p/11422562.html