Install a Warm Standby With Sybase Replication Server

This post contains a step by step instruction on how to setup a warm standby replication.

Preparation of the Sybase ASE-servers

Create a maintenance user on both ASE’s

The maintenance user is used by the replication server to apply transactions. Make sure that the name and password of the maintenance user on both servers are identical. For practical reasons make the maintenance user aliased to “dbo” in the database. Since a dump-load scenario is used to materialize the standby database, make sure that the suid of the maintenance user on both servers are identical.

This assumes that the databases <syb_src_db> in <syb_src_srvr> and the databases <syb_trgt_db> on <syb_trgt_srvr> are present and exactly the same size. The databases on <syb_trgt_srvr> do not need to have data in it, but need to be created and online.

isql –Usa –P<sa_password> -S<syb_src_srvr>

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 <syb_src_db>
go
sp_addalias "<rep_maint_user>","dbo"
go

isql –Usa –P<sa_password> -S<syb_trgt_srvr>

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 <syb_trgt_db>
go
sp_addalias "<rep_maint_user>","dbo"
go

 

Install the replication server stored procedures and tables

To do this, make a copy of the script rs_install_primary.sql located in the $SYBASE/$SYBASE_REP/scripts directory. Remove the last two commands of the script (the dbcc settrunc and the sp_setreplicate commands). The commands that are skipped will be executed at a later stage, when the replication agent is configured. Apply the script on the active server in the right database.

isql -Usa -P<sa_password> -S<syb_src_srvr>
–D<syb_src_db> -i changed_rs_install_primary.sql
isql -Usa -P<sa_password> -S<syb_trgt_srvr>
–D<syb_trgt_db> -i changed_rs_install_primary.sql

 

Configure both servers for replication

This step can be repeated several times. The setting is dynamic and no restart of ASE is necessary.

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

sp_configure "enable rep agent threads",1
go

isql -Usa -P<sa_password> -S<syb_trgt_srvr>
sp_configure "enable rep agent threads",1
go

 

Preparation of the Replication Server

Create a logical connection on the replication server

The name of it does not have to match with the name of the primary database server and database, but this convention is widely used.

isql -Usa -P<sa_password> -S<syb_trgt_srvr>_rs

create logical connection to <syb_src_srvr>.<syb_src_db>
go

 

Create a connection from the replication server to the active database

isql -Usa -P<sa_password> -S<syb_trgt_srvr>_rs

create connection to <syb_src_srvr>.<syb_src_db>
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 <syb_src_srvr>.<syb_src_db>
go

Create a login in the replication server

This login is used by the rep-agent running in the ASE to connect to the replication server.

isql -Usa -P<sa_password> -S<syb_trgt_srvr>_rs

create user <rep_maint_user> set password <rep_maint_pswd>
go
grant connect source to <rep_maint_user>
go

 

Configure the RepAgent

The configuration of the Replication Agent within the active ASE should now be done. All steps within this paragraph should be executed within a controlled time frame since the transaction log cannot be cleared between the execution of the first sp_config_rep_agent and the sp_start_rep_agent. The configuration is only needed on the primary server. Since we use a dump-load scenario the configuration is copied to the standby server during the materialization phase.

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

use <syb_src_db>
go
-- This will clear previously installed rep agents.
-- Ho harm if none are present.
sp_config_rep_agent "<syb_src_db>", "disable"
go
-- Continue installing rep agent.
sp_config_rep_agent "<syb_src_db>", "enable",
"<syb_trgt_srvr>_rs", "<rep_maint_user>",
"<rep_maint_pswd>"
go
sp_config_rep_agent "<syb_src_db>", "send warm standby xacts", true
go
sp_setreplicate rs_marker,"true"
go
sp_setreplicate rs_update_lastcommit,"true"
go
sp_start_rep_agent "<syb_src_db>"
go

 

Mark the database for replication

Execute the sp_reptostandby stored procedure in the active ASE to activate replication from the active database to the replication server.

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

use <syb_src_db>
go
sp_reptostandby "<syb_src_db>","all"
go

Configure the replication server for the standby database

All steps within this paragraph should be executed within a controlled time frame since the stable queue in the replication server cannot be cleared between the execution of the create connection and resume connection.

Create a connection from the replication server to the standby server

isql -Usa -P<sa_password> -S<syb_trgt_srvr>_rs
create connection to <syb_trgt_srvr>.<syb_trgt_db>
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 <syb_src_srvr>.<syb_src_db>
use dump marker
go

STOP: Before continuing perform the following checks.

isql -Usa -P<sa_password> -S<syb_trgt_srvr>_rs

admin logical_status
go

This should show both connections active and with the /Awaiting to enable marker clause at the standby connection. Nowhere should it read suspended.

isql -Usa -P<sa_password> -S<syb_trgt_srvr>_rs

admin who_is_down
go

There should be only 2 entries. DSI down <syb_trgt_srvr>.<syb_trgt_db> and DSI down <syb_trgt_srvr>.pcrdb. Everything else should be up.
Dump the database on the active server so it can be loaded into the standby server

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

dump database <syb_src_db> to "<file-name>"
go

Load the database dump into the standby server

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

load database <syb_trgt_db> from "<file-name>"
go
online database <syb_trgt_db>
go

 

Start the connection from the replication server to the standby database

isql -Usa -P<sa_password> -S<syb_trgt_srvr>_rs

resume connection to <syb_trgt_srvr>.<syb_trgt_db>
go

 

Test Replication Connection

isql -Usa -P<sa_password> -S<syb_src_srvr>
use <syb_src_db>
go
--create a dummy table. Skip this step if this table already exists.
create table test (a int)
go
insert test values(1)
go
isql -Usa -P<sa_password> -S<syb_trgt_srvr>

use <syb_trgt_db>
go
select * from test
go
--you should see the following
a
-----
1
If you enjoyed this post, make sure you subscribe to my RSS feed!

10 Responses to “Install a Warm Standby With Sybase Replication Server”

  1. Thanks for this simple and straight forward procedure on Sybase Replication.

  2. [...] http://blog.doblerconsulting.com is the new home for step by step instructions on various technology topics. As I mentioned before, the first few entries are focused around Sybase Replication Server. The basic concept is to provide information on new technology that can be easily reproduced in a test environment. Although these instructions are very detailed, they are for demonstration purposes only. [...]

  3. I don’t usually post but I enjoyed your blog a lot.

  4. I got started in 1995, working in a group called The Cash Money Click.

  5. It was awsome, just fix the last
    isql -Usa -P -S
    by
    isql -Usa -P -S
    and! remember to run the last two steps left from the rs_install_primary.sql, not sure if the sequence matters or not…
    Voi-lá after a long time I got my replication working!
    PUREFACT!!
    Thank you Indeed.
    I hope I can colaboratte with you on a step by step simple and basic, but less important, admin commands, to switch over stop and start , and how to start over… I had to because I decided to use different users … checked the log and started over using only one user to everything.
    Thank you again.
    Guto.

  6. revising..
    isql -Usa -P -S “src”
    by “trgt”
    and… NOT less important stuff, admin commands
    :)

  7. Guto,

    Thank you very much for the correction. I will change it right away to maintain a version that can help many other the way it helped you.

    Thanks,
    Peter

  8. IT IS VERY IMPRESSIVE. My covetousness is to see this approach for regular replication setup including intermediate RS not just warm standby environment… Thanks!

  9. Wonderful blog:D I will want some time to think about your website!

  10. Thank you for the auspicious writeup. It actually was once a amusement account it. Look complicated to more brought agreeable from you! However, how can we keep up a correspondence?

Leave a Reply