Monday, August 1, 2011

Creating Physical Database in 11g using active database in text mode


Creating a physical standby database:

1.       Primary Database: orcl1 on node1
Standby Database: orcl2 on node2
2.       Create a database by the global database name of orcl and Oracle SID=orcl1
As a result if you look into the initorcl.ora file of primary database you will see the following parameter values:
db_name=orcl
db_unique_name=orcl1
3.       Open the netmgr on the node1 and make a static entry for the orcl database and the orcl1 database.Keep in mind that both of them will have the same entry.
4.       Open the netmgr on the node1 and make a static entry for the orcl database and the orcl2 database.Keep in mind that both of them will have the same entry.
5.       Make a service using netmgr in the node1 called orcl1 and orcl2:
orcl1 -> orcl1
orcl2 -> orcl2
6.       Make a service using netmgr in the node2 called orcl1 and orcl2:
orcl1 -> orcl1
orcl2 -> orcl2
7.       Enable archiving on the primary database:
SQL> connect sys/oracle@orcl1 as sysdba
SQL> shutdown immediate
SQL> startup mount
SQL> alter database archivelog;
SQL> alter database open;
8.       Enable flash back database on the primary database:
SQL> alter database flashback on;
9.       Next add some standby log files in the orcl1:
SQL>conn sys/oracle@orcl1 as sysdba
SQL>  alter database add standby logfile=’/u01/app/oracle/oradata/orcl/srl01.log’ size 3G;
SQL>  alter database add standby logfile=’/u01/app/oracle/oradata/orcl/srl02.log’ size 3G;
SQL>  alter database add standby logfile=’/u01/app/oracle/oradata/orcl/srl03.log’ size 3G;
10.   Make the following addition to the primary database:
SQL>conn sys/oracle@orcl1 as sysdba
SQL> ALTER SYSTEM SET LOG_ARCHIVE_CONFIG=’dg_config=(orcl1,orcl2)’;
SQL> ALTER SYSTEM SET log_archive_dest_2=’service=orcl2 async  valid_for=(online_logfiles,primary_role) db_unique_name=orcl2’;
SQL>ALTER SYSTEM SET fal_client=’orcl1’;
SQL> ALTER SYSTEM SET fal_server=’orcl2’;
SQL> ALTER SYSTEM log_archive_dest_state_2=’enable’;
11.   Increase the size of the flash recovery area of orcl1:
SQL> connect sys/oracle@orcl1
SQL>alter system set db_recovery_file_dest_size=5G;
12.   Copy the password from the node1 to the same location in the node2:
/u01/app/oracle/product/11.2.0/db_1/dbs/pwdorcl1.ora -> /u01/app/oracle/product/11.2.0/db_1/dbs/pwdorcl2.ora
13.   Create a pfile in the node2 with only entry suppose /u01/initorcl2.ora:
db_name=orcl
14.   Create the following directories manually on node2:
/u01/app/oracle/admin/orcl
/u01/app/oracle/admin/orcl/adump
/u01/app/oracle/oradata/orcl
15.   Startup the standby database in nomount state using the pfile created in step 11.
SQL> connect sys/oracle@orcl2 as sysdba
SQL> startup pfile=’/u01/initorcl2.ora’ nomount
16.   Restart the listener on both the database:
$ lsnrctl stop
$ lsnrctl start
17.   From the primary database use the following commands:
 $ rman
RMAN> connect target sys/oracle@orcl1
RMAN> connect auxiliary sys/oracle@orcl2
18.   Run the following rman script to perform the standby creation:
RMAN> run{
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
allocate channel c4 type disk;
allocate auxiliary channel stby type disk;
duplicate target database for standby from active database
spfile
parameter_value_convert ‘orcl1’,’orcl2’
set db_unique_name=’orcl2’
set control_files=’/u01/app/oracle/oradata/orcl/control01.ctl’
set log_archive_max_processes=’5’
set fal_client=’orcl2’
set fal_server=’orcl1’
set log_archive_config=’dg_config=(orcl1,orcl2)’
set log_archive_dest_2=’service=orcl1 async valid_for=(ONLINE_LOGFILES,PRIMARY_ROLE) db_unique_name=orcl1’
;
}
19.   Once the standby database has been created check if the standby database is in archivelog mode and flashback database is on. If not set them up in the standby database.
20.   Testing the dataguard configuration:
In the primary database execute some log switch:
SQL> connect sys/oracle@orcl1 as sysdba
SQL> ALTER DATABASE SWITCH LOGFILE;
SQL> ALTER DATABASE SWITCH LOGFILE;
SQL> ALTER DATABASE SWITCH LOGFILE;
Execute the following command to check if the logfiles have been applied:
SQL> SELECT sequence#, applied from v$archived_log order by sequence#;
If there are any archivelog files that are not applied to the standby the execute the following command in the standby to perform recovery of the standby:
SQL> connect sys/oracle@orcl2
SQL>ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT;
Reconnect to the primary database and recheck if the archives are getting transported and applied using the command:
SQL>connect sys/oracle@orcl1 as sysdba
SQL> SELECT sequence#, applied from v$archived_log order by sequence#;

No comments:

Post a Comment