Saturday, June 30, 2012

Data Guard - Physical Standby (11g)

A physical standby database is an identical, block-for-block copy of the primary database and is kept in sync with the primary using media recovery. As redo gets generated on the primary database, it gets transferred to the standby database where an RFS process receives the primary redo and applies the change vectors directly to the standby database. A physical standby database is an excellent choice for disaster recovery.
  1. Hardware & OS configurations
  2. Configuring Primary Database
  3. Oracle Net Configuration
  4. Configuring Standby Database
  5. Verifying the Physical Standby
 
1. Hardware & OS configurations
  • Primary Database
      - Oracle Release 11g (11.2.0)
      - Hostname: rhel5401.shannura.com (192.168.1.4)
      - Operating System: RHEL 5.4 (x64)
      - Database Name [DB_NAME]: 'dbuat01'
      - Database domain [DB_DOMAIN]: 'shannura.com'
      - Instance name [INSTANCE_NAME]: 'dbuat01'
      - Database Unique Name [DB_UNIQUE_NAME]: 'dbuat01'
      - TNS Name: 'dbuat01srv'
      - File structure: /u02/oradata/dbuat01
  • Standby Database
      - Oracle Release 11g (11.2.0)
      - Hostname: rhel5402.shannura.com (192.168.1.5)
      - Operating System: RHEL 5.4 (x64)
      - Database Name [DB_NAME]: 'dbuat01'
      - Database domain [DB_DOMAIN]: 'shannura.com'
      - Instance name [INSTANCE_NAME]: 'dbtau01'
      - Database Unique Name [DB_UNIQUE_NAME]: 'dbtau01'
      - TNS Name: 'dbtau01srv'
      - File structure: /u02/oradata/dbtau01
 
2. Configuring Primary Database
 
Let's first create the file structures:
 
# mkdir -p /u02/oradata/dbuat01/
# cd /u02/oradata/dbuat01/
# mkdir -p archived_logs redo data control
 
Ensure the database is running in ARCHIVELOG mode. Because DG is all about archivelogs. Also verify if the database is enabled 'FORCE LOGGING' mode.
 
SQL> select log_mode, force_logging from v$database;

LOG_MODE     FORCE_LOGGING
------------ -------------
ARCHIVELOG   YES
 
Create a password file (e.g. orapwdbuat01). The same file could be copied, renamed (e.g. orapwdbtau01) and used for standby database as well. This ensures the SYS passwords remain identical in both databases.
 
Create STANDBY REDO logs (optional, however good practice). When creating the standby redo logs, it is recommended to have one more standby redo log file group than the number of online redo log file groups on the primary database. In addition, the standby redo log file groups must be the same size as the online redo log file groups.
 
SQL> select group#, type, member from v$logfile order by group#, member

     GROUP# TYPE    MEMBER
 ---------- ------- ------------------------------------------------------------
          1 ONLINE  /u02/oradata/dbuat01/redo/redo_g1_m1.log
          1 ONLINE  /u02/oradata/dbuat01/redo/redo_g1_m2.log
          2 ONLINE  /u02/oradata/dbuat01/redo/redo_g2_m1.log
          2 ONLINE  /u02/oradata/dbuat01/redo/redo_g2_m2.log
          3 ONLINE  /u02/oradata/dbuat01/redo/redo_g3_m1.log
          3 ONLINE  /u02/oradata/dbuat01/redo/redo_g3_m2.log

          4 STANDBY /u02/oradata/dbuat01/redo/redo_g4_m1.log
          4 STANDBY /u02/oradata/dbuat01/redo/redo_g4_m2.log
          5 STANDBY /u02/oradata/dbuat01/redo/redo_g5_m1.log
          5 STANDBY /u02/oradata/dbuat01/redo/redo_g5_m2.log
          6 STANDBY /u02/oradata/dbuat01/redo/redo_g6_m1.log
          6 STANDBY /u02/oradata/dbuat01/redo/redo_g6_m2.log
          7 STANDBY /u02/oradata/dbuat01/redo/redo_g7_m1.log
          7 STANDBY /u02/oradata/dbuat01/redo/redo_g7_m2.log

14 rows selected.
 
initdbuat01.ora
 
[ ----------------------------------< code - expandable on mouseover >----------------------------------- ]
*.audit_file_dest='$ORACLE_BASE/admin/dbuat01/adump'
*.audit_trail='db'
*.compatible='11.2.0'
*.control_files='/u02/oradata/dbuat01/control/control01.ctl','/u02/oradata/dbuat01/control/control02.ctl','/u02/oradata/dbuat01/control/control03.ctl'   
*.db_block_size=4096
*.db_domain='shannura.com'
*.db_name='dbuat01'
*.instance_name='dbuat01'
*.diagnostic_dest='$ORACLE_BASE/admin'
*.global_names=TRUE
*.log_archive_dest_1='location=/u02/oradata/dbuat01/archived_logs'
*.log_archive_format='dbuat01_%t_%s_%r.arc'
*.memory_max_target=1073741824
*.memory_target=1073741824
*.open_cursors=100
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.undo_management='auto'
*.undo_tablespace='undotbs01'
*.log_archive_config='dg_config=(dbuat01,dbtau01)'

# --- primary role parameters ---- #
*.db_unique_name='dbuat01'
*.log_archive_dest_1='location=/u02/oradata/dbuat01/archived_logs valid_for=(all_logfiles,all_roles) db_unique_name=dbuat01'
*.log_archive_dest_2='service=dbtau01srv valid_for=(online_logfiles,primary_role) db_unique_name=dbtau01'
*.log_archive_dest_state_1='enable'
*.log_archive_dest_state_2='defer'  # this must be enabled later
*.service_names='dbuat01srv,dbuat01'

# --- standby role parameters ---- #
*.db_file_name_convert='/dbtau01/','/dbuat01/'
*.log_file_name_convert='/dbtau01/','/dbuat01/'
*.fal_server='dbuat01','dbtau01'
*.fal_client='dbuat01'
*.standby_file_management='auto'
 
Restart the database to effect the parameters' changes. Then perform RMAN backup of the primary database.
 
# rman target sys/mypassword@dbuat01srv

RMAN> backup device type disk format '/u02/oradata/backup/dbuat01/rman/%U' database plus archivelog;
RMAN> backup device type disk format '/u02/oradata/backup/dbuat01/rman/%U' current controlfile for standby;
 
Copy the RMAN backup files from primary host to the standby host.
 
# scp /u02/oradata/backup/dbuat01/rman/* rhel5402:/u02/oradata/backup/dbuat01/rman/
 
 
3. Oracle Net Configuration:
  • listener (primary)
SID_LIST_LISTENER_DBUAT01=
  (SID_LIST=
    (SID_DESC=
      (GLOBAL_DBNAME=dbuat01.shannura.com)
      (ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1)
      (SID_NAME=dbuat01)))

INBOUND_CONNECT_TIMEOUT_LISTENER_DBUAT01 = 0

LISTENER_DBUAT01=
  (DESCRIPTION=
    (ADDRESS_LIST=
      (ADDRESS=(PROTOCOL=tcp)(HOST=rhel5401.shannura.com)(PORT=1521))))
  • listener (standby)
SID_LIST_LISTENER_DBTAU01=
  (SID_LIST=
    (SID_DESC=
      (GLOBAL_DBNAME=dbtau01.shannura.com)
      (ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1)
      (SID_NAME=dbtau01)))

INBOUND_CONNECT_TIMEOUT_LISTENER_DBTAU01 = 0

LISTENER_DBTAU01=
  (DESCRIPTION=
    (ADDRESS_LIST=
      (ADDRESS=(PROTOCOL=tcp)(HOST=rhel5402.shannura.com)(PORT=1521))))
  • Net aliases (primary)
dbuat01srv =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = rhel5401.shannura.com)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = dbuat01.shannura.com)))

dbtau01srv =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = rhel5402.shannura.com)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = dbtau01.shannura.com)))
  • Net aliases (standby)
dbtau01srv =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = rhel5402.shannura.com)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = dbtau01.shannura.com)))

dbuat01srv =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = rhel5401.shannura.com)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = dbuat01.shannura.com)))
 
 
4. Configuring Standby Database:
 
Let's create the file structures as we did for the primary:
 
# mkdir -p /u02/oradata/dbtau01/
# cd /u02/oradata/dbtau01/
# mkdir -p archived_logs redo data control
 
initdbtau01.ora
 
[ ----------------------------------< code - expandable on mouseover >----------------------------------- ]
*.audit_file_dest='$ORACLE_BASE/admin/dbtau01/adump'
*.audit_trail='db'
*.compatible='11.2.0'
*.control_files='/u02/oradata/dbtau01/control/control01.ctl','/u02/oradata/dbtau01/control/control02.ctl','/u02/oradata/dbtau01/control/control03.ctl'   
*.db_block_size=4096
*.db_domain='shannura.com'
*.db_name='dbuat01'
*.instance_name='dbtau01'
*.diagnostic_dest='$ORACLE_BASE/admin'
*.global_names=TRUE
*.log_archive_dest_1='location=/u02/oradata/dbtau01/archived_logs'
*.log_archive_format='dbuat01_%t_%s_%r.arc'
*.memory_max_target=1073741824
*.memory_target=1073741824
*.open_cursors=100
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.undo_management='auto'
*.undo_tablespace='undotbs01'
*.log_archive_config='dg_config=(dbuat01,dbtau01)'

# --- primary role parameters ---- #
*.db_unique_name='dbtau01'
*.log_archive_dest_1='location=/u02/oradata/dbtau01/archived_logs valid_for=(all_logfiles,all_roles) db_unique_name=dbtau01'
*.log_archive_dest_2='service=dbuat01srv valid_for=(online_logfiles,primary_role) db_unique_name=dbuat01'
*.log_archive_dest_state_2='enable'
*.service_names='dbtau01srv,dbtau01'

# --- standby role parameters ---- #
*.db_file_name_convert='/dbuat01/','/dbtau01/'
*.log_file_name_convert='/dbuat01/','/dbtau01/'
*.fal_server='dbuat01','dbtau01'
*.fal_client='dbtau01'
*.standby_file_management='auto'
 
Starting up the standby instance:
 
# export ORACLE_SID=dbtau01
# sqlplus / as sysdba
 
SQL> startup nomount
 
Let's duplicate the primary database using RMAN:
 
# rman target sys/mypassword@dbuat01srv auxiliary sys/mypassword@dbtau01srv

RMAN> duplicate target database for standby;
 
Start Redo Apply on the standby database
 
SQL> alter database recover managed standby database disconnect;
 
 
5. Verifying the Physical Standby Database:
 
In the primary database, modify the 'LOG_ARCHIVE_DEST_STATE_2' parameter.
 
SQL> alter system set log_archive_dest_state_2 = enable scope=both;
 
Perform a couple of log switches in the primary database and then verify the transmissions of the archived redo log file was successful. VALID indicates successful.
 
SQL> select status, error from v$archive_dest where dest_id = 2;
 
STATUS  ERROR
----------  -------------------------------
VALID
 
Then, verify Redo Apply on the standby database:
 
# sqlplus sys/mypassword@dbtau01srv as sysdba

SQL> alter session set nls_date_format = 'DD-MON-YYYY HH24:MI:SS';
SQL> select sequence#, first_time, next_time, archived, applied from v$archived_log order by sequence#;
 
Verifying the alertlog of the standby database
 
# tail -f alert_dbtau01.log
 
[ Top ]
 
Last modified: Jul 03, 2012 10:42 IST

Friday, June 29, 2012

'less' Command

The navigation keys in 'less' command are similar to Vim editor. Let's look at few navigation commands.
 
Forward & backward pattern search
  • / - search for a pattern which will take you to the next occurrence
  • ? - search for a pattern which will take you to the previous occurrence
  • n - for next match in forward (using /) or backward direction (using ?)
  • N - for next match in backward (using /) or forward direction (using ?)
 
Screen navigation
  • j - navigate one line down
  • k - navigate one line up
  • h - navigate one character left
  • l - navigate one character right
  • w - navigate one word right
  • b - navigate one word left
  • G - End of file
  • g - Beginning of file
  • q - quit less pager
  • F - Simulate 'tail -f' inside less pager (this might come very handy, because when you open a file using less command, any content that is being appended will not be displayed automatically. Using 'F' command, we can tail the active file which is similar to 'tail -f'. By pressing [Ctrl+C], you will be back to the normal less pager)
  • [Ctrl + F] - forward one window
  • [Ctrl + B] - backward one window
  • [Ctrl + D] - forward half window
  • [Ctrl + U] - backward half window
  • [Ctrl + G] - show the current file name along with line, byte and percentage statistics
  • 10j - 10 lines forward
  • 10k - 10 lines backward
  • v - toggle between the vi editor back and forth
  • h - summary of less commands
  • &pattern - display only the matching lines, not all
 
Working with multiple files
 
Multiple files can be opened by passing file names as arguments as shown below:
 
# less file1 file2
 
While viewing file1, use :e to open another file as shown below:
 
# less file1
  :e file2
 
Navigate between the files using:
  • :n - go to the next file
  • :p - go to the previous file
 
[ Top ]

Template (used across this blog)

Oracle Database Server (Head1)
Oracle Appliction SErer (Head2)
Business Intelligence (Head3)
 
An Oracle Server consists of a database and an instance. Although, it’s quite common among the practitioners to use the terms instance and database interchangeably, they are different but related entities. The term database refers to the physical storage of information and instance refers to the memory structures and several background processes running on the server that provides access to the information in the database.
 
Forward Search
  1. / - search for a pattern which will take you to the next occurrence
  2. n - for next match in forward
  3. N - for previous match in backward
Your code must go here...
 
The Data Guard discussed in this guide is configured for 'Maximum Performance' mode. Log Transport Services (LTS) enables and controls the automated transfer of redo data within a DG configuration from primary to standby site.  
 
Row continuous here...
The Data Guard discussed in this guide is configured for 'Maximum Performance' mode. Log Transport Services (LTS) enables and controls the automated transfer of redo data within a DG configuration from primary to standby site. ...More
Tips:
The Data Guard discussed in this guide is configured for 'Maximum Performance' mode. Log Transport Services (LTS)..
 
Last modified: Jul 03, 2012 10:36 IST