Sunday, August 3, 2014

Creating Standby Database using RMAN -

Creating Physical Standby Database using RMAN -

db name is -sync
Primary Db instance/db_unique_name name is  sync
Standby Db instance/db_unique_name name is  syncxx

Some pre_check - please make sure your Primary db is archive log mode , and  forced Logging is enable before moving to next step.

Step_1 -TAKE A LEVEL O BACKUP @Primary database .

run
{
allocate channel d1 device type disk format '/shared/sync/8aug_backup/%U.bkp';
allocate channel d2 device type disk format '/shared/sync/8aug_backup/%U.bkp';
allocate channel d3 device type disk format '/shared/sync/8aug_backup/%U.bkp';
allocate channel d4 device type disk format '/shared/sync/8aug_backup/%U.bkp';
BACKUP INCREMENTAL LEVEL 0 DATABASE;
release channel d1;
release channel d2;
release channel d3;
release channel d4;
}

Step_2 -TAKE CONTROL FILE BACKUP and parameter file for standby db.@Primary database .

 backup current controlfile for standby format '/shared/sync/8aug_backup/CTRL.bck';

Step_3- scp * standby_hostname:/backup/8aug_backup  @Primary database .
---- Come out from Primary db here --- all below command we will run into standby db server.-----

Step_4- Copy the primary database parameter file and make necessary changes :@Standby database .


sync.__db_cache_size=1610612736
sync.__java_pool_size=16777216
sync.__large_pool_size=16777216
sync.__shared_pool_size=452984832
sync.__streams_pool_size=33554432
*.background_dump_dest='/backup/syncxx/bdump/'
*.control_files='/backup/syncxx/data/control01.ctl'
*.core_dump_dest='/backup/syncxx/cdump/'
*.db_block_size=8192
*.db_name='sync'
instance_name = syncxx
service_names = syncxx
REMOTE_LOGIN_PASSWORDFILE = EXCLUSIVE
db_unique_name=syncxx
#*log_archive_dest_1='/backup/syncxx/arch'
*.processes=100
*.sessions=100
*.sga_target=2G
*.undo_management='AUTO'
standby_file_management = auto
*.user_dump_dest='/backup/syncxx/udump/'
-- create above folder -- like ( adump,bdump,data etc...)

Step_5 Startup nomount in standby server.@Standby database .

Step_6 Open one more standby db into putty** session and tail alerts logfile of standby db . .and keep eye on standby db .@Standby database
Step_7 restore control_file in standby.@Standby database .
      "restore standby controlfile from '/backup/8aug_backup/CTRL.bck'"

Step_8- Keep database into mount state now@Standby database .
      "Alter database Open"    
Step_9- Catalog the backup pieces@Standby database .
    "CATALOG START WITH '/backup/8aug_backup/';"

Step_10-Restore database in new location.@Standby database .

run
{
SET NEWNAME FOR DATAFILE 1 TO '/backup/syncxx/data/system01.dbf';
SET NEWNAME FOR DATAFILE 2 TO '/backup/syncxx/data/undo01.dbf';
SET NEWNAME FOR DATAFILE 3 TO '/backup/syncxx/data/sysaux01.dbf';
SET NEWNAME FOR DATAFILE 4 TO '/backup/syncxx/data/users.dbf';
SET NEWNAME FOR DATAFILE 5 TO '/backup/syncxx/data/users01.dbf';
SET NEWNAME FOR DATAFILE 6 TO '/backup/syncxx/data/users02.dbf';
SET NEWNAME FOR DATAFILE 7 TO '/backup/syncxx/data/system04.dbf';
SET NEWNAME FOR DATAFILE 8 TO '/backup/syncxx/data/tmp.dbf';
RESTORE DATABASE;
SWITCH DATAFILE ALL;
}

---- Since my db is smalll after taking backup only 25 arch files was created so i am not going to take another L1 backup .
if your db is big and more arch file was created aftre taking backup let's tale another L1 backup and appy that on standby db (via rman recover command)

Here your standby database is created , :) but archive logfile will not apply Automatically  on standby side.

Step_11-Create Listner on standby Db and  add new db detail into both Primary and standby db tns file @Standby database

Step_12-logfile into Primary db and copy passowrd file into standby Db , plz do not forget to change password file name and standb db.and update log_archive_dest_2/DG_CONFIG into Primary db server.@Primary database .

log_archive_dest_2 = 'SERVICE=STANDBY LGWR ASYNC NOAFFIRM'
DG_CONFIG=(syncxx,sync)';
Step_13- Put standby database in recovery mode@Standby database

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;

Step_14. swicth some arch file mannuly via ("Alter database swicth logilfe")

Step_15- Check if those file are moving are applying to standy db . @Standby database
 a -below step my help you to find standby side arch number -
 1- Archive log list
 2-SELECT ARCH.THREAD# "Thread", ARCH.SEQUENCE# "Last Sequence Received", APPL.SEQUENCE# "Last Sequence Applied", (ARCH.SEQUENCE# - APPL.SEQUENCE#) "Difference"
FROM(SELECT THREAD# ,SEQUENCE# FROM V$ARCHIVED_LOG WHERE (THREAD#,FIRST_TIME ) IN (SELECT THREAD#,MAX(FIRST_TIME) FROM V$ARCHIVED_LOG GROUP BY THREAD#)) ARCH,
(SELECT THREAD# ,SEQUENCE# FROM V$LOG_HISTORY WHERE (THREAD#,FIRST_TIME ) IN (SELECT THREAD#,MAX(FIRST_TIME) FROM V$LOG_HISTORY GROUP BY THREAD#)) APPL
WHERE
ARCH.THREAD# = APPL.THREAD#
ORDER BY 1;

after 15- 20 mints compare arch file primary and standby side make sure those are same _
 b- On the primary database issue the following to find out recent archive number .
SELECT THREAD#, MAX(SEQUENCE#)
FROM V$LOG_HISTORY
WHERE RESETLOGS_CHANGE# =
(SELECT RESETLOGS_CHANGE#
FROM V$DATABASE_INCARNATION
WHERE STATUS = 'CURRENT')
GROUP BY THREAD#;
 or -
 Archive log list




No comments:

Post a Comment

How to create user in MY SQL

Create  a new MySQL user Account mysql > CREATE USER ' newuser '@'localhost' IDENTIFIED BY ' password '...