- Virtualbox on Ubuntu 11.10 with 2 virtual machine Oracle Linux 5 is used for Data Guard installation.
- First installed Oracle Linux 5 on Virtualbox (hostname=oracle10g), installed requied rpms, installed oracle software and a database named ORCL. Then clone this virtual machine as hostname=oracle10gs
- Primary hostname : oracle10g, Standby hostname: oracle10gs
- Primary database UNIQUE NAME: ORCL, standby database UNIQUE NAME: ORCL_STBY
- Primarydatabase Net Service Name: ORCL, standby database Net Service Name: ORCL_STBY
- This is a phiysical standby database with Maximum Performance mode. In this mode: Transactions on the primary commit as soon as redo information has been written to the online redo log. Transfer of redo information to the standby server is asynchronous, so it does not impact on performance of the primary.
ON PRIMARY SIDE:
- Check for Primary database whether archivelog mode is on.
LOG_MODE
------------
NOARCHIVELOG
Put the database to archivelog mode:
SQL> SHUTDOWN IMMEDIATE;
SQL> STARTUP MOUNT;
SQL> ALTER DATABASE ARCHIVELOG;
SQL> ALTER DATABASE OPEN;
- Enable force logging:
- Create password file if it is not exist:
$ orapwd file=$ORACLE_HOME/dbs/orapwORCL password=****** entries=30
- Add these parameters to primary instance ORCL init file:
DB_UNIQUE_NAME=ORCL
LOG_ARCHIVE_CONFIG='DG_CONFIG=(ORCL,ORCL_STBY)'
LOG_ARCHIVE_DEST_2='SERVICE=ORCL_STBY NOAFFIRM ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=ORCL_STBY'
LOG_ARCHIVE_DEST_STATE_2=ENABLE
REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE
LOG_ARCHIVE_FORMAT='%t_%s_%r.arc'
LOG_ARCHIVE_FORMAT='%t_%s_%r.arc'
LOG_ARCHIVE_MAX_PROCESSES=30
STANDBY_FILE_MANAGEMENT=AUTO
STANDBY_ARCHIVE_DEST='/u01/db_files/ARCH'
- Primary Database: Standby Role Initialization Parameters
These parameters are needed when there is a switchower between primary role and standby role.
###################################################
#These parameters are needed when switchover occurs.
###################################################
#FAL_SERVER=ORCL_STBY
#FAL_CLIENT=ORCL
######################
#If file name conversion is needed:
#DB_FILE_NAME_CONVERT='boston','chicago'
#LOG_FILE_NAME_CONVERT='/arch1/boston/','/arch1/chicago/'
######################
#STANDBY_FILE_MANAGEMENT=AUTO
#############################################
- Modify tnsnames.ora by adding standby instance and catalog database instance of RMAN:
ORCL_STBY =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle10gs)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ORCL)
)
)
CATALOG =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle10g)(PORT = 1522))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = CATALOG)
)
)
- Add standby logfiles:
ALTER DATABASE ADD STANDBY LOGFILE GROUP 5 ('/u01/oradata/standby05.dbf') SIZE 50M
ALTER DATABASE ADD STANDBY LOGFILE GROUP 6 ('/u01/oradata/standby06.dbf') SIZE 50M
ALTER DATABASE ADD STANDBY LOGFILE GROUP 7 ('/u01/oradata/standby07.dbf') SIZE 50M
ALTER DATABASE ADD STANDBY LOGFILE GROUP 8 ('/u01/oradata/standby08.dbf') SIZE 50M
- Backup the database using RMAN with standby controlfile
connect to rman:
rman catalog rman/rman@CATALOG target /
Run the script:
run
{
allocate channel ch1 type disk format '/u01/backup/std_%U';
allocate channel ch2 type disk format '/u01/backup/std_%U';
BACKUP DATABASE INCLUDE CURRENT CONTROLFILE FOR STANDBY PLUS ARCHIVELOG;
}- Copy or share these backup files under /u01/backup to standby instance
$ scp /u01/backup/* oracle@oracle10gs:/u01/backup
- Copy the init file to standby side
$ scp $ORACLE_HOME/dbs/initORCL.ora oracle@oracle10gs:/u01
ON STANDBY SIDE:
- modify init parameter by adding these lines:
DB_NAME=ORCL
DB_UNIQUE_NAME=ORCL_STBY
FAL_SERVER=ORCL
FAL_CLIENT=ORCL_STBY
LOG_ARCHIVE_FORMAT='%t_%s_%r.arc'
STANDBY_FILE_MANAGEMENT=AUTO
LOG_ARCHIVE_CONFIG='dg_config=(ORCL,ORCL_STBY)'
LOG_ARCHIVE_DEST_1='LOCATION=/u01/db_files/ARCH'
Log_archive_dest_state_1=ENABLE
- add tnsnames.ora entries:
ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle10g)(PORT = 1522))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ORCL)
)
)
CATALOG =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle10g)(PORT = 1522))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = CATALOG)
)
)
- start the standby listener
lsnrctl start
- start the instance in nomount state:
set environments:
export ORACLE_HOME=/u01/app/oracle/product/10.2.0/realdb_1
export ORACLE_SID=ORCL
export PATH=$PATH:$ORACLE_HOME/bin
$ sqlplus / as sysdba
startup nomount pfile=?/dbs/initORCL.ora
- restore database
$ rman catalog rman/rman@CATALOG target sys/******@ORCL auxiliary /
run
{
allocate channel C1 device type disk;
allocate channel C2 device type disk;
set until SCN 1391907;
RESTORE DATABASE;
RECOVER DATABASE;
}
- start apply process:
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;
If you need to cancel the process:
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
If you need to open the standby process read only:
alter database open read only;
- Control scripts
Shows Data Guard log numbers:
Primary side:
select thread#, sequence# from v$log
Standby side
select thread#, sequence#, status from v$managed_standby;
Last archived log on standby
select max(sequence#) "Last Seq Recieved" from v$archived_log;
Shows archive processes status. If log_archive_dest_state_2 is VALID, it writes archive logs to standby side .
select dest_name,status,target,destination,db_unique_name from v$archive_dest;
Stop/start writing to standby side:
alter system set log_archive_dest_state_2=ENABLE
alter system set log_archive_dest_state_2=DEFER
Dataguard messages:
select message from v$dataguard_status where dest_id = 2;
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.