Você está na página 1de 6

Sybase Replication Server

Step-by-step instructions to install a warm


standby Replication Server

Create a maintenance user on the Primary and Replicate


Sybase ASE dataservers.
The maintenance user, typically <db>_maint, is used to server to apply replicated
transactions at the destination dataserver. Under normal circumstances you would not
change the name and password of the maintenance user. Ensure that these values are
identical at the source and destination. Also since the databases will be synced using a
database backup and restore, it will help to sync logins on the primary and replicate
dataservers. This can be achieved by Bcp-ing syslogins and sysloginroles.
The following acronyms are used for various entities in the replication topology
PDB – Primary database
RDB – Replicate database
RS - Replication server
PDS – Primary Dataserver
RDS – Replicate Dataserver
It is assumed that databases <PDS>.<PDB>and <RDS>.<RDB> exist and are the same
size.

STEP 1 : Create logins on PDS and RDS


isql –Usa –P<sa_password> -S<PDS>
sp_addlogin "<rep_maint_user>","<rep_maint_pswd>"
go
grant role replication_role to "<rep_maint_user>"
go
-- check the value of the suid
select suser_id("<rep_maint_user>")
go
use <PDB>
go
sp_addalias "<rep_maint_user>","dbo"
go
isql –Usa –P<sa_password> -S<RDS>
sp_addlogin "<rep_maint_user>","<rep_maint_pswd>"
go
grant role replication_role to "<rep_maint_user>"
go
-- check the value of the suid
select suser_id("<rep_maint_user>")
go
use <RDB>
go
sp_addalias "<rep_maint_user>","dbo"
go

STEP 2 : Install the replication server stored procedures


and tables
Execute the script rs_install_primary.sql located in $SYBASE/$SYBASE_REP/script in both the
PDB and RDB databases. Please comment out commands “dbcc settrunc” and
“sp_setreplicate” in the script since these need to be run after the replication agent is
configured.
isql -Usa -P<sa_password> -S<PDS> –D<PDB> -i rs_install_primary.sql
isql -Usa -P<sa_password> -S<RDS> –D<RDB> -i rs_install_primary.sql

STEP 3 : Configure ASE dataservers for replication


This step is essentially to enable rep agent threads
isql -Usa -P<sa_password> -S<PDS>
sp_configure "enable rep agent threads",1
go
isql -Usa -P<sa_password> -S<RDS>
sp_configure "enable rep agent threads",1
go

STEP 4 : Create logical connection on the replication


server
Name of the logical connection below is <PDS>.<PDB> and but refers to the current
primary data source
isql -Usa -P<sa_password> -S<RDS>_rs
create logical connection to <PDS>.<PDB>
go

STEP 5 : Create connection to the active database


isql -Usa -P<sa_password> -S<RS>
create connection to <PDS>.<PDB>
set error class to rs_sqlserver_error_class
set function string class to rs_sqlserver_function_class
set username to <rep_maint_user>
set password to <rep_maint_pswd>
with log transfer on
as active for <PDS>.<PDB>
go

STEP 6 : Create the maintenance login on the replication


server
This login is used by the replication agent running in the ASE to connect to the replication
server.
isql -Usa -P<sa_password> -S<RS>
create user <rep_maint_user> set password <rep_maint_passwd>
go
grant connect source to <rep_maint_user>
go

STEP 7 : Configure replication agent


isql -Usa -P<sa_password> -S<PDS>
use <PDB>
go
-- This will clear previously installed rep agents. Ho harm if none are
present.
sp_config_rep_agent "<PDB>", "disable"
go
-- Continue installing rep agent.
sp_config_rep_agent "<PDB>", "enable", "<RDS>_rs", "<rep_maint_user>",
"<rep_maint_pswd>"
go
sp_config_rep_agent "<PDB>", "send warm standby xacts", true
go
sp_setreplicate rs_marker,"true"
go
sp_setreplicate rs_update_lastcommit,"true"
go
sp_start_rep_agent "<PDB>"
go

STEP 8 : Mark the database for replication


Execute the sp_reptostandby stored procedure in the primary or active ASE to activate
replication from the active database to the replication server.
isql -Usa -P<sa_password> -S<PDS>
use <PDB>
go
sp_reptostandby "<PDB>","all"
go

STEP 9 : Create connection to the standby database


isql -Usa -P<sa_password> -S<RDS>_rs
create connection to <RDS>.<RDB>
set error class to rs_sqlserver_error_class
set function string class to rs_sqlserver_function_class
set username to <rep_maint_user>
set password to <rep_maint_pswd>
with log transfer on
as standby for <PDS>.<PDB>
use dump marker
go

STEP 10 : Check the status of replication connections


isql -Usa -P<sa_password> -S<RDS>_rs
admin logical_status
go
This command should show the primary and standby connections active and the standby
connection awaiting “enable marker”
isql -Usa -P<sa_password> -S<RDS>_rs
admin who_is_down
go
DSI threads to <RDS>.<RDB> should be DOWN.

STEP 11 : Dump the primary database


isql -Usa -P<sa_password> -S<PDS>
dump database <PDB> to "<dump_device>"
go

STEP 12 : Restore standby database from the dump


isql -Usa -P<sa_password> -S<RDS>
load database <RDB> from "<dump_device>"
go
online database <RDB>
go

STEP 13 : Resume connection to the standby database


isql -Usa -P<sa_password> -S<RDS>_rs
resume connection to <RDS>.<RDB>
go

STEP 14 : Test replication


Test Replication Connection

isql -Usa -P<sa_password> -S<PDS>


use <PDB>
go
--create a test table
create table dummy (f1 int)
go
insert dummy select 1
go

isql -Usa -P<sa_password> -S<PDS>


use <RDB>
go
select * from dummy
go
f1
-----
1

Sybase Replication Server Maintenance


Health Checks

The following commands are being used to check the replication system.

isql -Usa -P<sa_password> -S<RS>


>admin who_is_down
>go.
isql -Usa -P<sa_password> -S<RS>
>admin health
>go
isql -Usa -P<sa_password> -S<RS>
>admin logical_status
>go

Re-Syncing the Standby Database


Sometimes it may be necessary to resync the warm standby database. This could be due to
replication errors, huge data updates in case of which it is preferred to break replication and
restart it after the update or due to replication changes to text or image columns.
In such case the steps to resync a warmstandby database are as follows:
• Suspend connection to <RDB>
• Drop connection to <RDB>
• Stop the replication agent on <PDB>
• Create connection to <RDB> with dump marker
• Start replication agent on <PDB>
• Dump the primary database
• Load database dump to the standby database
• Resume connection to <RDB>

These are the commands used to re-sync a standby database.


isql -Usa -P<sa_password> -S<RS>
>suspend connection to <RDS>.<RDB>
>go
>drop connection to <RDS>.<RDB>
>go
isql -Usa -P<sa_password> -S<priamary_server>
>use <PDB>
>go
>sp_stop_rep_agent "<PDB>"
>go
isql -Usa -P<sa_password> -S<RS>
>create connection to <RDS>.<RDB>
>set error class to rs_sqlserver_error_class
>set function string class to rs_sqlserver_function_class
>set username to <PDB>_rep
set password to <password>
>with log transfer on
>as standby for <PDS>.<PDB>
>use dump marker
>go
isql -Usa -P<sa_password> -S<PDS>
>use <PDB>
>go
>sp_start_rep_agent "<PDB"
>go
isql -Usa -P<sa_password> -S<RS>
>admin logical_status
>go

--this should display Suspended/Awaiting for Enable Marker on <RDS>.<RDB>. DO NOT


PROCEED unless this any issues are fixed
isql -Usa -P<sa_password> -S<PDS>
>dump database <PDB> to "<file-name>"
>go
isql -Usa -P<sa_password> -S<RDS>
>load database <RDB> from "<file-name>"
>go
>online database <RDB>
>go

isql -Usa -P<sa_password> -S<RS>


>resume connection to <RDS>.<RDB>
>go

~ good luck ~

Você também pode gostar