This session includes the following topics: Linked servers Types of replication Monitoring and improving replication performance Resolving conflicts in merge replication Recove
Trang 1Instructor Inputs S e
Trang 3This session includes the following topics:
Linked servers
Types of replication
Monitoring and improving replication performance
Resolving conflicts in merge replication
Recovering from a failure in replication
Best practices
Tips and Tricks
Slide 1
Installing Windows XP Professional Using Attended Installation Querying, Managing, and Administering Databases Using SQL Server 2005 Objectives
In this session, you will learn about:
Linked servers Types of replication Monitoring and improving replication performance Resolving conflicts in merge replication Recovering from a failure in replication Using KILL statement
Best practices that can be considered while replicating databases in SQL Server 2005
Tips and tricks that will help you use import and export utilities
in SQL Server 2005 FAQs related to replication concepts of SQL Server 2005
Trang 4Slide 2 of 19 Ver 1.0 Collaborate Session 9
Knowledge Byte
Linked server:
Is like an alias on a local SQL Server that points to an external data source
Offers the following advantages:
Remote server access.
The ability to issue distributed queries, updates, commands, and transactions on heterogeneous data sources across the enterprise.
The ability to address diverse data sources similarly.
Specifies the following objects:
An OLE DB provider
An OLE DB data source
Slide 3
Installing Windows XP Professional Using Attended Installation Querying, Managing, and Administering Databases Using SQL Server 2005 Knowledge Byte (Contd.)
SQL Server 2005 provides the following types of replications:
Snapshot replication:
is used to replicate data that does not change frequently
is also used when the subscribers require read-only data with a high degree of latency time
Transactional replication:
is used when the subscribers require the updated data with minimal delay
is generally implemented at the server-to-server level.
Merge replication:
is used when both the publishers as well as the subscribers can change the data In this case, changes are replicated to all the subscribers and publishers until all the servers have the same data.
Trang 5Slide 4 of 19 Ver 1.0 Collaborate Session 9
Knowledge Byte (Contd.)
Replication Monitor:
Is a graphical tool that allows you to track the overall activity of
a replication
Provides information on the status and performance of publications and subscriptions
Window has two panes, the left and the right pane
The left pane shows the list of publishers and its associated publications
The right pane contains three tabs, All Subscriptions, Tracer Tokens, and Warnings and Agents.
Slide 5
Installing Windows XP Professional Using Attended Installation Querying, Managing, and Administering Databases Using SQL Server 2005 Knowledge Byte (Contd.)
Replication conflict occurs in merge replication when copies
of an article that are part of a subscription are updated at two subscriber locations or on a publisher and a subscriber.
The articles can be updated by any of the INSERT, UPDATE, or DELETE DML statements The detection of replication conflict is done by the merge agent.
Trang 6Slide 6 of 19 Ver 1.0 Collaborate Session 9
Knowledge Byte (Contd.)
To recover from a failure in replication:
A best practice is to maintain back ups of the publisher and subscriber data
Take a full backup of the publisher database and maintain regular backups at regular intervals after short periods
Maintain backup of distribution database
Set the minimum transaction retention period at the distributor.
This retention period should be greater than the transaction log backup period at publisher
Slide 7
Installing Windows XP Professional Using Attended Installation Querying, Managing, and Administering Databases Using SQL Server 2005 Knowledge Byte (Contd.)
The KILL statement is used to terminate a process on the basis of the session ID
The KILL statement can also be used to terminate a normal connection, which internally terminates the transactions that are associated with the specified session ID
The syntax of using a KILL statement is:
KILL { session ID } [ WITH STATUSONLY ]
where,
session_ID is the session ID of the process to terminate.
session_ID is a unique integer that is assigned to each user connection when the connection is made.
Trang 7Slide 8 of 19 Ver 1.0 Collaborate Session 9
Best Practices
Program your application to use stand by server in case of database failover.
Backup replication databases regularly.
The following databases should be backed up regularly:
Publication database Distribution database Subscription databases msdb database and master database at the Publisher, Distributor, and Subscribers server
Validate data periodically to verify the replication between Subscriber and Publisher.
Slide 9
Installing Windows XP Professional Using Attended Installation Querying, Managing, and Administering Databases Using SQL Server 2005 Tips and Tricks
When the bcp utility is connecting to SQL Server with a trusted connection using integrated security, use the -T option (trusted connection) instead of the user name and password combination.
While using bcp utility do not use a blank password, use a strong password.
While using bcp utility, if the file name includes a space or quotation mark at the command prompt, enclose the identifier in quotation marks ("").
Trang 8Slide 10 of 19 Ver 1.0 Collaborate Session 9
Do you need to stop an Activity on a database when it is published?
No, Activity can continue on a database while a publication is being created.
FAQs
Slide 11
Installing Windows XP Professional Using Attended Installation Querying, Managing, and Administering Databases Using SQL Server 2005
When is a subscription available?
A subscription is available after a snapshot has been applied
to the subscription database.
FAQs (Contd.)
Trang 9Slide 12 of 19 Ver 1.0 Collaborate Session 9
What recovery model is required on a replicated database?
Replication functions properly using any of the recovery models: simple, bulk-logged, or full.
FAQs (Contd.)
Slide 13
Installing Windows XP Professional Using Attended Installation Querying, Managing, and Administering Databases Using SQL Server 2005
Does replication encrypt data?
No, replication does not encrypt data that is stored in the database or transferred over the network.
FAQs (Contd.)
Trang 10Slide 14 of 19 Ver 1.0 Collaborate Session 9
Does replication resume if a connection is dropped?
Yes, replication processing resumes at the point at which it left off if a connection is dropped.
FAQs (Contd.)
Slide 15
Installing Windows XP Professional Using Attended Installation Querying, Managing, and Administering Databases Using SQL Server 2005 Challenge
Which of the following editions of SQL Server 2005 allows database snapshots?
Standard edition Enterprise edition Express edition Workgroup edition
Answer:
Enterprise edition
Trang 11Slide 16 of 19 Ver 1.0 Collaborate Session 9
Challenge (Contd.)
You want to create a database snapshot Which command will you use with AS SNAPSHOT OF clause to create a snapshot of a database?
CREATE SNAPSHOT ALTER DATABASE ALTER SNAPSHOT CREATE DATABASE
Answer:
CREATE DATABASE
Slide 17
Installing Windows XP Professional Using Attended Installation Querying, Managing, and Administering Databases Using SQL Server 2005 Challenge (Contd.)
Which of the following task you cannot perform with respect
to database snapshots?
Create multiple snapshots of a database Drop files from database snapshot Create table through a snapshot Create snapshot on the same server instance as the source database
Answer:
Trang 12Slide 18 of 19 Ver 1.0 Collaborate Session 9
Challenge (Contd.)
Which of the following command reverts back a database from a snapshot?
RETRIEVE DATABASE <db1> FROM DATABASE_SNAPSHOT=<Sn1>
RESTORE DATABASE FROM DATABASE_SNAPSHOT=<Sn1>
RESTORE DATABASE <db1> FROM DATABASE_SNAPSHOT=<Sn1>
RETRIEVE DATABASE FROM DATABASE_SNAPSHOT=<Sn1>
Answer:
RESTORE DATABASE <db1> FROM DATABASE_SNAPSHOT=<Sn1>
Slide 19
Installing Windows XP Professional Using Attended Installation Querying, Managing, and Administering Databases Using SQL Server 2005 Challenge (Contd.)
Which of the following method is used to query against a linked server?
openlink() openquery() createquery() createlink()
Answer:
openquery()
Trang 131 b Enterprise edition
3 b Drop files from a database snapshot
4 c RESTORE DATABASE <db1> FROM DATABASE_SNAPSHOT=<Sn1>
5 b openquery() method
Trang 141 Which of the following is the publisher in replication implementation by using SQL Server 2005?
a Database server that replicates the data and database objects
b Database objects that are to be replicated
c Database data that is replicated
d Database server that takes the publication
2 Which of the following creates the snapshot of data in the primary server?
a Replication job
b Database server
c Distributor
d Replication agent
3 Which replication agent transfers the changes made to the publication from the distributor to the subscribers?
a Snapshot agent
b Distributor agent
c Log reader agent
4 Which replication job detects replication agents that are not actively logging history?
a Agent history clean up
b Distribution clean up
c Expired subscription clean up
d Replication agent checkup
5 Which type of replication is used to replicate data that does not change frequently?
a Merge replication
b Transaction replication
c Snapshot replication
d Distribution replication
6 Consider the following stages of a replication process:
Trang 15independently?
a Transactional publication
b Snapshot publication
c Merge publication
d Transactional publication with updatable subscriptions
8 What is the default value for the replication latency threshold?
9 Which statement is not true with regard to the BCP utility?
a It is a command line utility
b It is used to copy the SQL Server data to or from an operating system data file
c It provides the BCP GET and BCP SET operations
d BCP parameters are case-sensitive
10 Which of the following tool/command is not used to import and export data in SQL
Server 2005?
b BCP Utility
d Bulk Import Tool
Solutions
1 Database server that replicates the data and database objects
2 Replication agent
Trang 16Replication refers to a set of technologies used for copying and distributing data and database objects from one database to another and then synchronizing the databases to maintain consistency
Discuss the need for replicating data in an enterprise In addition, discuss the different replication types and their respective uses
Instructor Inputs
You can conduct the discussion as follows:
Encourage the students to discuss the need for replication in an enterprise
Ask the students to discuss the different replication types with the help of different situations in which each replication type is useful
Solution
Replicating data at physically different locations helps in quick access of data In addition,
it reduces network traffic, as the users do not need to send the data to a distant server for every transaction Replication involves various components such as publisher, distributor, and subscriber Synchronization of data between these components depends on the type of replication you select, such as snapshot replication, transactional replication, or merge replication
Snapshot Replication
Snapshot replication is used to replicate data that does not change frequently It is also used when the subscribers require read-only data with a high degree of latency time For example, the price list of a sales organization changes once or twice a year In this case, you can replicate the snapshot of the data after it has changed
Transactional Replication
Trang 17the data In this case, changes are replicated to all the subscribers and publishers until all
the servers have the same data Consider an example of a book store, which has various
regional offices Every office has its own database server The transaction details at the
regional offices need to be synchronized In such a case, merge replication can be
implemented