Apress - Pro SQL Server 2008 Replication (2009)01

40 503 1
Apress - Pro SQL Server 2008 Replication (2009)01

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

this print for content only—size & color not accurate spine = 1.773" 936 page count Books for professionals By professionals ® Pro SQL Server 2008 Replication Dear Reader: Replication facilitates the transfer of data and objects from one database to another across different platforms and geographic locales. The physical separa- tion of databases and the inherent latency associated with replication makes it an attractive technology in various business implementations. However, configuring, administering, and optimizing a harmonious replication environment can be a daunting task even for the seasoned DBA due to the complexities of not only maintaining data integrity, but also knowing how the innards of replication work. This book explains the different types of replication available in SQL Server 2008 and provides realistic examples of how those types can be deployed. In this book I discuss the configuration and administration of snapshot, trans- actional, peer-to-peer, merge, and heterogeneous replication. You’ll see how to work with configuration from both a GUI and a command-line perspective. Besides discussing the internals of different types of replication, I also dem- onstrate the new features, such as the filestream feature in merge replication. You’ll learn about bidirectional, transactional replication. And you’ll learn to configure replication through SQLCMD, using it, for example, to configure log shipping with replication. Other tools such as the tablediff utility, the Database Engine Tuning Advisor, and Replication Monitor are covered, with emphasis upon their use in backing up, recovering, and optimizing replication environments. Management Data Warehouse, which is new in SQL Server 2008, is an exciting technology that can help you monitor replication performance. You’ll find examples of how to use the Management Data Warehouse in this book. I hope you find this book rewarding and as pleasurable to read as it was to write. I am grateful for the opportunity to teach you what I know on a topic I am passionate about. Sujoy P. Paul, MCP Author of Pro SQL Server 2005 Replication Shelve in Programming User level: Intermediate–Advanced Paul SQL Server 2008 Replication The eXperT’s Voice ® in sQl serVer Pro SQL Server 2008 Replication cyan MaGenTa yelloW Black panTone 123 c Sujoy P. Paul Companion eBook Available THE APRESS ROADMAP Pro T-SQL 2008 Programmer’s Guide Pro SQL Server Disaster Recovery Pro SQL Server 2008 Replication Accelerated SQL Server 2008 SQL Server 2008 Query Performance Tuning Distilled www.apress.com SOURCE CODE ONLINE Companion eBook See last page for details on $10 eBook version An essential and comprehensive guide to developing, administering, and mastering the complexities of SQL Server 2008 replication ISBN 978-1-4302-1807-4 9 781430 218074 9 0 0 0 0 Pro Pro SQL Server 2008 Replication ■■■ Sujoy Paul Paul_18074FRONT.fm Page i Friday, May 22, 2009 9:11 AM Pro SQL Server 2008 Replication Copyright © 2009 by Sujoy Paul All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher. ISBN-13 (pbk): 978-1-4302-1807-4 ISBN-13 (electronic): 978-1-4302-1808-1 Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1 Trademarked names may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, we use the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. Lead Editor: Jonathan Gennick Technical Reviewer: Don Watters Editorial Board: Clay Andres, Steve Anglin, Mark Beckner, Ewan Buckingham, Tony Campbell, Gary Cornell, Jonathan Gennick, Michelle Lowman, Matthew Moodie, Jeffrey Pepper, Frank Pohlmann, Ben Renow-Clarke, Dominic Shakeshaft, Matt Wade, Tom Welsh Project Manager: Kylie Johnston Copy Editor: Ami Knox Associate Production Director: Kari Brooks-Copony Production Editor: Ellie Fountain Compositor: Susan Glinert Proofreader: April Eddy Indexer: BIM Indexing & Proofreading Services Artist: Kinetic Publishing Services, LLC Cover Designer: Kurt Krames Manufacturing Director: Tom Debolski Distributed to the book trade worldwide by Springer-Verlag New York, Inc., 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax 201-348-4505, e-mail orders-ny@springer-sbm.com, or visit http://www.springeronline.com. For information on translations, please contact Apress directly at 2855 Telegraph Avenue, Suite 600, Berkeley, CA 94705. Phone 510-549-5930, fax 510-549-5939, e-mail info@apress.com, or visit http:// www.apress.com. Apress and friends of ED books may be purchased in bulk for academic, corporate, or promotional use. eBook versions and licenses are also available for most titles. For more information, reference our Special Bulk Sales–eBook Licensing web page at http://www.apress.com/info/bulksales. The information in this book is distributed on an “as is” basis, without warranty. Although every precaution has been taken in the preparation of this work, neither the author(s) nor Apress shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in this work. The source code for this book is available to readers at http://www.apress.com. Paul_18074FRONT.fm Page ii Friday, May 22, 2009 9:11 AM Dedicated to my parents, the late Subhendu P. Paul and Kavita Paul Paul_18074FRONT.fm Page iii Friday, May 22, 2009 9:11 AM Paul_18074FRONT.fm Page iv Friday, May 22, 2009 9:11 AM v Contents at a Glance About the Author . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii About the Technical Reviewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxi Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxiii ■ CHAPTER 1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 ■ CHAPTER 2 Replication Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 ■ CHAPTER 3 Types of Replication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 ■ CHAPTER 4 Configuring Snapshot Replication Using the GUI . . . . . . . . . . . . . . . 85 ■ CHAPTER 5 Configuring Snapshot Replication Using T-SQL . . . . . . . . . . . . . . . 123 ■ CHAPTER 6 Snapshot Generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151 ■ CHAPTER 7 Internals of Snapshot Replication . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169 ■ CHAPTER 8 Configuring Transactional Replication Using the GUI . . . . . . . . . . 223 ■ CHAPTER 9 Configuring Transactional Replication Using T-SQL . . . . . . . . . . . 261 ■ CHAPTER 10 Internals of Transactional Replication . . . . . . . . . . . . . . . . . . . . . . . . 315 ■ CHAPTER 11 Configuring Merge Replication Using the GUI . . . . . . . . . . . . . . . . . 399 ■ CHAPTER 12 Web Synchronization with Merge Replication . . . . . . . . . . . . . . . . . 443 ■ CHAPTER 13 Configuring Merge Replication Using T-SQL . . . . . . . . . . . . . . . . . . 471 ■ CHAPTER 14 The Internals of Merge Replication . . . . . . . . . . . . . . . . . . . . . . . . . . 537 ■ CHAPTER 15 Backup and Recovery of Snapshot and Transactional Replication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 599 ■ CHAPTER 16 Backup and Recovery of Merge Replication . . . . . . . . . . . . . . . . . . 653 ■ CHAPTER 17 Optimizing Snapshot Replication . . . . . . . . . . . . . . . . . . . . . . . . . . . . 697 ■ CHAPTER 18 Optimizing Transactional Replication . . . . . . . . . . . . . . . . . . . . . . . . 737 ■ CHAPTER 19 Optimizing Merge Replication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 801 ■ CHAPTER 20 Heterogeneous Replication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 837 ■ APPENDIX E-R Diagram of the mysales Database . . . . . . . . . . . . . . . . . . . . . . . 875 ■ INDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 879 Paul_18074FRONT.fm Page v Friday, May 22, 2009 9:11 AM Paul_18074FRONT.fm Page vi Friday, May 22, 2009 9:11 AM vii Contents About the Author . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii About the Technical Reviewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxi Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxiii ■ CHAPTER 1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Distributed Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Distributed Data Transactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Replication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 Eager Replication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 Lazy Replication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 Replication in SQL Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 Benefits of Replication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 SQL Server 2008 Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 SQL Server Configuration Manager . . . . . . . . . . . . . . . . . . . . . . . . . . 15 SQL Server Management Studio . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 Database Engine Tuning Advisor . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 Replication Monitor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 Quick Tips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 ■ CHAPTER 2 Replication Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 Publisher-Subscriber Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 Components of Replication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 Distributor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 Publisher . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 Subscriber . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 Publication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 Article . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 Subscriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 Agents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 Paul_18074FRONT.fm Page vii Friday, May 22, 2009 9:11 AM viii ■ CONTENTS Physical Replication Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 Publisher/Distributor–Subscriber Model . . . . . . . . . . . . . . . . . . . . . . 26 Central Publisher–Multiple Subscribers Model . . . . . . . . . . . . . . . . . 26 Central Subscriber–Multiple Publishers Model . . . . . . . . . . . . . . . . . 28 Multiple Publishers–Multiple Subscribers Model . . . . . . . . . . . . . . . 29 Installing and Configuring Replication . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 Installing SQL Server Replication . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 Configuring with the GUI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 Configuring Database Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 Configuring with T-SQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 Quick Tips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 ■ CHAPTER 3 Types of Replication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 Snapshot Replication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 The Snapshot Agent Profile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 How Snapshot Replication Works . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 Transactional Replication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 How Transactional Replication Works . . . . . . . . . . . . . . . . . . . . . . . . 64 Immediate Updating and Queued Updating Subscriptions . . . . . . . . 65 The Log and Queue Reader Agent Profiles . . . . . . . . . . . . . . . . . . . . 68 Peer-to-Peer Transactional Replication . . . . . . . . . . . . . . . . . . . . . . . 72 Merge Replication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 The Merge Agent Profile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 Quick Tips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83 ■ CHAPTER 4 Configuring Snapshot Replication Using the GUI . . . . . . . . 85 Configuring Publication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86 Configuring a Subscription . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 Configuring Push Subscriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 Configuring Pull Subscriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104 Adding and Deleting an Article . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121 Quick Tips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122 Paul_18074FRONT.fm Page viii Friday, May 22, 2009 9:11 AM [...]... example, using replication in SQL Server, you can transmit data from the SQL Server databases to remote servers running Oracle databases SQL Server provides access to heterogeneous databases by using the ODBC or OLE DB drivers The Microsoft OLE DB provider for SQL Server (SQLOLEDB) is installed automatically with SQL Server 2008 The other OLE DB providers that are installed with SQL Server 2008 are • Microsoft... integrity, but also knowing how replication works This book explains the different replication types like snapshot, transactional, and merge that are available in SQL Server 2008 and helps to fill in the necessary gaps in knowledge with real-life examples The book covers replication between SQL Server databases, and also covers heterogeneous replication between SQL Server and other database brands... such as SQL Server s Management Data Warehouse can be used to good advantage in monitoring optimization of replication Finally, Chapter 20 shows the configuration of heterogeneous replication involving SQL Server and Oracle Prerequisites Readers should be familiar with the principles of SQL and have a basic understanding of the fundamentals of SQL Server Readers should be comfortable issuing T -SQL statements,... either be homogeneous, such as when using all SQL Server databases, or heterogeneous, using databases like DB2, Oracle, or Sybase residing on different servers Homogeneous databases in a distributed environment provide tight coupling, such as the close interaction between the SQL Server client and the SQL Server database server Heterogeneous databases provide looser coupling due to the autonomous nature... systems, such as Microsoft SQL Server, Sybase ASA, and Sybase ASE; data modeling; and case-based tools like PowerDesigner and ERWIN His background includes expertise in database replication, with a special interest in two-way replication, backup and recovery, performance and tuning, and troubleshooting He is a Microsoft Certified Professional on SQL Server 2000 His other professional interests include... providers that are installed with SQL Server 2008 are • Microsoft OLE DB Provider for ODBC • Microsoft OLE DB Provider for Jet • Microsoft OLE DB Provider for Oracle For a list of OLE DB providers, please refer to http://msdn2.microsoft.com/en-us/library/ ms187072.aspx ■Note Throughout this book, the term SQL Server refers to SQL Server 2008 Although each of the databases in a distributed database system... INTRODUCTION SQL Server Management Studio (SSMS) can be used in the configuration of linked servers The configuration of a linked server is shown in Figure 1-3 A linked server configuration can issue distributed queries, updates, commands, and transactions Figure 1-3 Configuring linked servers Now suppose an application issues a transaction, in the linked server configuration of Figure 1-3 , and the... that read or modify the data in different databases SQL Server users can execute distributed queries across data in several instances of SQL Server and across OLE DB–enabled heterogeneous data sources by the use of a linked server, as shown in Figure 1-2 3 Paul_18074C01.fm Page 4 Tuesday, March 24, 2009 4:25 PM 4 CHAPTER 1 ■ INTRODUCTION Figure 1-2 SQL Server using OLE DB to communicate with heterogeneous... data A linked server facilitates the execution of the queries locally, and since data is retrieved from the remote sites and transferred across the network to the local server, it can cause significant overhead and have an impact on system performance ■Note For more information on linked servers, refer to SQL Server 2008 Books Online (BOL) You can install the BOL when you install SQL Server 2008 Paul_18074C01.fm... ■CHAPTER 20 Heterogeneous Replication 837 Snapshot Replication from an Oracle Publisher to a SQL Server Subscriber 837 Configuring an Oracle Publication for Snapshot Replication 837 Configuring a SQL Server Subscription for Snapshot Publication 849 Monitoring Replication with Replication Monitor . Guide Pro SQL Server Disaster Recovery Pro SQL Server 2008 Replication Accelerated SQL Server 2008 SQL Server 2008 Query Performance Tuning Distilled www .apress. com. mastering the complexities of SQL Server 2008 replication ISBN 97 8-1 -4 30 2-1 80 7-4 9 781430 218074 9 0 0 0 0 Pro Pro SQL Server 2008 Replication ■■■ Sujoy Paul

Ngày đăng: 08/11/2013, 21:15

Từ khóa liên quan

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan