ASE Replicator User's Guide

Transcription

ASE Replicator User’s GuideAdaptive Server Enterprise12.5

DOCUMENT ID: 35431-01-1250-01LAST REVISED: February 2002Copyright 1989-2002 by Sybase, Inc. All rights reserved.This publication pertains to Sybase database management software and to any subsequent release until otherwise indicated in neweditions or technical notes. Information in this document is subject to change without notice. The software described herein is furnishedunder a license agreement, and it may be used or copied only in accordance with the terms of that agreement.To order additional documents, U.S. and Canadian customers should call Customer Fulfillment at (800) 685-8225, fax (617) 229-9845.Customers in other countries with a U.S. license agreement may contact Customer Fulfillment via the above fax number. All otherinternational customers should contact their Sybase subsidiary or local distributor. Upgrades are provided only at regularly scheduledsoftware release dates. No part of this publication may be reproduced, transmitted, or translated in any form or by any means, electronic,mechanical, manual, optical, or otherwise, without the prior written permission of Sybase, Inc.Sybase, the Sybase logo, AccelaTrade, ADA Workbench, Adaptable Windowing Environment, Adaptive Component Architecture,Adaptive Server, Adaptive Server Anywhere, Adaptive Server Enterprise, Adaptive Server Enterprise Monitor, Adaptive ServerEnterprise Replication, Adaptive Server Everywhere, Adaptive Server IQ, Adaptive Warehouse, AnswerBase, Anywhere Studio,Application Manager, AppModeler, APT Workbench, APT-Build, APT-Edit, APT-Execute, APT-FORMS, APT-Translator, APT-Library,Backup Server, BizTracker, ClearConnect, Client-Library, Client Services, Convoy/DM, Copernicus, Data Pipeline, Data Workbench,DataArchitect, Database Analyzer, DataExpress, DataServer, DataWindow, DB-Library, dbQueue, Developers Workbench, DirectConnect Anywhere, DirectConnect, Distribution Director, e-ADK, E-Anywhere, e-Biz Integrator, E-Whatever, EC-GATEWAY,ECMAP, ECRTP, eFulfillment Accelerator, Embedded SQL, EMS, Enterprise Application Studio, Enterprise Client/Server, EnterpriseConnect, Enterprise Data Studio, Enterprise Manager, Enterprise SQL Server Manager, Enterprise Work Architecture, Enterprise WorkDesigner, Enterprise Work Modeler, eProcurement Accelerator, EWA, Financial Fusion, Financial Fusion Server, Gateway Manager,ImpactNow, Industry Warehouse Studio, InfoMaker, Information Anywhere, Information Everywhere, InformationConnect,InternetBuilder, iScript, Jaguar CTS, jConnect for JDBC, KnowledgeBase, MainframeConnect, Maintenance Express, MAP, MDIAccess Server, MDI Database Gateway, media.splash, MetaWorks, MySupport, Net-Gateway, Net-Library, New Era of Networks,ObjectConnect, ObjectCycle, OmniConnect, OmniSQL Access Module, OmniSQL Toolkit, Open Biz, Open Client, OpenClientConnect, Open Client/Server, Open Client/Server Interfaces, Open Gateway, Open Server, Open ServerConnect, Open Solutions,Optima , PB-Gen, PC APT Execute, PC DB-Net, PC Net Library, Power , power.stop, PowerAMC, PowerBuilder, PowerBuilderFoundation Class Library, PowerDesigner, PowerDimensions, PowerDynamo, PowerJ, PowerScript, PowerSite, PowerSocket,Powersoft, PowerStage, PowerStudio, PowerTips, Powersoft Portfolio, Powersoft Professional, PowerWare Desktop, PowerWareEnterprise, ProcessAnalyst, Rapport, Report Workbench, Report-Execute, Replication Agent, Replication Driver, Replication Server,Replication Server Manager, Replication Toolkit, Resource Manager, RW-DisplayLib, RW-Library, S-Designor, SDF, Secure SQLServer, Secure SQL Toolset, Security Guardian, SKILS, smart.partners, smart.parts, smart.script, SQL Advantage, SQL Anywhere, SQLAnywhere Studio, SQL Code Checker, SQL Debug, SQL Edit, SQL Edit/TPU, SQL Everywhere, SQL Modeler, SQL Remote, SQLServer, SQL Server Manager, SQL SMART, SQL Toolset, SQL Server/CFT, SQL Server/DBM, SQL Server SNMP SubAgent, SQLStation, SQLJ, STEP, SupportNow, S.W.I.F.T. Message Format Libraries, Sybase Central, Sybase Client/Server Interfaces, SybaseFinancial Server, Sybase Gateways, Sybase MPP, Sybase SQL Desktop, Sybase SQL Lifecycle, Sybase SQL Workgroup, Sybase UserWorkbench, SybaseWare, Syber Financial, SyberAssist, SyBooks, System 10, System 11, System XI (logo), SystemTools, Tabular DataStream, TradeForce, Transact-SQL, Translation Toolkit, UNIBOM, Unilib, Uninull, Unisep, Unistring, URK Runtime Kit for UniCode,Viewer, Visual Components, VisualSpeller, VisualWriter, VQL, WarehouseArchitect, Warehouse Control Center, Warehouse Studio,Warehouse WORKS, Watcom, Watcom SQL, Watcom SQL Server, Web Deployment Kit, Web.PB, Web.SQL, WebSights, WebViewer,WorkGroup SQL Server, XA-Library, XA-Server and XP Server are trademarks of Sybase, Inc. 02/02Unicode and the Unicode Logo are registered trademarks of Unicode, Inc.All other company and product names used herein may be trademarks or registered trademarks of their respective companies.Use, duplication, or disclosure by the government is subject to the restrictions set forth in subparagraph (c)(1)(ii) of DFARS 52.2277013 for the DOD and as set forth in FAR 52.227-19(a)-(d) for civilian agencies.Sybase, Inc., 5000 Hacienda Drive, Dublin, CA 94568.

ContentsAbout This Book . viiCHAPTER 1Introduction to ASE Replicator. 1Understanding replication . 1Table replication . 2Stored procedure replication . 2Transaction replication . 2Guaranteed delivery . 3Understanding ASE Replicator . 3ASE Replicator components . 4ASE Replicator processing. 6ASE Replicator objects. 8ASE Replicator limitations . 13Using Sybase Central to administer ASE Replicator. 13CHAPTER 2Setting Up and Starting ASE Replicator .Setting up ASE Replicator.Configuring the Adaptive Server .Configuring the replicate servers and databases .Initializing the ASE Replicator process.Starting ASE Replicator .Using the aserep script.Using the RUN script .15162124272729Administering ASE Replicator .Setting up a replication system .Administering ASE Replicator with Sybase Central .Administering ASE Replicator from the command line.Administering the ASE Replicator process.Monitoring ASE Replicator .Managing database connections.Managing publications and subscriptions.Managing primary and replicate articles.3132323335364347CHAPTER 31531iii

ContentsASE Replicator configuration parameters . 60General configuration parameters. 60Connection configuration parameters . 69CHAPTER 4ivASE Replicator Procedures . 73Introduction to ASE Replicator procedures . 73Executing ASE Replicator procedures . 73Entering parameter values . 74List of ASE Replicator procedures . 75sp addprimaryart . 77sp addprimaryconn. 80sp addpub . 80sp addreplicateart. 81sp addreplicateconn . 85sp addsub. 86sp configprimaryconn . 87sp configrep. 88sp configreplicateconn . 90sp dropprimaryart . 92sp dropprimaryconn . 93sp droppub . 93sp dropreplicateart . 94sp dropreplicateconn . 95sp dropsub . 96sp helpconn. 97sp helplastcommit . 98sp helplocator. 99sp helpprimaryart . 100sp helpprimaryconn . 103sp helppub. 107sp helprep . 109sp helpreplicateart . 114sp helpreplicateconn . 117sp helpsub. 121sp materializesub . 125sp resumeprimaryconn. 126sp resumerep . 127sp resumereplicateconn . 127sp resumesub. 128sp shutdownrep . 129sp suspendprimaryconn . 130sp suspendrep. 130sp suspendreplicateconn . 131sp suspendsub . 132

Contentssp tracerep . 132sp validatesub . 135CHAPTER 5Troubleshooting ASE Replicator.Problems that prevent replication from starting.Adaptive Server configuration problems .Remote server configuration problems .ASE Replicator configuration problems.User login or permission problems.Inconsistencies between primary and replicate objects .Datatype issues.Problems that cause ongoing replication to fail.137137137138139139140143144AP PE ND IX ADistribution Database Schema .Distribution Database base objects.Distribution Database datatypes .Base tables in the Distribution Database .Base procedures in the Distribution Database .Distribution Database shadow tables.Shadow tables for primary tables without large objects .Shadow tables for primary tables with large objects .Shadow tables for primary procedures.Distribution Database replicate objects.Distribution procedures .Replicate article proxy tables .147147147148158158159160161162162163Glossary . 165Index . 167v

Contentsvi

About This BookThe ASE Replicator User’s Guide describes how to set up and use the ASEReplicator feature of Sybase Adaptive Server Enterprise. ASEReplicator is a new feature in Adaptive Server version 12.5 that extendsAdaptive Server Enterprise capabilities and provides basic replicationfrom a primary database to one or more replicate databases.AudienceThis book is intended for Sybase System Administrators and databaseadministrators.How to use this bookThis book contains the following chapters:Chapter 1, “Introduction to ASE Replicator,” provides an introduction toreplication system concepts and an overview of the ASE Replicator. Thischapter describes the major ASE Replicator components and explainshow they work.Chapter 2, “Setting Up and Starting ASE Replicator,” describes the initialsetup and configuration procedure for ASE Replicator. The setupprocedures in this chapter must be performed after installing the software,and before replication can begin.Chapter 3, “Administering ASE Replicator,” describes administrativeoperations, including managing and monitoring ASE Replicator and thereplication system.Chapter 4, “ASE Replicator Procedures,” describes the ASE Replicatorcommand procedures in detail, including syntax, options, usage, andexamples.Chapter 5, “Troubleshooting ASE Replicator,” describes basictroubleshooting and recovery procedures for ASE Replicator.Appendix A, “Distribution Database Schema,” describes the schema ofthe Distribution Database.Related documentsThe Adaptive Server Enterprise documentation set comprises thefollowing documents: The release bulletin for your platform – contains last-minuteinformation that was too late to be included in the books.vii

About This BookA more recent version of the release bulletin may be available on theWorld Wide Web. To check for critical product or document informationthat was added after the release of the product CD, use the SybaseTechnical Library.viii The Installation Guide for your platform – describes installation, upgrade,and configuration procedures for all Adaptive Server and related Sybaseproducts. Configuring Adaptive Server Enterprise for your platform – providesinstructions for performing specific configuration tasks for AdaptiveServer. What’s New in Adaptive Server Enterprise? – describes the new featuresin Adaptive Server version 12.5, the system changes added to supportthose features, and the changes that may affect your existing applications. Transact-SQL User’s Guide – documents Transact-SQL , Sybase’senhanced version of the relational database language. This manual servesas a textbook for beginning users of the database management system.This manual also contains descriptions of the pubs2 and pubs3 sampledatabases. System Administration Guide – provides in-depth information aboutadministering servers and databases. This manual includes instructionsand guidelines for managing physical resources, security, user and systemdatabases, and specifying character conversion, international language,and sort order settings. Reference Manual – contains detailed information about all Transact-SQLcommands, functions, procedures, and datatypes. This manual alsocontains a list of the Transact-SQL reserved words and definitions ofsystem tables. Performance and Tuning Guide – explains how to tune Adaptive Serverfor maximum performance. This manual includes information aboutdatabase design issues that affect performance, query optimization, how totune Adaptive Server for very large databases, disk and cache issues, andthe effects of locking and cursors on performance. The Utility Guide – documents the Adaptive Server utility programs, suchas isql and bcp, which are executed at the operating system level. The Quick Reference Guide – provides a comprehensive listing of thenames and syntax for commands, functions, system procedures, extendedsystem procedures, datatypes, and utilities in a pocket-sized book.Available only in print version.

About This Book The System Tables Diagram – illustrates system tables and their entityrelationships in a poster format. Available only in print version. Error Messages and Troubleshooting Guide – explains how to resolvefrequently occurring error messages and describes solutions to systemproblems frequently encountered by users. Component Integration Services User’s Guide – explains how to use theAdaptive Server Component Integration Services feature to connectremote Sybase and non-Sybase databases. Java in Adaptive Server Enterprise – describes how to install and use Javaclasses as datatypes, functions, and stored procedures in the AdaptiveServer database. Using Sybase Failover in a High Availability System – providesinstructions for using Sybase’s Failover to configure an Adaptive Serveras a companion server in a high availability system. Using Adaptive Server Distributed Transaction Management Features –explains how to configure, use, and troubleshoot Adaptive Server DTMfeatures in distributed transaction processing environments. EJB Server User’s Guide – explains how to use EJB Server to deploy andexecute Enterprise JavaBeans in Adaptive Server. XA Interface Integration Guide for CICS, Encina, and TUXEDO –provides instructions for using Sybase’s DTM XA interface with X/OpenXA transaction managers. Glossary – defines technical terms used in the Adaptive Serverdocumentation. Sybase jConnect for JDBC Programmer’s Reference – describes thejConnect for JDBC product and explains how to use it to access data storedin relational database management systems. Full-Text Search Specialty Data Store User’s Guide – describes how to usethe Full-Text Search feature with Verity to search Adaptive ServerEnterprise data. Historical Server User’s Guide – describes how to use Historical Server toobtain performance information for SQL Server and Adaptive Server. Monitor Server User’s Guide – describes how to use Monitor Server toobtain performance statistics from SQL Server and Adaptive Server.ix

About This Book Other sources ofinformationMonitor Client Library Programmer’s Guide – describes how to writeMonitor Client Library applications that access Adaptive Serverperformance data.Use the Sybase Technical Library CD and the Technical Library ProductManuals Web site to learn more about your product: Technical Library CD contains product manuals and is included with yoursoftware. The DynaText browser (downloadable from Product Manuals tml) allows you to accesstechnical information about your product in an easy-to-use format.Refer to the Technical Library Installation Guide in your documentationpackage for instructions on installing and starting the Technical Library. Technical Library Product Manuals Web site is an HTML version of theTechnical Library CD that you can access using a standard Web browser.In addition to product manuals, you will find links to the TechnicalDocuments Web site (formerly known as Tech Info Library), the SolvedCases page, and Sybase/Powersoft newsgroups.To access the Technical Library Product Manuals Web site, go to ProductManuals at The following style conventions are used in this manual: In a sample screen display, commands you should enter exactly as shownappear in:this font In a sample screen display, words that you should replace with theappropriate value for your installation are shown in:this font In the regular text of this document, the names of files and directoriesappear in this font:/usr/u/sybase The names of programs, utilities, procedures, and commands appear inthis font:sqlupgradeTable 1 shows the conventions for syntax statements that appear in this manual:x

About This BookTable 1: Syntax statement conventionsKeycommandvariable{}[]() ,DefinitionCommand names, command option names, configurationparameter names, and other keywords are in this font in bodytext.Variables, options, or words that stand for values that you fillin, are in this font in body text.Curly braces indicate that you choose at least one of the enclosed options. Do not include braces in your option.Brackets mean choosing one or more of the enclosed options isoptional. Do not include brackets in your option.Parentheses are to be typed as part of the command.The vertical bar means you may select only one of the optionsshown.The comma means you may choose as many of the optionsshown as you like, separating your choices with commas to betyped as part of the command.In this manual, most of the examples are in lowercase. However, you candisregard case when typing Transact-SQL keywords. For example, SELECT,Select, and select are the same.Adaptive Server’s sensitivity to the case of database objects, such as tablenames, depends on the sort order installed on Adaptive Server. You can changecase sensitivity for single-byte character sets by reconfiguring the AdaptiveServer sort order. See the System Administration Guide for more information.If you need helpEach Sybase installation that has purchased a support contract has one or moredesignated people who are authorized to contact Sybase Technical Support. Ifyou cannot resolve a problem using the manuals or online help, please have thedesignated person contact Sybase Technical Support or the Sybase subsidiaryin your area.xi

About This Bookxii

CH A PTE R1Introduction to ASE ReplicatorThis chapter provides an introduction to replication concepts and anoverview of the ASE Replicator feature of Adaptive Server Enterprise.TopicUnderstanding replicationUnderstanding ASE ReplicatorPage13Using Sybase Central to administer ASE Replicator13Understanding replicationA replication system maintains current data in separate databases byreplicating the data-changing operations that take place in one databaseand sending those operations to another database.The source of a replicated transaction is called the primary database. Thetarget (or destination) of a replicated transaction is called the replicatedatabase. As shown in Figure 1-1, the primary database publishesreplicated transactions, and the replicate database subscribes to replicatedtransactions.Figure 1-1: Basic replicationReplicationPublishPrimarydatabasedata flowSubscribeReplicatedatabaseIn bidirectional replication, a single database acts as both a primarydatabase and a replicate database. Bidirectional replication requires amethod of filtering the replicated transactions to prevent circularreplication back to the original primary database source.1

Understanding replicationTable replicationTo replicate data-changing operations, tables in the primary database arepublished. When a table is published, data-changing operations that affect thecontents of that table are captured for subsequent distribution to a replicatedatabase.To receive replicated operations, a replicate database must subscribe to apublished table in the primary database. When a replicate database subscribesto a published table, data-changing operations from the primary database canbe distributed to a subscribing table in the replicate database.Stored procedure replicationIn addition to replicating data-changing operations in tables, the ASEReplicator feature can replicate stored procedure invocations in the primarydatabase. Replicating a stored procedure invocation can be more efficient thanreplicating the individual data-changing operations it produces.When a stored procedure in a primary database is published for replication,input parameter values that are specified when the stored procedure is invokedare captured and recorded, along with the name of the stored procedure. Whena replicate database subscribes to a published stored procedure, the storedprocedure invocation in the primary database is distributed to the replicatedatabase as a remote procedure call (RPC).When a published stored procedure generates an operation that affects the datain a published table, the data-changing operation generated by the storedprocedure is ignored, and only the stored procedure invocation is replicated.Transaction replicationTransaction replication ensures database integrity and transactionalconsistency across multiple database sites. All data-changing operations thatare replicated are considered “transactions,” even though they might notcorrespond to an actual transaction in the primary database.For example, if a transaction changes both published tables and unpublishedtables in the primary database, only the data-changing operations that affect thepublished tables are replicated. Operations on unpublished tables are notreplicated.2

CHAPTER 1Introduction to ASE ReplicatorAll data-changing operations are replicated within a transaction context. Inother words, only committed transaction operations are replicated; transactionoperations that are rolled back are not replicated.Even though a “transaction” replicated through ASE Replicator is really just aset of operations, those operations are grouped in an atomic collection, andeach collection represents the results of a committed transaction in the primarydatabase.Stored procedure invocations are part of a transaction, just like the datachanging operations in a table. They are not necessarily transactions inthemselves.Guaranteed deliveryIn a replication system, guaranteed delivery means that all data-changingoperations published by a primary database are guaranteed to be received bythe subscribing replicate database, regardless of any hardware, software, ornetwork problems that might interfere with replication.To provide guaranteed delivery, ASE Replicator uses two mechanisms: A stable queue – records published data-changing operations in anonvolatile form until the subscribing replicate database can confirm thatit received them. The ASE Replicator stable queue consists of tables in adatabase that resides in the same Adaptive Server as the primary database. A locator – identifies the last published transaction that was successfullyreceived and stored in the stable queue, and the last published transactionthat was successfully received by the subscribing replicate database. Thelocator is a string value that ASE Replicator maintains.Understanding ASE ReplicatorASE Replicator extends Adaptive Server Enterprise capabilities and providesbasic replication from a primary database to one or more replicate databases.ASE Replicator: Replicates both tables and stored procedures Maintains database integrity and transactional consistency at multiplesites3

Understanding ASE Replicator Provides guaranteed delivery of replicated data Manages database objects with a publish-and-subscribe modelASE Replicator takes advantage of Component Integration Services (CIS) tohandle transaction and RPC distribution to replicate databases.For more information about CIS, see the Component Integration ServicesUser’s Guide.ASE Replicator componentsASE Replicator components work together to replicate transactions and storedprocedures. Figure 1-2 shows these components; a description of each follows.Figure 1-2: ASE Replicator componentsASE onentDistributionDatabaseASE Replicator processThe ASE Replicator process is an external application that connects to andinteracts with Adaptive Server, and it receives all its instructions from theAdaptive Server to which it connects. The ASE Replicator process managesand coordinates all the other ASE Replicator components and all replicationprocessing.ASE Replicator can support multiple primary databases, replicate databases,and replicate database servers, but each instance of ASE Replicator can supportonly one primary Adaptive Server.4

CHAPTER 1Introduction to ASE ReplicatorEven though you can set up ASE Replicator on two Adaptive Servers tosupport bidirectional replication, you cannot coordinate the operations ofmultiple instances of ASE Replicator, nor can they share data or metadata.Distribution DatabaseThe Distribution Database is a user database in Adaptive Server. It contains allthe metadata needed to support

Replication Server Manager, Replication Toolkit, Resource Mana ger, RW-DisplayLib, RW-Library, S-Designor, SDF, Secure SQL . Financial Server, Sybase Gateways , Sybase MPP, Sybase SQL Desktop, Sybase SQL Lifecycle, Sybase SQL Workgroup, Sybase User