prerequest : primary database name is ocmdb , standby database's directory strutrue is different than primary (ocmdb,ocmdg) maximize protection mode
1. create database
2. alter database force logging
3. orapwd
4.modify primary initocmdb.ora setting following parameters: primary db_unique_name=ocmdb standby db_unique_name=ocmdg
fal_server=ocmdg
fal_client=ocmdb
log_archive_dest_1='location=/u01/oracle/oradata/arch/ocmdb valid_for(all_logfiles,all_roles) db_unique_name=ocmdb'
log_archive_dest_2='service=ocmdg lgwr sync affirm valid_for(online_logfiles, primary_role) db_unique_name=ocmdg'
db_file_name_convert=(ocmdb,ocmdg)
log_archive_config='dg_config=(ocmdb,ocmdg)'
standby_file_management=auto
user_dump_dest=/u01/oracle/admin/ocmdb/udump
core_dump_dest=/u01/oracle/admin/ocmdb/cdump
backgroud_dump_dest=/u01/oracle/admin/ocmdb/bdump
db_unique_name=ocmdb -- this parmater can garantee the database has a service name that be registered by listener
5. on primary : alter database create standby controlfile as '/u01/control.ctf' ;
6.shutdown primary and scp /u01/oracle/oradata/ocmdb/* oracle@db2:/u01/oracle/oradata/ocmdg scp $ORACLE_HOME/dbs/initocmdb.init oracle@db2:/$ORACLE_HOME/dbs and modify initocmdb.ora on standby and replace the standby control file with standby control file. orapwd on standby database
fal_server=ocmdb
fal_client=ocmdg
log_archive_dest_1='location=/u01/oracle/oradata/arch/ocmdb valid_for(all_logfiles,all_roles) db_unique_name=ocmdb'
log_archive_dest_2='service=ocmdg lgwr sync affirm valid_for(online_logfiles, primary_role) db_unique_name=ocmdg'
db_file_name_convert=(ocmdb,ocmdg)
log_archive_config='dg_config=(ocmdb,ocmdg)'
standby_file_management=auto
user_dump_dest=/u01/oracle/admin/ocmdg/udump
core_dump_dest=/u01/oracle/admin/ocmdg/cdump
backgroud_dump_dest=/u01/oracle/admin/ocmdg/bdump
db_unique_name=ocmdg
7.startup mount primary
8. create standby logfile on primary , attention is standby logfile should be same size to normal logfile ,otherwise max protection will fail.
alter database create standby logfile group 4('/u01/oracle/oradata/ocmdb/dredo04.log') size 5m;
alter database create standby logfile group 5('/u01/oracle/oradata/ocmdb/dredo05.log') size 5m;
alter database create standby logfile group 6('/u01/oracle/oradata/ocmdb/dredo06.log') size 5m;
alter database create standby logfile group 7('/u01/oracle/oradata/ocmdb/dredo07.log') size 5m;
9.startup mount on standby database , make the primary and standby database both at least at mount state , this way pmon can auto find and register the database on listener
10. netca to configue the listener and tnsnames.ora all using normal mode on both primary and standby , lsnrctl start and lsnrctl status make sure all the tns alias work fine.
11. create standby logfile file group on standby database
12.alter the standby database in recover mode : alter database recover managed standby database using current logfile disconnect;
13.on primary alter database open , check select error from v$archive_dest , if no error ,issue the command alter database set standby database to maximize protection;
14.alter database commit to switchover to [primary|physical standby];
15.open a terminal both on primary and standby and tail -f alert log to check the state of database