110 likes | 380 Views
Replication. What is Replication?. Replication is the process of copying database information Replication is used for: Backing up your database Migrating to a new server Mirroring Syncing with Subscriber servers. Types of Servers Used in Replication. PUBLISHER
E N D
What is Replication? • Replication is the process of copying database information • Replication is used for: • Backing up your database • Migrating to a new server • Mirroring • Syncing with Subscriber servers
Types of Servers Used in Replication • PUBLISHER • Server that stores source data • SUBSCRIBER • Server that receives replicated data • DISTRIBUTOR • Server that monitors changes and updates Publisher. • Can be on Publisher side (push), or Subscriber side (pull), or on it’s own machine. • The distributor should be placed on the most powerful server.
Types of Replication • SNAPSHOT • Copy of the database from a specific time. Similar to creating a system image of a hard drive. • MERGE • Starts as Snapshot, then changes are tracked with triggers. • Subscribers are synched as they connect. • Used when Subscribers are often working offline. • TRANSACTIONAL • Starts with Snapshot, then Distributor updates Subscribers in near real-time. • PEER-TO-PEER • Based on Transactional foundation, but both servers are at the same hierarchical level. • ORACLE PUBLISHER • Used when migrating from Oracle server to SQL Server
Replication Agents • Programs or services that manage the replication process • SNAPSHOT AGENT • All replication processes use this agent. • Generates snapshot and writes information to the file system. • Is located on the Publisher server • DISTRIBUTION AGENT • Applies snapshot to Subscribers in Snapshot Replication, applies changes in Transactional replication • Runs on Distributor server • MERGE AGENT • Detects changes on Publisher and Subscriber and pushes changes from Publisher to Subscriber. • Contains conflict resolution processes, and created a conflict table to store conflicting values. • LOG READER • Used only by Transactional replication. • Moves transactions from transaction log to Distributor server.
Setting Up Replication on SQL SERVER • It’s All Wizards!!!
Configuring the Distributor • Inside SSMS, connect to instance of server and right click the Replication folder inside “Databases” • Select “Configure Distributor” • If Distributor is on remote server, you must indicate the UNC path • On the Distribution Database Page, change the name of the database and specify a location • You can enable other Publisher servers to use this Distributor from the Publishers page • If you like, you can create a script of all the actions from the Wizards Action page • Configuration Begins!!!
Configure Transactional Publisher • Right click Local Publications folder inside Replication folder and select “New Publication” • Select the database and choose the type of Publication you want to set up • Replicated objects are referred to as articles. Select which objects to replicate. • Under Set Properties, you can choose to replicate constraints, triggers, indexes, etc. • You may specify only certain rows to replicate by utilizing a WHERE clause • Select when to create the Snapshot and how often • For security, you can specify which account the Snapshot Agent and Log Reader Agent will run. Be careful with this, as the selected account may have authority beyond replication • The new Publisher will be shown under Replication => Local Publications
Configure Transactional Subscriber • Expand replication folder and right click Local Subscriptions folder. Select New Subscriber. • You may then select whether to run the Distributor from the Subscriber machine or the Publisher machine. In general, it is best to run it from the more powerful machine • Select your Subscriber Database • As with the Publisher, you may select the account under which the Subscriber runs. • You may configure the synchronization timing from the Synchronization Schedule window. You can run continuously, on demand, or set a schedule • Select whether to initialize immediately or at first synchronization
Replication Monitoring • SQL Server allows you to monitor all Publishers, Subscribers, and Distributors from a graphical interface • This interface reports on the health of the various machines and all agents that are running. • SQL Server Agent also allows you to start and stop each individual agent.