You can materialize a primary database from a replicate database where user activity can be stopped and the replicate database is a duplicate of the primary database.
use pri go sp_reptostandby pri go The replication status for database 'pri' is 'ALL'. The replication mode for database 'pri' is 'off'. (return status = 0)
use pri go sp_setreplicate go Name Type ------- ---------------- t1 user table t2 user table rs_marker stored procedure (3 rows affected) (return status = 0)
use pri go dbcc gettrunc go secondary trunc page secondary trunc state dbrepstat ------------------- --------------------- ------- 2669 1 173 generation id database id database name ltl version ------------- ------------ ------------- --------- 0 7 pri 720
use PRS2_RSSD go rs_helpuser go User Name Permission(s) Name ------------ ------------------------------ PRS2_id_user no grants sa sa PRS2_ra connect source PRS2_rsi connect source PRS2_RSSD_prim source, primary subscr Maintenance Users User name Destination DS.DB ------------ ------------------------------------- PRS2_RSSD_maint sunak1505x.PRS2_RSSD pri_maint sunak1505x.pri pri_maint sunak1505x.rep (return status = 0)
In this example, “pri_maint” is the maintenance user for both the connection to the primary database, sunak1505x.pri. and replicate database, sunak1505x.rep.
You need not stop user activity at the source database; because when the new database goes online, Adaptive Server creates a database that is transactionally consistent at the time of the dump.
isql –Usa –P –SPRS2 suspend connection to sunak1505.rep go Connection to 'sunak1505x.rep' is suspended.
sp_stop_rep_agent pri go The Replication Agent thread for database 'pri' is being stopped. (return status = 0) isql -Usa -P –SPRS2 suspend connection to sunak1505x.pri go Connection to 'sunak1505x.pri' is suspended.
admin who go Spid Name State Info ---- ---------- -------------------- ------------ DSI EXEC Suspended 104(1) sunak1505x.pri DSI Suspended 104 sunak1505x.pri 129 DIST Awaiting Wakeup 104 sunak1505x.pri 130 SQT Awaiting Wakeup 104:1 DIST sunak1505x.pri 123 SQM Awaiting Message 104:1 sunak1505x.pri 56 SQM Awaiting Message 104:0 sunak1505x.pri REP AGENT Down sunak1505x.pri NRM Down sunak1505x.pri DSI EXEC Suspended 106(1) sunak1505x.rep DSI Suspended 106 sunak1505x.rep 124 SQM Awaiting Message 106:0 sunak1505x.rep
dump database diffprim to '/c11014900/sybase1520x/rep.dmp' go
load database pri from '/c11014900/sybase1520x/rep.dmp' go
online database pri go
use pri go sp_adduser pri_maint go New user added. (return status = 0) grant execute on rs_get_lastcommit to pri_maint go grant all on rs_lastcommit to pri_maint go
sp_addlogin <maintenance user>, <maintenance userpassword>, <database> go sp_role "grant", replication_role, <maintenance user> go
alter connection to <dataserver>.<database> set password to <new password> go
use pri go dbcc settrunc (ltm,ignore) go secondary trunc page secondary trunc state dbrepstat -------------------- --------------------- -------- 2667 0 166 generation id database id database name ltl version ------------- ------------ ------------- ---------- 0 7 pri 720
sp_config_rep_agent pri,'disable' go Replication Agent disabled for database 'pri'. The secondary truncation point in the database is no longer active. (return status = 0)
sp_config_rep_agent pri, 'enable','PRS2','PRS2_ra','PRS2_ra_ps' go Replication Agent enabled for database 'pri'. The Replication Agent thread needs to be started using sp_start_rep_agent. (return status = 0)
use PRS2_RSSD go rs_zeroltm sunak1505x,pri go Locater has been reset to zero. (return status = 0) isql –Usa –P –Ssunak1505x use pri go dbcc settrunc (ltm,valid) go secondary trunc page secondary trunc state dbrepstat -------------------- --------------------- -------- 2670 1 167 generation id database id database name ltl version ------------- ------------ ------------- ---------- 0 7 pri 720
dbcc settrunc (ltm,gen_id,1) go secondary trunc page secondary trunc state dbrepstat -------------------- --------------------- -------- 2670 1 167 generation id database id database name ltl version ------------- ------------ ------------- ---------- 0 7 pri 720
use rep go truncate table rs_lastcommit go
isql -Usa -P –SPRS2 sysadmin hibernate_on go The Replication Server has now entered hibernation mode.
sysadmin sqm_purge_queue, 104,1 go sysadmin sqm_purge_queue, 106,0 go
sysadmin hibernate_off go The Replication Server has now finished hibernation mode.
isql -Usa -P –SPRS2 sysadmin hibernate_off go
resume connection to sunak1505x.pri go Connection to 'sunak1505x.pri' is resumed. resume connection to sunak1505x.rep go Connection to 'sunak1505x.rep' is resumed
sp_start_rep_agent pri go Replication Agent thread is started for database 'pri'. (return status = 0)
admin who go Spid Name State Info ---- -------- ------------ ------------------ 139 DSI EXEC Awaiting Command 104(1) sunak1505x.pri 135 DSI Awaiting Message 104 sunak1505x.pri 129 DIST Awaiting Wakeup 104 sunak1505x.pri 130 SQT Awaiting Wakeup 104:1 DIST sunak1505x.pri 123 SQM Awaiting Message 104:1 sunak1505x.pri 56 SQM Awaiting Message 104:0 sunak1505x.pri 143 REP AGENT Awaiting Command sunak1505x.pri 145 NRM Awaiting Command sunak1505x.pri