Xác đ nh data and database object articles to publish... Execute sp_addpublication with repl_freq set to snapshot to define the publication.. Execute sp_addpublication_snapshot to cr
Trang 1Replication – SQL
Server
Trang 2Các vai trò
Publisher : là server ch a b n chính c a d Publisher : là server ch a b n chính c a d ứ ứ ả ả ủ ư ủ ư
li u s nhân b n ệ ẽ ả
Distributor: ng Distributor: ng ườ ườ i ghi nh n và qu n lý vi c i ghi nh n và qu n lý vi c ậ ậ ả ả ệ ệ
Subcribers : là các server nh n các b n sao Subcribers : là các server nh n các b n sao ậ ậ ả ả
Trang 3Các đ n v d li u ơ ị ữ ệ Các đ n v d li u ơ ị ữ ệ
Article : là m t m nh d li u Article : là m t m nh d li u ộ ộ ả ả ữ ệ ữ ệ
Publication : là m t t p h p g m m t hay Publication : là m t t p h p g m m t hay ộ ậ ộ ậ ợ ợ ồ ồ ộ ộ
nhi u article ề
Trang 4Khai báo nhân b n ả
Push Subcription : do Publisher phát ra
Pull Subcription : do subscriber phát ra
Trang 5Các l ai b n sao ọ ả
Trang 6 C u hình cho quá trình nhân b n C u hình cho quá trình nhân b n ấ ấ ả ả
T o và sao chép b n sao đ u tiên T o và sao chép b n sao đ u tiên ạ ạ ả ả ầ ầ
Hi u ch nh các b n sao Hi u ch nh các b n sao ệ ệ ỉ ỉ ả ả
Đ ng b và lan truy n d li u Đ ng b và lan truy n d li u ồ ồ ộ ộ ề ề ữ ệ ữ ệ
Trang 7C u hình ấ
Ch ra distributor Ch ra distributor ỉ ỉ
T o CSDL phân tán trên distributer T o CSDL phân tán trên distributer ạ ạ
Xác đ nh (enable) các publisher s s d ng Xác đ nh (enable) các publisher s s d ng ị ị ẽ ử ụ ẽ ử ụ
distributer
Enable c s d li u xu t b n Enable c s d li u xu t b n ơ ở ư ệ ơ ở ư ệ ấ ả ấ ả
Enable các subscribes s nh n d li u xu t Enable các subscribes s nh n d li u xu t ẽ ẽ ậ ậ ư ệ ư ệ ấ ấ
b n ả
Trang 8S d ng EM ử ụ
M r ng SQL Server group M r ng SQL Server group ở ộ ở ộ
M r ng m t server trong nhóm M r ng m t server trong nhóm ở ộ ở ộ ộ ộ
Click mouse ph i vào Click mouse ph i vào ả ả Replication
Click Configure Publishing, Subscribers, and Distribution
Theo s h Theo s h ự ướ ự ướ ng d n c a wizard đ ch n Distributor, t o ng d n c a wizard đ ch n Distributor, t o ẫ ẫ ủ ủ ể ể ọ ọ ạ ạ distribution database, và r i ồ
distribution database, và r i ồ
Trên Customize the Configuration ch n Trên Customize the Configuration ch n ọ ọ
Publisher and Subscriber defaults
Ho c ch n Ho c ch n ặ ặ ọ ọ Yes, let me set the distribution database properties,
enable Publishers or set the publishing settings
Trang 9S d ng T-SQL ử ụ
Th c hi n Th c hi n ự ự ệ ệ sp_adddistributor server s làm distributor. server s làm distributor ở ở ẽ ẽ
Th c hi n Th c hi n ự ự ệ ệ sp_adddistributiondb t o server distributor đ t o server distributor đ ạ ạ ể ể
t o c s d li u ch a các d li u s nhân b n ạ ơ ở ữ ệ ứ ữ ệ ễ ả
t o c s d li u ch a các d li u s nhân b n ạ ơ ở ữ ệ ứ ữ ệ ễ ả
Th c hi n Th c hi n ự ự ệ ệ sp_adddistpublisher t i m i server s là các t i m i server s là các ạ ạ ỗ ỗ ẽ ẽ
publisher s dùng distributor đã t o ẽ ạ
publisher s dùng distributor đã t o ẽ ạ
Trên CSDL master trên Publisher, th c hi n trên Publisher, th c hi n ự ự ệ ệ
sp_replicationdboption cho m i CSDL mà s nhân b n. cho m i CSDL mà s nhân b n ỗ ỗ ẽ ẽ ả ả
Trang 10Xu t b n d li u ấ ả ữ ệ
Xu t b n d li u ấ ả ữ ệ
T i server Publisher,right click vào Publications folder, ch n T i server Publisher,right click vào Publications folder, ch n ạ ạ ọ ọ New Publication
Ch n Ch n ọ ọ Show advanced options in this wizard
Ch n Ch n ọ ọ publication database
S d ng m t khuôn m u xu t b n S d ng m t khuôn m u xu t b n ử ụ ử ụ ộ ộ ẩ ẩ ấ ả ấ ả publication template
Ch n l ai xu t b n (type of publication.) Ch n l ai xu t b n (type of publication.) ọ ọ ọ ọ ấ ả ấ ả
Ch n l ai nhân b n updatable subscriptions or transformable subscriptions (snapshot Ch n l ai nhân b n updatable subscriptions or transformable subscriptions (snapshot ọ ọ ọ ọ ả ả replication or transactional replication).
Ch ra l ai Subscriber types Ch ra l ai Subscriber types ỉ ỉ ọ ọ
Xác đ nh data and database object articles to publish Xác đ nh data and database object articles to publish ị ị
Ch n tên c a xu t b n Ch n tên c a xu t b n ọ ọ ủ ủ ấ ả ấ ả
Xác đ nh các thông s cho xu t b n Xác đ nh các thông s cho xu t b n ị ị ố ố ấ ả ấ ả
Trang 11Xu t b n d li u ấ ả ữ ệ
Xu t b n d li u ấ ả ữ ệ
How to Create Publications and Define Articles (Transact-SQL)
To create a snapshot or transactional publication
Execute sp_replicationdboption to enable publication of the current database
Execute sp_addpublication with repl_freq set to snapshot to define the publication
Execute sp_addpublication_snapshot to create a Snapshot Agent, set the publication agent_id, and place the schema and data into the replication working directory
Execute sp_addarticle n times to define each article in the publication
To define an article for a snapshot or transactional publication
Execute sp_addarticle to define an article
Execute sp_articlefilter to filter a table horizontally
Execute sp_articlecolumn to filter a table vertically
Execute sp_articleview to create the synchronization object for an article when a table is filtered vertically or horizontally
To create a merge publication
Execute sp_replicationdboption to enable publication of the current database
Execute sp_addmergepublication to define the publication
Execute sp_addpublication_snapshot to create a Snapshot Agent and place the schema and data into the replication working directory
Execute sp_addmergearticle n times to define each article in the publication
To define a merge article
Execute sp_addmergearticle to define an article
Execute sp_addmergefilter to create a partitioned publication
Trang 12T o phiên b n đ u tiên ạ ả ầ
trong Create Publication Wizard.
Trang 13Đ ng b ồ ộ
T i Publisher, click T i Publisher, click ạ ạ Replication, Publications, ch n ch n ọ ọ
publication c n đ ng b ầ ồ ộ
publication c n đ ng b ầ ồ ộ
Click chu t ph i vào subscription c n đ ng b , r i click Click chu t ph i vào subscription c n đ ng b , r i click ộ ộ ả ả ầ ầ ồ ồ ộ ồ ộ ồ
Start Synchronizing
T i Subscriber, click T i Subscriber, click ạ ạ Replication, Subscriptions.
Click chu t ph i vào subscription c n đ ng b , r i click Click chu t ph i vào subscription c n đ ng b , r i click ộ ộ ả ả ầ ầ ồ ồ ộ ồ ộ ồ
Start Synchronizing
Trang 14Đ ng b ồ ộ