SQL Select Log - Mode From V$database OR SQL Archive Log List
SQL Select Log - Mode From V$database OR SQL Archive Log List
STANDBY server installed only RDBMS software without any Database. Following below
details:
Primary:
IP Address: 192.168.1.10
DB_NAME=db11g
DB_UNIQUE_NAME=db11g
Standby:
IP Address: 192.168.1.20
DB_NAME=db11g
DB_UNIQUE_NAME=std
Required parameters:
DB_NAME
Must be same on primary and on all standby
DB_UNIQUE_NAME
Must be different on primary and all standby
LOG_ARCHIVE_CONFIG
This parameter includes db_unique_name which are the
part
of
Dataguard
configuration
LOG_ARCHIVE_DEST_n
Define local and remote archive log file location
LOG_ARCHIVE_DEST_STATE_n
Define state of archiving (ENABLE or DIFER)
REMOTE_LOGIN_PASSWORDFILE
Must be in EXCLUSIVE mode
FAL_SERVER
Use for archivelog gap resolution (required only in
physical
standby
server)
DB_FILE_NAME_CONVERT
Required when directory structure is different
datafile
LOG_FILE_NAME_CONVERT
Required when directory structure is different
logfile
STANDBY_FILE_MANAGEMENT
Keep auto to create file automatically on standby
Perform following steps on primary database:
Note:- Make sure primary database is runing in archivelog mode
Check your database mode using following command
SQL> select log_mode from v$database;
OR
SQL> archive log list
If your database is not runing in archivelog mode use following command to change to archive
mode.
SQL> SHU IMMEDIATE;
Now Make DB_UNIQUE_NAME to be part of dataguard. (std service we will create soon)
SQL> alter system set log_archive_config=DG_CONFIG=(db11g,std);
Set fail server and file name convert parameter in case if directory structure is different in
primary and standby database.
SQL>
SQL>
SQL>
SQL>
ALTER
ALTER
ALTER
ALTER
SYSTEM
SYSTEM
SYSTEM
SYSTEM
SET
SET
SET
SET
FAL_SERVER=std;
DB_FILE_NAME_CONVERT=std,db11g scope=spfile;
LOG_FILES_NAME_CONVERT=std,db11g scope=spfile;
STANDBY_FILE_MANAGEMENT=AUTO;
*.remote_login_passwordfile='EXCLUSIVE'
*.standby_file_management='AUTO'
*.undo_tablespace='UNDOTBS1'
After creating appropriate directory on physical standby and copy backupset, archivelog, pfile,
standby controlfile and password file to physical standby database.
#scp /u01/stdcontrol.ctl
[email protected]:/u01/app/oracle/oradata/std/control01.ctl
#scp /u01/stdcontrol.ctl
[email protected]:/u01/app/oracle/fast_recovery_area/std /control02.ctl
Then finish
Std:/u01/app/oracle/product/11.2.0.4/db_1:N
Now exit from SQL prompt and login with RMAN then restore backup
Sql> exit
$rman target=/
RMAN>startup mount
RMAN> restore database;
RMAN> exit
Note:- After finishing restore database we need to create standby redo log file on standby server,
and it should be one extra either then online redo log file.
$sqlplus / as sysdab
SQL> alter database add standby logfile
(/u01/app/oracle/oradata/std/standby_redo01.log)
SQL> alter database add standby logfile
(/u01/app/oracle/oradata/std/standby_redo02.log)
SQL> alter database add standby logfile
(/u01/app/oracle/oradata/std/standby_redo03.log)
SQL> alter database add standby logfile
(/u01/app/oracle/oradata/std/standby_redo04.log)
size 50m;
size 50m;
size 50m;
size 50m;
Note:- we have needed to add four redo log files because we have three online redo log file.
Now check your log members and you can confirm using this command
Note:- Now we need to create same online redolog files on PRIMARY machine also in case you
planing switch the role so if your primary become STANDBY then you need to have STANDBY
redolog files.
So now going on PRIMARY server and add redolog files.
SQL> alter database add standby logfile
(/u01/app/oracle/oradata/db11g/standby_redo01.log)
SQL> alter database add standby logfile
(/u01/app/oracle/oradata/db11g/standby_redo02.log)
SQL> alter database add standby logfile
(/u01/app/oracle/oradata/db11g/standby_redo03.log)
SQL> alter database add standby logfile
(/u01/app/oracle/oradata/db11g/standby_redo04.log)
size 50m;
size 50m;
size 50m;
size 50m;
Now CHECK.
SQL> select member from v$logfile
where type=STANDBY;
Now switch the log file using following command and check its applying on standby server or
not.
SQL> alter system switch logfile;
Then going on STANDBY machine and check redo are going on standby machine or not.
STANDBY:SQL> select sequence#,first_time,next_time,applied from v$archived_log order
by sequence#;
Now going on PRIMARY machine and run switch logfile command one more time.
SQL> alter system switch logfile;
Now check DB mode and protection mode run below command on both machines
SQL> desc v$database
SQL> select name,open_mode,database_role,db_unique_name,protection_mode from
v$database;
After running these all commands your database will be open in read only mode.
Check
SQL> select name,open_mode,database_role,db_unique_name,protection_mode from
v$database;
SQL> select * from scott.emp;
(now you able to read your database)
Now login on PRIMARY machine and run switch log file command
SQL>alter system switch logfile;