Getting Started With SQL Server Replication Robert Verell
GOLD
SILVER BRONZE PERSONAL/BLOG
About Me Senior DBA at Cigna-Healthspring since 2011 MCITP 2008 Database Admin Robert.verell@gmail.com @sqlcowbell Sqlcowbell.com/wordpress ONE OF the chapter leaders for NashSUG
@SQLCowbell??
For Discussion Today Ways to natively copy data Different types of replication How replication works on the backend Demo setup of transactional replication Demo setup of snapshot replication Adding an article without a full snapshot Demo adding new subscription and changes replicating downstream
Ways to Replicate Data (Native) Backup/Restore SSIS Package/Import-Export Wizard/ETL Log Shipping Mirroring/Availability Groups Replication Triggers? CDC/Service Broker
Different Replication Types Transactional Snapshot Merge Peer to Peer/Bidirectional First let’s look at transactional replication. If you can understand that, snapshot is pretty easy.
How Does It Work(components)? Jonah Jameson is the publisher Paperboy is the distributor People are the subscribers Publisher Distributor Subscribers
How Does It Work? Publisher Distributor Subscribers For the millennials. Publisher Distributor Subscribers
Ok, How Does It Do That in SQL Server? Initial setup – snapshot of articles Distribution Agent applies snapshot THEN, Log Reader Agent reads transaction log Distribution Agent applies changes The snapshot uses BCP in and BCP out – it’s the fastest way to get data from one server to another You can also do a database restore for initial setup of a subscriber
Push or Pull? Push Pull If you have a separate distributor If distributor, publisher, and subscriber are on same inst If your subscriber is under heavy load If distributor and publisher are on same instance If your publisher is under heavy load
Replication Restrictions Primary Key for tables XML Schema collections (snapshot only) Code using WITH ENCRYPTION You can replicate almost any object. But there are some restrictions.
Let’s Walk Through Setup Yes, we’re going to walk through the wizard. We start with distributor setup
First you have to configure the distributor First you have to configure the distributor. So you right click replication and select configure distribution.
Now For the Publisher
Who can tell me why ChangeTicketJob111 is not selectable?
You can run under the agent account but for segregation of duties it’s recommended that you use a sep acct
That was easy right? Still got the subscribers
Lastly the Subscriber(s)
I actually set this up to run under the agent account, so any scripts will be for that setup.
You can select “on demand” as well
You can also select immediately if you’ve run the snapshot already
Let’s See The Rest of This Demo Live
You CAN Run Into A Problem Here. Differentiated by the is_published flag in sys.objects
So Thats Transactional Questions?
Let’s Look at Snapshot It’s even easier
So Let’s See It in Action
Questions On Snapshot Replication So you came to my session and you already knew all this crap that I’ve showed you. Well, maybe I can introduce you to some newer things!
Let’s look at adding an article! NO FULL SNAPSHOT REQUIRED!!!!
One Moar Demo Showing the data replicating; we’ll also add another snapshot
Tips For Making it Moar Faster Multiple publications with larger articles having their own publications Segregate your publisher/distributor/subscriber Replicate Stored Procedures Minimize Transaction size at publisher
Some More Advanced Options AGENT PROFILES So you came to my session and you already knew all this crap that I’ve showed you. Well, maybe I can introduce you to some newer things! DO NOT implement these directly in production. TEST these settings.
Agent Profile Settings -QueryTimeout -BcpBatchSize -MaxBcpThreads -READBATCHSIZE -CommitBatchSize -CommitBatchThreshold -MaxDeliveredTransactions http://msdn.microsoft.com/en-us/library/ms146939.aspx http://msdn.microsoft.com/en-us/library/ms151223.aspx
Let’s See What Agent Profiles Look Like
That’s It! Questions? Contact: Robert.verell@gmail.com @sqlcowbell Sqlcowbell.com/wordpress