You can materialize a replicate database from a primary database where all user activity has stopped at the primary database.
Use this materialization method when replication is broken between the primary database and the replicate database for a significant period of time and the queues are filling up, which needs to be purged. Refresh the replicate database with a copy from the current primary database. This can be used with either table replication or database replication. This scenario assumes that user activity is stopped at the primary while the database dump is taken.
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.
isql –Usa –P –SPRS2 suspend connection to sunak1505x.rep go Connection to 'sunak1505x.rep' is suspended.
isql –Usa –P –SSunak1505x use pri go sp_stop_rep_agent pri go The Replication Agent thread for database 'pri' is being stopped. (return status = 0) dbcc settrunc (ltm,ignore) go secondary trunc page secondary trunc state dbrepstat -------------------- --------------------- ------- 2669 0 172 generation id database id database name ltl version ------------- ------------ ------------- ---------- 0 7 pri 720
dump database pri to '/c11014900/sybase1520x/ASE- 15_0/bin/pri.dmp' go
load database rep from '/c11014900/sybase1520x/ASE- 15_0/bin/pri.dmp' 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.
online database rep go
use rep 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
resume connection to sunak1505x.rep go Connection to 'sunak1505x.rep' is resumed.
admin who go Spid Name State Info ----- ------- ------------ ------------------- 103 DSI EXEC Awaiting Command 104(1) sunak1505x.pri 100 DSI Awaiting Message 104 sunak1505x.pri 95 DIST Awaiting Wakeup 104 sunak1505x.pri 96 SQT Awaiting Wakeup 104:1 DISTsunak1505x.pri 92 SQM Awaiting Message 104:1 sunak1505x.pri 56 SQM Awaiting Message 104:0 sunak1505x.pri REP AGENT Down sunak1505x.pri NRM Down sunak1505x.pri 107 DSI EXEC Awaiting Command 106(1)sunak1505x.rep 106 DSI Awaiting Message 106 sunak1505x.rep 91 SQM Awaiting Message 106:0 sunak1505x.rep
create database replication definition pri_db_repdef with primary at sunak1505x.pri replicate DDL go Database replication definition 'pri_db_repdef' for sunak1505x.pri is created. create subscription rep_db_repdef for database replication definition pri_db_repdef with primary at sunak1505x.pri with replicate at sunak1505x.rep without materialization subscribe to truncate table go Subscription 'rep_db_repdef' is in the process of being created
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 -------------------- --------------------- --------- 2669 1 173 generation id database id database name ltl version ------------- ------------ ------------- ---------- 0 7 pri 720
use pri go sp_start_rep_agent pri go Replication Agent thread is started for database 'pri'. (return status = 0)
admin who go Spid Name State Info ---- -------- ------------ ------------- 103 DSI EXEC Awaiting Command 104(1) sunak1505x.pri 100 DSI Awaiting Message 104 sunak1505x.pri 95 DIST Awaiting Wakeup 104 sunak1505x.pri 96 SQT Awaiting Wakeup 104:1 DIST sunak1505x.pri 92 SQM Awaiting Message 104:1 sunak1505x.pri 56 SQM Awaiting Message 104:0 sunak1505x.pri 108 REP AGENT Awaiting Command sunak1505x.pri 109 NRM Awaiting Command sunak1505x.pri 107 DSI EXEC Awaiting Command 106(1) sunak1505x.rep 106 DSI Awaiting Message 106 sunak1505x.rep 91 SQM Awaiting Message 106:0 sunak1505x.rep