Server Detials
Primary Database : DB11G
IP: 192.168.222.133
Server Name : oraclepri
……………………………………………
Standby Database : STD
IP: 192.168.222.135
Server Name: oraclesec
stop iptables service in both the machine with following command
service iptables stop
Do a ping test from both server to check if they can resolve each others ip address
Required Parameters
DB_Name : Must be same on Primary and all Standby database
DB_Unique_Name : Must be different on Primary and all Standby database
Log_Archive_Config : This parameter includes db_unique_name
which are the part of dataguard
Configuration
Log_Archive_dest :Define local and remote archive
log file location
Log_archive_dest_state_n : Define state of archiving
(enable or differ)
Remote_login_passwordfile : Must be in EXCLUSIVE mode
FAL_SERVER : Used for archivelog gap
resolution(required only in
Physical standby database server)
DB_FILE_NAME_CONVERT: Required when directory
structure different for datafile
in standby server
Log_file_name_convert : Required when directory
structure different for log file
in standby server
Standby_file_management : Set it to auto to create new files in standby automatically
On Oraclepri DB11G database check archive log mode
select log_mode from v$database;
If it is not in archive log mode then change it with following steps
shutdown immediate;
startup mount;
alter database archivelog;
alter database open;
select log_mode from v$database;
Make sure Database is in force_logging mode
Select force_logging from v$database;
If it is not in forcelogging mode then change it to forcelogging
Alter database force logging;
Verify DBName and DBUniqueName of Primary database
show parameter db_name
show parameter db_unique_name
Make DB_unique_name to be part of dataguard
alter system set log_archive_config=’DG_CONFIG=(DB11G,STD)’;
Set archivelog destinations
ALTER SYSTEM set log_archive_dest_2=’service=STD VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=STD’;
ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_2=ENABLE;
Set remote login password to exclusive
ALTER SYSTEM SET REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE SCOPE=SPFILE;
SHOW PARAMETER REMOTE_LOGIN
Set FAL_SERVER and file name convert parameter in case the directory structure is different in primary and standby database
alter system set fal_server=STD;
alter system set db_file_name_convert=’STD’,’DB11G’ SCOPE=SPFILE;
alter system set log_file_name_convert=’STD’,’DB11G’ SCOPE=SPFILE;
alter system standby_file_management=AUTO
Lets configure required services in primary server
netmgr
Service Naming should be for db11g and std in both the servers and listener configuration on primary is as above and for secondary as below image
The difference is Global Database Name is same for both primary and secondary but SID is different.
Start the listener in both primary and secondary after configuring the netmgr
Let’s take the backup of the database by
rman target /
backup database plus archivelog;
After the backup is completed you can find the backup files in /u01/app/oracle/flash_recovery_area/DB11G folder
Now lets create standby control file and pfile
alter database create standby controlfile as ‘/tmp/stdcontrol.ctl’
create pfile=’/tmp/initSTD.ora’ from spfile;
Change initSTD.ora file parameter as we will shift it to standby server
Below images are of pfile of primary and secondary server
on primary
On Secondary
Now copy the control file to standby server
scp /tmp/stdcontrol.ctl oracle@192.168.222.135:/u01/app/oracle/oradata/control01.ctl
Now lets go to standby server and copy the control01.ctl to /u01/app/oracle/flash_recovery_area/STD/control02.ctl
cp /u01/app/oracle/oradata/control01.ctl /u01/app/oracle/flash_recovery_area/STD/control02.ctl
Now copy the pfile to standby server
scp /tmp/initSTD.ora oracle@192.168.222.135:/u01/app/oracle/product/11.2.0/dbhome/dbs/
Lets copy the backup folder to standby server
scp -r /u01/app/oracle/flash_recovery_area/DB11G oracle@192.168.222.135:/u01/app/oracle/ flash_recovery_area/
Create a password file in primary site and copy it to the secondary site and change the name to match the seocndary database name copying
go inside the $ORACLE_HOME/dbs/
orapwd file=orapwDB11G password=oracle force=y (password should be same as sys password)
Now copy the file to standby side
scp orapwDB11G oracle@192.168.222.135:/u01/app/oracle/product/11.2.0/dbhome/dbs/orapwSTD
On standby server update the /etc/oratab file with below information
vi /etc/oratab
STD:/u01/app/oracle/product/11.2.0/dbhome:N
update the .bash_profile with standby database name
Now run
source ~/.bash_profile
Now login as sysdba
sqlplus / as sysdba
create spfile from pfile=’/u01/app/oracle/product/11.2.0/dbhome/dbs/initSTD.ora’;
Now restore the backups
rman target /
startup mount;
restore database;
Now create standby logfile in both standby and primary server
first on standby server
alter database add standby logfile ( ‘/u02/app/oracle/oradata/STD/standby_redo01.log’) size 50M;
alter database add standby logfile ( ‘/u02/app/oracle/oradata/STD/standby_redo02.log’) size 50M;
alter database add standby logfile ( ‘/u02/app/oracle/oradata/STD/standby_redo03.log’) size 50M;
alter database add standby logfile ( ‘/u02/app/oracle/oradata/STD/standby_redo04.log’) size 50M;
On Primary Server
alter database add standby logfile ( ‘/u02/app/oracle/oradata/DB11g/standby_redo01.log’) size 50M;
alter database add standby logfile ( ‘/u02/app/oracle/oradata/DB11g/standby_redo02.log’) size 50M;
alter database add standby logfile ( ‘/u02/app/oracle/oradata/DB11g/standby_redo03.log’) size 50M;
alter database add standby logfile ( ‘/u02/app/oracle/oradata/DB11g/standby_redo04.log’) size 50M;
Now the moment come when we start the standby database
alter database recover managed standby database disconnect from session;
Now check the alert log file to see the progress
Go to primary database and do a log switch by
alter system switch logfile;
Then check the alert log file in standby server to see the progress
the default mode for dataguard is MAX_PERFORMANCE
In this mode after a log switch occurs the archive log file is transfered to secondary file to apply
Open the Standby database in read only mode
alter database recover managed standby database cancel;
alter database open read only;
To put the database in standby mode again do the following
alter database recover managed standby database disconnect from session;