11gR2 ASMCMD Commands

April 2, 2018 | Author: Ashok Thiyagarajan | Category: Oracle Database, Computer File, Databases, Backup, Application Programming Interface


Comments



Description

11gR2 ASMCMD commandschdg - Changes existing disk group (add disks, drop disks, or rebalance) based on XML configuration file. You can use ALTER DISKGROUP... commands for same too, but here we are learning ASMCMD commands extensions in 11gr2. The chdg command add disks, delete disks or set rebalance power level on an existing disk group. Syntax : chdg {config_file.xml | 'contents_of_xml_file'} XML configuration template <chdg> update disk clause (add/delete disks/failure groups) name disk group to change power power to perform rebalance <add> items to add are placed here </add> <drop> items to drop are placed here </drop> <fg> failure group name failure group name </fg> <dsk> diskname disk name path disk path size size of the disk to add </dsk> </chdg> Example: We will add disk /dev/disk/disk61 to existing disk group DISK and set rebalance power level to 4. find existing disk in a disk group DATA SQL> select name,path from v$asm_disk where group_number=1; NAME PATH --------------- ----------------DATA_0000 /dev/rdisk/disk50 DATA_0001 /dev/rdisk/disk51 DATA_0002 /dev/rdisk/disk60 Create following XML configuration file and save it as adddsk.xml <chdg name="data" power="4"> <add> <dsk string="/dev/rdisk/disk61"/> </add> </chdg> and execute following $asmcmd ASMCMD>chdg adddsk.xml ASMCMD> Now check again to see disks in DATA disk group SQL> select name,path from v$asm_disk where group_number=1; NAME PATH --------------- ----------------DATA_0000 /dev/rdisk/disk50 DATA_0001 /dev/rdisk/disk51 DATA_0002 /dev/rdisk/disk60 DATA_0003 /dev/rdisk/disk61 <--- New disk added Lets drop this disk with chdg command. You can use ALTER DISKGROUP DATA DROP DISK command too. Create a XML file <chdg name="data" power="4"> <drop> <dsk name="DATA_0003"/> </drop> </chdg> and save it as dropdsk.xml and execute following. $asmcmd ASMCMD>chdg adddsk.xml ASMCMD> Now check again to see disks in DATA disk group SQL> select name,path from v$asm_disk where group_number=1; NAME PATH --------------- ----------------DATA_0000 /dev/rdisk/disk50 DATA_0001 /dev/rdisk/disk51 DATA_0002 /dev/rdisk/disk60 DATA_003 disk name no longer exits!!! chkdg - Checks or repairs a disk group. The 11gR2 ASM CHECK command checks for    The disks consistency The alias directory is linked correctly All metadata directories and internal consistency of ASM disk group metadata. It writes findings in alert logs and display them on database control page too.In 11gR2 the default is norepair Syntax : chkdg [--repair] <<diskgroupname>> Example: ASMCMD> chkdg data ASMCMD> The following are the contents from ASM alert log file ... ... SQL> /* ASMCMD */ALTER DISKGROUP data CHECK NOREPAIR NOTE: starting check of diskgroup DATA kfdp_checkDsk(): 6 kfdp_checkDsk(): 7 kfdp_checkDsk(): 8 SUCCESS: check of diskgroup DATA found no errors SUCCESS: /* ASMCMD */ALTER DISKGROUP data CHECK NOREPAIR ... ... mkdg -Creates a disk group based on XML configuration file Syntax : mkdg {config_file.xml | 'contents_of_xml_file'} XML configuration template <dg> disk group name disk group name redundancy normal, external, high <fg> failure group name failure group name </fg> <dsk> disk name disk name path disk path size size of the disk to add </dsk> <a> attribute name attribute name value attribute value </a> </dg> Example: Create new disk group DATA2 First, create a XML configuration file with external redundancy and save it as mkdg.xml <dg name="data2" redundancy="external"> <dsk string="/dev/rdisk/disk61"/> <a name="compatible.rdbms" value="10.2"/> </dg> $ls -l mkdg.xml -rw-r--r-- 1 oracle oinstall 86 Nov 20 10:59 mkdg.xml $asmcmd ASMCMD>mkdg mkdg.xml ASMCMD> ASMCMD> lsdg State Type Rebal Sector Block AU Total_MB Free_MB Req_mir_free_MB Usable_file_MB Offline_disks Voting_files Name MOUNTED EXTERN N 1024 4096 1048576 80896 78196 0 78196 0 N DATA/ MOUNTED EXTERN N 1024 4096 1048576 76800 76750 0 76750 0 N DATA2/ lsdsk - Lists Oracle ASM Disks. It runs in connected mode first and pulls information from v$ASM_DISK_STAT and v$ASM_DISK dynamic views otherwise it runs in disconnected mode and pulls information from disk header. The -I option forces non-connected mode. Syntax : lsdsk {-kptgMHI}{-G diskgroup } { --member|--candidate} {--discovery}{--statistics}{pattern} -k:Displays the TOTAL_MB, FREE_MB, OS_MB,NAME, FAILGROUP, LIBRARY, LABEL, UDID, PRODUCT, REDUNDANCY, and PATH columns of the V$ASM_DISK view. --statistics: Displays the READS, WRITES, READ_ERRS, WRITE_ERRS, READ_TIME, WRITE_TIME, BYTES_READ, BYTES_WRITTEN, and the PATH columns of the V$ASM_DISK view. -p:Displays the GROUP_NUMBER, DISK_NUMBER, INCARNATION, MOUNT_STATUS, HEADER_STATUS, MODE_STATUS, STATE, and the PATH columns of the V$ASM_DISK view. -t:Displays the CREATE_DATE, MOUNT_DATE, REPAIR_TIMER, and the PATH columns of the V$ASM_DISK view. -g:Selects from GV$ASM_DISK_STAT, or from GV$ASM_DISK if the -discovery flag is also specified. GV$ASM_DISK.INST_ID is included in the output. --discovery:Selects from V$ASM_DISK, or from GV$ASM_DISK if the -g flag is also specified. This option is always enabled if the Oracle ASM instance is version 10.1 or earlier. This flag is disregarded if lsdsk is running in nonconnected mode. -H:Suppresses column headings. -I:Scans disk headers for information rather than extracting the information from an Oracle ASM instance. This option forces non-connected mode. -G:Restricts results to only those disks that belong to the group specified by diskgroup. -M:Displays the disks that are visible to some but not all active instances. These are disks that, if included in a disk group, cause the mount of that disk group to fail on the instances where the disks are not visible. --candidate: Restricts results to only disks having membership status equal to CANDIDATE. --member:Restricts results to only disks having membership status equal to MEMBER. pattern: Returns only information about the specified disks that match the supplied pattern. 026287 3.Example 1: $ asmcmd ASMCMD> lsdsk Path /dev/rdisk/disk50 /dev/rdisk/disk51 /dev/rdisk/disk60 /dev/rdisk/disk61 Example 2: The following command display disk attached to disk group DATA2 and their space information.841985 77824 1830912 N 20-NOV-10 20-NOV-10 0 /dev/rdisk/disk61 Example 4: The following displays disks attached to DATA2 and DATA disk groups ASMCMD> lsdsk -G DATA2 Path /dev/rdisk/disk61 ASMCMD> lsdsk -G DATA Path /dev/rdisk/disk50 /dev/rdisk/disk51 /dev/rdisk/disk60 ASMCMD> dropdg -Drops a disk group. DROP diskgroup command marks the headers of disks belonging to a diskgroup that cannot be mounted by ASM as . ASMCMD> lsdsk -k -G DATA2 Total_MB Free_MB OS_MB Name Failgroup Library Label UDID Product Redund Path 76800 76750 76800 DATA2_0000 DATA2_0000 System UNKNOWN /dev/rdisk/disk61 Example 3: The following shows io statistics for disks in DATA2 disk group ASMCMD> lsdsk -t -G DATA2 --statistics Reads Write Read_Errs Write_Errs Read_time Write_Time Bytes_Read Bytes_Written Voting_File Create_Date Mount_Date Repair_Timer Path 18 447 0 0 . -f Forces the dismount operation. Syntax: dropdg { -r -f } { -r } <<diskgroup>> Example: ASMCMD> dropdg data2 ORA-15039: diskgroup not dropped ORA-15053: diskgroup "DATA2" contains existing files (DBD ERROR: OCIStmtExecute) ASMCMD>dropdg -r data2 ASMCMD> iostat -Displays I/O statistics for disks. If the --discovery flag is specified. . The -f(Force) with INCLUDING CONTENTS should be used with caution as this will not check if diskgroup is being used by any other ASM instance and it will clear all disks in that diskgroup. the V$ASM_DISKGROUP is queried instead. Example: ASMCMD> lsdg State Type Rebal Sector Block AU Total_MB Free_MB Req_mir_free_MB Usable_file_MB Offline_disks Voting_files Name MOUNTED EXTERN N 1024 4096 1048576 80896 78196 0 78196 0 N DATA/ MOUNTED EXTERN N 1024 4096 1048576 76800 76750 0 76750 0 N DATA2/ umount -Dismounts a disk group Syntax: umount { -a | [-f] diskgroup } -a Dismounts all mounted disk groups. If diskgroup is being used by any other nodes or ASM instance then this dropdg command fails. The -r (INCLUDING CONTENTS) option of dropdg will drop the diskgroup and files if diskgroup is empty .FORMER.The lsdg command queries V$ASM_DISKGROUP_STAT by default. lsdg -Displays disk groups and their information. If you are running RAC then MOUNT RESTRICT will mount diskgroup exclusively on that instance and clients cannot access files in that diskgroup until it mounted back in normal mode. lets mount DATA2 disk group in restrict mode again and then unmount and mount in normal mode. Syntax: mount [--restrict] { [-a] | [-f] diskgroup[ diskgroup . Example: In the previous example of unmount command we left DATA2 in unmounted stage.Example: The following example first checks the disk group with lsdg command and then unmount the data2 diskgroup... ASMCMD> lsdg State Type Rebal Sector Block AU Total_MB Free_MB Req_mir_free_MB Usable_file_MB Offline_disks Voting_files Name .You can mount ASM diskgroup in restrict mode for mainitance/rebalnace operations and during this mode client cannot access files in that diskgroup. ASMCMD> lsdg State Type Rebal Sector Block AU Total_MB Free_MB Req_mir_free_MB Usable_file_MB Offline_disks Voting_files Name MOUNTED EXTERN N 1024 4096 1048576 80896 78196 0 78196 0 N DATA/ MOUNTED EXTERN N 1024 4096 1048576 76800 76750 0 76750 0 N DATA2/ ASMCMD> umount data2 ASMCMD> lsdg State Type Rebal Sector Block AU Total_MB Free_MB Req_mir_free_MB Usable_file_MB Offline_disks Voting_files Name MOUNTED EXTERN N 1024 4096 1048576 80896 78196 0 78196 0 N DATA/ ASMCMD> mount : Mounts a disk group. You will see data2 is unmounted if you run lsdg command again. -f Forces the mount operation.] } -a Mounts all disk groups. Why in restricted mode? It improve the rebalance operation performace as there are no external connections to the disk group. --restrict Mounts in restricted mode. You won't be able to take disk offline in a disk group with external redundancy Syntax: offline -G diskgroup { -F failgroup |-D disk} [-t {minutes | hours}] -G diskgroup Disk group name.Offline disks or failure groups that belong to a disk group. Example: Lets add a disk to disk group2 with chdg command. where m specifies minutes and h specifies hours. -t minutes | hours Specifies the time before the specified disk is dropped as nm or nh. offline . -D disk Specifies a single disk name. ASMCMD> chdg adddsk. The default unit is hours.xml . -F failgroup Failure group name.MOUNTED EXTERN N 1024 4096 1048576 80896 78196 0 78196 0 N DATA/ ASMCMD> ASMCMD> mount --restrict DATA2 ASMCMD> lsdg State Type Rebal Sector Block AU Total_MB Free_MB Req_mir_free_MB Usable_file_MB Offline_disks Voting_files Name MOUNTED EXTERN N 1024 4096 1048576 80896 78196 0 78196 0 N DATA/ RESTRICTED EXTERN N 1024 4096 1048576 76800 76750 0 76750 0 N DATA2/ The state in above showing output showing RESTRICTED for DATA2 ASMCMD> umount data2 ASMCMD> mount data2 ASMCMD> lsdg State Type Rebal Sector Block AU Total_MB Free_MB Req_mir_free_MB Usable_file_MB Offline_disks Voting_files Name MOUNTED EXTERN N 1024 4096 1048576 80896 78196 0 78196 0 N DATA/ MOUNTED EXTERN N 1024 4096 1048576 76800 76750 0 76750 0 N DATA2/ DATA2 is removed from RESTRICTED mode. ASMCMD> lsdsk -G DATA2 Path /dev/rdisk/disk61 /dev/rdisk/disk62 <-. rebal . If the rebalance power is not specified.Online all disks. -w Wait option. The default is not waiting. -F failgroup Failure group name. Causes ASMCMD to wait for the disk group to be rebalanced before returning control to the user.Rebalances a disk group and it's useful if you have added some disks to a diskgroups to load balance I/O. Syntax : online { [-a] -G diskgroup | -F failgroup |-D disk} [-w] -a Online all offline disks in the disk group. -D disk Disk name. -G diskgroup Disk group name.New disk added ASMCMD> ASMCMD> lsdsk -k -G data2 Total_MB Free_MB OS_MB Name Failgroup Library Label UDID Product Redund Path 76800 76774 76800 DATA2_0000 DATA2_0000 System UNKNOWN /dev/rdisk/disk61 76800 76774 76800 DATA2_0001 DATA2_0001 System UNKNOWN /dev/rdisk/disk62 ASMCMD> offline -G data2 -D data2_0001 ORA-15067: command or option incompatible with diskgroup redundancy (DBD ERROR: OCIStmtExecute) ASMCMD> online . You can determine if a rebalance operation is occurring with the ASMCMD . or a failure group that belongs to a disk group.The power level can be set from 0 to 11. the value defaults to the setting of the ASM_POWER_LIMIT initialization parameter. A value of 0 disables rebalancing. a single disk. HALT : Halted by Admins. .REAP : Rebalance operation stopped. Causes ASMCMD to wait for the disk group to be rebalanced before returning control to the user.rebalance is currently running.lsop command Syntax: rebal [--power power] [-w] diskgroup --power power Power setting (0 to 11).Wait : No rebalance is running or wait period is specified by Admins .means no rebalance activity completed. ASMCMD> lsop Group_Name Dsk_Num State Power <--. ASMCMD> lsop Group_Name Dsk_Num State Power <--.. ..means no rebalance activity is going on ASMCMD> lsdg State Type Rebal Sector Block AU Total_MB Free_MB Req_mir_free_MB Usable_file_MB Offline_disks Voting_files Name MOUNTED EXTERN N 1024 4096 1048576 80896 78196 0 78196 0 N DATA/ MOUNTED EXTERN N 1024 4096 1048576 153600 153548 0 153548 0 N DATA2/ ASMCMD> ASMCMD> rebal --power 4 data2 ASMCMD> lsop Group_Name Dsk_Num State Power DATA2 REBAL WAIT 4 <--. Example: The following example rebalance the data2 disk group power level set to 4 from 0. md_backup. The default is not waiting.ERRORS : Errors during rebalance operations and halted. -w Wait option. The STATE can be one of the followings: . . . md_restore: Create backup file on a filesystem for asm disk group metadata information you can restore this backup file by md_restore command of ASMCMD.Run : Rebalance is running. We will restore DATA2 and it's directory tree with md_restore and tablespace datafiles from the RMAN backup.. Use SET newname for datafile <<fileno#>> to <<new diskgroup>> or db_file_name_convert option to restore these files to new disk group. Recreate ASM diskgroup manually and other user defined directory structures inside that diskgroup. ORA-17502: ksfdcre:4 Failed to create file . ORA-15001: diskgroup "DATA" does not exist or is not mounted You have two options to restore : 1...Syntax: md_backup -b <<backupfilename>> -G <<diskgroup>> When you restore RMAN backup to a lost diskgroup or to a different server you will get errors something like ORA-01119: error in creating database file . ASMCMD> cd DATA2 ASMCMD>mkdir mydir1 ASMCMD>mkdir mydir2 ASMCMD>ls -l Type Redund Striped Time Sys Name N mydir2/ N mydir1/ ASMCMD> cd mydir1 ASMCMD> cd mydir1 ASMCMD> ls -l ASMCMD>mkdir ts1_dir ASMCMD>mkdir ts2_dir ASMCMD>ls -l Type Redund Striped Time Sys Name N ts1_dir/ N ts2_dir/ Create a tablespace and create one table inside it. 2. Example: For this example I will create different directories paths and one tablespace ts1 with 2 datafiles on DATA2 disk group. Let try this with this example. DATA2 diskgroup metadata backup. .. We will take a tablespace backup. RMAN> run { 2> allocate channel c1 type disk. Tablespace created.dbf' size 1m. Tablespace altered SQL> connect scott/tiger SQL> create table test tablespace ts1 as select * from user_objects.dbf' size 2m.1 oracle oinstall 13418 Nov 20 13:03 data2aasm_backup Take RMAN tablespace ts1 backup with following commands.SQL> create tablespace ts1 datafile '+DATA2/test1. 4> } using target database control file instead of recovery catalog allocated channel: c1 channel c1: sid=51 instance=TEST1 devtype=DISK Starting backup at 20-NOV-10 channel c1: starting full datafile backupset . Table created SQL> select count(1) from test. COUNT(1) ---------7 Take the ASM DATA2 diskgroup metadata backup ASMCMD> md_backup data2asm_backup -G DATA2 Disk group metadata to be backed up: DATA2 Current alias directory path: mydir1/ts2_dir Current alias directory path: mydir1 Current alias directory path: mydir2 Current alias directory path: mydir1/ts1_dir Current alias directory path: TEST Current alias directory path: TEST/DATAFILEST/DATAFILE ASMCMD> exit $ ls -lt -rw-r--r-. 3> backup tablespace ts1 format "/backup/test/ts1_%s_%t". SQL> alter tablespace ts1 add datafile '+DATA2/ts2. 3> restore tablespace ts1 .channel c1: specifying datafile(s) in backupset input datafile fno=00007 name=+DATA2/ts2. $asmcmd ASMCMD> dropdg data2 ORA-15039: diskgroup not dropped ORA-15053: diskgroup "DATA2" contains existing files (DBD ERROR: OCIStmtExecute) ASMCMD>dropdg -r data2 ASMCMD> SQL>connect scott/tiger SQL> select * from test. 4> } . Now drop the DATA2 disk group with force option. select * from test * ERROR at line 1: ORA-00376: file 6 cannot be read at this time ORA-01110: data file 6: '+DATA2/ts1. Tablespace altered. RMAN> run { 2> allocate channel c1 type disk format '/backup/test/ts1_%s_%t' . elapsed time: 00:00:01 Finished backup at 20-NOV-10 released channel: c1 RMAN> RMAN> RMAN> **end-of-file** SQL> alter tablespace ts1 offline.dbf channel c1: starting piece 1 at 20-NOV-10 channel c1: finished piece 1 at 20-NOV-10 piece handle=/backup/test/ts1_11_735580273 tag=TAG20101120T155112 comment=NONE channel c1: backup set complete.dbf' It's time to restore ts1 tablespace files from RMAN backup.dbf input datafile fno=00006 name=+DATA2/ts1. $ asmcmd ASMCMD> md_restore disk2asm_backup Current Diskgroup metadata being restored: DATA2 Diskgroup DATA2 created! System template ONLINELOG modified! System template AUTOBACKUP modified! System template ASMPARAMETERFILE modified! System template OCRFILE modified! System template ASM_STALE modified! System template OCRBACKUP modified! System template PARAMETERFILE modified! System template ASMPARAMETERBAKFILE modified! System template FLASHFILE modified! System template XTRANSPORT modified! System template DATAGUARDCONFIG modified! System template TEMPFILE modified! System template ARCHIVELOG modified! System template CONTROLFILE modified! System template DUMPSET modified! System template BACKUPSET modified! System template FLASHBACK modified! System template DATAFILE modified! System template CHANGETRACKING modified! Directory +DATA2/mydir1 re-created! Directory +DATA2/TEST re-created! Directory +DATA2/mydir2 re-created! Directory +DATA2/mydir1/ts2_dir re-created! Directory +DATA2/mydir1/ts1_dir re-created! Directory +DATA2/TEST/DATAFILE re-created! ASMCMD> Restore tablespace ts1 datafiles from RMAN backups RMAN> run { 2> allocate channel c1 type disk format '/backup/test/ts1_%s_%t' . 3> restore tablespace ts1 . .Lets use ASM md_restore command to create DATA2 diskgroup from backup. 4> } SQL> alter tablespace ts1 online. This will restore all the metadata information and create directory structure. Tablespace altered. Media recovery complete. 10g Example: In 10gR2 this is how you need to setup FTP with Oracle XMLDB .dbf' SQL> recover tablespace ts1.use ftp to move files between ASM and filesystem FTP> open <<hostname>> 7777 331 pass required for SYSTEM Password: 230 SYSTEM logged in ftp> Relax! in 11g you can move files just by using cp command 11gR2 example 11gR2 Example: .Connect to Oracle instance as sys and execute @ORACLE_HOME/rdbms/admin/catxdbdbca 7777 8080 This will enable ftp on port 7777 and http service on port 8080 .alter tablespace ts1 online * ERROR at line 1: ORA-01113: file 6 needs media recovery ORA-01110: data file 6: '+DATA2/ts1. SQL> select count(1) from test. COUNT(1) ---------7 cp . SQL> alter tablespace ts1 online.It's going to make your life so easy when moving database across different servers. SQL> alter tablespace ts1 online. Tablespace altered. In eairler release you have to use either RMAN command or setup FTP to move files between. It allows you to copy files between ASM diskgroup and OS filesystem. SQL> connect scott/tiger Connected. . Shutdown the database and start the instance: SQL> shutdown normal SQL> startup nomount 3. NAME -------------------------------------------------------------------------------/oradata2/102b/oradata/P10R2/control01.735585509 ASMCMD> Duplicating a controlfile into ASM Duplicating a controlfile into ASM when original controlfile is stored on a file system On the database instance: 1. Use RMAN to duplicate the controlfile: $ rman nocatalog RMAN>connect target RMAN>restore controlfile to '' from ''.$ ls -l -rw-r----.304. Identify the location of the current controlfile: SQL> select name from v$controfile.1 oracle oinstall 212992 Nov 20 15:51 ts1_11_735580273 $ asmcmd ASMCMD> cp /backup/test/ts1_11_735580273 +DATA/ copying /backup/test/ts1_11_735580273 -> +DATA/ts1_11_735580273 ASMCMD> cd +DATA ASMCMD> ls -l Type Redund Striped Time Sys Name Y ASM/ Y TEST/ N archlogs/ Y test-mvip/ N ts1_11_735580273 => +DATA/ASM/BACKUPSET/ts1_11_735580273.ctl' 2. On the ASM instance. identify the name of the controlfile: Using ASMCMD: $ asmcmd ASMCMD> cd ASMCMD> find -t controlfile .RMAN> restore controlfile to '+DG1' from '/oradata2/102b/oradata/P10R2/control01.ora or spfile. adding the new path to parameter control_files. * +DG1/P10R2/CONTROLFILE/backup.577785757 ASMCMD> Note the name assigned to the controlfile. Use ASMCMD or sqlplus to identify the name assigned to the controlfile 4. On the database side: Modify init. so Oracle will create an OMF (Oracle Managed File). just modify the control_files parameter and restart the database. This just the name assigned for the identical copy of the current controlfile. .ora. Starting restore at 23-DEC-05 allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=156 devtype=DISK channel ORA_DISK_1: copied control file copy Finished restore at 23-DEC-05 We are only specifying the name of the diskgroup. Output: ASMCMD> find -t controlfile . * Changing the current directory to the diskgroup where the controlfile was created will speed the search. if using init. Although the name starts with the backup word. that does not indicate is a backup of the file.308.ctl'. 5. 577785757'. the controlfile is duplicated into a new diskgroup where controlfiles have not been created before. so it is only required to create the directory for the controlfile.'/oradata2/102b/oradata /P10R2/control01.ctl' scope=spfile. Asumming that other OMF files were created on the diskgroup. . If the new controlfile was not used. Create the directory to store the new controlfile.308. Note that ASM uses directories to store the files and those are created automatically when using OMF files. (just specifying the diskgroup name). SQL> alter diskgroup add directory '+//CONTROLFILE'. On the ASM instance: A.If using spfile. Duplicating a controlfile into ASM using a specific name It is also possible to duplicate the controlfile using a specific name for the new controlfile. 3) shutdown immediate start the instance. the first directory (DB_NAME) already exist. Verify that new control file has been recognized.'/oradata2/102b/oradata /P10R2/control01. 1) startup nomount the database instance 2) alter system set control_files='+DG1/P10R2/CONTROLFILE/backup.ctl' scope=spfile sid='*'. In the following example.308. the complete procedure needs to be repeated.577785757'. For RAC instance: alter system set control_files='+DG1/P10R2/CONTROLFILE/backup. ctl' from '/oradata2/102b/oradata/P10R2/control01.ctl'. RMAN> restore controlfile to '+DG1/PROD/controlfile/control02.ctl' C. ASMCMD can also be used ASMCMD>cd dg1 ASMCMD>mkdir controlfile On the database instance: B.ora or spifile and modify parameter control_file: control_files='+DG1/P10R2/CONTROLFILE/control02. Shutdown the database and start the instance: SQL> shutdown normal SQL> startup nomount E.SQL> alter diskgroup DG1 add directory '+DG1/P10R2/CONTROLFILE'.'/oradata2/102b/oradata/P10R2 /control01. Edit init. Use RMAN to duplicate the controlfile: $ rman nocatalog RMAN>connect target RMAN>restore controlfile to '' from ''. NAME -------------------------------------------------------------------------------/oradata2/102b/oradata/P10R2/control01. Identify the location of the current controlfile: SQL> select name from v$controfile.ctl'. Starting restore at 23-DEC-05 allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=156 devtype=DISK .ctl' D. Start the database: SQL> alter database mount. duplicate the controlfile $ rman nocatalog RMAN>connect target RMAN> restore controlfile from '+DATA1/v102/controlfile/current. Now. Duplicating a controlfile into ASM when original controlfile is stored on ASM If using spfile to start the instance: 1. sql> alter system set control_files='+DATA1/v102/controlfile/current. In this example. using ASMCMD to search for information for the controlfiles.261. the find -t contrlfile command will return two records.channel ORA_DISK_1: copied control file copy Finished restore at 23-DEC-05 F.'+ DATA1' scope=spfile sid='*'. The name specified is an alias name and is only an entry in the ASM metadata (V$ASM_ALIAS). a second controlfile is going to be created on same diskgroup DATA1. SQL> alter database open. Start the instance in NOMOUNT mode. From rman.637923577'. 3. The output for the execution is like: Starting restore at 08-NOV-07 allocated channel: ORA_DISK_1 . Modify the spfile specifically the parameter control_files. That does not indicate there were created two controlfiles. 2.261.637923577'. Oracle will create the alias and the OMF entry when user specifies the file name. 269.637923577'.261. Modify the control_file parameter with the complete path of the new file: sql> alter system set control_files='+DATA1/v102/controlfile/current.269. RMAN> sql 'alter database open. Mount and Open the database RMAN> sql 'alter database mount'.638120375 6.638120375' scope=spfile sid='*'. Next time instance are restarted. When using init.638120375 Finished restore at 08-NOV-07 Note that the command prints the name of the new created file: +DATA1/v102/controlfile/current.638120375 4. 5. Validate both controlfiles are present SQL> select name from v$controlfile. NAME -------------------------------------------------------------------------------+DATA1/v102/controlfile/current.ora and add new disk group name or same disk group name for mirroring .269.637923577 +DATA1/v102/controlfile/current. will pick both files.'+ DATA1/v102/controlfile/current.261.269.channel ORA_DISK_1: sid=147 instance=V1021 devtype=DISK channel ORA_DISK_1: copied control file copy output filename=+DATA1/v102/controlfile/current.637923577 output filename=+DATA1/v102/controlfile/current.ora file: 1) Edit init.261. 260.268.260. database opened RMAN> exit (5) Verify new mirrored controlfiles via sqlplus .controlfiles. Example: control_files=('+GROUP1'.605208993'.5 Finished restore at 29-APR-05 (4) Mount and open the database: RMAN> alter database mount. execute: RMAN> restore controlfile from '+data/V10G/controlfile/Current. Starting restore at 29-APR-05 allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=317 devtype=DISK channel ORA_DISK_1: copied controlfile copy output filename=+GROUP2/v10g/controlfile/backup. your current controlfile location DISK path is '+data/V10G/controlfile/Current. Presuming.605208993' .'+GROUP2') (2) Start the instance in NOMOUNT mode.260. (3) Execute restore command.7 output filename=+GROUP2/v10g/controlfile/backup. to duplicate the controlfile using the original location. database mounted released channel: ORA_DISK_1 RMAN> alter database open. Fully Qualified ASM Filename: +group/dbname/file_type/file_type_tag.----------.SQL> show parameter control_files NAME TYPE VALUE -----------------------------------.file.260.268. +GROUP2/v10g/controlfile/backup.5 ASM Filenames  1.7.-----------------------------control_files string +GROUP2/v10g/controlfile/backup.incarnation . incarnation Example: +dgroup2. and then ASMCMD prompts for the next command. . perform searches. Alias ASM Filenames: +group/dir_1/…/dir_n/filename Example: +dgroup1/myfiles/control_file1 +dgroup2/mydir/second. display space utilization.541956473  3. Enter an ASMCMD command and press the Enter key. Numeric ASM Filename: +group. and more. ASMCMD> 2. Alias ASM Filename with Template: +group(template_name)/alias Example: +dgroup1(my_template)/config1  5. create and remove directories and aliases.541956473  2. enter: asmcmd An ASMCMD command prompt is displayed. At the operating system command prompt. if any.257. It can list the contents of disk groups. To run ASMCMD in interactive mode: 1.dbf  4.Example: +dgroup2/sample/controlfile/Current.256.file. Incomplete ASM Filename:+group Example: +dgroup1  6. The command runs and displays its output. Incomplete ASM Filename with Template: +group(template_name) Example: +dgroup1(my_template) ASMCMD ASMCMD is a command-line utility that you can use to easily view and manipulate files and directories within Automatic Storage Management (ASM) disk groups. rmalias: Deletes the specified alias. the attributes of the specified file. ls: Lists the contents of an ASM directory.PURPOSE : Provide a summary report of all alias definitions contained within all ASM disk groups. rm: Deletes the specified ASM files or directories.sql -. mkalias: Creates an alias for a system-generated filename. mkdir: Creates ASM directories. lsct: Lists information about current ASM clients. retaining the file that the alias points to            asm_alias. help: Displays the syntax and description of ASMCMD commands. pwd:Displays the path of the current ASM directory. Commands:   cd: Changes the current directory to the specified directory. recursively. exit: Exits ASMCMD. find: Lists the paths of all occurrences of the specified name (with wildcards) under the specified directory. lsdg: Lists all disk groups and their attributes. Enter the command exit to exit ASMCMD.3. du: Displays the total disk space occupied by ASM files in the specified ASM directory and all its subdirectories. SET LINESIZE 145 SET PAGESIZE 9999 SET VERIFY off COLUMN disk_group_name FORMAT a16 HEAD 'Disk Group Name' COLUMN alias_name FORMAT a30 HEAD 'Alias Name' COLUMN file_number HEAD 'File|Number' COLUMN file_incarnation HEAD 'File|Incarnation' COLUMN alias_index HEAD 'Alias|Index' COLUMN alias_incarnation HEAD 'Alias|Incarnation' COLUMN parent_index HEAD 'Parent|Index' COLUMN reference_index HEAD 'Reference|Index' COLUMN alias_directory FORMAT a10 HEAD 'Alias|Directory?' COLUMN system_created FORMAT a8 HEAD 'System|Created?' break on report on disk_group_name skip 1 . or the names and attributes of all disk groups. Continue entering ASMCMD commands. sql -. a. a.system_created system_created FROM v$asm_alias a JOIN v$asm_diskgroup g USING (group_number) ORDER BY g. c. a. a. a.file_incarnation file_incarnation . a.name disk_group_name .SELECT g. a. a.parent_index parent_index .file_number / asm_clients.alias_incarnation alias_incarnation .reference_index reference_index .alias_directory alias_directory . SET LINESIZE 145 SET PAGESIZE 9999 SET VERIFY off COLUMN disk_group_name FORMAT a15 HEAD 'Disk Group Name' COLUMN instance_name FORMAT a20 HEAD 'Instance Name' COLUMN db_name FORMAT a9 HEAD 'Database Name' COLUMN status FORMAT a12 HEAD 'Status' break on report on disk_group_name skip 1 SELECT a.name .instance_name instance_name .PURPOSE : Provide a summary report of all clients making use of this ASM instance.alias_index alias_index . a.name alias_name .name disk_group_name . a.file_number file_number . reads . c..name / asm_disks_perf. SET LINESIZE 145 SET PAGESIZE 9999 SET VERIFY off COLUMN disk_group_name FORMAT a15 HEAD 'Disk Group Name' COLUMN disk_path FORMAT a20 HEAD 'Disk Path' COLUMN reads FORMAT 999.writes disk_group_name disk_path reads writes .999. b. b.999 HEAD 'Bytes|Written' break on report on disk_group_name skip 2 compute sum label "" of reads writes read_errs write_errs read_time write_time bytes_read bytes_written on disk_group_name compute sum label "Grand Total: " of reads writes read_errs write_errs read_time write_time bytes_read bytes_written on report SELECT a.999 HEAD 'Read|Time' COLUMN write_time FORMAT 999.999 HEAD 'Reads' COLUMN writes FORMAT 999.sql -.999.db_name db_name . c.status status FROM v$asm_diskgroup a JOIN v$asm_client c USING (group_number) ORDER BY a.999 HEAD 'Write|Errors' COLUMN read_time FORMAT 999.999 HEAD 'Read|Errors' COLUMN write_errs FORMAT 999.999. b.999 HEAD 'Writes' COLUMN read_errs FORMAT 999.999.path .999.name .999.999.999 HEAD 'Write|Time' COLUMN bytes_read FORMAT 999.PURPOSE : Provide a summary report of all disks contained within all ASM disk groups along with their performance metrics.999.999 HEAD 'Bytes|Read' COLUMN bytes_written FORMAT 999. name / asm_diskgroups.read_time read_time . Used' break on report on disk_group_name skip 1 compute sum label "Grand Total: " of total_mb used_mb on report SELECT name .write_time write_time . SET LINESIZE 145 SET PAGESIZE 9999 SET VERIFY off COLUMN group_name FORMAT a16 HEAD 'Disk Group|Name' COLUMN sector_size FORMAT 99. b. b.PURPOSE : Provide a summary report of all disk groups.999..999 HEAD 'Sector|Size' COLUMN block_size FORMAT 99. b.bytes_written bytes_written FROM v$asm_diskgroup a JOIN v$asm_disk b USING (group_number) ORDER BY a.999 HEAD 'Used Size (MB)' COLUMN pct_used FORMAT 999.999 HEAD 'Allocation|Unit Size' COLUMN state FORMAT a11 HEAD 'State' COLUMN type FORMAT a6 HEAD 'Type' COLUMN total_mb FORMAT 999.sql -.999 HEAD 'Block|Size' COLUMN allocation_unit_size FORMAT 999.999.read_errs read_errs . sector_size .999. b. block_size group_name sector_size block_size .999 HEAD 'Total Size (MB)' COLUMN used_mb FORMAT 999. b. b.99 HEAD 'Pct.bytes_read bytes_read .write_errs write_errs . .(free_mb / total_mb))*100.failgroup disk_file_fail_group . (total_mb . b.free_mb) used_mb . ROUND((1.name. state state . Used' break on report on disk_group_name skip 1 compute sum label "" of total_mb used_mb on disk_group_name compute sum label "Grand Total: " of total_mb used_mb on report SELECT NVL(a. SET LINESIZE 145 SET PAGESIZE 9999 SET VERIFY off COLUMN disk_group_name FORMAT a20 HEAD 'Disk Group Name' COLUMN disk_file_path FORMAT a17 HEAD 'Path' COLUMN disk_file_name FORMAT a20 HEAD 'File Name' COLUMN disk_file_fail_group FORMAT a20 HEAD 'Fail Group' COLUMN total_mb FORMAT 999. type type .sql -. 2) pct_used FROM v$asm_diskgroup ORDER BY name / asm_disks. b.PURPOSE : Provide a summary report of all disks contained within all disk -groups. allocation_unit_size allocation_unit_size .those that are not assigned to any disk -group. '[CANDIDATE]') disk_group_name . total_mb total_mb .99 HEAD 'Pct.name disk_file_name .999 HEAD 'Used Size (MB)' COLUMN pct_used FORMAT 999.999. This script is also responsible for queriing all -candidate disks .999 HEAD 'File Size (MB)' COLUMN used_mb FORMAT 999.path disk_file_path . b.999. (b.999. 2) pct_used FROM v$asm_diskgroup a RIGHT OUTER JOIN v$asm_disk b USING (group_number) ORDER BY a.total_mb total_mb . bytes . space . SYS_CONNECT_BY_PATH(alias_name.999.999. creation_date . SET LINESIZE 150 SET PAGESIZE 9999 SET VERIFY off COLUMN full_alias_path FORMAT a63 HEAD 'File Name' COLUMN system_created FORMAT a8 HEAD 'System|Created?' COLUMN bytes FORMAT 9. 18).free_mb / b. 4) system_created .free_mb) used_mb .PURPOSE : Provide a summary report of all files (and file metadata) information for all ASM disk groups.(b.total_mb .999 HEAD 'Bytes' COLUMN space FORMAT 9. LPAD(system_created.b. '<DIRECTORY>') type . ROUND((1.sql -.999.999 HEAD 'Space' COLUMN type FORMAT a18 HEAD 'File Type' COLUMN redundancy FORMAT a12 HEAD 'Redundancy' COLUMN striped FORMAT a8 HEAD 'Striped' COLUMN creation_date FORMAT a20 HEAD 'Creation Date' COLUMN disk_group_name noprint BREAK ON report ON disk_group_name SKIP 1 compute sum label "" of bytes space on disk_group_name compute sum label "Grand Total: " of bytes space on report SELECT CONCAT('+' || disk_group_name.. NVL(LPAD(type.total_mb))*100. b. disk_group_name .999. '/')) full_alias_path .name / asm_files.999. FROM ( SELECT g. TO_CHAR(f. a. POWER(2. file_number) JOIN v$asm_diskgroup g USING (group_number) ) WHERE type IS NOT NULL START WITH (MOD(pindex.999.999.sql -. a.creation_date.type type .999 HEAD 'Bytes' COLUMN space FORMAT 9. f.parent_index pindex .999.bytes bytes . 24))) = 0 CONNECT BY PRIOR rindex = pindex / asm_files2. a. 'DD-MON-YYYY HH24:MI:SS') creation_date FROM v$asm_file f RIGHT OUTER JOIN v$asm_alias a USING (group_number.reference_index rindex . SET LINESIZE 145 SET PAGESIZE 9999 SET VERIFY off COLUMN disk_group_name FORMAT a16 HEAD 'Disk Group Name' COLUMN file_name FORMAT a30 HEAD 'File Name' COLUMN bytes FORMAT 9.space space . f.name alias_name . a.999 HEAD 'Space' COLUMN type FORMAT a18 HEAD 'File Type' COLUMN redundancy FORMAT a12 HEAD 'Redundancy' COLUMN striped FORMAT a8 HEAD 'Striped' COLUMN creation_date FORMAT a20 HEAD 'Creation Date' break on report on disk_group_name skip 1 compute sum label "" of bytes space on disk_group_name compute sum label "Grand Total: " of bytes space on report .999.PURPOSE : Provide a summary report of all files (and file metadata) -information for all ASM disk groups.999.system_created system_created . f.name disk_group_name .999. | PURPOSE : Provide a summary report of all template information for all ASM disk groups. 'DD-MON-YYYY HH24:MI:SS') creation_date FROM v$asm_file f JOIN v$asm_alias a USING (group_number.redundancy . a.sql -. file_number) JOIN v$asm_diskgroup g USING (group_number) WHERE system_created = 'Y' ORDER BY g.name file_name .name disk_group_name .name .name . file_number / asm_templates.stripe disk_group_name entry_number redundancy stripe .entry_number . a. f.space space . f. a. SET LINESIZE 145 SET PAGESIZE 9999 SET VERIFY off COLUMN disk_group_name FORMAT a16 HEAD 'Disk Group Name' COLUMN entry_number FORMAT 999 HEAD 'Entry Number' COLUMN redundancy FORMAT a12 HEAD 'Redundancy' COLUMN stripe FORMAT a8 HEAD 'Stripe' COLUMN system FORMAT a6 HEAD 'System' COLUMN template_name FORMAT a30 HEAD 'Template Name' break on report on disk_group_name skip 1 SELECT b.creation_date.bytes bytes . f. TO_CHAR(f. a.type type .SELECT g. a.name template_name FROM v$asm_template a JOIN v$asm_diskgroup b USING (group_number) ORDER BY b.name . a..system system . a.entry_number / Data Guard Quick Reference . 1. If the MRP0 or MRP process exists.3 Shut down the standby database. 1.2 If log apply services are running. and opens the database for read-only access. . then the standby database is applying redo. cancel them as shown in the following example: SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL. 2.1 Find out if the standby database is performing Redo Apply or real-time apply. but does not open the database. SQL> STARTUP MOUNT. Starting Up a Physical Standby Database 1.1 STARTUP: Starts the database.Managing a Physical Standby Database 1. mounts the database as a physical standby database. STATUS FROM V$MANAGED_STANDBY. SQL> SHUTDOWN.2 STARTUP MOUNT: Starts and mounts the database as a physical standby database. SQL> SELECT PROCESS. To start real-time apply. Shutting Down a Physical Standby Database 2. issue the following statement: SQL>ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE. 2.3 Start log apply services after mounting DB: To start Redo Apply. issue the following statement: SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION. 2. Data Pump Data Pump Home >> Reference >> General Reference >> Data Pump Introduction .2 Restart Redo Apply or real-time apply. 4. Open the database for read-only access: SQL> ALTER DATABASE OPEN. issue the following statement: SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE. 3.2 Open a standby database for read-only access when it is currently performing Redo Apply or realtime apply: Cancel Redo Apply or real-time apply: SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL. To start Redo Apply. To start real-time apply.Opening a Physical Standby Database for Read-Only Access 3. 4.1 Open a standby database for read-only access when it is currently shut down: SQL> STARTUP.3. To change the standby database from being open for read-only access to performing Redo Apply: 4.1 Terminate all active user sessions on the standby database. issue the following statement: SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION. For the import dump operation.  Data Pump Processes All Data Pump work is done though jobs. it does so through a special table created at runtime known as a master table. Data Pump jobs. The master table has the same name as the name of the Data Pump job. Data Pump uses the information in this table to restart the job. This table maintains one row per object with status information. Data Pump uses the master table to restart a failed or suspended job. . The main process. Database object definitions are stored using XML rather than SQL. it maintains all the information about the job. The DBMS_METADATA package is used by worker processes for all metadata unloading and loading. The SQL*Loader client has been integrated with external tables. coordinates this effort via Advanced Queuing. Master Table  During the operation. known as a master control process. The DBMS_DATAPUMP package embodies the API for high-speed export and import utilities for bulk data and metadata movement. The master table is dropped (by default) when the Data Pump job finishes successfully. a master table is maintained in the schema of the user who initiated the Data Pump export. The master table is written to the dump file set as the last step of the export dump operation and is removed from the user’s schema. The expdp and impdp clients are thin layers that make calls to the DBMS_DATAPUMP package to initiate and monitor Data Pump operations. External Table Services: Data Pump uses the new ORACLE_DATAPUMP access driver that provides external tables write and read access to files containing binary streams. The master table is the heart of every Data Pump operation. the master table is loaded from the dump file set to the user’s schema as the first step and is used to sequence the objects being imported.Data Pump Components:       Direct Path API (DPAPI): Oracle Database 10g supports a direct path API interface that minimizes data conversion and parsing at both unload and load time. thereby providing automatic migration of loader control files to external table access parameters. are merely server processes that process the data on behalf of the main process. In the event of a failure. unlike DBMS jobs. restart. Shadow process: When a client logs into the Oracle database. The worker processes have the format ORACLE_SID_DWnn_PROCESS_ID. Since the Data Pump is completely integrated to the database. directory objects must be created in the database where the Data Pump files will be stored. this process is not necessary for the progress of the job. Master control process (MCP): Master control process controls the execution of the Data Pump job. once the Data Pump job is initiated. Remapping capabilities during import Data sampling and metadata compression          Create Data Pump Directory   Since the Data Pump is server based. BUT the database user does NOT need any operating system privileges on the directory for Data Pump to succeed. or other clients to make calls to the Data Pump API. MCP divides the Data Pump job into various metadata and data load or unload jobs and hands them over to the worker processes. This process creates the master table and creates Advanced Queuing (AQ) queues used for communication. and WRITE permission is required to perform export and to create log files or SQL files. a foreground process is created (a standard feature of Oracle). It maintains the job state. Parallel Query (PQ) processes: The worker processes can initiate parallel query processes if external table is used as the data access method for loading or unloading. . These are standardparallel query slaves of the parallel execution architecture. The user (who owns the software installation and database files) must have READ and WRITE operating system privileges on the directory. The MCP has a process name of the format ORACLE_SID_DMnn_PROCESS_ID.  SQL> SELECT * FROM dba_directories.impdp. This shadow process services the client data dump API requests. there is one MCP per job. Worker process: The MCP creates the worker processes based on the value of the PARALLEL parameter. The worker processes maintain the current status in the master table that can beused to restart a failed job. Once the client process is ended. job description. and file information in the master table.     Client process: This process is initiated by the client utility: expdp. The worker process performs the tasks requested by MCP. Data Pump Benefits  Data access methods: – Direct path – External tables Detachment from and reattachment to long-running jobs Restarting of Data Pump jobs Fine-grained object and data selection Explicit database version specification Parallel execution Estimation of export job space consumption Network mode in a distributed environment: the data pump operations can be performed from one database to another without writing to a dump file. using the network method. the shadow process also goes away. The user executing Data Pump must have been granted permissions on the directory. mainly loading or unloading data and metadata. READ permission is required to perform import. log JOB_NAME=expdp 5. SQL> GRANT READ. . Table expdp \'/ as sysdba\' DIRECTORY=dpdata DUMPFILE=scott.blake.emp. Full expdp \'/ as sysdba\' DIRECTORY=dpdata DUMPFILE=exp%U.dmp TABLESPACES=users.log JOB_NAME=expdp PARALLEL=30 2. WRITE ON DIRECTORY dpdataTO scott. Tablespace expdp \'/ as sysdba\' DIRECTORY=dpdata DUMPFILE=exp.dmp TABLES=scott. ALTER TABLESPACE example READ WRITE. expdp \'/ as sysdba\' DIRECTORY=dpdata DUMPFILE=exp_tbs. -. Export Modes 1. User (Owner) expdp \'/ as sysdba\' DIRECTORY=dpdata DUMPFILE=scott.dept LOGFILE=exp.dmp TRANSPORT_TABLESPACES=users.example TRANSPORT_FULL_CHECK=y LOGFILE=exp_tbs.log ALTER TABLESPACE users READ WRITE.Set up default directory data_pump_dir (The name of the default directory must be DATA_PUMP_DIR) SQL> CREATE OR REPLACE DIRECTORY dpdata AS ''. tools TRANSPORT_FULL_CHECK=y LOGFILE=exp.dmp FULL=y LOGFILE=exp. ALTER TABLESPACE example READ ONLY.dmp SCHEMAS=scott LOGFILE=exp.log JOB_NAME=expdp 3.log JOB_NAME=expdp 4. Transportable Tablespace Export ALTER TABLESPACE users READ ONLY.SQL> CREATE OR REPLACE DIRECTORY data_pump_dir AS 'c:\temp'. log JOB_NAME=impdp 3.blake. User (Owner) impdp \'/ as sysdba\' DIRECTORY=dpdata DUMPFILE=scott. Transportable Tablespace Other Features      REMAP_DATAFILE REMAP_SCHEMA REMAP_TABLESPACE TRANSFORM NETWORK_LINK Data Pump Monitoring . Full impdp \'/ as sysdba\' DIRECTORY=dpdata DUMPFILE=exp.log JOB_NAME=impdp impdp \'/ as sysdba\' DIRECTORY=dpdata DUMPFILE=exp%U.dmp CONTENT=metadata_only Import Modes 1. Table impdp \'/ as sysdba\' DIRECTORY=dpdata DUMPFILE=scott.emp.log JOB_NAME=impdp 4.dmp FULL=y LOGFILE=imp. Export metadata expdp \'/ as sysdba\' SCHEMAS=scott DIRECTORY=dpdata DUMPFILE=meta.dmp SCHEMAS=scott LOGFILE=imp.dept LOGFILE=imp.log JOB_NAME=DMFV_impdp PARALLEL=30 2. Tablespace 5.dmp TABLES=scott.dmp FULL=y LOGFILE=imp.6. 2 switch from interactive client mode back to logging mode Export> CONTINUE_CLIENT 2. kupprdp: worker process DW01 started with worker id=1.saddr = d. 'ANANDA').MAIN('CASES_EXPORT'. pid=25. Switching Between Logging and Interactive Client Mode: expdp system/oracle parfile=c:\rmancmd\longexport.1.KUPW$WORKER. the MCP and the worker processes are shown in the alert log as follows: kupprdp: master process DM00 started with pid=23.Viewing Job Status: . SQL> select sid.saddr.KUPM$MCP.MAIN('CASES_EXPORT'. V$SESSION_LONGOPS predict the time it will take to complete the job.1 switch this job to interactive client mode by typing CTRL-C 1.sql 2. kupprdp: worker process DW03 started with worker id=2. 3. Script: @dpstatus. 5. DBA_DATAPUMP_JOBS how many worker processes (column DEGREE) are working on the job. Alert log When the process starts up. pid=24. dba_datapump_sessions d where s. DBA_DATAPUMP_SESSIONS when joined with the previous view and V$SESSION gives the SID of the session of the main foreground process. OS id=20532 to execute SYS. sofar. 'ANANDA'). serial#.MAIN('CASES_EXPORT'. select sid.dpectl 1. OS id=20530 to execute SYS. OS id=20534 to execute SYS. totalwork from v$session_longops where sofar != totalwork. 'ANANDA'). 4. serial# from v$session s.KUPW$WORKER. Controlling Data Pump Jobs 1. reopen a session by $ expdp system/oracle attach=longexport 4.2 reattach to a running job after closing the client connection. End the job Export> kill_job Transportable Tablespaces Limitations    COMPATIBLE parameter set to 10. Halt the execution of the job: Export> stop_job restart the job: Export> START_JOB 5. RMAN does not convert the CLOB data.0 or higher on both source and target databases The databases must use the same database character set and national character set.1 detach from a client session.From interactive mode Export> status 3. Character set conversion is not possible in transportable tablespaces. Steps . Closing and Reattaching To A Job 3. the application must take care of the conversion if any is required. but leave a running job still executing Export> exit_client 3. A limitation exists on the CLOB datatype columns created prior to Oracle 10g (applicable only if the database was upgraded from an earlier release).0. you can skip this step and proceed to step 6. Check self-contained tablespaces Ensure the tablespaces to be transported are self-contained. Use the DBMS_TTS. 4. v$database b where a. a. 3. $ expdp system DUMPFILE=sales_tts.dmp LOGFILE=sales_tts.SALES_INDEX 5.---------10 Linux IA (32-bit) Little 2.log DIRECTORY=dumplocation TRANSPORT_FULL_CHECK=Y TRANSPORT_TABLESPACES=SALES_DATA.TRUE). if we have determined that the Endian formats are same for the platforms. SQL> ALTER TABLESPACE SALES_INDEX READ ONLY.TRANSPORT_SET_CHECK procedure to determine this.platform_id.1. the datafiles need to be converted using RMAN.-------------------------. endian_format from v$transportable_platform a. RMAN conversion (optinonal) In step 1. To convert the datafiles from the little-Endian format (Linux) to the big-Endian format .platform_name. Read-only tablespaces in source database Make the tablespaces to be transported read-only in the source database.TRANSPORT_SET_CHECK( 'SALES_DATA. For example: SQL> EXEC DBMS_TTS. Check Endian format Determine if the platforms use the same Endian format by querying the V$TRANSPORTABLE_PLATFORM in the source and target databases: SQL> select a.SALES_INDEX'. SQL> ALTER TABLESPACE SALES_DATA READ ONLY.platform_id = b. Export metadata Use the expdp utility to unload the metadata information for the tablespaces to be transported. PLATFORM_ID PLATFORM_NAME ENDIAN_FOR ----------.platform_id. If the Endian formats are different. you can do so—just replace line 2 with FROM_PLATFORM 'Linux IA (32-bit)'.log DIRECTORY=data_dump_dir TRANSPORT_DATAFILES='/oradata/SL10H/sales_data01. 6. like so: SQL> ALTER TABLESPACE SALES_DATA READ WRITE. sales_index' 2> TO PLATFORM 'Solaris[tm] OE (64-bit)' 3> DB_FILE_NAME_CONVERT = 4> '/oradata/BT10GNF1/sales_data01. SQL> ALTER TABLESPACE SALES_INDEX READ WRITE. if not. Use the impdp utility on the target to import the metadata and plug-in the tablespaces.dbf' 7.dbf'.dbf'.dmp LOGFILE=sales_tts_imp. If you decide to convert the datafiles at the target platform. as shown here: $impdp system DUMPFILE=sales_tts. Import metadata Use operating system utilities to copy the converted datafiles and the metadata dump file to the target server. Backup Sample Scripts and Examples . do the following: $ rman target / RMAN> CONVERT TABLESPACE 'sales_data. you can make the objects owned by an existing user using the REMAP_SCHEMA parameter. 7> '/tmp/sales_index01_sun. 5> '/tmp/sales_data01_sun. Read-write tablespace in target database Make the new tablespaces read-write in the target database. The target user must already exist in the target database. 6> '/oradata/BT10GNF1/sales_index01.dbf'. '/oradata/SL10H/sales_index01.dbf'.(Sun Solaris).dbf'. SQL "alter system archive log current". SQL "alter system archive log current". SQL "ALTER DATABASE BACKUP CONTROLFILE TO TRACE". backup FILESPERSET 5 format '/backup/%d_t%t_s%s_FULL' (database) CURRENT CONTROLFILE SPFILE. backup format 'ALO_%d_%s_%t' (archivelog all).ctl'. Backup as backupsets connect target / set echo on run { allocate channel channel1 type disk. release channel channel1.ctl'. BACKUP AS COPY CURRENT CONTROLFILE FORMAT '/backup/control01.RMAN online full backup to disk 1. } 2. BACKUP AS COPY CURRENT CONTROLFILE FORMAT '/backup/control01. Backup as image copy connect target / set echo on run { allocate channel channel1 type disk. backup as copy format '/backup/%U' (database) CURRENT CONTROLFILE SPFILE. . . Backup as backupsets connect target / run { shutdown immediate. release channel channel1. startup force DBA.ctl'. allocate channel channel1 type DISK. shutdown immediate. SQL "ALTER DATABASE BACKUP CONTROLFILE TO TRACE". BACKUP CURRENT CONTROLFILE FORMAT '/backup/cntrlfile. } 2. SQL "ALTER DATABASE BACKUP CONTROLFILE TO TRACE". } RMAN offline full backup to disk 1. startup. shutdown immediate. startup mount. BACKUP AS COPY CURRENT CONTROLFILE FORMAT '/backup/control01. startup force DBA.copy'. Backup as image copy connect target / run { shutdown immediate. backup FILESPERSET 8 format '/backup/%d_t%t_s%s_OFFLINE' (database) CURRENT CONTROLFILE SPFILE. release channel channel1.backup as copy format '/backup/ALO_%d_%s_%t' (archivelog all). allocate channel channel1 type DISK. } RMAN backup schell script for RAC (two nodes example) Adapted from Alejandro Vargas's blog #!/usr/bin/ksh # rman_backup_as_copy_to_FS export v_inst1=racdbtst1 export v_inst2=racdbtst2 # Rman Backup Location variable # ----------------------------export v_rman_loc=/vmasmtest/BACKUP/rman_backups # Step 1: Administrative tasks. startup mount.ctl'. crosscheck copy. startup. backup as copy format '/backup/%U' (database) CURRENT CONTROLFILE SPFILE. crosscheck archivelog all. delete noprompt obsolete. BACKUP AS COPY CURRENT CONTROLFILE FORMAT '/backup/control01.shutdown immediate. crosscheck and delete obsolete # -----------------------------------------------------------export ORACLE_SID=$v_inst1 rman target / nocatalog <<EOF crosscheck backupset. delete noprompt expired backup . exit EOF . SQL "ALTER DATABASE BACKUP CONTROLFILE TO TRACE". shutdown immediate. release channel channel1. release channel backup_disk1. # Step 4: Rman backup as copy to file system including controlfile and archivelogs # ------------------------------------------------------------------------------rman target / nocatalog <<EOF run { allocate channel backup_disk1 type disk format '$v_rman_loc/%U'. we need to have configured # ORACLE_HOME. ORACLE_SID and PATH on the environment. We use an external identified DBA user. ops$oracle. } exit EOF # Step 5 and 6: Archive log current on 1st and 2nd Instances # ---------------------------------------------------------sqlplus -s /@$v_inst1 << EOF select instance_name from v\$instance / . select instance_name from v\$instance / alter system archive log current / exit EOF # On step 4 we use 4 channels. backup as COPY tag '%TAG' database include current controlfile. release channel backup_disk2.# This script run from 1st node. This needs to be customized according the number of cpu's/IO # channels available. to execute # the archive log current. From the same session we connect as ops$oracle into the 2nd instance # You need remote_os_authent=TRUE on both instances to connect remotely without password # Step 2: Archive log current on 1st Instance # Step 3: Archive log current on 2nd Instance # ------------------------------------------sqlplus -s /@$v_inst1 << EOF select instance_name from v\$instance / alter system archive log current / connect /@$v_inst2. as we did in the previous steps. allocate channel backup_disk2 type disk format '$v_rman_loc/%U'. Rman is invoked in nocatalog mode. log <<EOF list backup summary. list backup of controlfile. list backupset. select instance_name from v\$instance / alter system archive log current / exit EOF # Step 7: Rman backup as copy archivelogs not backed up and print backupset list to log rman target / nocatalog <<EOF backup as copy archivelog all format '$v_rman_loc/%d_AL_%T_%u_s%s_p%p' . exit EOF # eof rman_backup_as_copy_to_FS Notes: 1.world) (INSTANCE_NAME = upgrade1) ) ) upgrade2 = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = vip02)(PORT = 1521)) (CONNECT_DATA = . list backupset. rman target / nocatalog log=$v_rman_loc/backupset_info. because of that # running separately.alter system archive log current / connect /@$v_inst2. exit EOF # Redirecting rman output to log will suppress standard output. Add the similar entries to tnsnames.ora if necessary upgrade1 = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = vip01)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = upgrade. startup nomount. set controlfile autobackup format for device type disk to '/db1/orabackup/%F'. restore database. alter database open. alter database open. } . restore database. startup mount. Change login as following if necessary: sqlplus -s system/<password>@$v_inst1 << EOF Recovery scripts and examples RMAN recover database connect target / RUN { shutdown immediate.(SERVER = DEDICATED) (SERVICE_NAME = upgrade. recover database. mount database. recover database. } connect target / RUN { shutdown immediate. restore controlfile from autobackup.world) (INSTANCE_NAME = upgrade2) ) ) 2. } RMAN recover data file connect target / RUN { sql "alter tablespace sysaux offline". RESTORE TABLESPACE sysaux.DBF'. RECOVER DATABASE UNTIL SCN 1000.RMAN recover tablespace connect target / RUN { sql "alter tablespace sysaux offline".1.. Restore database. # recovers through SCN 999 or ALTER DATABASE OPEN RESETLOGS. SQL "alter tablespace sysaux online". SQL "alter tablespace sysaux online". } Until Time: export NLS_DATE_FORMAT='DD-MON-YYYY HH24:MI:SS' connect target / RUN { set until time '28-JUL-05 06:00:00'. . Recover database. } RMAN Point-In-Time-Recovery database (incomplete recovery) Until SCN: connect target / RUN { RESTORE DATABASE.DBF'.1. recover datafile 'C:\ORACLE\PRODUCT\10. RECOVER TABLESPACE sysaux. restore datafile 'C:\ORACLE\PRODUCT\10.0\ORADATA\NICK\SYSAUX01.0\ORADATA\NICK\SYSAUX01. The instance will start and try to mount the database. check alert log for more info . RESTORE DATABASE.sql "alter database open reset logs".dbf'' REUSE".tmp'.tmp'. # you must add new tempfiles to locally-managed temporary tablespaces after restoring # a backup control file SQL "ALTER TABLESPACE temp ADD TEMPFILE ''?/oradata/trgt/temp01. # recovers through log 1233 ALTER DATABASE OPEN RESETLOGS. RECOVER DATABASE. the database fails to mount: RMAN> SHUTDOWN IMMEDIATE. } RMAN restore control file See also here 1. database closed database dismounted Oracle instance shut down RMAN> STARTUP Oracle instance started RMAN-00571: RMAN-00569: ERROR MESSAGE STACK FOLLOWS RMAN-00571: RMAN-03002: failure of startup command at 07/11/2005 17:18:05 ORA-00205: error in identifying controlfile. RUN { SET UNTIL SEQUENCE 1234 THREAD 1. but when it doesn’t find the control files. RESTORE CONTROLFILE FROM '?/oradata/cf. Shut down the database and try to start it up. } Until Log Seq: This example assumes that log sequence 1234 was lost due to a disk failure and the database needs to be recovered by using available archived redo logs. # restores to all CONTROL_FILES locations ALTER DATABASE MOUNT. RESTORE CONTROLFILE TO '?/oradata/cf. 5. Because RMAN restores the control files from its backups. 4. mount the database: RMAN> ALTER DATABASE MOUNT. which is created solely to serve as the staging area for the recovery of the tablespaces. Issue the RESTORE CONTROLFILE command so RMAN can copy the control file backups to their default locations specified in the init.ora file: RMAN> RESTORE CONTROLFILE. you have to open the database with the RESETLOGS option: RMAN> ALTER DATABASE OPEN RESETLOGS. 2. 3. IF YOU DON'T WANT TO OVERWRITE TARGET TABLESPACE DATA!!!! Recover the tablespaces from the database (the target database) by first performing the PITR in a temporary instance called the auxiliary database. RMAN tablespace Point-In-Time-Recovery (TSPITR) THIS PROCEDURE WILL RECOVER THE TABLESPACE IN AUX INSTANCE FIRST AND TRANSFER DATA TO TARGET IN ONE RMAN STEP DON'T USE THIS PROCEDURE. After the restore is over.You can avoid the preceding error messages by using the alternative command STARTUP NOMOUNT: RMAN> SHUTDOWN IMMEDIATE. Here’s how to use RMAN to perform a TSPITR: . Recover the database: RMAN> RECOVER DATABASE. RMAN> STARTUP NOMOUNT. and auxiliary databases—as follows: $ rman target sys/sys_passwd@targetdb catalog rman/rman@rmandb auxiliary system/oracle@aux 5. but RMAN performs a number of tasks in this step. This is a deceptively simple step. Connect to all three databases—the catalog. Generate some archived redo logs and back up the target database. It then exports the metadata about the objects in the tablespaces from the auxiliary to the target database. '/tmp/') /* Lets you convert the target database data files to a different name */ log_file_name_convert=('/oraclehome/oradata/target/redo'. for example.0. Use a skeleton initialization parameter file for the auxiliary instance along the lines of the following: db_name=help (this is the target database_name) db_file_name_convert=('/oraclehome/oradata/target/'. You can use the ALTER SYSTEM SWITCH LOGFILE command to produce the archived redo log files. RMAN also uses the SWITCH command to point the control file to the newly recovered data files.ctl compatible=10.1. */ instance_name=aux control_files=/tmp/control1.ora 3. '/tmp/redo') /* Lets you convert the target database redo log files to a different name. you can use the following statement (assuming your NLS_DATE format uses the following format mask: Mon DD YYYY HH24:MI:SS): RMAN> RECOVER TABLESPACE users UNTIL TIME ('JUN 30 2005 12:00:00'). It restores the data files in the users tablespace to the auxiliary database and recovers them to the time you specified. Perform a TSPITR. If you want to recover until a certain time. Create the auxiliary database. . target. Start up the auxiliary database in the nomount mode: $ sqlplus /nolog SQL> CONNECT sys/oracle@aux AS sysdba SQL> STARTUP NOMOUNT PFILE = /tmp/initaux. 4.2 db_block_size=8192 2. 6. only full and incremental backups (if you were taking incremental backups) are available for restore and recovery. Startup database in NOMOUNT mode. and data files pertaining to the auxiliary database. Once the recovery is complete. RMAN restore and recover a non-archivelog database from a full (cold) backup Source: http://www.ora (optional) are all in their appropriate places. however. 4. we did not make use of incremental backups!) NOTE: Because redo logs are not archived. Shut down the auxiliary instance and remove all the control files. The steps are: 1. use the SET UNTIL command to recover to different points in time when incrementals are taken. .) 3. Restore controlfile. (Keep in mind that in our example. any user error or media failure would require a complete database recovery.ora * listener. (You should have restored the initialization file for database. (running in no-archivelog mode). It is assumed that you have all the configuration files like: * Server parameter file (spfile .idevelopment. or if the database name is ambiguous in.info/ In this case study. It is also assumed that you can startup the Oracle instance in NOMOUNT MODE and connect from RMAN to the target instance. and listener files [only if connecting over SQLNET].ora in 9i) * tnsnames. redo log files. If not using a recovery catalog. 2.ora * sqlnet. Mount the database. bring the user tablespace online: $ rman target sys/sys_passwd@targetdb RMAN> SQL "alter tablespace users online". 7. RMAN> Exit. you need to start RMAN and set the DBID before restoring the controlfile from autobackup. You can.equivalent of init. Apply all incrementals.5. so this step is not required. recover database noredo. # ----------------------------------------------------------set controlfile autobackup format for device type disk to '/orabackup1/rman/TARGDB/%F'. } exit NOTE: Tempfiles are automatically excluded from RMAN backups. set dbid 2528050866. Restore all database files.dbf'' size 500m autoextend on next 500m maxsize 1500m".) 7. startup nomount. # SET UNTIL TIME 'SYSDATE-2'. 8. restore database. 6. You will need to manually add any tempfiles back to the database after recovering the database. (In this example. run { # ----------------------------------------------------------# Uncomment the SET UNTIL command to restore database to the # incremental backup taken two days ago. sql "alter tablespace temp add tempfile ''/u06/app/oradata/TARGDB/temp01. alter database open resetlogs. alter database mount. connect target /. This requires them to be re-added at recovery time. RAC Recovery Scripts and Examples . Open database with RESETLOGS mode to re-create the online log files. restore controlfile from autobackup. we are not taking incremental backups. RMAN> restore database. Place the database back into cluster mode and startup both instances: # sqlplus "/ as sysdba" SQL> alter system set cluster_database=true scope=spfile sid='*'. 4.Restore and recover the database . # srvctl start database -d em [oracle@rac1 bdump]$ srvctl status database -d em Instance em1 is running on node rac1 Instance em2 is running on node rac2 Restore and recover the Database using recovered control file -incomplete/point in time recovery 1. Check the backup files and take note of the Database ID rman target / nocatalog RMAN> set dbid=519338572 --find dbid by checking backup log or file name . Restore the database via RMAN: rman target=/ RMAN> startup mount. shutdown abort/immeidate 2. RMAN> alter database open. Take the database out of cluster mode SQL> SQL> SQL> SQL> shutdown abort startup no mount alter system set cluster_database=false scope=spfile sid='*'. 3. Recover the Database RMAN> recover database. Take the database out of cluster mode SQL> SQL> SQL> SQL> shutdown abort startup nomount alter system set cluster_database=false scope=spfile sid='*'. SQL> shutdown immediate.complete recovery 1. shutdown abort/immeidate 2. RMAN> exit Recovery Manager complete. using the 'set until time' clause. RMAN> mount database. 1)Mount instance 1 and set cluster_database=true : SQL> show parameters cluster_database SQL> alter system set cluster_database=true scope=spfile sid='*'. Once recover finish we open using restlogs option: RMAN> alter database open RESETLOGS. } 5. the we do restore and recover.'DD-MON-YY HH24:MI:SS')". Restore the controlfile from a time previous to the crash: RMAN> list backup of controlfile. 2> restore database. 3.RMAN> startup nomount. SQL> shutdown immediate 2) Restart the database in cluster Mode: srvctl start database -d racdbtst srvctl start service -d racdbtst crs_stat –t 3) Check restore point on test table: SQL> select * from restable1. Finally we need to establish Cluster Mode and open both instances. 4. . Set until which time we want to recover. 3> recover database. in this example the three commands are passed to Rman within a single block: RMAN> run { set until time="to_date('01-FEB-07 16:14:28'. 6. RMAN> restore controlfile from '/vmasmtest/BACKUP/rman_backups/cf_DRACDBTST_id-519338572_6ei8vq5p'. 2.2.2.2.sh: #!/bin/ksh export ORACLE_SID=GRID export ORACLE_HOME=/u01/app/oracle/product/10.0/oms10g/opmn/bin/opmnctl startall /u01/app/oracle/product/10.0/oms10g/bin/emctl stop iasconsole /u01/app/oracle/product/10.0/oms10g/bin/emctl start oms /u01/app/oracle/product/10.0/oms10g export PATH=$ORACLE_HOME/bin:$PATH:$ORACLE_HOME/opmn/bin export LD_LIBRARY_PATH=$ORACLE_HOME/lib /u01/app/oracle/product/10.2.0/oms10g export PATH=$ORACLE_HOME/bin:$PATH:$ORACLE_HOME/opmn/bin export LD_LIBRARY_PATH=$ORACLE_HOME/lib /u01/app/oracle/product/10.2.2.2.sh: #!/bin/ksh export ORACLE_SID=GRID export ORACLE_HOME=/u01/app/oracle/product/10.0/agent10g/bin/emctl stop agent exit .0/oms10g/bin/emctl stop oms /u01/app/oracle/product/10.0/agent10g/bin/emctl start agent Stop Grid Control Run stop_grid.2.2.2.0/agent10g export PATH=$ORACLE_HOME/bin:$PATH /u01/app/oracle/product/10.sh Content of stop_grid.0/agent10g/network/admin export PATH=$ORACLE_HOME/bin:$PATH /u01/app/oracle/product/10.0/oms10g/bin/emctl start iasconsole export ORACLE_SID=AGENT export ORACLE_HOME=/u01/app/oracle/product/10.2.0/oms10g/opmn/bin/opmnctl stopall export ORACLE_SID=AGENT export ORACLE_HOME=/u01/app/oracle/product/10.0/agent10g export TNS_ADMIN=/u01/app/oracle/product/10.sh Content of start_grid.2.Start Grid Control Run start_grid. 0/db_1/bin/emca -config dbcontrol db -repos recreate Reconfigure dbconsole repository .0/db_1/bin/emca -config dbcontrol db -repos drop Recreate dbconsole repository /u01/app/oracle/product/10.2.0/db_1/bin/emca -config dbcontrol db -repos create Drop dbconsole repository /u01/app/oracle/product/10.OMS Commands emctl start oms emctl stop oms emctl status oms EM Console Commands for Application Server emctl start em emctl stop em emctl status em OEM Agent Commands emctl start agent emctl stop agent emctl status agent Grid Control and Agent logs ORACLE_HOME/sysman/log/ AGENT_HOME/sysman/log/ DB Control Repository Create dbconsole repository /u01/app/oracle/product/10.2.2. Option 2  Step1. SQL> drop public synonym MGMT_TARGET_BLACKOUTS.remove the following directories from your filesystem: <ORACLE_HOME>/<hostname_sid> <ORACLE_HOME>/oc4j/j2ee/OC4J_DBConsole_<hostname>_<sid>  Step5. and drop the sysman account & mangement objects: * Clean up the Db Console repository SQL> drop user sysman cascade. Recreate the DB Console Repository & external Configuration files by issuing: emca -config dbcontrol db -repos create Partition Methods o o o o o Range Partitioning List Partitioning Hash Partitioning Composite Partitioning Invterval Partitioning . Cleanup the External DB Console Configuration files by issuing: emca -deconfig dbcontrol db -repos drop OR To delete the configurartion files: .Problem: Clone and rename the db to another host and dbconsole won't start with error $ emctl start dbconsole OC4J Configuration issue. Change directories to the $ORACLE_HOME/bin directory Step4. /u01/app/oracle/product/10. SQL> drop role MGMT_USER. SQL> drop public synonym SETEMVIEWUSERCONTEXT. Login to SQLPLUS as user SYS or SYSTEM. SQL> drop user MGMT_VIEW cascade. If fails go to option 2. * issue a "commit. Export the correct values for the ORACLE_HOME and ORACLE_SID environment variables Step3."    Step2.2.0/db_1/oc4j/j2ee/OC4J_DBConsole_<hostname>_<dbnname> not found. Option 1 try <ORACLE_HOME>/bin/emca -deconfig dbcontrol db -repos recreate. you should try to use local indexes because they are easier to manage. availability. myrac1> cluvfy -h 10. If the application is an OLTP one and users need quick response times. cluvfy comp { -list | -help } 15. cluvfy stage {-pre|-post} <stage-name> <stage-specific options> [-verbose] 14. If this is not the case. use a local index. continue to guideline 2. When deciding what kind of partitioned index to use. Home >> Reference >> Oracle RAC >> RAC Commands Cheatsheet 7. If this is the case. . RAC Commands Cheatsheet 6. use a local index. 2. use a local index. If this is not the case. you should use global indexes for OLTP applications and local indexes for data warehousing or DSS applications. use a global index. and scalability. USAGE: 11. If this is the case. you are finished. continue to guideline 3.dbaexpert. 3. use a global index. If this is not the case. If the application is a DSS one and users are more interested in throughput. you are finished. If this is the case. Also. http://www. performance.o o Reference Partitioning Virtual column-based Partitioning (11g) Partitioned Indexes o o o Local Partitioned Indexes Global Partitioned Indexes  Global Range Partitioned Indexes  Global Hash Partitioned Indexes Global Nonpartitioned Indexes Global Indexes vs Local Indexes Just like partitioned tables. 17. 4. cluvfy 9. myrac1> oifcfg -help 19. 5. In general. If the table partitioning column is a subset of the index keys. whenever possible. partitioned indexes improve manageability.com/blog/2007/07/rac-cheatsheet/ 8. you should consider the following guidelines in order: 1. cluvfy stage { -list | -help } 13. you are finished. cluvfy comp <component-name> <component-specific options> [-verbose] 16. continue to guideline 4. If the index is unique. oifcfg 18. If your priority is manageability. They can either be partitioned independently (global indexes) or automatically linked to a table's partitioning method (local indexes). cluvfy [ -help ] 12. crs_stat -ls [resource_name [. as known to a communications network 30.]] -t [-v] [-q] [-c cluster_member] 60.20. -help . -replace ocr|ocrmirror [<filename>] .. crs_stat -p [resource_name [. -restore <filename> . crs_stat [-a] application -r [-c cluster_member] 63. oifcfg getif [-node <nodename> | -global] [ -if <if_name>[/<subnet>] [-type <if_type>] ] 26. <if_type> .Configuration tool for Oracle Cluster Registry. oifcfg setif {-node <nodename> | -global} {<if_name>/<subnet>:<if_type>}… 25.]] [-v] [-l] [-q] [-c cluster_member] 59.Overwrite OCR configuration on disk 53.. <nodename> . . crs_stat 57. Synopsis: 39. ocrconfig [option] 40. -upgrade [<user> [<group>]] 45. -downgrade [-version <version string>] 47. ocrconfig 35. Name: 37. ocrconfig . -showbackup . crs_stat [resource_name [.Import cluster registry contents from a file 44.. Usage: crs_stat [resource_name [.]] [-q] .. . oifcfg [-help] 28.Oracle Interface Configuration Tool. -export <filename> [-s online] 42..Add/replace/remove a OCR device/file 52. <if_name> ..Downgrade cluster registry to the specified version 48. . oifcfg .Export cluster register contents to a file 43. myrac1> crs_stat -h 58. Usage: oifcfg iflist [-p [-n]] 24. oifcfg delif [-node <nodename> | -global] [<if_name>[/<subnet>]] 27. -overwrite .Configure periodic backup location 49. Name: 21.]] [-q] [-c cluster_member] 64. 56..name of the host. 29.Upgrade cluster registry from previous version 46.]] [-q] 61. 22. -repair ocr|ocrmirror <filename> .Show backup information 50..Restore from physical backup 51.. crs_stat [-a] application -g 62. -import <filename> .name by which the interface is configured in the system 31.Repair local OCR configuration 54..subnet address of the interface 32.Print out this help information 55. <subnet> . option: 41. 23. myrac1> ocrconfig -help 36. -backuploc <dirname> . 34. crs_stat -f [resource_name [. 38.type of the interface { cluster_interconnect | public | storage } 33. 94. crsctl set css <parameter> <value> .checks the viability of CSS 99. 76. clscfg — Oracle cluster configuration tool 78. clscfg: EXISTING configuration version 3 detected. clscfg 74.65. It configures cluster topology and other 81. clscfg: version 3 is 10G Release 2. -install . -upgrade . 73. settings.checks the viability of CRS 100. crs_start 70. crsctl 96. myrac1 > crsctl 97. 91.adds a node to the configuration 87. Do not 93. crsctl check evmd . crs_stop 71.creates a special single-node configuration for ASM 89. crsctl unset css <parameter> . -trace .checks the viability of the CRS stack 98. Services install process.upgrades an existing configuration 85. crs_unregister 72.checks the viability of EVM 101. -local . 82. -downgrade . crsctl check crsd . 79.creates a new configuration 84. crs_register –u resname 67. -concepts . crs_profile 68. Usage: crsctl check crs . 66. WARNING: Using this tool may corrupt your cluster configuration.deletes a node from the configuration 88.lists the voting disks used by CSS . -delete . crsctl get css <parameter> . myrac1> clscfg -h 75.sets a parameter override 102.sets CSS parameter to its default 104. Use one of the following modes of operation. crsctl check cssd .gets the value of a CSS parameter 103. 95. Use -help for information on any of these modes. This tool is typically invoked as part of the Oracle Cluster Ready 80. use unless you positively know what you are doing.may be used in conjunction with any mode above for tracing 92. 83.brief listing of terminology used in the other modes 90. -add . crs_relocate 69. crsctl query css votedisk . 77.downgrades an existing configuration 86. crsctl debug log res <resname:level> turns on debugging for resources 126. 141. crsctl enable crs .Turns on debugging for CRS 121. crsctl stop resources . crsctl debug trace css . . crsctl query crs softwareversion [<nodename>] . Stops CRS resources in case of cluster. crsctl debug trace evm .Turns on debugging for EVM 124. 111.dumps EVM in-memory tracing cache 125.dumps CSS in-memory tracing cache 119.disables startup for all CRS daemons 109.stops all CRS daemons. 113. adding a ―trace‖ argument at the very front. crsctl debug log css [module:level]{.lists the CRS modules that can be used for debugging 130.stops CRS resources. 134. log files in $ORA_CRS_HOME/nodename Crsctl check crs Crsctl check cssd Crsctl check crsd Crsctl check evmd Crsctl query crs softwareversion Crsctl query crs softwareversion node2 Crsctl start crs Crsctl stop crs Crsctl debug log res ―resname:level‖ .lists the EVM modules that can be used for debugging 131. crsctl lsmodules crs .dumps state info for css objects 116.starts all CRS daemons. 137. 143. Clusterware check 136.module:level} … 123. crsctl delete css votedisk <path> . crsctl debug trace crs . 138.lists the CRS software operating version 128. crsctl start resources . crsctl debug statedump css .105.starts CRS resources. 132. crsctl lsmodules css . 112.lists the CSS modules that can be used for debugging 129. crsctl add css votedisk <path> .Turns on debugging for CSS 118. crsctl debug statedump crs . If necesary any of these commands can be run with additional tracing by 133. crsctl start crs .removes a voting disk 107.dumps state info for evm objects 114. 142. 146.adds a new voting disk 106. 139. crsctl lsmodules evm . 140.module:level} … 120. Example: crsctl trace check css 135.dumps state info for crs objects 115. crsctl disable crs . . crsctl query crs activeversion .module:level} … 117. 144.enables startup for all CRS daemons 108. crsctl debug log crs [module:level]{.lists the version of CRS software installed 127. 145. crsctl debug log evm [module:level]{. crsctl debug statedump evm .dumps CRS in-memory tracing cache 122. . (start this first in 10g2) 110. crsctl stop crs . Usage: srvctl add instance -d <name> -i <inst_name> -n <node_name> 181.199.crs -rw-r–r– 1 root system 3093 Feb 22 21:58 /etc/inittab OCR check: 161. Ifconfig en8 delete host1-vip 169. Usage: srvctl add service -d <name> -s <service_name> -r ―<preferred_list>‖ [-a "<available_list>"] [-P <TAF_policy>] 182. Ocrcheck Ocrconfig –export /tmp/dba/exp_ocr.crsd -r-xr-xr-x 1 root system 2226 Feb 22 16:19 /etc/init.0/CRS/bin/racgons add_config ictcdb621:6200 ictcdb622:6200 171. 157. 155. 165.0:public en9/172. 149. Usage: srvctl add service -d <name> -s <service_name> -u {-r ―<new_pref_inst>‖ | -a ―<new_avail_inst>‖} .16. 152.0:cluster_interconnect 172. 153. Ifconfig en8 delete host2-vip 170. Command = /apps/oracle/product/10. 177. 150.cssd -r-xr-xr-x 1 root system 4854 Feb 22 16:19 /etc/init. 164. myrac1> ls -lrt /etc/init* lrwxrwxrwx 1 root system 14 Feb 20 11:18 /etc/init -> /usr/sbin/init -rw-r–r– 1 root system 2914 Feb 22 16:19 /etc/inittab. 158.147. Set the SRVM_TRACE environment variable to debug srvctl: 175. Interconnect check: 148. Usage: srvctl add database -d <name> -o <oracle_home> [-m <domain_name>] [p <spfile>] [-A <name|ip>/netmask] [-r {PRIMARY | PHYSICAL_STANDBY | LOGICAL_STANDBY}] [-s <start_options>] [-n <db_name>] [-y {AUTOMATIC | MANUAL}] 180. Oifcfg getif olsnodes disable auto reboot of aix nodes /etc/init* 151. $ export SRVM_TRACE=true 176.2. 166. 163. Usage: srvctl [-V] 179.32. myrac1> srvctl -h 178. 156. srvctl 174.dmp –s online Ocrconfig –showbackup ocrdump VIP: 167.2.orig -r-xr-xr-x 1 root system 3194 Feb 22 16:19 /etc/init. 154.evmd -r-xr-xr-x 1 root system 36807 Feb 22 16:19 /etc/init.0/CRS/bin/oifcfg setif -global en8/10. 162. Ifconfig –a 168. 173.249. 159. 160. Command = /apps/oracle/product/10. Usage: srvctl modify service -d <name> -s <service_name> -i <avail_inst_name> -r [-f] 208. Usage: srvctl getenv nodeapps -n <node_name> [-t "<name_list>"] 203. Usage: srvctl disable database -d <name> 192. Usage: srvctl getenv service -d <name> -s <service_name> [-t "<name_list>"] 202. Usage: srvctl add asm -n <node_name> -i <asm_inst_name> -o <oracle_home> [p <spfile>] 185. Usage: srvctl modify service -d <name> -s <service_name> -i <old_inst_name> -t <new_inst_name> [-f] 207.. Usage: srvctl enable database -d <name> 196. Usage: srvctl remove nodeapps -n ―<node_name_list>‖ [-f] 215. Usage: srvctl config asm -n <node_name> 190. Usage: srvctl modify asm -n <node_name> -i <asm_inst_name> -p <spfile> 210. Usage: srvctl add nodeapps -n <node_name> -o <oracle_home> -A <name|ip>/netmask[/if1[|if2|.]] 184. Usage: srvctl enable service -d <name> -s ―<service_name_list>‖ [-i <inst_name>] 198. Usage: srvctl disable service -d <name> -s ―<service_name_list>‖ [-i <inst_name>] 194. Usage: srvctl disable asm -n <node_name> [-i <inst_name>] 195. Usage: srvctl config listener -n <node_name> 191.. Usage: srvctl config database -d <name> [-a] [-t] 187. Usage: srvctl remove instance -d <name> -i <inst_name> [-f] 213.183. Usage: srvctl config service -d <name> [-s <service_name>] [-a] [-S <level>] 188. Usage: srvctl modify instance -d <name> -i <inst_name> {-s <asm_inst_name> | r} 206. Usage: srvctl remove database -d <name> [-f] 212. Usage: srvctl enable instance -d <name> -i ―<inst_name_list>‖ 197. Usage: srvctl remove asm -n <node_name> [-i <asm_inst_name>] [-f] 216.<name>=<val>. Usage: srvctl setenv database -d <name> {-t <name>=<val>[.. Usage: srvctl config nodeapps -n <node_name> [-a] [-g] [-o] [-s] [-l] 189.] | -T <name>=<val>} . Usage: srvctl relocate service -d <name> -s <service_name> -i <old_inst_name> t <new_inst_name> [-f] 211. Usage: srvctl modify database -d <name> [-n <db_name] [-o <ohome>] [-m <domain>] [-p <spfile>] [-r {PRIMARY | PHYSICAL_STANDBY | LOGICAL_STANDBY}] [-s <start_options>] [-y {AUTOMATIC | MANUAL}] 204. Usage: srvctl getenv instance -d <name> -i <inst_name> [-t "<name_list>"] 201.. Usage: srvctl config database 186. Usage: srvctl disable instance -d <name> -i ―<inst_name_list>‖ 193. Usage: srvctl remove service -d <name> -s <service_name> [-i <inst_name>] [-f] 214.. Usage: srvctl modify service -d <name> -s <service_name> -n -i <prefered_inst> [-a <available_list>] [-f] 209. Usage: srvctl enable asm -n <node_name> [-i <inst_name>] 199. Usage: srvctl modify instance -d <name> -i <inst_name> -n <node_name> 205. Usage: srvctl getenv database -d <name> [-t "<name_list>"] 200. ]‖ | -T ―<name>=<val>‖} 218. Usage: srvctl stop instance -d <name> -i ―<inst_name_list>‖ [-o <stop_options>] [-c <connect_str> | -q] 233. Usage: srvctl unsetenv instance -d <name> [-i <inst_name>] -t ―<name_list>‖ 239. Usage: srvctl stop asm -n <node_name> [-i <asm_inst_name>] [-o <stop_options>] [-c <connect_str> | -q] 236. Usage: srvctl status database -d <name> [-f] [-v] [-S <level>] 227. Usage: srvctl start service -d <name> [-s "<service_name_list>" [-i <inst_name>]] [-o <start_options>] [-c <connect_str> | -q] 223.<name>=<val>. Usage: srvctl unsetenv nodeapps -n <node_name> -t “<name_list> 241. Usage: srvctl setenv nodeapps -n <node_name> {-t ―<name>=<val>[. Usage: srvctl status service -d <name> [-s "<service_name_list>"] [-f] [-v] [-S <level>] 229. We can check about enable/disable startup status of the Oracle Clusterware daemons at crsstart file in /etc/oracle/scls_scr/<hostname>/root/ path. Usage: srvctl status instance -d <name> -i ―<inst_name_list>‖ [-f] [-v] [-S <level>] 228.]‖ | -T ―<name>=<val>‖} 219. Usage: srvctl unsetenv service -d <name> [-s <service_name>] -t ―<name_list>‖ 240. Oracle has scls_scr directory at /etc/oracle path...<name>=<val>. Check enable/disable the startup of the Oracle Clusterware daemons 242. Usage: srvctl status asm -n <node_name> 231. Usage: srvctl start listener -n <node_name> [-l <lsnr_name_list>] 226. Usage: srvctl start nodeapps -n <node_name> 224. Usage: srvctl status nodeapps -n <node_name> 230.. Usage: srvctl start asm -n <node_name> [-i <asm_inst_name>] [-o <start_options>] [-c <connect_str> | -q] 225. Usage: srvctl stop listener -n <node_name> [-l <lsnr_name_list>] 237. Usage: srvctl stop nodeapps -n <node_name> 235. 243. Usage: srvctl start database -d <name> [-o <start_options>] [-c <connect_str> | q] 221. Usage: srvctl start instance -d <name> -i ―<inst_name_list>‖ [-o <start_options>] [-c <connect_str> | -q] 222. Usage: srvctl stop database -d <name> [-o <stop_options>] [-c <connect_str> | -q] 232.<name>=<val>.. root@rac1# cat /etc/oracle/scls_scr/rac1/root/crsstart enable ...217. Usage: srvctl setenv instance -d <name> [-i <inst_name>] {-t ―<name>=<val>[. Usage: srvctl setenv service -d <name> [-s <service_name>] {-t ―<name>=<val>[..]‖ | -T ―<name>=<val>‖} 220. Usage: srvctl stop service -d <name> [-s "<service_name_list>" [-i <inst_name>]] [-c <connect_str> | -q] [-f] 234. Usage: srvctl unsetenv database -d <name> -t ―<name_list>‖ 238... <instance-name-list>] [-f] [-v] [-S <level>] srvctl status service -d <database-name> -s <service-name>[.<instance-name-list>] [-o <start-options>] [-c <connect-string> | -q] ./crsctl enable crs root@rac1# cat /etc/oracle/scls_scr/rac1/root/crsstart enable after enabled by "crsctl enable crs". RAC02 -v Status of a named services.<service-name-list>] [-f] [-v] [-S <level>] srvctl status nodeapps [-n <node-name>] srvctl status asm -n <node_name> EXAMPLES: Status of the database. all instances and all services. srvctl status database -d ORACLE -v Status of named instances with their current services. srvctl status service -d ORACLE -s ERP -v Status of all nodes supporting database applications. srvctl status instance -d ORACLE -i RAC01.root@rac1# cd CRS_HOME/bin root@rac1# . crsstart file was changed be "enable" CRS RESOURCE STATUS srvctl status database -d <database-name> [-f] [-v] [-S <level>] srvctl status instance -d <database-name> -i <instance-name> >[. srvctl status node START CRS RESOURCES srvctl start database -d <database-name> [-o < start-options>] [-c <connect-string> | -q] srvctl start instance -d <database-name> -i <instance-name> [./crsctl disable crs root@rac1# cat /etc/oracle/scls_scr/rac1/root/crsstart disable after disabled by "crsctl disable crs". crsstart file was changed be "disable" root@rac1# . srvctl stop nodeapps -n myclust-4 . srvctl start database -d ORACLE Start named instances.<service-name-list>]] [-i <instance-name>] [-o <start-options>] [-c <connect-string> | -q] srvctl start nodeapps -n <node-name> srvctl start asm -n <node_name> [-i <asm_inst_name>] [-o <start_options>] EXAMPLES: Start the database with all enabled instances. srvctl start instance -d ORACLE -i RAC03. srvctl start service -d ORACLE -s CRM Start a service at the named instance. RAC04 Start named services. srvctl stop instance -d ORACLE -i RAC03. srvctl start nodeapps -n myclust-4 STOP CRS RESOURCES srvctl stop database -d <database-name> [-o <stop-options>] [-c <connect-string> | -q] srvctl stop instance -d <database-name> -i <instance-name> [.RAC04 Stop the service. srvctl stop service -d ORACLE -s CRM Stop the service at the named instances. Note that instances and services also stop.<service-name-list>]] [-i <instance-name>][-c <connect-string> | -q] [-f] srvctl stop nodeapps -n <node-name> srvctl stop asm -n <node_name> [-i <asm_inst_name>] [-o <start_options>] EXAMPLES: Stop the database. srvctl start service -d ORACLE -s CRM -i RAC04 Start node applications.srvctl start service -d <database-name> [-s <service-name>[. first relocating all existing services. srvctl stop service -d ORACLE -s CRM -i RAC04 Stop node applications.<instance-name-list>] [-o <stop-options>][-c <connect-string> | -q] srvctl stop service -d <database-name> [-s <service-name>[. Dependent instances are started as needed. srvctl stop database -d ORACLE Stop named instances. all instances and all services. . PRECONNECT -r for services. The format of address string is: [<logical host name>]/<VIP address>/<net mask>[/<host interface1[ | host interface2 |. srvctl add instance -d ORACLE -i RAC01 -n myclust-1 srvctl add instance -d ORACLE -i RAC02 -n myclust-2 srvctl add instance -d ORACLE -i RAC03 -n myclust-3 Add a service to an existing database with preferred instances (-r) and available instances (-a). list of available instances.201.255.. address specification.1/255.]>] [. TAF preconnect policy .. .184. srvctl add database -d ORACLE -o $ORACLE_HOME Add named instances to an existing database.0/hme0 Add a new database. this list cannot include available instances. list of preferred instances. and database.mydomain.] [<logical host name>]/<VIP address>/<net mask> [/<host interface1[ | host interface2 |..com‖ -n node name that will support one or more instances -o $ORACLE_HOME to locate Oracle binaries -P for services.NONE. Instances that already support the service should not be included. Use basic failover to the available instances. EXAMPLES: Add a new node: srvctl add nodeapps -n myclust-1 -o $ORACLE_HOME –A 139.255. -s spfile name -u updates the preferred or available list for the service to support the specified instance.]]] srvctl add asm -n <node_name> -i <asm_inst_name> -o <oracle_home> OPTIONS: -A vip range.]>] -a for services. node. Only one instance may be specified with the -u switch. this list cannot include preferred instances -m domain name with the format ―us.ADD CRS RESOURCES srvctl add database -d <name> -o <oracle_home> [-m <domain_name>] [-p <spfile>] [-A <name|ip>/netmask] [-r {PRIMARY | PHYSICAL_STANDBY | LOGICAL_STANDBY}] [-s <start_options>] [-n <db_name>] srvctl add instance -d <name> -i <inst_name> -n <node_name> srvctl add service -d <name> -s <service_name> -r <preferred_list> [-a <available_list>] [-P <TAF_policy>] [-u] srvctl add nodeapps -n <node_name> -o <oracle_home> [-A <name|ip>/netmask[/if1[|if2|. srvctl add service -d ORACLE -s STD_BATCH -r RAC01,RAC02 -a RAC03,RAC04 Add a service to an existing database with preferred instances in list one and available instances in list two. Use preconnect at the available instances. srvctl add service -d ORACLE -s STD_BATCH -r RAC01,RAC02 -a RAC03,RAC04 -P PRECONNECT REMOVE CRS RESOURCES srvctl remove database -d <database-name> srvctl remove instance -d <database-name> [-i <instance-name>] srvctl remove service -d <database-name> -s <service-name> [-i <instance-name>] srvctl remove nodeapps -n <node-name> EXAMPLES: Remove the applications for a database. srvctl remove database -d ORACLE Remove the applications for named instances of an existing database. srvctl remove instance -d ORACLE -i RAC03 srvctl remove instance -d ORACLE -i RAC04 Remove the service. srvctl remove service -d ORACLE -s STD_BATCH Remove the service from the instances. srvctl remove service -d ORACLE -s STD_BATCH -i RAC03,RAC04 Remove all node applications from a node. srvctl remove nodeapps -n myclust-4 MODIFY CRS RESOURCES srvctl modify database -d <name> [-n <db_name] [-o <ohome>] [-m <domain>] [-p <spfile>] [-r {PRIMARY | PHYSICAL_STANDBY | LOGICAL_STANDBY}] [-s <start_options>] srvctl modify instance -d <database-name> -i <instance-name> -n <node-name> srvctl modify instance -d <name> -i <inst_name> {-s <asm_inst_name> | -r} srvctl modify service -d <database-name> -s <service_name> -i <instance-name> -t <instance-name> [-f] srvctl modify service -d <database-name> -s <service_name> -i <instance-name> -r [-f] srvctl modify nodeapps -n <node-name> [-A <address-description> ] [-x] OPTIONS: -i <instance-name> -t <instance-name> the instance name (-i) is replaced by the instance name (-t) -i <instance-name> -r the named instance is modified to be a preferred instance -A address-list for VIP application, at node level -s <asm_inst_name> add or remove ASM dependency EXAMPLES: Modify an instance to execute on another node. srvctl modify instance -d ORACLE -n myclust-4 Modify a service to execute on another node. srvctl modify service -d ORACLE -s HOT_BATCH -i RAC01 -t RAC02 Modify an instance to be a preferred instance for a service. srvctl modify service -d ORACLE -s HOT_BATCH -i RAC02 –r RELOCATE SERVICES srvctl relocate service -d <database-name> -s <service-name> [-i <instance-name >]-t<instancename > [-f] EXAMPLES: Relocate a service from one instance to another srvctl relocate service -d ORACLE -s CRM -i RAC04 -t RAC01 ENABLE CRS RESOURCES (The resource may be up or down to use this function) srvctl enable database -d <database-name> srvctl enable instance -d <database-name> -i <instance-name> [,<instance-name-list>] srvctl enable service -d <database-name> -s <service-name>] [, <service-name-list>] [-i <instance-name>] EXAMPLES: Enable the database. srvctl enable database -d ORACLE Enable the named instances. srvctl enable instance -d ORACLE -i RAC01, RAC02 Enable the service. srvctl enable service -d ORACLE -s ERP,CRM Enable the service at the named instance. srvctl enable service -d ORACLE -s CRM -i RAC03 DISABLE CRS RESOURCES (The resource must be down to use this function) srvctl disable database -d <database-name> srvctl disable instance -d <database-name> -i <instance-name> [,<instance-name-list>] srvctl disable service -d <database-name> -s <service-name>] [,<service-name-list>] [-i <instance-name>] EXAMPLES: Disable the database globally. srvctl disable database -d ORACLE Disable the named instances. srvctl disable instance -d ORACLE -i RAC01, RAC02 Disable the service globally. srvctl disable service -d ORACLE -s ERP,CRM Disable the service at the named instance. srvctl disable service -d ORACLE -s CRM -i RAC03,RAC04 11gR2 RAC Commands SRVCTL Commands SRVCTL is used to manage the following resources (components): Component asm database diskgroup filesystem home listener service ons, eons Abbreviation asm db dg filesystem home lsnr serv ons, eons Description Oracle ASM instance Database instance Oracle ASM disk group Oracle ASM file system Oracle home or Oracle Clusterware home Oracle Net listener Database service Oracle Notification Services (ONS) The available commands used with SRVCTL are: Command Description add Adds a component to the Oracle Restart configuration. config Displays the Oracle Restart configuration for a component. disable Disables management by Oracle Restart for a component. enable Reenables management by Oracle Restart for a component. getenv Displays environment variables in the Oracle Restart configuration for a database, Oracle ASM instance, or listener. modify Modifies the Oracle Restart configuration for a component. remove Removes a component from the Oracle Restart configuration. setenv Sets environment variables in the Oracle Restart configuration for a database, Oracle ASM instance, or listener. start Starts the specified component. status Displays the running status of the specified component. stop Stops the specified component. unsetenv Unsets environment variables in the Oracle Restart configuration for a database, Oracle ASM instance, or listener. Commands Objects Comment srvctl add srvctl modify srvctl remove srvctl relocate instance database service nodeapps service The OCR is modified. You can reallocate a service from one named instance to another named instance. srvctl start srvctl stop srvctl status instance database service asm nodeapps enable = when the server restart the resource must be restarted disable = when the server restart the resource must NOT be restarted (perhaps we are working for some maintenance tasks) Lists configuration information from the OCR (Oracle Cluster Registry). srvctl getenv = displays the environment variables stored in the OCR for target. srvctl setenv = allows these variables to be set srvctl unsetenv = llows these variables to be unset srvctl disable srvctl enable instance database service asm srvctl config database service asm nodeapps instance database service nodeapps srvctl getenv srvctl setenv srvctl unsetenv Frequently used commands: srvctl start database -d DBname srvctl stop database -d DBname srvctl start instance -d DBname -i INSTANCEname srvctl stop instance -d DBname -i INSTANCEname srvctl start instance -d DBname -i INSTANCEname srvctl stop instance -d DBname -i INSTANCEname srvctl status database -d DBname srvctl status instance -d DBname -i INSTANCEname srvctl status nodeapps -n NODEname srvctl enable database -d DBname srvctl disable database -d DBname srvctl enable instance -d DBname -i INSTANCEname srvctl disable instance -d DBname -i INSTANCEname srvctl config database -d DBname srvctl getenv nodeaps -> to get some information about the database from OCR. which consists of the following: Oracle Clusterware. the member nodes and server pools Oracle ASM (if installed) Cluster Synchronization Services Cluster Time Synchronization Services crsctl add crs administrator crsctl add css votedisk crsctl add serverpool . CRSCTL Commands Dual Environment CRSCTL Commands: crsctl add resource crsctl add type crsctl check css crsctl delete resource crsctl delete type crsctl get hostname crsctl getperm resource crsctl getperm type crsctl modify resource crsctl modify type crsctl setperm resource crsctl setperm type crsctl start resource crsctl status resource crsctl status type crsctl stop resource Oracle RAC Environment CRSCTL Commands: The commands listed in this section manage the Oracle Clusterware stack in an Oracle RAC environment. crsctl check cluster crsctl check crs crsctl check resource crsctl check ctss crsctl config crs crsctl delete crs administrator crsctl delete css votedisk crsctl delete node crsctl delete serverpool crsctl disable crs crsctl enable crs crsctl get css crsctl get css ipmiaddr crsctl get nodename crsctl getperm serverpool crsctl lsmodules crsctl modify serverpool crsctl pin css crsctl query crs administrator crsctl query crs activeversion crsctl query crs releaseversion crsctl query crs softwareversion crsctl query css ipmidevice crsctl query css votedisk crsctl relocate resource crsctl relocate server crsctl replace discoverystring crsctl replace votedisk crsctl set css crsctl set css ipmiaddr crsctl set css ipmiadmin crsctl setperm serverpool crsctl start cluster crsctl start crs crsctl status server crsctl status serverpool crsctl stop cluster crsctl stop crs crsctl unpin css crsctl unset css . Oracle Restart Environment CRSCTL Commands: The commands listed in this section control Oracle High Availability Services. crsctl check has crsctl config has crsctl disable has crsctl enable has crsctl query has releaseversion crsctl query has softwareversion crsctl start has crsctl stop has ATTENTION: The following commands are deprecated in Oracle Clusterware 11g release 2 (11.2): crs_stat crs_register crs_unregister crs_start crs_stop crs_getperm crs_profile crs_relocate crs_setperm crsctl check crsd crsctl check cssd crsctl check evmd crsctl debug log crsctl set css votedisk crsctl start resources crsctl stop resources CRSD:   Cluster Ready Services Daemon Engine for HA operation . LMS (Global Cache Services) Enables copies of blocks to be transferred from one instance to another without writing to disk (cache fusion) LMON (Global Enqueue Services Monitor) .2. spawns children Scans callout directory and invokes callouts Runs as Oracle Restarted automatically on failure OPROCD   Process monitor for the cluster (not used on Linux and Windows) Starting with 10.Stores current known state in the OCR. Failure exit causes machine reboot.0. and fails 'application resources' over Spawns separate 'actions' to start/stop/check application resources Maintains configuration profiles in the OCR (Oracle Configuration Repository). clusterware will reboot the nodes. stops. when present Can also runs without integration to vendor clustware Runs as Oracle.4. If OPROCS fails. This is a feature to prevent data corruption in event of a split brain. Runs as root Is restarted automatically on failure OCSSD:           Cluster Synchronization Services Daemon OCSSD is part of RAC and Single Instance with ASM Provides access to node membership Provides group services Provides basic cluster locking Integrates with existing vendor clusteware. on demand. it replace hangcheck timer module on Linux.      Manages 'application resources' Starts. EVMD:        Event Management Daemon Generates events when things happen Spawns a permanent child evmlogger Evmlogger. responsible for cluster reconfiguration and locks when an instance joins or leaves the cluster LMD (Global Enqueue Services daemon) Lock Manager.Lock monitor. Specify the type of failover. Three types of Oracle Net failover functionality are available by default to Oracle Call Interface (OCI) applications: . A backup should be specified when using preconnect to pre-establish connections. FAILOVER_MODE can contain the subparameters described in Table 13-4. Table 13-4 Subparameters of the FAILOVER_MODE Parameter FAILOVER_MODE Subparameter BACKUP TYPE Description Specify a different net service name for backup connections. manage requests for resources to control access to blocks LCK0 (Instance Enqueue process) Manages instance resource requests and cross-instance call operations for shared resources DIAG (Diagnostic daemon) Diagnostic needs for a RAC environment TAF Database Configurations TAF works with the following database configurations to effectively mask a database failure:     Oracle Real Application Clusters Replicated systems Standby databases Single instance Oracle database See Also: Oracle Real Application Clusters Installation and Configuration Guide FAILOVER_MODE Parameters The FAILOVER_MODE parameter must be included in the CONNECT_DATA section of a connect descriptor. Note: Oracle Net Manager does not provide support for TAF parameters. none: This is the default. Note: If a callback function is registered. This provides faster failover but requires that the backup instance be able to support all connections from every supported instance. No failover functionality is used. If DELAY is specified. preconnect: Set to pre-established connections. DELAY defaults to one second. RETRIES defaults to five retry attempts. a new session is automatically created for the user on the backup. TAF Implementation Important: Do not set the GLOBAL_DBNAME parameter in the SID_LIST_listener_name section of the listener. RETRIES Specify the number of times to attempt to connect after a failover. DELAY Specify the amount of time in seconds to wait between connect attempts. This option requires almost no work on the backup server until failover time. This can also be explicitly specified to prevent failover from happening. However. Note: If a callback function is registered. select: Set to enable users with open cursors to continue fetching on them after failure. If RETRIES is specified. then this subparameter is ignored. . This type of failover does not attempt to recover selects. A statically configured global database name disables TAF.ora. These parameters must be manually added. If a user's connection is lost.FAILOVER_MODE Subparameter Description  session:   Set to failover the session. then this subparameter is ignored. this mode involves overhead on the client side in normal select operations. METHOD Determines how fast failover occurs from the primary node to the backup node:   basic: Set to establish connections at failover time. com= (DESCRIPTION= (ADDRESS= (PROTOCOL=tcp) (HOST=sales1-server) (PORT=1521)) (CONNECT_DATA= (SERVICE_NAME=sales. In the following example.com= (DESCRIPTION= (LOAD_BALANCE=on) (FAILOVER=on) (ADDRESS= (PROTOCOL=tcp) (HOST=sales1-server) (PORT=1521)) (ADDRESS= (PROTOCOL=tcp) (HOST=sales2-server) (PORT=1521)) (CONNECT_DATA= (SERVICE_NAME=sales.us. Oracle Net attempts to reconnect up to 20 times.com) (FAILOVER_MODE= (TYPE=select) (METHOD=basic) (RETRIES=20) . reserving any SELECT statements in progress. If the failover connection fails. you can implement TAF in a number of ways.us. Oracle Net waits 15 seconds before trying to reconnect again.Depending on the FAILOVER_MODE parameters.acme.us.acme. Oracle Net tries to reconnect to the listener on sales1-server. If the instance fails after the connection. Oracle recommends the following methods:    Example: TAF with Connect-Time Failover and Client Load Balancing Example: TAF Retrying a Connection Example: TAF Pre-Establishing a Connection Example: TAF with Connect-Time Failover and Client Load Balancing Implement TAF with connect-time failover and client load balancing for multiple addresses.acme.acme. the TAF application fails over to the other node's listener. sales. sales.us. In the following example.com) (FAILOVER_MODE= (TYPE=select) (METHOD=basic)))) Example: TAF Retrying a Connection TAF also provides the ability to automatically retry connecting if the first connection attempt fails with the RETRIES and DELAY parameters. Oracle Net connects randomly to one of the protocol addresses on sales1-server or sales2-server. acme. Likewise. Use the V$SESSION view to obtain information about the connected clients and their TAF status.us.acme.us.us.com= (DESCRIPTION= (ADDRESS= (PROTOCOL=tcp) (HOST=sales2-server) (PORT=1521)) (CONNECT_DATA= (SERVICE_NAME=sales.acme.com to connect to the listener on sales2-server.com) (INSTANCE_NAME=sales2) (FAILOVER_MODE= (BACKUP=sales1. Oracle Net fails over to sales2server. and FAILED_OVER columns to verify that you have correctly configured TAF as in the following SQL statement: SELECT MACHINE.us.(DELAY=15)))) Example: TAF Pre-Establishing a Connection A backup connection can be pre-established. FAILOVER_METHOD. preserving any SELECT statements in progress. For example.us. and FAILED_OVER columns in the V$SESSION view to verify that TAF is correctly configured.acme. FAILOVER_METHOD. FAILOVER_METHOD. Oracle Net preconnects to sales1-server for those clients that use sales2. If sales1-server fails after the connection.us.us. sales1.us. FAILED_OVER. The initial and backup connections must be explicitly specified. query the FAILOVER_TYPE.com= (DESCRIPTION= (ADDRESS= (PROTOCOL=tcp) (HOST=sales1-server) (PORT=1521)) (CONNECT_DATA= (SERVICE_NAME=sales. FAILOVER_TYPE.acme.com) (INSTANCE_NAME=sales1) (FAILOVER_MODE= (BACKUP=sales2.com) (TYPE=select) (METHOD=preconnect)))) sales2.com) (TYPE=select) (METHOD=preconnect)))) TAF Verification You can query FAILOVER_TYPE.acme.com to connect to the listener on sales1-server are also preconnected to sales2-server.acme. COUNT(*) FROM V$SESSION . clients that use net service name sales1.acme. In the following example. GROUP BY MACHINE.------------.---------. See Also:   Oracle Call Interface Programmer's Guide Oracle Database Reference for more information about the V$SESSION view Specifying the Instance Role for Primary and Secondary Instance Configurations The INSTANCE_ROLE parameter is an optional parameter for the CONNECT_DATA section of a connect descriptor. FAILED_OVER. This parameter is useful when:   You want to explicitly connect to a primary or secondary instance.---------. The output before failover resembles the following: MACHINE FAILOVER_TYPE FAILOVER_M FAI COUNT(*) -------------------.--. INSTANCE_ROLE supports the following values: primary — Specifies a connection to the primary instance secondary — Specifies a connection to the secondary instance . FAILOVER_METHOD. You want to use TAF to preconnect to a secondary instance.------------.--.---------sales2 NONE NONE NO 10 sales2 SELECT PRECONNECT YES 1 Note: You can monitor each step of TAF using an appropriately configured OCI TAF CALLBACK function.---------sales1 NONE NONE NO 11 sales2 SELECT PRECONNECT NO 1 The output after failover is: MACHINE FAILOVER_TYPE FAILOVER_M FAI COUNT(*) -------------------. FAILOVER_TYPE. The default is the primary instance. It enables you to specify a connection to the primary or secondary instance of Oracle9i Real Application Clusters configurations. com) (INSTANCE_ROLE=secondary))) Example: Connection To a Specific Instance There are times when Oracle Enterprise Manager and other system management products need to connect to a specific instance regardless of its role to perform administrative tasks. net service name sales1 enables connections to the instance on sales1-server and sales2 enables connections to the instance on sales2-server. In the following example.us.acme.com) (INSTANCE_ROLE=primary))) sales_secondary= (DESCRIPTION= (ADDRESS= (PROTOCOL=tcp) (HOST=sales1-server) (PORT=1521)) (ADDRESS= (PROTOCOL=tcp) (HOST=sales2-server) (PORT=1521)) (CONNECT_DATA= (SERVICE_NAME=sales. sales1= (DESCRIPTION= (ADDRESS= (PROTOCOL=tcp) (HOST=sales1-server) . sales_primary= (DESCRIPTION= (ADDRESS= (PROTOCOL=tcp) (HOST=sales1-server) (PORT=1521)) (ADDRESS= (PROTOCOL=tcp) (HOST=sales2-server) (PORT=1521)) (CONNECT_DATA= (SERVICE_NAME=sales. net service name sales_primary enables connections to the primary instance. (SERVER=dedicated) is specified to force a dedicated server connection. configure (INSTANCE_NAME=instance_name) and (INSTANCE_ROLE=any) to connect to the instance regardless of its role. For these types of connections.any — Specifies a connection to whichever instance has the lowest load. regardless of primary or secondary instance role Example: Connection to Instance Role Type In the following example.us.acme. and net service name sales_secondary enables connections to the secondary instance. If sales1-server fails after the connection.us.(PORT=1521)) (CONNECT_DATA= (SERVICE_NAME=sales.com) (INSTANCE_ROLE=any) (INSTANCE_NAME=sales2) (SERVER=dedicated))) sales2= (DESCRIPTION= (ADDRESS= (PROTOCOL=tcp) (HOST=sales2-server) (PORT=1521)) (CONNECT_DATA= (SERVICE_NAME=sales.acme. a backup connection can be preestablished to the secondary instance. preserving any SELECT statements in progress. sales1.acme. the secondary instance.us.acme.acme. The initial and backup connections must be explicitly specified.acme. Oracle Net connects to the listener on sales1-server and preconnects to sales2-server.us.com= (DESCRIPTION= (ADDRESS= (PROTOCOL=tcp) (HOST=sales1-server) (PORT=1521)) (CONNECT_DATA= (SERVICE_NAME=sales.acme.com) (TYPE=select) (METHOD=preconnect)))) sales2.acme. the secondary instance.com) (INSTANCE_ROLE=primary) (FAILOVER_MODE= (BACKUP=sales2.com) (INSTANCE_ROLE=any) (INSTANCE_NAME=sales2) (SERVER=dedicated))) Example: TAF Pre-Establishing a Connection If Transparent Application Failover (TAF) is configured. the TAF application fails over to sales2-server.com) (INSTANCE_ROLE=secondary))) racandtaf .com= (DESCRIPTION= (ADDRESS= (PROTOCOL=tcp) (HOST=sales2-server) (PORT=1521)) (CONNECT_DATA= (SERVICE_NAME=sales.us. In the following example. com/art_oramag_rac_taf. tracking how many rows have been fetched back to the client for each cursor associated with a SELECT statement. Now let's see how Oracle RAC and TAF work together to ensure that a server failure does not cause an unplanned service interruption. repositioning the cursors so the client can continue .RAC and TAF Home >> Reference >> Oracle RAC >> RAC and TAF From http://www. Inside OCI are TAF callback routines that can be used to make any application failover-aware. because there are many ways to restart in-flight transactions. Using Transparent Application Failover After an Oracle RAC node crashes—usually from a hardware failure—all new application transactions are automatically rerouted to a specified backup node. While the concept of failover is simple. providing an apparent instant failover can be extremely complex. Oracle RAC keeps track of all resources and resource states on each node and then uses this information to restart these resources on a backup node. The TAF architecture offers the ability to restart transactions at either the transaction (SELECT) or session level:  SELECT failover. These services are then remastered based on the current membership of the cluster. With SELECT failover. Oracle Net establishes a connection to another Oracle RAC node and reexecutes the SELECT statements. the Cluster Manager uses a background process—Global Enqueue Service Monitor (LMON)—to monitor the health of the cluster.dba-oracle. To successfully remaster the cluster services. TAF allows the DBA to configure the type and method of failover for each Oracle Net client. Oracle Net keeps track of all SELECT statements issued during the transaction. the Cluster Manager reports the change in the cluster's membership to Global Cache Services (GCS) and Global Enqueue Service (GES). For an application to use TAF. If the connection to the instance is lost. allowing a failed node to resume processing on another server without interruption. Oracle's answer to application failover is a new Oracle Net mechanism dubbed Transparent Application Failover. The challenge in rerouting is to not lose transactions that were "in flight" at the exact moment of the crash. it must use failover-aware API calls from the Oracle Call Interface (OCI).htm Oracle RAC and Hardware Failover To detect a node failure. When a node fails. These processes also manage the state of in-flight transactions and work with TAF to either restart or resume the transactions on the new node. One of the requirements of continuous availability is the ability to restart in-flight application transactions. depending on processing requirements. This approach has low overhead. Let's take a closer look at how this works. and each Oracle Net client may have unique failover types and methods. In this approach. Transactions involving INSERT. TAF must restart some types of transactions from the beginning of the transaction. but the end user experiences a delay while the new connection is created. where transactions are small. PL/SQL package states are lost during failover. The following is a client tnsnames. UPDATE. PRECONNECT failover. including its current TAF failover parameters: . or DELETE statements are not supported by TAF. SESSION failover. Currently. But the extra connection adds everyday overhead by duplicating connections. tnsnames. The Oracle DBA may choose one of the following failover methods:   BASIC failover. the application simultaneously connects to both a primary and a backup node. PL/SQL package states. The following types of transactions do not automatically fail over and must be restarted by TAF:      Transactional statements. SESSION failover results only in the establishment of a new connection to another Oracle RAC node. This offers faster failover. TAF will fail over standard SQL SELECT statements that have been caught during a node crash in an in-flight transaction failure. In the current release of TAF. Transactions using temporary segments in the TEMP tablespace and global temporary tables do not fail over. the application connects to a backup node only after the primary connection fails. Using Oracle RAC and TAF Together The continuous availability features of Oracle RAC and TAF come together when these products cooperate in restarting failed transactions.ora file parameters define the failover types and methods for that client. The SELECT failover approach is best for data warehouse systems that perform complex and time-consuming transactions. SESSION failover is ideal for online transaction processing (OLTP) systems. The following do not fail over and cannot be restarted: Temporary objects. however. In this approach. any work in progress is lost. It is important to note that TAF failover control is external to the Oracle RAC cluster. Oracle TAF also offers choices on how to restart a failed transaction. ALTER SESSION statements. fetching rows as if nothing has happened. When the connection to an instance is lost. The parameters direct Oracle RAC and TAF on how to restart any transactions that may be in-flight during a hardware failure on the node. ALTER SESSION and SQL*Plus SET statements do not fail over. Within each connected Oracle Net client.ora file entry for a node. because a pre-spawned connection is ready to use. Remember. RETRIES=20.ora file on every Oracle Net client that needs transparent failover. DELAY=3.world = (DESCRIPTION_LIST = (FAILOVER = true) (LOAD_BALANCE = true) (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP) (HOST = redneck)(PORT = 1521)) (CONNECT_DATA = (SERVICE_NAME = bubba) (SERVER = dedicated) (FAILOVER_MODE = (BACKUP=cletus) (TYPE=select) (METHOD=preconnect) (RETRIES=20) (DELAY=3) ) ) ) The failover_mode section of the tnsnames.ora file that governs the failover method for all connections that are routed to that application server. This tells TAF to restart all in-flight transactions from the beginning of the transaction (and not to track cursor states within each transaction).ora file lists the parameters and their values: BACKUP=cletus. the primary server is bubba. In case of instance failure. the cletus database will be ready to resume the failed transaction.bubba. METHOD=preconnect. In this example. This tells TAF to wait three seconds between connection retries. TYPE=select. Putting It All Together An Oracle Net client can be a single PC or a huge application server. This names the backup node that will take over failed connections when a node crashes. Watching TAF in Action . and TAF will reconnect failed transactions to the cletus instance in case of server failure. In the architectures of giant Oracle RAC systems. you must set these TAF parameters in every tnsnames. each application server has a customized tnsnames. This directs TAF to retry a failover connection up to 20 times. This directs TAF to create two connections at transaction startup time: one to the primary bubba database and a backup connection to the cletus database. and they need to be able to get the status of failover transactions. so you'll only see entries for a short period of time immediately after the failover.Current block CR . Remember. The following query calls the new FAILOVER_TYPE. TAF will quickly redirect transactions. To provide this capability. serial#. You can run this script against the backup node after an instance failure to see those transactions that have been reconnected with TAF.Consistent Read block . because Oracle data definition language (DDL) and data manipulation language (DML) are not recoverable with TAF. 'PERFSTAT') and failed_over = 'YES'. A backup node can have a variety of concurrent failover transactions. and FAILED_OVER columns of the V$SESSION view. Be sure to note that the query is restricted to nonsystem sessions.ora file on each Oracle Net client specifies the backup node.Global Cache Current .The transparency of TAF operation is a tremendous advantage to application users. failover_type. failover_method. failed_over from v$session where username not in ('SYS'.'SYSTEM'. because the tnsnames. sid. the Oracle data dictionary has several new columns in the V$SESSION view that give the current status of failover transactions. and the failover method. the failover type. select username. but DBAs need to quickly see what has happened and where failover traffic is going. FAILOVER_METHOD. RAC Performance Tuning Global Cache Wait Events GC . Use the above actions to increase the performance .Wait Event Contention type Description An instance requests authorization for a block to be accessed in current mode t the resource receives the request. The master has the current version of the blo to the requester via Cache Fusion and keeps a Past Image (. It also keeps a past Image (PI). segments in the "current blocks received" secti Use application partitioning scheme Make sure the system has enough CPU power Make sure the interconnect is as fast as possible Ensure that socket send and receive buffers are configured correctly gc current block 3-way write/write An instance requests authorization for a block to be accessed in current mode t the resource receives the request and forwards it to the current holder of the bl holding instance sends a copy of the current version of the block to the request exclusive lock to the requesting instance.PI) If you get this then do the following gc current block 2-way write/write      Analyze the contention. you can use incremental backups to quickly move a standby database forward in time or load new data into a clone database for testing purposes. You can perform testing in a clone or standby database configuration. Steps .Transaction enqueue.Sequence enqueue.Enqueue used mainly for transaction recovery as part of instance recovery Incremental Roll Forward Overview With Oracle Database 10g. used to serialize incrementing of an Oracle sequence number US . used to protect table definitions during DML operations HW . used to protect table definitions during DML operation SQ . mainly used by the Automatic Undo Management (AUM) feature TA . then flash back the test changes.gc current block 2-way gc current block 3-way write/read write/read The difference with the one above is that this sends a copy of the block thus ke The difference with the one above is that this sends a copy of the block thus ke The requester will eventually get the block via cache fusion but it is delayed du   gc current block busy The block was being used by another session on another session was delayed as the holding instance could not write the corresponding write/write If you get this then do the following  Ensure the log writer is tuned gc current buffer busy gc current block congested local none This is the same as above (gc current block busy).Table or partition enqueue. used for transaction demarcation and tracking TM . and periodically refresh the clone database (or standby database) from the primary database by using the generated incremental backups. the difference is that anothe requested the block (hence local contention) This is caused if heavy congestion on the GCS.Undo Segment enqueue. thus CPU resources are stretch Global Enqueue Waits       TX .High-Water Mark enqueue. Startup and Open Standby Database Startup commands startup nomount alter database mount standby database. Errors when users are connecting: SQL> alter database recover managed standby database disconnect from session. Open standby read only alter database recover managed standby database cancel. select OPEN_MODE from v$database. alter database open read only.'DD-MON-YYYY HH24:MI:SS') from v$dataguard_status. Enable Flashback Database on the clone database. 5. Flash back all changes done during the testing. Go to step 2. Apply incremental backup from the original production database.1. 7. select severity. 2.message. 4. Back to redo apply (it only works when users are disconnect from the database) alter database recover managed standby database disconnect from session. alter database recover managed standby database disconnect. 6. Open the clone database resetlogs for use as a testing database. Roll the clone database forward to make it transactionally consistent. alter database recover managed standby database disconnect from session * ERROR at line 1: ORA-01093: ALTER DATABASE CLOSE only permitted with no sessions connected .to_char(timestamp. 8. Make an image copy (clone) of the primary database for test purposes. 3. Perform testing for the required period (day or week). error_code. --9i db Check protection mode on primary database select protection_mode. Start. Log Apply Start log apply in standby alter database recover managed standby database disconnect from session. alter database recover managed standby database nodelay disconnect. Cancel managed recovery/stop log apply alter database recover managed standby database cancel... . alter database stop logical standby apply. DB_UNIQUE_NAME. Disable/Enable archive log destinations alter system set log_archive_dest_state_2 = 'defer'. OPEN_MODE. DATABASE_ROLE from v$database. protection_level from v$database..BLOCK#. alter system set log_archive_dest_state_2 = 'enable'.SEQUENCE#. STATUS. PROTECTION_MODE PROTECTION_LEVEL -------------------..Check Primary and Standby Status Check role and status (both primary and standby) select NAME. OPEN_MODE.-------------------MAXIMUM PERFORMANCE MAXIMUM PERFORMANCE Check processes and statuses SELECT PROCESS.BLOCKS. Logical standby apply stop/start Stop. select NAME. DATABASE_ROLE from v$database. Remove a delay from a standby alter database recover managed standby database cancel. DELAY_MINS FROM V$MANAGED_STANDBY. from sequence# v$archived_log where dest_id=1) local where local.thread# . select * from v$archive_gap. first_time. select sequence#.thread#) . archived. select local. next_time v$archived_log order by sequence#. from Run this on both primary and standby select count(*) from v$archive_gap. select max(sequence#) from v$log_history. Logs Check which logs are missing and log apply gap Run this on the standby alter session set nls_date_format = 'DD-MON-YYYY HH24:MI:SS'. local.alter database start logical standby apply.sequence# not in (select sequence# from v$archived_log where dest_id=2 and thread# = local.sequence# from (select thread# . applied. alter database recover automatic standby database. If that doesn't work. Switch logs alter system switch logfile. If FAL doesn't work and it says the log is already registered alter database register or replace physical logfile '<fullpath/filename>'. shutdown immediate startup nomount alter database mount standby database. . Then run this on the standby set numwidth 15 select max(applied_seq#) last_seq from v$archive_dest_status. try this... Register a missing log file alter database register physical logfile '<fullpath/filename>'. alter system archive log current./ See how up to date a physical standby is Run this on the primary set numwidth 15 select max(sequence#) current_seq from v$log. dest_id = ad.status . Display info about all log destinations To be run on the primary set lines 100 set numwidth 15 column ID format 99 column "SRLs" format 99 column active format 99 col type format a4 select ds. v$archive_dest ad where ds. ds.archiver type .wait for the recovery to finish . ds.standby_logfile_active active . ds.dest_id / Display log destinations options To be run on the primary set numwidth 8 lines 100 . ds. alter database recover managed standby database disconnect. ds.recovery_mode .database_mode db_mode .dest_id and ad.status != 'INACTIVE' order by ds. ad.then cancel shutdown immediate startup nomount alter database mount standby database. ad.dest_id id .protection_mode .standby_logfile_count "SRLs" . ds.archived_seq# from v$archive_dest_status ds . async_blocks async .group# . delay_mins delay . net_timeout net_time .sequence# .member from v$standby_log st .group# . v$logfile lf where st.column id format 99 select dest_id id . st. ceil(st. archiver . lf.binding from v$archive_dest order by dest_id / List any standby redo logs set lines 100 pages 999 col member format a70 select st. affirm . register.bytes / 1048576) mb . transmit_mode .group# = lf. reopen_secs reopen . select OPEN_MODE from v$database. alter database recover managed standby database disconnect.message.'DD-MON-YYYY HH24:MI:SS') from v$dataguard_status. Open standby read only alter database recover managed standby database cancel. Back to redo apply (it only works when users are disconnect from the database) alter database recover managed standby database disconnect from session. alter database recover managed standby database disconnect from session * ERROR at line 1: ORA-01093: ALTER DATABASE CLOSE only permitted with no sessions connected . alter database open read only.Misc Turn on fal tracing on the primary db alter system set LOG_ARCHIVE_TRACE = 128. select severity.to_char(timestamp. Stop the Data Guard broker alter system set dg_broker_start=false. Startup and Open Standby Database Startup commands startup nomount alter database mount standby database. Errors when users are connecting: SQL> alter database recover managed standby database disconnect from session. error_code. -------------------MAXIMUM PERFORMANCE MAXIMUM PERFORMANCE Check processes and statuses SELECT PROCESS. Disable/Enable archive log destinations alter system set log_archive_dest_state_2 = 'defer'. protection_level from v$database. Cancel managed recovery/stop log apply alter database recover managed standby database cancel. Remove a delay from a standby alter database recover managed standby database cancel. OPEN_MODE.Check Primary and Standby Status Check role and status (both primary and standby) select NAME. . DATABASE_ROLE from v$database. Logical standby apply stop/start Stop. DATABASE_ROLE from v$database. alter system set log_archive_dest_state_2 = 'enable'. alter database recover managed standby database nodelay disconnect. DELAY_MINS FROM V$MANAGED_STANDBY. STATUS.BLOCK#. alter database stop logical standby apply.SEQUENCE#. --9i db Check protection mode on primary database select protection_mode. Log Apply Start log apply in standby alter database recover managed standby database disconnect from session. PROTECTION_MODE PROTECTION_LEVEL -------------------. OPEN_MODE. select NAME. DB_UNIQUE_NAME..BLOCKS.. sequence# not in (select sequence# from v$archived_log where dest_id=2 and . first_time. select sequence#.Start. select max(sequence#) from v$log_history. archived. Logs Check which logs are missing and log apply gap Run this on the standby alter session set nls_date_format = 'DD-MON-YYYY HH24:MI:SS'..thread# . applied. next_time v$archived_log order by sequence#. from Run this on both primary and standby select count(*) from v$archive_gap. select local.sequence# from (select thread# . alter database start logical standby apply. from sequence# v$archived_log where dest_id=1) local where local. select * from v$archive_gap. local.. If that doesn't work. Switch logs alter system switch logfile. shutdown immediate startup nomount alter database mount standby database. try this.thread# = local.. . alter system archive log current.thread#) / See how up to date a physical standby is Run this on the primary set numwidth 15 select max(sequence#) current_seq from v$log. Register a missing log file alter database register physical logfile '<fullpath/filename>'. Then run this on the standby set numwidth 15 select max(applied_seq#) last_seq from v$archive_dest_status. alter database recover automatic standby database. If FAL doesn't work and it says the log is already registered alter database register or replace physical logfile '<fullpath/filename>'.. ds.protection_mode . ds.dest_id = ad.then cancel shutdown immediate startup nomount alter database mount standby database.wait for the recovery to finish . Display info about all log destinations To be run on the primary set lines 100 set numwidth 15 column ID format 99 column "SRLs" format 99 column active format 99 col type format a4 select ds. ad.archived_seq# from v$archive_dest_status ds . ds.dest_id and ad.status .database_mode db_mode .dest_id id . v$archive_dest ad where ds. alter database recover managed standby database disconnect. ds.dest_id / Display log destinations options To be run on the primary . ds. ds. ad.recovery_mode .standby_logfile_count "SRLs" .standby_logfile_active active .status != 'INACTIVE' order by ds.archiver type . affirm . archiver . lf.group# .sequence# .binding from v$archive_dest order by dest_id / List any standby redo logs set lines 100 pages 999 col member format a70 select st. register. st.group# = lf. reopen_secs reopen . delay_mins delay . v$logfile lf where st. async_blocks async . net_timeout net_time .set numwidth 8 lines 100 column id format 99 select dest_id id .group# . transmit_mode . ceil(st.member from v$standby_log st .bytes / 1048576) mb . Instance Tuning Steps Step 1: Define the Problem      Identify the performance objective. What is affected by the slowdown? Is the whole instance slow? Is it a particular application. Note that wait I/O should be considered as idle CPU. What is the measure of acceptable performance? How many transactions an hour. or database bottleneck. Stop the Data Guard broker alter system set dg_broker_start=false. application software.Misc Turn on fal tracing on the primary db alter system set LOG_ARCHIVE_TRACE = 128. or has the data volume or user population grown Step 2: Examine the Host System and Examine the Oracle Statistics Examine Host System   CPU Usage o If there is a significant amount of idle CPU. application. program. hardware. then use SQL_TRACE and TKPROF to identify the SQL or PL/SQL statements o Oracle CPU statistics: V$SYSSTAT. or a single user? Identify the time frame when the problem occurs. then determine whether the CPU is being used effectively. or Oracle release been upgraded? Has more data been loaded into the system. specific operation. If a small number of Oracle processes consumes most of the CPU resources. Has the operating system software. response time will meet the required performance level? Identify the scope of the problem. or seconds. or is the CPU consumed by an evenly distributed workload? o If the CPU is used by a small number of high-usage programs. o If there is high CPU usage. Identify any changes. Is the majority of CPU usage attributable to a small number of high-CPU using programs. V$SESSTAT and V$RSRC_CONSUMER_GROUP I/O Problems . Is the problem only evident during peak hours? Does performance deteriorate over the course of the day? Was the slowdown gradual (over the space of months or weeks) or sudden? Quantify the slowdown. then look at the programs to determine the cause. then there could be an I/O. CPU Performance Find CPU Consuming Sessions Method 1: compare the PID from ‗top‘ and ‗session. o Check the Oracle wait event data in V$SYSTEM_EVENT to see whether the top wait events are I/O related. then investigate possible causes. SQL> SPOO OFF 2. An overly active I/O system can be evidenced by disk queue lengths greater than two.sql‘: $ top (then 'c') SQL> @sess. MARK TIME $date SQL> prompt -. o Use operating system monitoring tools. Tuning Steps Scripts NOTES: 1. then repeat steps 2 and 3 until the performance goals are met. For example. o Step 3: Implement and Measure Change  asdfasd Step 4: Determine whether the performance objective defined in step 1 has been met. to determine what processes are running on the system as a whole and to monitor disk access to all files. 'Dy DD-Mon-YYYY HH24:MI:SS') as "Current Time" from dual. If the network is causing large delays in response time.sql Method 2: run the following SQL script: SQL> @top_cpu_user.current system time is: SQL>select to_char(sysdate. Network: Using operating system utilities. the difficulty in finding a free buffer in the buffer cache or high wait times for log to be flushed to disk can also be symptoms of an I/O problem. such as sar -d or iostat. look at the network round-trip ping time and the number of collisions. SPOOL ALL THE RESULTS IN SQLPLUS IF NECESSARY SQL> SPOOL FILENAME SQL > …. or disk service times that are over 20-30ms. o An I/O problem can also manifest itself with non-I/O related wait events.sql Wait Event . If not. sql Lock and Block List Blocking and Blocked Sessions SQL> @whoblock SQL> @show_blocking_sessions SQL> @rac_locks_blocking List Locks SQL> @show_dml_lock SQL> @show_all_lock Running SQL Find Bad SQL Statements SQL> @expensive_sql SQL> @find_sql.lst) SGA Statistics SQL> @sga_stat SQL> @sga_free_pool .List Wait Events SQL> @wait.sql SQL> @suspicious_sql SQL> @wait_sql List Currently Running SQL Statements SQL> @what_sql SQL> @who_sql SQL> @who_sql2 Memory Statistics Memory Hit Ratio SQL> @hit (The result is spooled to hit. Their selectivity (fraction of table being accessed) How to Use Explain Plan 1.Unselective range scans .Hard Parsing Statistics SQL> @hard_parse SQL> @recent_hard (The result is spooled to recent_hard. such as the set of accessed partitions .The columns of the index being used . such as the distribution method of join inputs  Examine an explain plan: Look for the following in an explain plan: .Late filter operations .lst) Other RAC hang diag: SQL> @hang SQL> @racdiag Introduction to Explain Plan Explain plan displays:  Row source tree : . such as the cost and cardinality of each operation . sort.Wrong join order .a join method for tables affected by join operations in the statement .an ordering of the tables referenced by the statement .optimization.Late predicate filters .an access method for each table mentioned in the statement .Full scans .parallel execution. or aggregation The plan table also contains: . Create the plan table if it does not already exist .partitioning.Data operations like filter. ALL.SQL> @?/rdbms/admin/utlxplan. Generate plan  General method: SQL> delete plan_table. SERIAL. SQL> explain plan for <SQL_STATEMENT>. same as "select plan_table_output from table(dbms_xplan.  UTLXPLP.  Option 1: Identifying Statements for EXPLAIN PLAN Example: SQL> EXPLAIN PLAN SET STATEMENT_ID = 'st1' FOR SELECT last_name FROM employees.SQL: this script displays the plan table output including parallel execution columns.'serial'))" SQL> @?/rdbms/admin/utlxpls. same as "select * from table(dbms_xplan. 3.  DBMS_XPLAN.display())" SQL> @?/rdbms/admin/utlxplp. .display('plan_table'.  Option 2: Specifying Different Tables for EXPLAIN PLAN Example: 1) SQL> EXPLAIN PLAN INTO my_plan_table FOR SELECT last_name FROM employees. 2) SQL> EXPLAIN PLAN SET STATEMENT_ID = 'st1' INTO my_plan_table FOR SELECT last_name FROM employees.SQL: this script displays the plan table output for serial processing.DISPLAY procedure accepts options for displaying the plan table output : o o o A plan table name if you are using a table different than PLAN_TABLE A statement Id if you have set a statement Id with the EXPLAIN PLAN A format option that determines the level of detail: BASIC.sql 2. and TYPICAL. Show the plan  UTLXPLS.null. Index range scan   Accessing a range values of a particular column.username.sql_id.DISPLAY_CURSOR(('&sql_id'). SQL> select plan_table_output from table(dbms_xplan.display(<table_name>. This access method is used for returning the data from B-tree indexes. <statement id>.username from v$session where username='&user'.'TYPICAL')). SQL> SELECT * FROM table(DBMS_XPLAN.display()). The optimizer chooses a unique scan when all columns of a unique (B-tree) index are specified with equality conditions. like empno> 34434 Index range scan is a common operation for accessing selective data.0. It can be bounded (bounded on both sides) or unbounded (on one or both sides). --in memory SQL> SELECT * FROM table(DBMS_XPLAN.sql_child_number.DISPLAY_AWR('&sql_id')) --in AWR report What to look in explain plan Execution Plan shows the SQL optimizer's query execution path Full Table Scan vs.'ALL')). Data is returned in the ascending . Indexes    Full Table Scan -whole table is read up to the high water mark FTS is not recommended for large tables unless you are reading >5-10% Index lookup -Data is accessed by looking up key values in an index and returning rowids Methods of index lookup: index unique scan    Always returns a single value (a single rowid). Explain Plan for Past Queries  Examples: SQL> select sid.display).Examples: SQL> select * from table(dbms_xplan.prev_sql_id. like empno=1345 Quickest access method available (points to the block) Index unique scan is one of the most efficient ways of accessing data. SQL> select plan_table_output from table(dbms_xplan. order of index columns. and at least one column in the index key has the NOTNULL constraint. In a partitioned object the partition key (in this case the leading column) defines which partition data is stored within. Join Types . A fast full scan accesses the data in the index itself.  The optimizer uses a range scan when it finds one or more leading columns of an index specified in conditions. Rows are not returned in sorted order Fast full index scans are an alternative to a full table scan when the index contains all the columns that are needed for the query. The trailing columns are ordered within the prefix column and so a 'normal' index access can be done ignoring the prefix. such as the following: * col1 = :b1 * col1 < :b1 * col1 > :b1 * AND combination of the preceding conditions for leading columns in the index otherwise * col1 like 'ASD%' wild-card searches should not be in a leading position the condition col1 like '%ASD' does not result in a range scan. 2) at least one of the index columns is not null index fast full scan   Scans all the block in the index. In the index case every row underneath each key (the prefix column) would be ordered under that key. index skip scan   Finds rows even if the column is not the leading column of a concatenated index This concept is easier to understand if one imagines a prefix index to be similar to a partitioned table. without accessing the table. Multiple rows with identical values are sorted (in ascending order) by the ROWIDs. In a skip scan of a prefixed index. index full scan    Statistics that indicate that it is going to be more efficient than a full table scan and a sort A full scan is available if a predicate references one of the columns in the index A full scan is also available if 1) all of the columns in the table referenced in the query are included in the index. the prefixed value is skipped and the non-prefix columns are accessed as logical sub-indexes. >. or >= Sort merge joins can perform better than hash joins if both of the following conditions exist: 1) The row sources are sorted already. with a good driving condition between the two tables.   Sort merge joins are useful when the join condition between two tables is an inequality condition (but not a nonequality) like <. The outer loop appears before the inner loop in the execution plan.   Sort merge joins perform better than nested loop joins for large data sets. The outer loop is the driving row source. The optimizer uses nested loop joins when joining small number of rows. as follows: NESTED LOOPS outer_loop inner_loop    Nested Loop is better only if a few rows are being retrieved. The outer loop is for every row in outer table and the inner loop is for every row in the inner table. 3) For every row in the outer table. USE_NL(table1 table2) hint . <=. The inner loop is iterated for every row returned from the outer loop. 2) A sort operation does not have to be done. Oracle accesses all the rows in the inner table. ideally by an index scan. 2) The other table is designated as the inner table. You cannot use hash joins unless there is an equality condition.Sort Merge Join  Two steps: 1) sort join operation: Both the inputs are sorted on the join key 2) merge join operation: The sorted lists are merged together. USE_MERGE hint Nested Loops  Steps: 1) The optimizer determines the driving table and designates it as the outer table. By default snapshot are generated once every 60min and maintained for 7 days by default. probing the hash table to find the joined rows. By specifying a table before its join table is specified. activation_level FROM v$statistics_level The AWR infrastructure   An in-memory statistics collection facility that is used by Oracle Database 10g components to collect statistics. It then scans the larger table. and at what level of the STATISTICS_LEVEL parameter the component is enabled. When the buffer is full. The V$STATISTICS_LEVEL view shows the statistic component. It resides in SYSAUX tablespace. . The MMON (which stands for manageability monitor) process is responsible for filtering and transferring the memory statistics to the disk every hour. SQL> SELECT statistics_name. The AWR snapshots are accessible through data dictionary views and Database Control. instructs the optimizer to use a Cartesian join. Sorts -expensive operations especially on large tables Filter –limiting by where clause and some other conditions AWR Introduction Introduction    Automatic workload repository (AWR) is a collection of persistent system performance statistics owned by SYS. A value BASIC turns off all AWR statistics and metrics collection and disables all self-tuning capabilities of the database. Data is owned by the SYS schema. the optimizer does a Cartesian join. the MMNL (which stands for manageability monitor light) process is responsible to flush the information to the repository. These statistics are stored in memory for performance reasons. The optimizer uses the smaller of two tables or data sources to build a hash table on the join key in memory. AWR is enabled only when the STATISTICS_LEVEL initialization parameter is set to TYPICAL (the default) or ALL. AWR snapshots represent the persistent portion of the facility.Hash Join     Hash joins are used for joining large data sets. Statistics stored in memory are accessible through dynamic performance (V$) views. description. Hash joins generally perform better than sort merge joins USE_HASH hint Cartesian Product   No join conditions between tables Applying the ORDERED hint. For text report. Generate reports by executing one of following scripts: $ORACLE_HOME/rdbms/admin/awrrpt. and Parse statistics The new wait classes interface used for high-level performance analysis The new time-model statistics based on how much time activities have spent Some of the statistics currently collected in V$SYSSTAT and V$SESSTAT Some of the Oracle optimizer statistics that include statistics for self-learning and tuning Operating system statistics The Active Session History (ASH).sql 2.sql $ORACLE_HOME/rdbms/admin/awrrpti. copy and paste the report to the following website to get recommendations: Statspack Analyzer AWR Report Information . which represents the history of recent session activity Metrics that provides the rate of change for certain base statistics AWR Report Quick Tip 1. Elapsed.sql $ORACLE_HOME/rdbms/admin/awrinput.AWR Data          Object statistics that determine both access and usage statistics of database segments New SQL statistics that are used to efficiently identify top SQL statements based on CPU. sql SQL script generates an HTML or text report that displays statistics for a range of snapshot Ids.sql script at the SQL prompt: Views . Run this report to inspect or debug the performance of a SQL statement. 6) The awrddrpi.                Report summary Wait events statistics SQL statistics Instance activity statistics I/O statistics Buffer pool statistics Advisory statistics Wait statistics Undo statistics Latch statistics Segment statistics Dictionary cache statistics Library cache statistics SGA statistics Resource limit statistics init. 5) The awrddrpt.sql SQL script generates an HTML or text report that compares detailed performance attributes and configuration settings between two selected time periods on a specific database and instance. 3) The awrsqrpt.sql SQL script generates an HTML or text report that displays statistics of a particular SQL statement for a range of snapshot Ids on a specified SQL.sql SQL script generates an HTML or text report that compares detailed performance attributes and configuration settings between two selected time periods.ora parameters Generate AWR reports You can generate AWR reports by running SQL scripts: 1)The awrrpt. 4) The awrsqrpi.sql SQL script generates an HTML or text report that displays statistics for a range of snapshot Ids on a specified database and instance. run the awrrpt.sql SQL script generates an HTML or text report that displays statistics of a particular SQL statement for a range of snapshot Ids. 2)The awrrpti. To generate an HTML or text report for a range of snapshot Ids. / Dropping the AWR baseline: BEGIN DBMS_WORKLOAD_REPOSITORY. / Creating the Baseline: BEGIN DBMS_WORKLOAD_REPOSITORY.create_baseline ( start_snap_id => 10. Current value retained if NULL.modify_snapshot_settings( retention => 43200. interval => 30). Current value retained if NULL. High_snap_id=>80). end_snap_id => 100. END. / . END. baseline_name => 'AWR First baseline'). -.Minutes.Few Views which helps while generating the AWR report DBA_HIST_SNAPSHOT DBA_HIST_WR_CONTROL DBA_HIST_BASELINE Procedures How to Modify the AWR SNAP SHOT SETTINGS: BEGIN DBMS_WORKLOAD_REPOSITORY.Minutes (= 30 Days). -. / Dropping the AWR snaps in range: BEGIN DBMS_WORKLOAD_REPOSITORY. END. END.drop_snapshot_range( (row_snap_id=>40.DROP_BASELINE ( baseline_name => 'AWR First baseline'). Displays baseline information.Creating SNAPSHOT Manually: BEGIN DBMS_WORKLOAD_REPOSITORY. * DBA_HIST_SQL_PLAN . * DBA_HIST_BASELINE .  WRM$_* stores metadata information such as the database being examined and the snapshots taken (M stands for "metadata. the view DBA_HIST_SYSMETRIC_SUMMARY is built upon the table WRH$_SYSMETRIC_SUMMARY.Displays the history contents of the active session history. which can be used to write your own performance diagnosis tool. * V$METRIC .Displays database environment information. for example.Displays the active session history (ASH) sampled every second.Displays metric information. and named in the format WRM$_* and WRH$_*. ADDM . * DBA_HIST_WR_CONTROL .Displays SQL execution plans.Displays AWR settings. The following workload repository views are available: * V$ACTIVE_SESSION_HISTORY .create_snapshot(). END. / Workload Repository Views:   All AWR tables are stored under the SYS schema in the new special tablespace named SYSAUX. * V$METRICNAME . * DBA_HIST_ACTIVE_SESS_HISTORY . (H stands for "historical" ) There are several views with the prefix DBA_HIST_ built upon these tables. * DBA_HIST_DATABASE_INSTANCE .")  WRH$_* holds the actual collected statistics.Displays snapshot information.Displays historical metrics. * DBA_HIST_SNAPSHOT .Displays the metrics associated with each metric group.Displays all metrics groups. * V$METRICGROUP . * V$METRIC_HISTORY . The names of the views directly relate to the table. Display the report.Set the start and end snapshots.'). value => 1032).set_task_parameter ( task_name => '970_1032_AWR_SNAPSHOT'. -. value => 970).execute_task(task_name => '970_1032_AWR_SNAPSHOT'). DBMS_ADVISOR.find out ADDM report name SELECT DBMS_ADVISOR. SET LONG 100000 SET PAGESIZE 50000 SELECT DBMS_ADVISOR. DBMS_ADVISOR.sql Create an Advisor Task BEGIN -.set_task_parameter ( task_name => '970_1032_AWR_SNAPSHOT'. DBMS_ADVISOR. . DBMS_ADVISOR.Execute the task. parameter => 'START_SNAPSHOT'. / -.get_task_report('&reportname') AS report FROM dual. END. task_name => '970_1032_AWR_SNAPSHOT'. parameter => 'END_SNAPSHOT'.Create ADDM Report in SQLPLUS @?/rdbms/admin/addmrpt.create_task ( advisor_name => 'ADDM'. task_desc => 'Advisor for snapshots 970 to 1032.Create an ADDM task. -.get_task_report('970_1032_AWR_SNAPSHOT') AS report FROM dual. SET PAGESIZE 24 Display ADDM Report in SQLPLUS SET LONG 100000 SET PAGESIZE 50000 select * from DBA_ADVISOR_TASKS order by created desc -. Findings identified for an existing task. DBA_ADVISOR_FINDINGS . Advisory Framework Framework        Automatic Database Diagnostic Monitor (ADDM): Performs a top-down instance analysis. DBA_ADVISOR_LOG . ADDM can potentially call other advisors.Related Views     DBA_ADVISOR_TASKS . identifies problems and potential causes.Status information about existing tasks.Recommendations for the problems identified by an existing task.Basic information about existing tasks. SQL Tuning Advisor: Provides tuning advice for SQL statements SQL Access Advisor: Deals with schema issues and determines optimal data access paths such as indexes and materialized views PGA Advisor: Gives detailed statistics for the work areas and provides recommendations about optimal usage of PGA memory based on workload characteristics SGA Advisor: Responsible for tuning and recommending SGA size depending on pattern of access for the various components within the SGA Segment Advisor: Monitors object space issues and analyzes growth trends Undo Advisor: Suggests parameter values and the amount of additional space that is needed to support flashback for a specified time ADDM . DBA_ADVISOR_RECOMMENDATIONS . and gives recommendations for fixing the problems. Usage information for each advisor DBA_ADVISOR_RATIONALE .Task‘s current status information DBA_ADVISOR_TASKS . which includes wait time and CPU time. The results of the ADDM analysis are also stored in the AWR and are accessible through the dictionary views and the EM Database Control.sql script. The MMON process triggers ADDM analysis each time a snapshot is taken to do an analysis of the period corresponding to the last two snapshots. Analysis is performed from the top down. count(*) FROM dba_advisor_findings NATURAL JOIN dba_advisor_tasks WHERE created between sysdate -1 and sysdate GROUP BY type You can invoke the ADDM report using SQL*Plus by running the $ORACLE_HOME/rdbms/admin/addmrpt.Object referenced by tasks DBA_ADVISOR_COMMANDS .Commands associated with actions DBA_ADVISOR_PARAMETERS .Rationales for the recommendations DBA_ADVISOR_ACTIONS .Task‘s recommendations DBA_ADVISOR_FINDINGS . DBtime is the cumulative time spent by the database server in processing user requests. You should look at the recommendations in the order they‘re listed in the RANK column.    ADDM analysis is performed every time an AWR snapshot is taken. The goal of analysis is to reduce a single throughput metric called the DBtime.Findings discovered by the advisor DBA_ADVISOR_OBJECTS .Task‘s parameters DBA_ADVISOR_LOG .Actions associated with recommendations DBA_ADVISOR_RECOMMENDATIONS . The ADDM is enabled automatically only when the STATISTICS_LEVEL parameter is set to TYPICAL or ALL.Global information about the task DBA_ADVISOR_DEFINITIONS .Properties of the advisors Tips    Show the number of findings of ADDM for the last 24 hours by category: SQL> SELECT type. The output is saved as a text file. SQL> SELECT distinct message FROM dba_advisor_recommendations JOIN dba_advisor_findings USING (finding_id. DBA Advisory Dictionaries            DBA_ADVISOR_USAGE . identifying symptoms first and then refining them to reach the root cause. task_id) WHERE rank = 0 Setting Alert Building Your Own Alert Mechanism You can use the following steps to set up a threshold and alert mechanism if you do not want to use the EM Database Control: . Query V$METRICNAME to identify the metrics in which you are interested. SQL Tuning Advisor takes one or more SQL statements as input. It also collects auxiliary information to supply missing statistics or correct stale statistics in case recommendations are not implemented. Optionally register for the alert enqueue notification using the DBMS_AQ. Associate the user with the AQ agent using the DBMS_AQADM. 10. Create an agent for the subscribing user of the alerts using the DBMS_AQADM. The suggested restructuring can be syntactic as well as semantic changes to the SQL code. 8.EXPAND_MESSAGE to expand the text of the message. 9.SET* procedures. 4.CREATE_AQ_AGENT procedure.SET_THRESHOLD procedure. based on past execution history of the SQL statement.GRANT_QUEUE_PRIVILEGE procedure. under normal mode. use DBMS_SERVER_ALERT. Dequeue the alert using the DBMS_AQ.DEQUEUE procedure. and when appropriate makes recommendations to create such indexes. 7. ATO tries to identify SQL statements that lend themselves to bad plans. Access Path Analysis: ATO explores whether a new index can be used to significantly improve access to each table in the query. such as first rows and all rows. When a SQL Profile is created.ADD_SUBSCRIBER procedure. SQL Profiling: ATO verifies its own estimates and collects auxiliary information to remove estimation errors. It also collects auxiliary information in the form of customized optimizer settings. After the message has been dequeued. the profile enables the query optimizer. Set warning and critical thresholds using the DBMS_SERVER_ALERT. SQL Tuning Advisor Home >> Reference >> Performance Tuning >> SQL Tuning Advisor Automatic Tuning Optimizer (ATO) to perform the following four specific types of analysis:     Statistics Analysis: ATO checks each query object for missing or stale statistics and makes a recommendation to gather relevant statistics. The input can come from different sources:   High-load SQL statements identified by ADDM SQL statements that are currently in cursor cache .REGISTER procedure. to generate a well-tuned plan. It builds a SQL Profile using the auxiliary information and makes a recommendation to create it.1. 5. 3. Configure e-mail using the DBMS_AQELM. 6. 2. Subscribe to the ALERT_QUE AQ using the DBMS_AQADM.ENABLE_DB_ACCESS procedure. and makes relevant suggestions to restructure them. Grant the DEQUEUE privilege using the DBMS_AQADM. SQL Structure Analysis: Here. staging_table_name => 'STAGING_TABLE'). Custom workload: A user can create a custom workload consisting of statements of interest to the user.new_profile_name => 'SP_NEW_DINA'. For such statements. by means of a Data Pump job or a database link. 4. These may be statements that are not in cursor cache and are not high-load to be captured by ADDM or AWR.  SQL statements from Automatic Workload Repository (AWR): A user can select any set of SQL statements captured by AWR. 3. EXEC DBMS_SQLTUNE. Move the staging table from your production environment to a test machine through the means of choice—for example. SQL Profile How to export and then import a SQL Profile: 1.CREATE_STGTAB_SQLPROF(table_name => 'STAGING_TABLE'. EXEC DBMS_SQLTUNE. This can be done using snapshots or baselines.UNPACK_STGTAB_SQLPROF(replace => TRUE. exec DBMS_SQLTUNE. a user can create a custom workload and tune it using the advisor. 2. in a data warehouse environment. or a combination of both would provide the most benefit . SQL Access Advisor Home >> Reference >> Performance Tuning >> SQL Access Advisor Input to the SQL Access Advisor can come from one or all of the following sources:     Current SQL statements from V$SQL (the SQL cache) A user-specified list of SQL statements The name of a schema.REMAP_STGTAB_SQLPROF(old_profile_name => 'SP_DINA'.staging_table_name => 'STAGING_TABLE'). On the test machine. exec DBMS_SQLTUNE.schema_name => 'JFV'). Call the PACK_STGTAB_SQLPROF procedure one or more times to write existing SQL profile data into the staging table. call the UNPACK_STGTAB_SQLPROF procedure to create SQL Profiles on the new system from the profile data in the staging table. the SQL Access Advisor performs an analysis that includes all the following tasks:  Considers whether only indexes. this is typically a dimensional model in a single schema STSs previously saved in the workload repository Given the workload. only materialized views. Create a staging table through a call to the CREATE_STGTAB_SQLPROF procedure.PACK_STGTAB_SQLPROF(profile_name => 'SP_DINA'.staging_table_name => 'STAGING_TABLE'). DBMS_SQLTUNE Home >> Reference >> Performance Tuning >> DBMS_SQLTUNE 6. exec DBMS_SQLTUNE.EXECUTE_TASK procedure.     Balances storage and maintenance costs against the performance gains when recommending new indexes or materialized views Generates DROP recommendations to drop an unused index or materialized view if a full workload is specified Optimizes materialized views to leverage query rewrite and fast refresh where possible Recommends materialized view logs to facilitate fast refresh Recommends combining multiple indexes into a single index where appropriate DBMS_ADVISOR Using the procedures of the DBMS_ADVISOR package.'this is a test sql profile'). and TIME_LIMIT. 2. Accept the SQL profile generated by the tuning task using ACCEPT_SQL_PROFILE. 4. 5. Review the results of the tuning task by calling the function REPORT_TUNING_TASK. Review the results using the DBMS_ADVISOR. A typical session using the SQL Tuning Advisor would use DBMS_SQLTUNE procedures and functions as follows: 1. TIME_WINDOW. You can then resume the interrupted analysis for more recommendations. .alter_sql_profile('some_sqlprofile'.alter_sql_profile('some_sqlprofile'. 4.SET_TASK_PARAMETERS procedure to set up appropriate parameters to control the advisor‘s behavior. 5. Create a tuning task with CREATE_TUNING_TASK. or you can adjust the task parameters and then resume execution. An existing task can be a template for another task. 'DISABLED'). 3. You can also view the results using dictionary views.CREATE_TASK procedure. Execute the tuning task using EXECUTE_TUNING_TASK. Typical parameters are TARGET_OBJECTS. The advisor task is a data area in the advisor repository that manages the tuning efforts. You can interrupt the analysis process anytime to review the results up to that point. 7. a typical tuning advisor session may comprise the following steps: 1.'DESCRIPTION'. 3. Perform analysis using the DBMS_ADVISOR.GET_TASK_REPORT procedure. Use the DBMS_ADVISOR. Understanding the SQL Tuning Advisor 333 2. Alters specific attributes of an existing SQL Profile object 8. 'STATUS'. exec dbms_sqltune. Create an advisor task using the DBMS_ADVISOR. specifies the total size of all SGA components specifies the size of the DEFAULT buffer pool for buffers with the primary block size (the block size defined by the DB_BLOCK_SIZE initialization parameter) specifies the size of the cache for the nK buffers Dynamic? NO ALTER SYSTEM ALTER SYSTEM ALTER SYSTEM NO ALTER SYSTEM ALTER SYSTEM ALTER SYSTEM ALTER SYSTEM DB_CACHE_SIZE DB_nK_CACHE_SIZE LOG_BUFFER the number of bytes allocated for the redo log buffer the size in bytes of the area devoted to shared SQL and SHARED_POOL_SIZE PL/SQL statements. LARGE_POOL_SIZE JAVA_POOL_SIZE STREAMS_POOL_SIZE the size of the large pool.Oracle Memory Compoments  SGA: Shared Pool (for SQL and PL/SQL execution): include library cache and data dictionary cache  Large pool (for large allocations such as RMAN backup buffers)  Java pool (for java objects and other java execution memory)  Buffer cache (for caching disk blocks)  Streams pool  Redo log buffer PGA: Process-private memory. such as memory used for sorting and hash joins   Memory Management   Automatic Shared Memory Management (10g) Automatic Memory Management(AMM) (11g) Memory Initialization Parameters Parameter SGA_MAX_SIZE SGA_TARGET Description specifies the maximum size of the SGA for the lifetime of the instance. the default is 0 the size of the Java pool Commands and Scripts . round((PHYRDS / PD.PHYBLKRD+FS.PHYBLKWRT "Total Block I/O's" from ( select sum(PHYRDS) PHYS_READS.pool.2) "Write %". fs. PHYWRTS "Physical Writes".bytes.PHYS_READS)*100. current_size/1024/1024 "CURRENT_SIZE". last_oper_type "TYPE" from v$sga_dynamic_components.name = 'free memory' AND f.pool = s. SQL> SELECT f.sgasize*100. f. v$datafile df. 2) "% Free" FROM (SELECT SUM(bytes) sgasize.sgasize. min_size/1024/1024. ROUND(f.pool. v$filestat fs . s. f.name. user_specified_size/1024/1024 "USER_SPECIFIED_SIZE". v$sgastat f WHERE f. pool FROM v$sgastat GROUP BY pool) s.bytes/s. SQL> sho sga Read and Write Concurrency Rates Component Read Rate Write Rate Concurrency Archive logs Redo logs Undo segment tablespaces TEMP High High Low Low Low High Low Low High High High Low Medium Medium Medium Low Low Low High High High High High High tablespaces Index tablespaces Data tablespaces Application log and output files Binaries (shared) Oracle File I/O Statistics select NAME.PHYS_WRTS.2) "Read %". Check SGA allocation: SQL> select component. PHYRDS "Physical Reads". round(PHYWRTS * 100 / PD. sum(PHYWRTS) PHYS_WRTS from v$filestat ) pd. An example: CREATE OR REPLACE TRIGGER SYS.including both bind variables and wait events.set_trace AFTER LOGON ON DATABASE WHEN (USER like '&USERNAME') DECLARE lcommand varchar(200).level 12'.including wait events  Level 12 . . Oradebug (10046) Logon Trigger: there may be some situations where it is necessary to trace the activity of a specific user.Datafile name  Physical Reads .Number of physical writes  Writes % .Number of physical reads  Reads % .FILE# order by fs.PHYBLKRD+fs.PHYBLKWRT desc  File Name .Percentage of physical reads  Physical Writes .FILE# = fs.  Level 1 .including values of bind variables  Level 8 .the same as a normal set sql_trace=true  Level 4 . In this case a logon trigger could be used. BEGIN EXECUTE IMMEDIATE 'alter session set statistics_level=ALL'. Disable: SQL> alter system set events '10046 trace name context off'.Number of I/O blocks Tracing a User Session       dbms_support dbms_system dbms_monitor (10g new feature) Oracle Event 10046 Trace  Trace session: Enable:SQL> ALTER SESSION SET EVENTS '10046 trace name context forever level 12' Disable: SQL> ALTER SESSION SET EVENTS '10046 trace name context off'  System-wide tracing: Enable: SQL> alter system set events '10046 trace name context forever.Percentage of physical writes  Total Block I/O's .where df.     Check Session History Check Session History Home >> Reference >> Performance Tuning >> Check Session History . 4.No report is generated. SET AUTOTRACE TRACEONLY .EXECUTE IMMEDIATE 'alter session set max_dump_file_size=UNLIMITED'.The report includes both the optimizer execution path and the SQL statement execution statistics. / SQL*Plus Autotrace 1.The report shows only the optimizer execution path. AUTOTRACE syntax:  SET AUTOTRACE OFF .Like SET AUTOTRACE ON.The report shows only the SQL statement execution statistics. SET AUTOTRACE ON STATISTICS . SET AUTOTRACE ON EXPLAIN . Create PLUSTRACE Role SQL> @?/sqlplus/admin/plustrce. Create Plan Table SQL> @?/rdbms/admin/catplan. level 12'''.sql 3.Grant PLUSTRACE Role SQL> GRANT plustrace TO <user_name>. This is the default. but suppresses the printing of the query output. END set_trace. SET AUTOTRACE ON .sql 2. EXECUTE IMMEDIATE 'alter session set events ''10046 trace name context forever. BLOCKING_SESSION_STATUS not in ('NO HOLDER'. v$sqltext text WHERE to_char (sample_time. 'DD-Mon-YYYY HH24:MI:SS') >= '07-Jun-2010 01:55:00' and to_char (sample_time.user_id AND us.user_id AND us. Query 3 Find out history SQL statements which has blocking session SELECT * FROM v$active_session_history sess.'NOT IN WAIT' ) Find out history SQL statements SELECT * FROM v$active_session_history sess. all_users us. all_users us.username not in ('SYS'. 'DD-Mon-YYYY HH24:MI:SS') <= '07-Jun-2010 02:05:00' --TRUNC (sample_time.username not in ('SYS'.'DBSNMP') and text.SQL_ID .user_id AND us. all_users us WHERE TRUNC (sample_time.sql_id=SESS.username = '&user'.user_id = sess. 'DD') = '16-MAY-2008' AND us. 'SYSTEM'.user_id = sess.Query 1 SELECT * FROM v$active_session_history sess.session_id= Query 2 SELECT * FROM dba_hist_active_sess_history ORDER BY sample_time DESC. -. 'DD-Mon-YYYY HH24:MI:SS') >= '07-Jun-2010 01:55:00' and to_char (sample_time.and sess. 'DD') = '07-JUN-2010' AND us. v$sqltext text WHERE to_char (sample_time.sql_id=SESS.'DBSNMP') and text. 'DD-Mon-YYYY HH24:MI:SS') <= '07-Jun-2010 02:05:00' AND us.user_id = sess. 'SYSTEM'.SQL_ID and sess. blocking_session.sql_id .a.blocking_session.sql_text .blocking_session.a.sql_id and blocking_session is not null and a. .sql_id and blocking_session_serial# <> 0 and a.program.sql_id=s.user_id .user_id <> 0 and a.user_id .inst_id.program) cpt.a. s.wrh$_sqltext s where a.program order by blocking_session.a. &bool).a. serial#. '&param_name'.module FROM GV$ACTIVE_SESSION_HISTORY a .sample_time > sysdate .a. COUNT(*) OVER (PARTITION BY a.sql_id .set_int_param_in_session( sid.WRH$_ACTIVE_SESSION_HISTORY a . UNDO_RETENTION Introduction  Proactive tuning – Undo retention is tuned for the longest-running query with an AUTOEXTEND undo tablespace.blocking_session.sql_text FROM sys.user_id <> 0 -.user_id.s.7 select * from ( SELECT a.exclude SYS user and a.user_id . exec dbms_system. &number).Query 4 All blocking locks for last 7 days.user_id .blocking_session_serial#.program ) rn.sql_id=s.sys. SELECT distinct a.'&param_name'.set_bool_param_in_session( sid. ROW_NUMBER() OVER (PARTITION BY a.a.a.sample_time > sysdate .gv$sql s where a.10 ) where rn = 1 Set parameter in a session Home >> Reference >> Performance Tuning >> Set parameters in a session exec dbms_system. serial#.a. a.a.a.a.a. If you set UNDO_RETENTION to a value other than zero. Reactive tuning – Undo retention is gradually lowered under space pressure. The STATISTICS_LEVEL parameter must be set to TYPICAL or ALL. the V$MTTR_TARGET_ADVICE dictionary view shows advisory information and an estimate of the number of additional I/O operations that would occur under different FAST_START_MTTR_TARGET values. This means that the database will make certain that undo will always be available for the specified undo retention period. To turn the retention guarantee off. – Undo retention never goes below either UNDO_RETENTION or 15 minutes. use the RETENTION NOGUARANTEE clause. This column shows the redo log file size in me . you disable automatic checkpoint tuning. Oracle 10g autotunes the undo retention using the specified value as the minimum RETENTION GUARANTEE    Use RETENTION GUARANTEE clause to guarantee the undo retention. – The oldest unexpired extents are used first. A new column OPTIMAL_LOGFILE_SIZE is now available in V$INSTANCE_RECOVERY. If you explicitly set this parameter to zero. After the database runs a typical workload for some time. Enabled by default UNDO_RETENTION    The default for this parameter is 900 seconds.  – Undo retention is tuned for the best possible value with a fixed size undo tablespace. Setting the FAST_START_MTTR_TARGET parameter to a nonzero value or not setting this parameter enables automatic checkpoint tuning. You do not need to set up any checkpoint related parameters. You can use the RETENTION GUARANTEE clause when creating the undo tablespace (CREATE UNDO TABLESPACE or CREATE DATABASE) or later using the ALTER TABLESPACE statement. – Query duration information is collected every 30 seconds. Automatic Checkpoint Tuning MTTR      The Mean Time to Recovery Advisor (the MTTR Advisor) performs automatic checkpoint tuning. Oracle 10g automatically tunes the undo retention for the current undo tablespace using 900 as the minimum value. If UNDO_RETENTION is set to zero or if no value is specified. Trace Analyzer Metalink 224270. The work required for cache recovery processing is proportional to the rate of change to the database and the time between checkpoints. During the cache recovery phase.sql control_file. As we are aware.FALSE). only the redo records containing changes at SCN(s) higher than the checkpoint need to be applied during recovery.sql largesql. &serial) 4.trc <== your trace file SQL> start trcanlzr.txt <== your text file . TRUE.dbms_monitor.) so that all data blocks less than or equal to the SCN are known to be written out to the data files.session_trace_enable (&sid . Using the Trace Analyzer sqlplus trcanlzr SQL> start /trca/run/trcanlzr. Download Trace Analyzer trca. Oracle applies all committed and uncommitted changes in the redo log files to the affected data blocks.cache recovery followed by transaction recovery.zip trca_sample.&serial. instance and crash recovery occur in two steps . exec sys.1 1. Trace sessions SQL> @sess exec sys.sql <file_name> SQL> start trcanlzr. Installing the Trace Analyzer SQL> @/trca/install/tacreate Enter value for default_tablespace: TOOLS01 Using TOOLS01 for the default tablespace Enter value for temporary_tablespace: TEMP Using TEMP for the temporary tablespace 3. If there is a failure and then subsequent cache recovery.session_trace_disable(&sid.dbms_monitor. also known as the rolling forward stage.Checkpoint Overview Check-pointing is an important Oracle activity which records the highest system change number (SCN.zip 2. granularity => 'ALL'. cascade => 'TRUE'.gather_database_stats(estimate_percent => NULL.gather_dictionary_stats . method_opt => 'AUTO'. SQL> select distinct trunc(last_analyzed).gather_schema_stats('schema_name'. GATHER_FIXED_OBJECTS_STATS Procedure  SQL> exec dbms_stats.gather_index_stats('schema_name'. GATHER_SCHEMA_STATS Procedures:  statistics for all objects in a schema SQL> exec dbms_stats. GATHER_INDEX_STATS Procedure:  an index statistics SQL> exec dbms_stats.gather_database_stats.GATHER_DATABASE_STATS Procedures: o statistics for all objects in a database SQL> exec dbms_stats. count(*) from dba_tables where owner='SYS' group by trunc(last_analyzed). SQL> exec dbms_stats. 'index_name' ). cascade=>TRUE ). -. GATHER_DICTIONARY_STATS Procedure: o statistics for all dictionary objects SQL> select distinct trunc(last_analyzed). options => 'GATHER AUTO' ).Check how many sys tables have statistics: SQL> exec dbms_stats.gather_fixed_objects_stats . GATHER_SYSTEM_STATS Procedure  link GATHER_TABLE_STATS Procedure: . count(*) from dba_tables where owner='SYS' group by trunc(last_analyzed).  a table. --check table changes: modified since the last time statistics were gathered on the tables.disalbe('GATHER_STATS_JOB'). column.2. job_name.M. SQL> exec dbms_stats. and all day on weekends. the maintenance window opens every night from 10 P. The Scheduler runs this job when the maintenance window is opened. dbms_stats can analyze external tables. last_analyzed from dba_tables order by 1. to 6 A. and its index statistics SQL> select * from dba_tab_modifications. DBMS_STATS vs ANALYZE DBMS_STATS        DBMS_STATS can be done in parallel Monitoring can be done and stale statistics can be collected for changed rows using DBMS_STATS Import/export/set statistics directly with dbms_stats It is easier to automate with dbms_stats (it is procedural.M. Automated scheduler job   Optimizer statistics are automatically gathered with the job GATHER_STATS_JOB.gather_table_stats('schema_name'. 'table_name') .  Disable automatic statistics collection: SQL> exec dbms_scheduler. table_name. it does not gather other statistics. This job gathers statistics on all objects in the database which have: * Missing statistics * Stale statistics This job is created automatically at database creation time and is managed by the Scheduler.enable('GATHER_STATS_JOB'). analyze is just a command) dbms_stats is the stated. the table statistics gathered by DBMS_STATS include the . For example.3. . Query: SQL> SELECT owner.enabled FROM DBA_SCHEDULER_JOBS WHERE JOB_NAME = 'GATHER_STATS_JOB'. By default. SQL>select owner. preferred method of collecting statisttics.  Enable automatic statistics collection: SQL> exec dbms_scheduler. analyze cannot DBMS_STATS gathers statistics only for cost-based optimization. the system has been thoroughly tuned already. such as the number of distinct values. STATISTICS_LEVEL The values for STATISTICS_LEVEL are as follows:    BASIC . number of rows. in the future. the size of the database changes infrequently. the database is static.A value of BASIC disables monitoring. dbms_stats can gather system stats ANALYZE   ANALYZE calculates global statistics for partitioned tables and indexes instead of gathering them directly. (SQL> @?/rdbms/admin/catblock) SQL> @?/rdbms/admin/utllockt . This can lead to inaccuracies for some statistics. or number of unused data blocks. and as a result the Automatic Workload Repository (AWR) snapshots are disabled in addition to the ADDM. and average row length but not the number of chained rows. average free space. ANALYZE will not collect statistics needed by the cost-based optimizer. Using BASIC may be advisable only in a DSS environment where the queries rarely vary day to day.Using a value of TYPICAL will collect most statistics required for database self-management and delivers the best overall performance ALL . Display lock wait-for in hierarchy: the lock information to the right of session ID describes the lock that the session is waiting for (not the lock it is holding). and the fastest possible execution speed of all queries is the top priority. TYPICAL .specifying ALL collects additional statistics such as timed operating system statistics and plan execution statistics. Locks Scripts: 1. but incurs a significant amount of overhead above and beyond the TYPICAL level that may have a noticeable impact on user transactions. number of blocks currently containing data. Most importantly. DBMS_Stats won't do that. This script shows who's blocking who: SQL> @whoblock...... SQL> @show_blocking_sessions... => No insert into table.null (NULL) 2 ... => RX update table => RX delete from table.sql SQL> @show_all_lock.share (S) 5 ..row-S (SS) 3 . WAIT = YES means that users are waiting for a lock SQL> @show_dml_locks. schema and PIDs are shown as well.sql 4... This script shows users waiting for a lock. in share row exlcusive mode lock table. the osuser..sql Modes of Locking Exclusive Locks select..in row exclusive mode lock table. lock table . in share mode lock table . from table.exclusive (X) . in exclusive mode Share Locks => => => RX RX RX select... => RX lock table. Table-Name).2...row-X (SX) 4 ... from table for update of. in row share mode lock table .sql 3..S/Row-X (SSX) 6 .. in row exclusive mode => => => => RS RS S SRX V$ Views for locks v$lock LMODE: Lock mode in which the session holds the lock: 0 .none 1 . the locker and the SQL-Command they are waiting for a lock. This script shows actual DML-Locks (incl.. null (NULL) 2 . and also see "Oracle Replication" a deeply-technical book on creating and managing materialized views.none 1 .REQUEST: Lock mode in which the process requests the lock: 0 .   Introduction to Oracle materialized views Finding Oracle materialized view opportunities . Also see my notes now how to identify opportunities for Oracle Materialized Views. allowing you to pre-join complex views and pre-compute summaries for superfast response time. SQL> alter system kill session 'sid.row-S (SS) 3 . Configuring for Materialized Views Oracle Tips by Burleson Consulting Oracle materialized views are one of the single most important SQL tuning tools and they are a true silver bullet. SQL> alter table xxx disable table lock nowait.row-X (SX) 4 .S/Row-X (SSX) v$locked_objects select count(*) from v$locked_object. I've devoted over a hundred pages to SQL tuning with Oracle materialized views in my book "Oracle Tuning: The Definitive Reference".share (S) 5 . serial#' immediate. Commands SQL> lock <table_name> in lock mode. we continue our discussion of Oracle materialized views and discuss how to set up and configure your Oracle database to use this powerful new feature. You want tips on tuning materialized views internal performance. We begin with a look at the initialization parameters and continue with details of the effective management and use of Oracle materialized views.Introduction to Oracle materialized views Oracle materialized views perform miracles in our goal to reduce repetitive I/O. over and over: Prerequisites for using Oracle materialized views In order to use Oracle materialized views. and in Oracle materialized views were enhanced to allow very fast dynamic creation of complex objects. In this article. the Oracle DBA must set special initialization . and Oracle dynamically rewrites SQL queries to reference existing Oracle materialized views. as summaries are computed. Without Oracle materialized views you may see unnecessary repeating large-table full-table scans. see:    Oracle materialized views and partitioning Materialized Views Tuning Materialized Views Refreshing Performance Oracle materialized views were first introduced in Oracle8. Oracle materialized views allow sub-second response times by pre-computing aggregate information. To use the fast warehouse refresh facility. as shown here:    trusted: Assumes that the Oracle materialized view is current. DBMS_JOB). or the refresh command will fail. grant create materialized view to scott. In many cases. You start by setting these initialization parameters within Oracle to enable the mechanisms for Oracle materialized views and query rewrite. alter session set query_rewrite_enabled = true. When creating an Oracle materialized view. you must have created a materialized view log for the underlying table. you must specify the ON DEMAND mode. Refreshing materialized views In Oracle. enforced (default): Always goes to Oracle materialized view with fresh data.. Query rewrite is generally automatic. Oracle provides several methods for invoking query rewrite. The DBMS_MVIEW package provides three types of refresh operations: . To refresh the Oracle materialized view. but you can explicitly enable it by using Isession.. if you specify REFRESH FAST for a single-table aggregate Oracle materialized view. the Oracle DBA will encapsulate these grant statements into a single role and grant the role to the end users: grant query rewrite to scott. alter system. you must grant several system privileges to all users who will be using the Oracle materialized views. Invoking SQL query rewrite Once Oracle materialized views have been enabled. call one of the procedures in DBMS_MVIEW. or SQL hints:   ALTER {SESSION|SYSTEM} DISABLE QUERY REWRITE Select /*+REWRITE(mv1)*/.parameters and grant special authority to the users of Oracle materialized views. stale_tolerated: Uses Oracle materialized view with both stale and fresh data Next. you have the option of specifying whether the refresh occurs manually (ON DEMAND) or automatically (ON COMMIT. INSERT. CREATE MATERIALIZED VIEW empdep . Below is an example of an Oracle materialized view with an ON COMMIT refresh.REFRESH_DEPENDENT: Refreshes all table-based Oracle materialized views Manual complete refresh A complete refresh occurs when the Oracle materialized view is initially defined.REFRESH: Refreshes one or more Oracle materialized views DBMS_MVIEW. This ON COMMIT refreshing can be used with materialized views on single-table aggregates and materialized views containing joins only. These additional checks include the following:    An Oracle materialized view log must be present for each detail table. not as primary-key logs. DELETE on the base tables will be refreshed). With Oracle. so you can refresh a snapshot with DBMS_JOB in a short interval according to the snapshot log. Automatic fast refresh of materialized views The automatic fast refresh feature is completely new in Oracle. unique constraints must be placed on the join columns of the inner table. especially if huge amounts of data need to be read and processed. Because the refresh involves reading the detail table to compute the results for the Oracle materialized view. Manual fast (incremental) refresh If you specify REFRESH FAST (which means that only deltas performed by UPDATE. The RowIDs of all the detail tables must appear in the SELECT list of the MVIEW query definition.REFRESH_ALL_MVIEWS: Refreshes all Oracle materialized views DBMS_MVIEW. Oracle performs further verification of the query definition to ensure that fast refresh can always be performed if any of the detail tables change. If there are outer joins. You can use the DBMS_MVIEW package to manually invoke either a fast refresh or a complete refresh.REFRESH('emp_dept_sum'. and a complete refresh may be requested at any time during the life of the Oracle materialized view. where F equals Fast Refresh and C equals Complete Refresh: EXECUTE DBMS_MVIEW. ON COMMIT MVIEW logs must be built as ROWID logs.'F'). unless it references a prebuilt table. Note that the underlying table for the MVIEW can be prebuilt.   DBMS_MVIEW. it's possible to refresh automatically on the next COMMIT performed at the master table. For performance reasons. this can be a very time-consuming process. it's best to create indexes on the ROWIDs of the MVIEW. Step 4 . Step 3 execute dbms_utility. dname.ON PREBUILT TABLE REFRESH FAST ON COMMIT ENABLE QUERY REWRITE AS SELECT empno. loc. execute dbms_mview.SUM(sal) FROM emp GROUP BY deptno. e. ename. The code for each step is shown here: Step 1 optimizer_mode = choose.rowid dep_rowid FROM emp e.job PCTFREE 5 PCTUSED 60 NOLOGGING PARALLEL 5 TABLESPACE users STORAGE (INITIAL 50K NEXT 50K) USING INDEX STORAGE (INITIAL 25K NEXT 25K) REFRESH FAST START WITH SYSDATE NEXT SYSDATE + 1/12.0 (or greater) Step 2 CREATE MATERIALIZED VIEW emp_sum ENABLE QUERY REWRITE AS SELECT deptno. or all_rows job_queue_interval = 3600 job_queue_processes = 1 query_rewrite_enabled = true query_rewrite_integrity = enforced compatible = 8. first_rows.refresh('emp_sum').'ESTIMATE').analyze_schema('SCOTT'.rowid emp_rowid.deptno.5. dept d WHERE e.job.0.deptno = d. let‘s take it one step at a time.1. Creating an Oracle materialized view To see all the steps in the creation of a materialized view. d. 1. Step 6 EXECUTE DBMS_MVIEW. SUM(sal) FROM emp GROUP BY deptno. job. Create the optimizer statistics and refresh the materialized view. Test the materialized view. we specify that the materialized view will be refreshed every two hours with the refresh fast option. Create the MVIEW log(s) MATERIALIZED VIEW. 5. Here. Instead of using DBMS_MVIEW. Execute a manual complete refresh. 2. job. Set the initialization parameters and bounce the database. Here is a SQL statement to check the generated job status for Oracle materialized views: . CREATE MATERIALIZED VIEW LOG ON dept WITH ROWID.REFRESH('emp_sum'). Create the materialized view table. Monitoring materialized views Oracle provides information in the data dictionary to monitor the behavior of Oracle materialized views. you can automatically refresh the MVIEW (Snapshot) using Oracle DBMS_JOB Management. 3. 6. When you‘re monitoring Oracle materialized views.set autotrace on explain SELECT deptno. Execution Plan ----------------------------------0 SELECT STATEMENT Optimizer=CHOOSE 1 0 TABLE ACCESS (FULL) OF 'EMP_SUM' Step 5 CREATE MATERIALIZED VIEW LOG ON emp_sum WITH ROWID. 4. it‘s critical that you check the refresh interval in the dba_jobs view. Conclusion Oracle materialized views are quite complex in nature and require a significant understanding to be used effectively. o Height-Balanced Histogram with Uniform Distribution o Height-Balanced Histogram with Non-Uniform Distribution   Frequency histograms: each value of the column corresponds to a single bucket of the histogram. I covered the required set-up methods and the steps for creating Oracle materialized views and appropriate refresh intervals Types of Histogram  Height-balanced histograms: the column values are divided into bands so that each band contains approximately the same number of rows. Query for the type of histogram: SQL> select owner. The useful information that the histogram provides is where in the range of values the endpoints fall. num_buckets. column_name. Each bucket contains the number of occurrences of that single value. table_name.3 Generating Histogram and Disabling Histogram . Frequency histograms are automatically created instead of height-balanced histograms when the number of distinct values is less than or equal to the number of histogram buckets specified. In this article.2. histogram from DBA_TAB_COL_STATISTICS order by 1. num_distinct. DBMS_STATS  Syntax: dbms_stats. histogram from DBA_TAB_COL_STATISTICS order by 1. You can also manually specify which columns should have histograms and the size of each histogram.gather_schema_stats(ownname=> &owner . Disabling Histogram: DBMS_STATS to gather statistics using ‘METHOD_OPT => 'FOR COLUMNS SIZE 1’ Analyze  Syntax: ANALYZE TABLE <schema. Oracle Corporation recommends setting the METHOD_OPT to FOR ALL COLUMNS SIZE AUTO. SQL> DBMS_STATS. method_opt => 'FOR ALL COLUMNS SIZE AUTO'.3  SYS.2. With this setting.METHOD_OPT => FOR COLUMN SIZE <integer> <column_name>) Example: SQL> exec dbms_stats.    Histograms are specified using the METHOD_OPT argument of the DBMS_STATS gathering procedures. Oracle automatically determines which columns require histograms and the number of buckets (size) of each histogram.2. estimate_percent=> 10 . <table_name>. . column_name. num_buckets.object_name> COMPUTE STATISTICS FOR COLUMNS <column_name> SIZE <number_of_buckets_integer> Viewing Histogram Statistics  Histogram Types: SQL> select owner. cascade => TRUE).3  Histogram Statistics: see if the histogram is uniformed or skewed SQL> select * from dba_histograms order by 1. METHOD_OPT => 'FOR COLUMNS SIZE 10 &col_name').COL_USAGE$: monitor the usage of predicates on columns in select statements. table_name.GATHER_table_STATS (OWNNAME => &owner. DBMS_STATS will make use of that info when deciding if it needs to create a histogram on a column. num_distinct. TABNAME => &tab_name.gather_table_stats(<schema_name>. obj# = u.obj$ o.name table_name. endpoint_value FROM DBA_HISTOGRAMS WHERE table_name = &tab_name and column_name = &col_name ORDER BY endpoint_number.name col_name.user# and (u.obj# and c.dbf' size 100M AUTOEXTEND OFF BLOCKSIZE 8192 EXTENT MANAGEMENT LOCAL UNIFORM SIZE 64k SEGMENT SPACE MANAGEMENT auto. like_preds. sys.user$ r where o. c. sys. 2. Start SQL*Plus and then connect with administrator privileges to the database containing the recovery catalog. Creating the Recovery Catalog Owner To create the recovery catalog schema in the recovery catalog database: 1. equality_preds. nonequijoin_preds.owner# = r. . equijoin_preds. This role provides the user with privileges to maintain and query the recovery catalog. null_preds from sys. o. sys.col_usage$ u.equijoin_preds > 0 or u.col$ c.obj# = u. schema and tablespace for the recovery catalog.obj# and c.3  Histogram Distribution: SQL> SELECT endpoint_number.nonequijoin_preds > 0) order by 1. Example: connect to recovery catalog database (catdb) SQL> CONNECT SYS/oracle@catdb AS SYSDBA 2. Grant the RECOVERY_CATALOG_OWNER role to the schema owner. Create a user.2. Example: 1. range_preds.SQL> select distinct r.intcol# and o. Create user (rman) SQL> CREATE USER rman IDENTIFIED BY rman TEMPORARY TABLESPACE temp DEFAULT TABLESPACE rmantbs QUOTA UNLIMITED ON rmantbs.col# = u.name owner. 3. create tablespace (rmantbs) SQL> create tablespace rmantbs datafile '/u02/oradata/RMANDB/rmantbs. Example: SQL> GRANT RECOVERY_CATALOG_OWNER TO rman. RESOURCE TO rman. Grant other desired privileges to the RMAN user. Connect to the database that will contain the catalog as the catalog owner. Connect to the target database and recovery catalog database. 4. Creating the Recovery Catalog To create the recovery catalog: 1. then: RMAN> CREATE CATALOG. Run the CREATE CATALOG command to create the catalog. 3. Optionally. start SQL*Plus and query the recovery catalog to see which tables were created: SQL> SELECT TABLE_NAME FROM USER_TABLES Registering a Database in the Recovery Catalog To register the target database: 1. Example: SQL> GRANT CONNECT. Example: connect to the target database and recovery catalog database (catdb) % rman TARGET / CATALOG rman/cat@catdb . If the catalog tablespace is this user's default tablespace. Example: connect to recovery catalog database (catdb) % rman CATALOG rman/cat@catdb Or connect from the RMAN prompt: Example: % rman RMAN> CONNECT CATALOG rman/cat@catdb 2. 'archive1_732. If the target database is not mounted. RMAN> REPORT SCHEMA. To use RMAN with a target database. If there are any existing user-created copies of datafiles or archived logs on disk that were created under Oracle release 8.dbf'.. RMAN> REGISTER DATABASE.2.dbf'. register the database. 4. .0 or higher. Connect at Command Line Syntax: RMAN [ TARGET [=] connectStringSpec | { CATALOG [=] connectStringSpec | NOCATALOG } | AUXILIARY [=] connectStringSpec | LOG [=] ['] filename ['] . RMAN> CATALOG ARCHIVELOG 'archive1_731. 3. then mount or open it. ].dbf'. After run REGISTER DATABASE:   RMAN creates rows in the repository that contain information about the target database.. you can add them to the recovery catalog with the CATALOG command. This command shows the database structure as it is stored in the repository. RMAN performs a full resynchronization with the catalog in which it transfers all pertinent data about the target database from the control file and saves it in the catalog. 5. The recovery catalog database must be open. Test that the registration was successful by running REPORT SCHEMA. Example: RMAN> CATALOG DATAFILECOPY 'users01. . . catalog and auxiliary databases % rman TARGET / CATALOG cat_usr/pwd@cat_str AUXILIARY aux_usr/pwd@aux_str 4. Otherwise. Connect to target and log % rman TARGET / LOG $ORACLE_HOME/dbs/log/backup. RMAN defaults to NOCATALOG mode and invalidates the use of CONNECT CATALOG in the session. Connect to target database and run command file % rman TARGET SYS/pwd@target_str @/scripts/test. Connecting Without a Recovery Catalog: % rman NOCATALOG RMAN> CONNECT TARGET sys/pwd@target_str . CONNECT AUXILIARY <connectString>: Establishes a connection between RMAN and an auxiliary instance. Example: 1. 2. Connecting in the Default NOCATALOG Mode: % rman RMAN> CONNECT TARGET sys/pwd@target_str . CONNECT CATALOG <connectString>: Establishes a connection between RMAN and the recovery catalog database.Connecting with a Recovery Catalog: % rman RMAN> CONNECT TARGET / # connects to the target database using OS authentication RMAN> CONNECT CATALOG rman/rman@cat_str . You can use an auxiliary instance with the DUPLICATE command or during TSPITR.rcv 5. # You cannot run CONNECT CATALOG after this point because RMAN has defaulted to NOCATALOG 3.log APPEND # using OS Authentication Connect from RMAN Prompt In RMAN prompt:    CONNECT TARGET <connectString>: Establishes a connection between RMAN and the target database. Connect to target. Connects in NOCATALOG mode % rman TARGET SYS/pwd@target_str 2. You must run this command before running any command that requires a repository. Connect to target database and catalog % rman TARGET / CATALOG cat_usr/pwd@cat_str 3.connectStringSpec::= ['] [userid] [/ [password]] [@net_service_name] ['] Example: 1. Connecting to Target.4. If the password is not provided in the connect string. "@@" . Change the permissions on the connect script so that everyone can execute the script but only the desired users have read access.rman  RMAN Commands "@" Run a command file. Place the connection information in a text file. RMAN> @connect. Start RMAN without connecting to any databases: % rman 2. Run the script from the RMAN prompt to connect to the target and catalog databases. enter: % chmod 711 connect. Place the following lines in a file called connect. Recovery Catalog. then you can use the following procedure: 1.rman: CONNECT TARGET SYS/oracle@trgt CONNECT CATALOG rman/cat@catdb 3. then RMAN prompts for the password.rman 4. Example: if you are running RMAN in an UNIX environment. and Duplicate Databases: % rman RMAN> CONNECT TARGET SYS/sysdba@target_str RMAN> CONNECT CATALOG rman/rman@cat_str RMAN> CONNECT AUXILIARY SYS/sysdba@dupdb Hiding Passwords When Connecting to Databases To connect to RMAN from the operating system command line and hide authentication information. Run a command file at the RMAN prompt that contains the connection information. You can set the read privileges on the command file to prevent unauthorized access. you must first start RMAN and then perform either of the following actions:  Run the CONNECT commands at the RMAN prompt. For example. or archived redo log as having the status UNAVAILABLE or AVAILABLE. or archived redo log. "CREATE CATALOG" Create the schema for the recovery catalog. "CONFIGURE" Configure persistent RMAN settings. which is a connection between RMAN and a database instance. "BLOCKRECOVER" Recover an individual data block or set of data blocks within one or more datafiles.Run a command file in the same directory as another command file that is currently running. or backup set. "BACKUP" Back up a database. "CHANGE" Mark a backup piece. "CATALOG" Add information about a datafile copy. The @@ command differs from the @ command only when run from within a command file. "ALLOCATE CHANNEL" Establish a channel. "COPY" Create an image copy of a datafile. remove the repository record for a backup or copy. image copy. "ALLOCATE CHANNEL FOR MAINTENANCE" Allocate a channel in preparation for issuing maintenance commands such as DELETE. These settings apply to all RMAN sessions until explicitly changed or disabled. archived redo log. override the retention policy for a backup or copy. auxiliary. control file. or control file copy to the repository. or recovery catalog database. "CONNECT" Establish a connection between RMAN and a target. tablespace. datafile. archived log. . "DELETE SCRIPT" Delete a stored script from the recovery catalog. "DELETE" Delete backups and copies. datafile copies. "DUPLICATE" Use backups of the target database to create a duplicate database that you can use for testing purposes or to create a standby database. "HOST" Invoke an operating system command-line subshell from within RMAN or run a specific operating system command. such as archived logs. "EXECUTE SCRIPT" Run an RMAN stored script. "EXIT" Quit the RMAN executable. remove references to them from the recovery catalog. "LIST" Produce a detailed listing of backup sets or copies. still exist on disk or tape. "CROSSCHECK" Determine whether files managed by RMAN. and backup pieces. "DROP CATALOG" Remove the schema from the recovery catalog. "PRINT SCRIPT" . and update their control file records to status DELETED."CREATE SCRIPT" Create a stored script and store it in the recovery catalog. "RESTORE" Restore files from backup sets or from disk copies to the default or a new location.Display a stored script. "QUIT" Exit the RMAN executable. or reset the target database to a prior incarnation. "RECOVER" Apply redo logs or incremental backups to a restored backup set or copy in order to update it to a specified time. "REPORT" Perform detailed analyses of the content of the recovery catalog. If the script does not exist. which creates a snapshot control file and then copies any new or changed information from that snapshot control file to the recovery catalog. "REGISTER" Register the target database in the recovery catalog. "RESYNC" Perform a full resynchronization. "RUN" . "RESET DATABASE" Inform RMAN that the SQL statement ALTER DATABASE OPEN RESETLOGS has been executed and that a new incarnation of the target database has been created. "REPLACE SCRIPT" Replace an existing script stored in the recovery catalog. "RELEASE CHANNEL" Release a channel that was allocated with an ALLOCATE CHANNEL command. then REPLACE SCRIPT creates it. "SEND" Send a vendor-specific quoted string to one or more specific channels. "SPOOL" Write RMAN output to a log file. "SWITCH" . This command is equivalent to the SQL*Plus SHUTDOWN command. "SET" Make the following session-level settings: * Control whether RMAN commands are displayed in the message log * Set the DBID when restoring a control file or server parameter file * Specify new filenames for restored datafiles * Specify a limit for the number of permissible block corruptions * Override default archived redo log destinations * Specify the number of copies of each backup piece * Determine which server session corresponds to which channel * Control where RMAN searches for backups when using an Oracle Real Application Clusters configuration * Override the default format of the control file autobackup "SHOW" Displays the current CONFIGURE settings. This command is equivalent to the SQL*Plus STARTUP command. "SHUTDOWN" Shut down the target database. "STARTUP" Start up the target database. "SQL" Execute a SQL statement from within Recovery Manager. which are one or more statements executed within the braces of RUN.Execute a sequence of one or more RMAN commands. Flashback Overview Flashback Time Navigation    Flashback Query – Query all data at point in time. This command is equivalent to the SQL statement ALTER DATABASE RENAME FILE as it applies to datafiles. RMAN scans all of the backup pieces in the specified backup sets and looks at the checksums to verify that the contents can be successfully restored. Flashback Versions Query – See all versions of a row between two times. Row level: – Flashback Query features are used to restore rows to a point in time. Table level: – Flashback Table restores all rows in a set of tables to a point in time. that is.Specify that a datafile copy is now the current datafile. – See transactions that changed the row. Oracle Flashback Technology . "VALIDATE" Examine a backup set and report whether its data is intact. the datafile pointed to by the control file. – Flashback Drop restores a dropped table or index. Flashback Transaction Query – See all changes made by a transaction Flashback Error Correction Recovery at all levels    Database level: – Flashback Database restores the whole database to a point in time. "UPGRADE CATALOG" Upgrade the recovery catalog schema from an older version to the version required by the RMAN executable. Flashback Technology Scenario Uses/Priviledges Affects Data Truncate table undesired changes made by DDL Flashback Logs/ or DML drop user batch job: partial changes Recyclebin/ Drop Drop Table Y Database Y SYSDBA DB connections Object privileges for objects in the recycle bin before they were dropped Query Compare current and past data or data from different point-in-time Undo Data, Flashback Archive N Undo Data, Flashback Archive/ Table Update with the wrong or no WHERE clause FLASHBACK TABLE system privilege and the appropriate object privileges Y Transaction Backout Transaction Query Reverse transaction(s) with/without Undo Data, Flashback Archive cascade (DBMS_FLASHBACK) Investigate several historical states of data Y Undo Data, Flashback Archive/ N SELECT ANY TRANSACTION system privilege Undo Data, Flashback Archive/ FLASHBACK TABLE system privilege and the appropriate object privileges N Version Query Compare versions of a row       Flashback Database Flashback Versions Query and Flashback Transaction Query Flashback Table Flashback Drop (Recylebin) Guaranteed Undo Retention SCN and Time Mapping Enhancements o The mapping granularity is three seconds. o The mapping is retained for: Max(five days, UNDO_RETENTION) o Access the mapping by using the following SQLfunctions: – SCN_TO_TIMESTAMP – TIMESTAMP_TO_SCN SQL> SELECT current_scn, SCN_TO_TIMESTAMP(current_scn), TIMESTAMP_TO_SCN(systimestamp)FROM v$database; Flashback database      Flashbacking a database means going back to a previous database state. The Flashback Database feature provides a way to quickly revert entire Oracle database to the state it was in at a past point in time. A new background process RVWR introduced which is responsible for writing flashback logs which stores pre-image(s) of data blocks One can use Flashback Database to back out changes that: o Have resulted in logical data corruptions. o Are a result of user error. This feature is not applicable for recovering the database in case of media failure. How to Configure Flashback database Prerequisite a) Database must be in archivelog mode. b) Last clean shutdown. Steps  1. Configure the following parameters in parameter file(init.ora) or spfile DB_RECOVERY_FILE_DEST dynamically modifiable dynamically modifiable dynamically modifiable Physical location where RVWR background process writes flashback logs Maximum size flashback logs can occupy in DB_RECOVERY_FILE_DEST Upper limit in minutes on how far back one can flashback the database DB_RECOVERY_FILE_DEST_SIZE DB_FLASHBACK_RETENTION_TARGET  Example: SQL> alter system set db_recovery_file_dest='/u01/app/oracle/flash_recovery_area' scope=spfile; SQL> alter system set db_recovery_file_dest_size=2147483648 scope=spfile; SQL> alter system set DB_FLASHBACK_RETENTION_TARGET=2880; (2 days)  2. Turn flashback on: SQL> Startup mount exclusive; SQL> alter database archivelog; SQL> Alter database flashback on; SQL> Alter database open;  3. Check status SQL> SELECT flashback_on, log_mode FROM gv$database; Sql> SELECT estimated_flashback_size FROM gv$flashback_database_log; $ ps -eaf | grep rvwr Disable Flashback Database Disabling Flashback Database with ALTER DATABASE FLASHBACK OFF automatically deletes all flashback logs in the flash recovery area. Flashback Database Using SQL or RMAN Commands Flashback Using SQL   Use an SCN or a time stamp in the SQL version Example: Flash back the database to a day before using SQL SQL> shutdown immediate; SQL> startup mount exclusive; SQL> flashback database to timestamp(sysdate-1); SQL> alter database open resetlogs; Flashback Using RMAN   Using RMAN, you can flash back to a time stamp, SCN, or log sequence number (SEQUENCE) and thread number (THREAD). Example: RMAN> FLASHBACK DATABASE TO TIME = TO_DATE('2002-12-10 16:00:00','YYYY-MM-DD HH24:MI:SS'); RMAN> FLASHBACK DATABASE TO SCN=23565; RMAN> FLASHBACK DATABASE TO SEQUENCE=223 THREAD=1; Views   V$FLASHBACK_DATABASE_LOG - monitor the estimated and actual size of the flashback logs in the flash recovery - Check flash recovery area disk quota: SQL> select retention_target, flashback_size, estimated_flashback_size FROM V$FLASHBACK_DATABASE_LOG; - Determine the current flashback window: SQL> SELECT oldest_flashback_scn,oldest_flashback_time FROM V$FLASHBACK_DATABASE_LOG; V$FLASHBACK_DATABASE_STAT - monitors the overhead of logging flashback data in the flashback logs. It contains at most 24 rows, with one row for each of the last 24 hours. - The flashback generation for the last hour: SQL> select to_char(end_time,'yyyy-mm-dd hh:miAM') end_timestamp, flashback_data, db_data, redo_data from v$flashback_database_stat where rownum=1; Excluding Tablespaces from Flashback Database SQL> ALTER TABLESPACE <ts_name> FLASHBACK {ON|OFF} SQL> SELECT name, flashback_on 2 FROM v$tablespace; Notes:   Take the tablespace offline before you perform the database flashback operation. After performing Flashback Database, drop the tablespace or recover the offline files with traditional point-in-time recovery. Flash back a RESETLOGS operation You can flash back to a point in time before a RESETLOGS operation: SQL> FLASHBACK DATABASE TO BEFORE RESETLOGS; Limitations  You cannot use Flashback Database in the following situations: o The control file has been restored or re-created. o A tablespace has been dropped. o A data file has been shrunk. Flashback Versions Query       Flashback Versions Query provides an easy way to show all versions of all rows in a table between two SCNs or time stamps, whether the rows were inserted, deleted, or updated. Syntax: query the actual table SELECT [pseudo_columns]...FROM table_name VERSION BETWEEN {SCN | TIMESTAMP {expr | MINVALUE} AND {expr | MAXVALUE}} [AS OF {SCN|TIMESTAMP expr}] WHERE [pseudo_column | column] . . The pseudo-columns: VERSIONS_STARTSCN The SCN at which this version of the row was created VERSIONS_STARTTIME The time stamp at which this version of the row was created VERSIONS_ENDSCN The SCN at which this row no longer existed (either changed or deleted) VERSIONS_ENDTIME The time stamp at which this row no longer existed (either changed or deleted) VERSIONS_XID The transaction ID of the transaction that created this version of the rows VERSIONS_OPERATION The operation done by this transaction: I=Insert, D=Delete, U=Update MINVALUE and MAXVALUE resolve to the SCN or time stamp of the oldest and most recent data available, respectively Example 1: Track history of changes made on employee number 111. The period of the past is determined by the oldest SCN available and the read SCN of the query (5525300): SQL> SELECT versions_xid AS XID, versions_startscn AS START_SCN, versions_endscn AS END_SCN, versions_operation AS OPERATION, first_name FROM employees VERSIONS BETWEEN SCN MINVALUE AND MAXVALUE AS OF SCN 5525300 WHERE employee_id = 111; Example 2: Track the salary of employee number 124. Use midnight as your starting point for the Flashback Versions Query: SQL> select versions_startscn startscn,versions_endscn endscn, versions_xid xid, Flashback Transaction Query       Flashback Transaction Query is a diagnostic tool that you can use to view changes made to the database at the transaction level. undo_sql. in all undo segments in the database. o provides the SQL statements that you can use to undo the changes made by a particular transaction Example 1: returns information about all transactions. SQL> SELECT operation. Example 2: returns information relevant to the transaction whose identifier is specified in the WHERE clause. Limitations: o The VERSIONS clause cannot be used to query: – External tables – Temporary tables – Fixed tables – Views o The VERSIONS clause cannot span DDLs. o Segment shrink operations are filtered out. Example 3: returns information about all transactions that began and committed within a half-hour interval. o Updates on key columns of IOTs are seen as delete statements followed by insert statements. employee_id empid. o Dropped users appear as user identifiers. last_name name. o Dropped objects appear as object numbers. FLASHBACK_TRANSACTION_QUERY o retrieve transaction information for all tables involved in a transaction. undo_sql. table_name FROM flashback_transaction_query WHERE xid = HEXTORAW('8C0024003A000000') ORDER BY undo_change#. table_name FROM flashback_transaction_query. Maximum available versions are dependent on the UNDO_RETENTION parameter. SQL> SELECT operation.employees versions between timestamp trunc(systimestamp) and systimestamp where employee_id = 124. SQL> SELECT operation.'YYYY-MM-DD HH:MI:SS'). Considerations o DDLs are seen as dictionary updates.'YYYY-MMDD HH:MI:SS') AND commit_timestamp <= TO_TIMESTAMP('2003-10-21 11:30:00'. . both active and committed. undo_sql.  versions_operation oper. table_name FROM flashback_transaction_query WHERE start_timestamp >= TO_TIMESTAMP ('2003-10-21 11:00:00'. salary sal from hr. o Minimal supplemental logging may be needed: ALTER DATABASE ADD SUPPLEMENTAL LOG DATA. It acquires exclusive DML locks. Flashback Table cannot be performed on system tables. SQL> FLASHBACK TABLE employees. departments TO SCN 5525293 ENABLE TRIGGERS. Statistics are not flashed back. Considerations         Flashback Table is executed within a single transaction. The operation maintains data integrity. by rolling back only the changes that were made to the given tables and their dependent objects. triggers currently enabled on the tables being flashed back are disabled for the duration of the flashback operation and brought back to the enabled state after the completion of the flashback operation. All tables must be flashed back successfully or the entire transaction is rolled back. A Flashback Table statement is executed as a single transaction. Example 2: uses an SCN instead of a time stamp   because both the EMPLOYEES table and the DEPARTMENTS table are linked by a referential integrity constraint. SQL> ALTER TABLE employees ENABLE ROW MOVEMENT. Operation is written to the alert log file. . Note: You can use Flashback Versions Query and Flashback Transaction Query to determine the appropriate flashback time. Flashback Table cannot span DDLs.Flashback Table Overview     Using Flashback Table. the FLASHBACK TABLE statement groups both tables together. Examples Example 1 : uses a time stamp to determine thepoint in time to which to flash back the EMPLOYEES table. Current indexes and dependent objects are maintained. SQL> ALTER TABLE departments ENABLE ROW MOVEMENT. SQL> FLASHBACK TABLE employees TO TIMESTAMP (SYSDATE-1). In the default operation mode. SQL> ALTER TABLE employees ENABLE ROW MOVEMENT. you can recover a set of tables to a specific point in time without having to perform traditional point-in-time recovery operations. A Flashback Table operation is done in-place while the database is online. When a tablespace or a user is dropped there is NO recycling of the objects. nested tables. Objects in the Recycle Bin will be automatically purged by the space reclamation process if o A user creates a new table or adds data that causes their quota to be exceeded. Flash Recovery Area Occupants . constraints. they are simply renamed with a prefix of BIN$$.        The objects are occupying the same space as when they were created. and other dependant objects are not moved. Recyclebin does not work for SYS objects Technical Details     Tables and Views of Recycle Bin Purging Objects in Recycle Bin Restoring Objects from Recycle Bin Disabling Recycle Bin Limitations    Protected tables: – Are non-SYSTEM tablespace tables – Are stored in locally managed tablespaces – Do not use FGA or VPD The following dependencies are not protected: – Bitmap join indexes – Materialized view logs – Referential integrity constraints – Indexes dropped before tables Purged tables cannot be flashed back. Dropped tables and any associated objects such as indexes. Users can view their dropped tables by querying the new RECYCLEBIN view.10g Recycle Bin Introduction The Recycle Bin is a virtual container where all dropped objects reside. Objects in the Recycle Bin will remain in the database until the owner of the dropped objects decides to permanently remove them using the new PURGE command. o The tablespace needs to extend its file size to accommodate create/insert operations. In addition. DB_RECOVERY_FILE_DEST: Specify this initialization parameter as a valid destination to create the flash recovery files. backupsets. The flash recovery area is also supported by Data Guard. the control file is automatically included in the RMAN backup. RMAN puts restored archive log files from tape into the flash recovery area in preparation for a recovery operation. RMAN uses the flash recovery area for both backup sets and image copies. Flash Recovery Directory Structure The flash recovery area directory structure is used by RMAN in a very organized fashion with separate directories for each file type. SQL> ALTER SYSTEM SET DB_RECOVERY_FILE_DEST = '/oracle/frec_area'. online redologs.By default. Notes:    You must specify the DB_RECOVERY_FILE_DEST_SIZE initialization parameter before the DB_RECOVERY_FILE_DEST initialization parameter. Defining Flash Recovery Area The flash recovery area is defined by setting the following initialization parameters:   DB_RECOVERY_FILE_DEST_SIZE: Specify the disk limit. Control file and SPFILE autobackups . archived redo logs not yet backed up to tape. and control file autobackups. This copy of the control file can be used as one of the mirrored copies of the control file to ensure that at least one copy of the control file is available after a media failure. control . When RMAN backs up datafile #1. RMAN backup sets . These parameters are dynamic and can be altered or disabled. Flashback logs . SQL> ALTER SYSTEM SET DB_RECOVERY_FILE_DEST_SIZE = 4G. such as archived logs. then its flashback logs are stored in the flash recovery area. image copies. all incremental backups. the default destination is the flash recovery area.When the flash recovery area is configured. which is the amount of space the flash recovery area is permitted to use with this initialization parameter.A copy of the control file is created in the flash recovery area when the database is created.The flash recovery area holds control file and SPFILE autobackups generated by RMAN. Data file copies .  To maximize the benefits of the flash recovery area. control files. it should be large enough to hold a copy of all datafiles. if RMAN is configured for control file autobackup. Archived log files . All instances in a RAC database must have the same values for these parameters.      Control files .If Flashback Database is enabled. the initialization parameter LOG_ARCHIVE_DEST_10 is automatically set to the flash recovery area location.  The minimum size of the flash recovery area should be at least large enough to contain archive logs that have not been copied to tape.For RMAN BACKUP AS COPY image files. The corresponding ARCn processes create archived log files in the flash recovery area and any other defined LOG_ARCHIVE_DEST_n locations. and so forth. and online logs in the database area Use the flash recovery area for recovery-related files: – Simplifies the location of database backups – Automatically manages the disk space allocated for recovery files . In addition. Files that fall into this category are full and incremental backup sets. incremental bitmaps. The files that fall into this category are full and incremental backup sets. RMAN> BACKUP RECOVERY FILES. each subdirectory is further divided by a datestamp.percent_space_reclaimable AS reclaimable. control files. number_of_files AS number FROM v$flash_recovery_area_usage . number_of_files AS files FROM v$recovery_file_dest . archive logs. Other files such as flashback logs. control file autobackups. V$DATAFILE_COPY.V$BACKUP_PIECE o BYTES – Size of the file – Tracked in V$BACKUP_PIECE Best Practices for the Database and Flash Recovery Area   Use OMF for the database area: – Simplifies the administration of database files – Puts database files. current control file. control file autobackups. This command backs up all recovery files on disk that have not previously been backed up to tape. archive logs. This can also include files not part of a recovery area Views    V$RECOVERY_FILE_DEST .information regarding the flash recovery area: SQL> SELECT name. space_limit AS size.making it easy to locate backupsets or image copies based on their creation date.indicate the flash recovery area disk space usage: SQL> SELECT file_type. and online redo log files are not backed up. space_reclaimable AS reclaimable. space_used AS used.file autobackups. New columns o IS_RECOVERY_DEST_FILE – Indicates whether the file was created in the flash recovery area – Values: YES / NO – Tracked in V$CONTROLFILE. and data file copies. V$LOGFILE. V$ARCHIVED_LOG.percent_space_used AS used. This command backs up all flash recovery files created in the current (and any previous) flash recovery area destinations that have not previously been backed up to tape. Backing Up the Flash Recovery Area RMAN> BACKUP RECOVERY AREA. and data file copies. V$FLASH_RECOVERY_AREA_USAGE . Restore whole database backup. 3. 3. 2) the redo logs from the time of the backup to the time of the error. Importing Lost Objects from Logical Backup If you have performed a logical backup by exporting the contents of the affected tables. 2. Create auxiliary instance with RMAN or user-managed methods. as long as you have enabled logging for flashback database in advance.– No changes needed for existing scripts – Puts database backups. This technique presumes that you are regularly exporting logical backups of your data. You can avoid having to record the SCN of the database before an operation from which you wish to recover using point-in-time recovery or Flashback Table.    You need: 1) backups from before the time of the error. Database Point-in-Time Recovery You can perform point-in-time recovery (incomplete recovery). DBPITR: 1. >>more about Flashback Database Creating Normal and Guaranteed Restore Points   Guaranteed restore points ensure that you can return your database to a specific previous time using Flashback Database. 2. or having to investigate after the operation to determine the correct SCN. and that any changes between exports are unimportant. archive logs. . sometimes you can import the data back into the table. Import data back into the primary database. Recover the database to the time just before the error. Normal restore points do not provide protection for your data. Recover the tablespace on the auxiliary to the time just before the error. Open RESETLOGS TSPITR: 1. and control file backups in the flash recovery area Recovery from User Error Flashback Database Using Flashback Database enables you to return your whole database to a previous state without restoring old copies of your datafiles from backup. bringing one tablespace or the whole database back to its state before the time of the error. * Open the database with the RESETLOGS option. do not perform a RESETLOGS). use the SET UNTIL command to specify the time. Recover the datafiles using the RECOVER command. Note: The only time you can open a database without performing RESETLOGS after restoring a NOARCHIVELOG backup is when you have not already overwritten the online log files that were current at the time of the most recent backup.Recovery from Media Failures RMAN Media Recovery General Steps The generic steps for media recovery using RMAN are as follows: 1. For example. One or more datafiles NOARCHIVELOG Closed One or more datafiles and an online redo log One or more datafiles and all control files One or more (but not all) datafiles NOARCHIVELOG Closed NOARCHIVELOG Closed ARCHIVELOG Open All datafiles One or more datafiles and an archived redo log required for recovery ARCHIVELOG Closed ARCHIVELOG Open Not All control files and possibly one ARCHIVELOG . or open the database when performing online tablespace recovery 2. Restore the necessary files using the RESTORE command. * Restore whole database from consistent backup. * Restore the whole database and control file from consistent backup. * No changes are lost * The database remains available during the recovery. 3. * Restore the lost control files and datafiles from backups and recover the datafiles. specify the UNTIL clause on the RESTORE and RECOVER commands. For example. 5. or log sequence number at which recovery terminates. * Perform TSPITR on the tablespaces containing the lost datafiles up to the point of the latest available archived redo log. * Lose all changes made after the last backup. and placed online. Alternatively. Place the database in the appropriate state: mounted or open (refer to the following Table). To perform incomplete recovery. open it or bring recovered tablespaces online Media Failures and Recovery Strategies Lost/Inaccessible Files Archiving Mode Status Strategy * Restore whole database from a consistent database backup. * Open with the RESETLOGS option. * Assuming all redo logs are available. restored from backups. mount the database when performing whole database recovery. * Restore the backup datafiles * Mount the control file and recover the database completely. * Lose all changes made after the last backup. * Open with the RESETLOGS option. recovered. open the database as normal (that is. SCN. * The tablespaces or datafiles are taken offline. * Perform tablespace or datafile recovery while the database is open. 4. Place the database in its normal state (refer to the following Table). * All changes made after the backup are lost. crashed. and the database is closed consistently: * perform OPEN RESETLOGS with no transaction loss. * If the lost redo log group was archived before it was lost. * Otherwise. * no transactions are lost. * Open with the RESETLOGS option. * Open with the RESETLOGS option. . then nothing further is required. as well as an ARCHIVELOG archived or online redo log required for recovery open * No changes are lost * The database is unavailable during recovery. In cases when a small number of blocks require media recovery.or more datafiles All control files and possibly one or more datafiles. * take a new full database backup immediately after the OPEN RESETLOGS. you should immediately take a new full backup of your database. * Restore the necessary files from backups * Perform incomplete recovery of the database up to the point of the most recent available log. you can selectively restore and recover damaged blocks rather than whole datafiles. * lose all transactions that were in the lost log. o Lose the current redo log group. Recovery from Datafile Block Corruption Introduction    Use the RMAN BLOCKRECOVER command to perform block media recovery. closed consistently. Block media recovery recovers an individual corrupt datablock or set of datablocks within a datafile. and the database is not closed consistently (either it is open. * Lose all changes contained in the lost log and in all subsequent logs. such as: * The state of the database (open. and so on) * Whether the lost redo log group was current * Whether the lost redo log group was archived Scenarios:  Lose the current group. Not open Online Redo Log Recovery   The method of recovery from loss of all members of an online log group depends on a number of factors. or it has crashed): * restore an old backup * perform point-in-time recovery * OPEN RESETLOGS. * take a new full database backup after that o Lose a noncurrent redo log group: * use the ALTER DATABASE CLEAR LOGFILE statement to re-create all members in the group. Incremental backups are not used by block media recovery.dbf' 2) You can then specify the corrupt blocks in the BLOCKRECOVER command as follows: RMAN>BLOCKRECOVER DATAFILE 7 BLOCK 3 . Only full backups and archived log files are used. You can only perform complete recovery of individual blocks.. Identify Block Corruption Block-level data loss usually results from intermittent.dbf' ORA-01578: ORACLE data block corrupted (file # 2. You must have a full RMAN backup. Any attempt to use a block undergoing media recovery results in an error message indicating that the block is media corrupt. you cannot stop recovery before all redo has been applied to the block. Restrictions       You can only perform block media recovery with RMAN. random I/O errors that do not cause widespread data loss. block # 3) ORA-01110: data file 7: '/oracle/oradata/trgt/tools01. VALIDATE command was run against the file. In other words.Block corruption are reported in the following locations:       Error messages in standard output The alert log User trace files Results of the SQL commands ANALYZE TABLE and ANALYZE INDEX Results of the DBVERIFY utility Third-party media management output Example: 1) you discover the following messages in a user trace file: ORA-01578: ORACLE data block corrupted (file # 7. o Allows affected datafiles to remain online during recovery of the blocks. Advantages: o Lowers the Mean Time to Recovery (MTTR) because only blocks needing recovery are restored and only necessary corrupt blocks undergo recovery. block # 235) ORA-01110: data file 2: '/oracle/oradata/trgt/undotbs01. The V$DATABASE_BLOCK_CORRUPTION view indicates which blocks in a file were marked corrupt since the most recent BACKUP or BACKUP . No SQL*Plus recovery interface is available. You can only recover blocks marked media corrupt. as well as memory corruptions that get written to disk. Block media recovery is able to restore blocks from parent incarnation backups and recover the corrupted blocks through a RESETLOGS.. Blocks that are marked media corrupt are not accessible to users until recovery is complete. For example. online backups. improved availability. it does not immediately signal an error because the block undergoing recovery may become a newed block later in the redo stream. data is replicated between a primary and a remote secondary storage subsystem by sending track-by-track changes from the primary site to the remote site over a secure network. When a block is newed all previous redo for that block becomes irrelevant because the redo applies to an old incarnation of the block. When RMAN first detects missing or corrupt redo records during block media recovery. and systems may then point to this mirrored site and continue operations. in the event of a database corruption. off site tape archiving. Data Protection Strategies     Backup and Recovery .In Remote Data Mirroring. fast one. Thus. There are many different ways to implement a RAID array. disks). the DBA may resort to the earliest snapshot in which the corruption does not exist.g.The fundamental principle behind RAID is the use of multiple hard disk drives in an array that behaves like a single large. Block Media Recovery When Redo Is Missing    Block media recovery can survive gaps in the redo stream if the missing or corrupt redo records do not affect the blocks being recovered. is a must for every database deployment. full and incremental backups. etc. RAID (Redundant Array Of Inexpensive/Independent Disks) . Effective backup strategies usually include local and remote copies of data. hi-speed tape. using some combination of mirroring.Block media recovery only requires an unbroken set of redo changes for the blocks being recovered. rather than going back to the previous night's tape backup. striping. In the event of an outage or a disaster. Each block is recovered independently during block media recovery. increased and integrated capacity and improved performance.Snapshots are images of all or part of a disk filesystem that are taken periodically and stored in another disk allocation. the database can new a block when users delete all the rows recorded in the block or drop a table. so recovery may be successful for a subset of blocks. The degree of benefits using RAID depends on the exact type of RAID that is configured. fault tolerance. . but RAID generally provides some combination of these benefits: higher data security.DATAFILE 2 BLOCK 235. without data loss.A well-designed and well-integrated Backup and Recovery strategy. Snapshots . >>more about RAID Remote Data Mirroring . support for desired secondary devices (e. duplexing and parity technologies. the database may be restored and recovered at the mirrored site. or related by a well defined transformation.Oracle Recovery Manager (RMAN) is Oracle's utility to manage the database backup. Oracle Advanced Replication . or in an asynchronous manner . and have those changes automatically propagate to other databases. Replication usually involves some strategy to resolve conflicting transactions that appear on the same dataset but in different databases.Oracle Data Guard is the most effective and comprehensive data protection and disaster recovery solution available today for enterprise data. Oracle Advanced Replication allows an application to update any replicas of a database. Click here for further details on Oracle Streams. can be used to maintain one or more replica copies of a production database. Streams also supports bi-directional replication with conflict detection and optional resolution. or even during planned maintenances. disasters.Oracle Advanced Replication enables the copying and maintenance of database objects in multiple databases that make up a distributed database system. while ensuring global transactional consistency and data integrity. Transactions can be replicated continuously or on a scheduled basis. It creates and maintains backup policies.  Data Replication . Changes can be transmitted from the primary database to these standby databases in a synchronous manner . rather than pure disaster protection. Data Replication is a softwarebased solution that copies data from the primary database to one or more secondary databases. which is an integrated feature of Oracle Database Enterprise Edition. Oracle Streams . errors. Oracle Recovery Manager . and corruptions. and catalogs all backup and recovery activities. Automated Standby Databases . Its unique flexibility supports replication across large numbers of databases via any network topology. Available as a feature of the Enterprise Edition of the Oracle database. Oracle's Data Protection and Disaster Recovery Solutions     Oracle Data Guard .they can be subsets of a production database. restore and recovery process.Oracle Streams. This technology also provides an automated framework to switch over to the standby system in the event of a disaster or a corruption on the production site. Data Guard can switch any standby database to the production role. it is a software infrastructure that creates.enabling zero data loss. the surviving databases will remain online. manages and monitors one or more standby databases to protect enterprise data from failures. Click here for further details on Oracle Advanced Replication. It maintains these standby databases as transactionally consistent copies of the production database.Automated Standby Databases are an effective means for disaster recovery by providing a completely automated framework to maintain transactionally consistent copies of the primary database. These replicas need not all be identical . Although some business situations may require the flexibility offered by Streams. The database can be kept . thus minimizing the downtime associated with the outage and enabling zero data loss. If the production database becomes unavailable because of a planned or an unplanned outage.minimizing any potential performance impact on the production system. In the event of a disaster at one of the sites. maintains. These multiple databases together constitute a distributed database system. Click here for an overview of the functional components of Oracle Data Guard. it is designed for integration of large distributed database environments.In contrast to remote data mirroring. offline range for read-only and offline tablespaces. All data blocks can be analyzed for corruption during backup and restore. Backing Up the Control File to a Trace File   To back up the control file to a trace file. Oracle partners have validated their remote mirroring solutions to be used with the Oracle database. Recovery Manager ensures all necessary data files are backed up. . online while RMAN is performing its backup. to prevent propagation of corrupt data through backups. But binary control file backups do not include tempfile entries. The list of partners which have their solutions validated through OSCP is available here. Click here for details on the OSCP. Syntax: ALTER DATABASE BACKUP CONTROLFILE TO <filename>. and the database is recoverable. Control File Backup and Recovery   Backup Control File Restore Control File o Restore Lost Copy of a Multiplexed Control File o Restore Control File from Backup After Loss of All Current Control Files o Restore Control File Using RMAN Recreate Control File  User Managed Backups of Control File Backing Up the Control File to a Binary File   A binary backup is preferable to a trace file backup because it contains additional information such as the archived log history. mount or open the database and issue the following SQL statement: SQL> ALTER DATABASE BACKUP CONTROLFILE TO TRACE. then the resulting trace file contains versions of the control file for both RESETLOGS and NORESETLOGS options. Click here for further details on Oracle Recovery Manager. This command writes a SQL script to the database's trace file where it can be captured and edited to reproduce the control file. Specify neither the RESETLOGS nor NORESETLOGS option in the SQL statement. Most importantly. and backup sets and copies (if you use RMAN). OSCP Validated Remote Mirroring .Through Oracle's Storage Compatibility Program (OSCP). * Whenever a BACKUP command within a RUN block is followed by a command that is not BACKUP. Autobackups of Control File After Database Structural Changes: * adding a new tablespace * altering the state of a tablespace or datafile (for example. * At the end of a RUN block. ADD TEMPFILE" statements. RMAN Backups of Control File Auto Backups of Control File    Configure auto backups of control file: RMAN> CONFIGURE CONTROLFILE AUTOBACKUP ON.   Back up datafile 1. if the last command in the block was BACKUP. Run BACKUP CURRENT CONTROLFILE Example: Backs up the current control file to the default disk device and assigns a tag RMAN> BACKUP CURRENT CONTROLFILE TAG = mondaypmbackup. and so on Manual Backups of Control File   In manual backups. only RMAN repository data for backups within the current RMAN session is in the control file backup. RMAN> CONFIGURE CONTROLFILE AUTOBACKUP OFF.. (default) Autobackups of Control File After Backup Acivities: * After every BACKUP command issued at the RMAN prompt. bringing it online) * adding a new online redo log * renaming a file * adding a new redo thread. because RMAN automatically includes the control file and SPFILE in backups of datafile 1 Backing Up a Control File Copy .  Include a backup of the control file within any backup by using the INCLUDE CURRENT CONTROLFILE option of the BACKUP command : Example: Backs up tablespace users to tape and includes the current control file in the backup RMAN> BACKUP DEVICE TYPE sbt TABLESPACE users INCLUDE CURRENT CONTROLFILE. and a manually backed-up control file cannot be automatically restored. Tempfile entries are included in the output using "ALTER TABLESPACE.. then copy one of the intact control files to the location of the missing control file.f o o 4. STEPS: to restore a control file to a nondefault location: o 1.Example: Creates the control file copy '/tmp/control01.f /oracle/dbs/bad_cf. 3.ctl' on disk and then backs it up to tape: RMAN> BACKUP AS COPY CURRENT CONTROLFILE FORMAT '/tmp/control01. If the instance is still running. SQL> STARTUP Copying a Multiplexed Control File to a Nondefault Location    Assuming that the disk and file system containing the lost control file are NOT INTACT. If the instance is still running. then CANNOT copy one of the good control files to the location of the missing control file. STEPS: to replace a damaged control file by copying a multiplexed control file: o 1. Start a new instance and mount and open the database. Restore Lost Copy of a Multiplexed Control File Copying a Multiplexed Control File to a Default Location    If the disk and file system containing the lost control file are INTACT.ctl'.ctl'. shut it down: . If you cannot repair the hardware problem quickly. then proceed with database recovery by restoring damaged control files to an alternative storage device. Do not have to alter the CONTROL_FILES initialization parameter setting. as described in "Copying a Multiplexed Control File to a Nondefault Location". Alter the CONTROL_FILES initialization parameter to indicate a new location for the missing control file. Correct the hardware problem that caused the media failure. Example: % cp /oracle/good_cf. shut it down: SQL> SHUTDOWN ABORT o o 2. RMAN> BACKUP DEVICE TYPE sbt CONTROLFILECOPY '/tmp/control01. Use an intact multiplexed copy of the database's current control file to copy over the damaged control files. SQL> STARTUP Restore Control File from Backup After Loss of All Current Control Files Home >> Reference >> Backup and Recovery >> Control File Backup and Recovery >> Restore Control File from Backup After Loss of All Current Control Files Status of Status of Online Logs Datafiles Available Current Restore Procedure If the online logs contain redo necessary for recovery. and then open RESETLOGS. open RESETLOGS.dbf to a new disk location: % cp $ORACLE_HOME/oradata/oldlocation/control01. After recovery. open RESETLOGS (when the online logs are accessible it is not necessary to OPEN RESETLOGS after recovery with a created control file).'/bad_disk/control02. perform complete recovery.dbf' o o 4. Copy the intact control file to new locations. Because the online redo logs are inaccessible. You must specify the filename of the online logs containing the changes in order to open the database. Change it to in initialization parameter file: CONTROL_FILES='/oracle/oradata/trgt/control01. then re-create the control file. and then open RESETLOGS.dbf'.SQL> SHUTDOWN ABORT o 2. perform incomplete recovery. Restore a backup control file.dbf o 3. Edit the parameter file of the database so that the CONTROL_FILES parameter reflects the current locations of all control files and excludes all control files that were not restored.dbf'. Unavailable Current Available Unavailable Backup Backup . Example: 1. Start a new instance and mount and open the database.dbf' 2. If the online logs contain redo necessary for recovery. Example: to copy a good version of control01. In the original initialization parameter file: CONTROL_FILES='/oracle/oradata/trgt/control01. then restore a backup control file and apply the logs during recovery.dbf $ORACLE_HOME/oradata/newlocation/ control01. Restore a backup control file.'/new_disk/control02. restore the control file to its original location. In this way. For example: 1.Begin recovery by executing the RECOVER command with the USING BACKUP CONTROLFILE clause. STEPS: to restore a backup control file to its default location: o 1.dbf % cp /backup/control02.dbf are the control file locations listed in the server parameter file.dbf ORACLE_HOME/oradata/trgt/control02. For example: if ORACLE_HOME/oradata/trgt/control01. shut it down: SQL> SHUTDOWN ABORT o o 2.Restoring a Backup Control File to the Default Location   If possible. Example: SQL> RECOVER DATABASE USING BACKUP CONTROLFILE UNTIL CANCEL o o 6.dbf ORACLE_HOME/oradata/trgt/control01.Start a new instance and mount the database: SQL> STARTUP MOUNT o 5.Correct the hardware problem that caused the media failure. it probably means that a necessary redo record is located in the online redo logs.Restore the backup control file to all locations specified in the CONTROL_FILES parameter. Specify UNTIL CANCEL if you are performing incomplete recovery.dbf and ORACLE_HOME/oradata/trgt/control02.  1) If you then receive another message saying that the required archived log is missing. you avoid having to specify new control file locations in the initialization parameter file. assume that you see the following: ORA-00279: change 55636 generated at 11/08/2002 16:59:47 needed for thread 1 ORA-00289: suggestion : /oracle/work/arc_dest/arcr_1_111.dbf o o 4.arc .Apply the prompted archived logs. then use an operating system utility to restore the backup control file to these locations: % cp /backup/control01. If the instance is still running. 3. This situation can occur when unarchived changes were located in the online logs when the instance crashed. Media recovery complete. o  o Copying a Multiplexed Control File to a Nondefault Location    Assuming that the disk and file system containing the lost control file are NOT INTACT. then you must re-create the control file.dbf $ORACLE_HOME/oradata/newlocation/ control01.dbf Log applied.Open the database with the RESETLOGS option after finishing recovery: SQL> ALTER DATABASE OPEN RESETLOGS. If the online logs are inaccessible. Example: 1. 2) If the online logs are inaccessible. using the procedure described in "Create New Control File After Losing All Current and Backup Control Files". Example: to copy a good version of control01.ORA-00280: change 55636 for thread 1 is in sequence #111 Specify log: {<RET>=suggested | filename | AUTO | CANCEL} 2. Edit the parameter file of the database so that the CONTROL_FILES parameter reflects the current locations of all control files and excludes all control files that were not restored. If all datafiles are current. and if redo in the online logs is required for recovery.If the instance is still running.dbf to a new disk location: % cp $ORACLE_HOME/oradata/oldlocation/control01. then you can cancel recovery without applying them. then shut it down: SQL> SHUTDOWN ABORT o 2. Copy the intact control file to new locations. then you cannot open the database without applying the online logs. STEPS: to restore a control file to a nondefault location: o 1. then CANNOT copy one of the good control files to the location of the missing control file. In the original initialization parameter file: . 7.dbf o 3. Alter the CONTROL_FILES initialization parameter to indicate a new location for the missing control file. You can specify the name of an online redo log and press Enter (you may have to try thi few times until you find the correct log): ORACLE_HOME/oradata/redo01. dbf'. Restore controlfile from a specific backup piece.CONTROL_FILES='/oracle/oradata/trgt/control01. Start a new instance and mount and open the database.'/new_disk/control02.dbf' o o 4.idevelopment. The following backup used all defaults. . 2. this backup should be in $ORACLE_HOME/dbs.dbf'. Change it to in initialization parameter file: CONTROL_FILES='/oracle/oradata/trgt/control01. SQL> STARTUP Restore Control File Using RMAN Home >> Reference >> Backup and Recovery >> Control File Backup and Recovery >> Restore Control File Using RMAN See also here Source: http://www. 4. 3.info/ The following examples use Oracle Database 10g and make use of a Recovery Catalog and the Flash Recovery Area (FRA). If not using a FRA. 1. RMAN> restore controlfile from autobackup. RMAN> restore controlfile. Restore controlfile from autobackup.'/bad_disk/control02. Restore controlfile from most recent available controlfile backup. RMAN> restore controlfile from '/backup_dir/piece_name'.dbf' 2. The big difference is the requirement to set the dbid of the database before executing restore with the instance in a nomount state. The following examples use Oracle Database 10g and do not require the use of a Recovery Catalog or a Flash Recovery Area (FRA). Restore the controlfile from a specific autobackup file to a temporary disk location the replicate the temp controlfile to the respective locations and names given in control_files. 5.tmp'.. 9. RMAN> restore controlfile from autobackup maxdays 20. . RMAN> restore controlfile from autobackup. 6. If you want to restore an autobackup that's older then the default you can use the 'maxdays' parameter. After you mount the controlfiles from Oracle101g 10. RMAN> replicate controlfile from '/tmp/control. Restoring from autobackup when the backup location is not default. Restore from autobackup increasing the number of autobackup sequences looked for restore in case your database generated many autobackups in a given day. 7..2. RMAN> restore controlfile from autobackup maxseq 10. RMAN> set dbid=nnnnnnnnn. RMAN> set dbid=nnnnnnnnn. RMAN> restore controlfile from '/tmp/c-1140771490-2008050203' to '/tmp/control.x > you can use the RESTORE PREVIEW command to see what backups will be required to restore and recover and what checkpoint you must exceed to open the database resetlogs.RMAN> set dbid=nnnnnnnnn. RMAN> set controlfile autobackup format for device type disk to '/tmp/%F'. Restore the controlfile from this specific autobackup. RMAN> set dbid=nnnnnnnnn. 8. RMAN> set dbid=nnnnnnnnn.tmp' Once you have the controlfile restored and mounted you have access to your previous backup configuration which will also be used during restore as well as the backup information required to restore and recover your database. Restore from autobackup looks at the most recent 7 days backups by default. RMAN> restore controlfile from autobackup. RMAN> set dbid=nnnnnnnnn. RMAN> restore controlfile from '/tmp/c-1140771490-20080502-03'. Start the database in NOMOUNT mode. SQL> STARTUP NOMOUNT   2 Create the control file with the CREATE CONTROLFILE statement. Use the control file copy to obtain SQL output. 1) Create a temporary database instance Backed up to a binary file: Backed up the control file with 2) mount the backup control file the ALTER DATABASE BACKUP CONTROLFILE TO 3) then run ALTER DATABASE filename statement BACKUP CONTROLFILE TO TRACE NORESETLOGS. 4) If the control file copy predated a recent structural change. Edit the output of ALTER Backed up to a trace file: ALTER DATABASE BACKUP DATABASE BACKUP CONTROLFILE TO TRACE before you made a structural CONTROLFILE TO TRACE to change to the database reflect the change. specifying the NORESETLOGS option (refer to the above for options). then edit the trace to reflect the change. and if you have saved the SQL command trace output How to Recreate Control File Use the CREATE CONTROLFILE statement from the trace output asis. Execute the CREATE Do not have a control file backup in either TO TRACE CONTROLFILE statement format or TO filename format manually STEPS  1.Recreate Control File Options How You Backed Up Control File Backed up to a trace file: ALTER DATABASE BACKUP CONTROLFILE TO TRACE NORESETLOGS after you made the last structural change to the database. Example: CREATE CONTROLFILE REUSE DATABASE SALES NORESETLOGS ARCHIVELOG . Open the database after recovery completes (RESETLOGS option not required): SQL> ALTER DATABASE OPEN. '/diskb/prod/sales/db/log1t2.dbf' REUSE.   4. the instance mounts the database.  3.MAXLOGFILES 32 MAXLOGMEMBERS 2 MAXDATAFILES 32 MAXINSTANCES 16 MAXLOGHISTORY 1600 LOGFILE GROUP 1 ( '/diska/prod/sales/db/log1t1.dbf' ) SIZE 100K. Example: SQL> ALTER DATABASE BACKUP CONTROLFILE TO '/backup/control01.dbf'. SQL> ALTER DATABASE MOUNT. DATAFILE '/diska/prod/sales/db/database1.dbf'. After creating the control file. Immediately back up the control file.dbf' ) SIZE 100K GROUP 2 ( '/diska/prod/sales/db/log2t1. '/diskb/prod/sales/db/log2t2.   6.dbf'. '/diskb/prod/sales/db/filea.dbf'. Recover the database as normal (without specifying the USING BACKUP CONTROLFILE clause): SQL> RECOVER DATABASE   5. Fast Incremental Backup Overview . this is automatic if you are using OMF. Monitor how effective the block change tracking is in minimizing the incremental backup I/O (the PCT_READ_FOR_BACKUP column) SQL> SELECT file#. avg(blocks_read/datafile_blocks) * 100 AS PCT_READ_FOR_BACKUP. avg(blocks) FROM v$backup_datafile WHERE used_change_tracking = 'YES' AND incremental_level > 0 GROUP BY file#. avg(datafile_blocks). – Changed blocks are tracked as redo is generated. The size of the block change tracking file is proportional to: . whether it is enabled. Configuration Enable block change tracking   SQL> alter database enable block change tracking.Number of enabled threads in a RAC environment .Number of old backups maintained by the block change tracking file -The minimum size for the block change tracking file is 10 MB.Database size in bytes . – Database backup automatically uses the changed block list. Monitor block change tracking   The dynamic performance view V$BLOCK_CHANGE_TRACKING shows where the block changetracking file is stored. and any new space is allocated in 10 MB increments. avg(blocks_read). Disable block change tracking SQL> ALTER DATABASE DISABLE BLOCK CHANGE TRACKING.dbf'. and how large it is: SQL> select * from v$block_change_tracking.    Optimizes incremental backups – Tracks which blocks have changed since the lastbackup Oracle Database 10g has integrated change tracking: – A change tracking file is introduced. The background process that performs the writes to the change tracking file is called the change tracking writer (CTWR). The block change-tracking file was automatically named and placed in the directory specified by the DB_CREATE_FILE_DEST initialization parameter SQL> alter database enable block change tracking using file '/u04/oradata/ord/changetracking/chg01. Fast Recovery Using Switch Database . Oracle recommends placing the block change-tracking file on the same disk asthe database files. and no files need to be renamed. At your earliest opportunity. SWITCH DATABASE: The switch process does not copy any backup data files. RMAN> switch database to copy. high-performance database file system and disk manager. RMAN adjusts the control file so that the data files point to the backup file location. Automatic Storage Management What is ASM Automatic Storage Management (ASM) is an integrated. you should migrate the datafiles out of the flash recovery area and create new backups. The downside to this method is that your datafiles are now in the flash recovery area. This may cause problems when you create backups: Now your datafiles and backups are in the same location. . and the recovery process begins. ASM eliminates the need for you to directly manage potentially thousands of Oracle database files. Differences Between Restore and Switch   RESTORE DATABASE: The restore process copies the backup data files from their backup location to the location specified in the control file. It takes one command. and the recovery process begins.Overview The new RMAN command SWITCH DATABASE is the fastest way to recover a database using backup copies of the database: No files are copied. Instead. Mirroring means keeping redundant copies. This even distribution of database files eliminates the need for regular monitoring and I/O performance tuning. or mirrored copies. of each extent of the file. and 3-way mirroring. where each file extent gets two .ASM Installation and Configuration    ASM Installation 'oraenv Does Not Set oracle_home For +asm Instance': Metalink Note:338441. which mirrors at the disk level. to help avoid data loss caused by disk failures. The mirrored copy of each file extent is always kept on a different disk from the original copy. unlike operating system mirroring. ASM supports 2-way mirroring. where each file extent gets one mirrored copy. ASM mirrors at the file level.sh Why Use ASM   Striping—ASM spreads data evenly across all disks in a disk group to optimize performance and utilization.1 Initialization Parameters for ASM Instances ASM New Features    10g Release 2 New Features 11g Release 1 New Features 11g Release 2 New Features ASM Administration            ASM Instance Disk groups and disks Files ASM Dynamic Views ASM Metadata and Internals ASM File Handling Migrating Databases from non-ASM to ASM Migrating Databases from ASM to non-ASM ASMLIB ASM Scripts Gather ASM Metadata ASM Commands    ASM and SRVCTL ASMCMD asm. Mirroring—ASM can increase availability by optionally mirroring any file. ASM can continue to access affected files by accessing mirrored copies on the surviving disks in the disk group. If a disk fails. ASM first rebalances by evenly relocating all file extents from the disk being removed to the other disks in the disk group. It is done in the background and with minimal impact to database performance. ASM reduces Oracle Database 10g cost and complexity without compromising performance or availability. alert logs. and automatically deletes files when they are no longer needed. ASM eliminates the need for over provisioning and maximizes storage resource utilization facilitating database consolidation. Any new files can be created as ASM files whilst existing files can also be migrated to ASM. ASM automatically redistributes the data so that it is evenly spread across all disks in the disk group. or password files. or leverage 3rd party RAID functionality. Managed file creation and deletion—ASM further reduces administration tasks by enabling files stored in ASM disk groups to be Oracle-managed files. Note ASM does not manage binaries.  mirrored copies. Key Benefits of ASM            I/O is spread evenly across all available disk drives to prevent hot spots and maximize performance. This redistribution is known as rebalancing. 11g Release 1 New Features Scalability and Performance    Fast Mirror Resynchronization for ASM redundancy disks groups Preferred Read for ASM redundancy disks groups Support for large allocation units . Supports Oracle Database 10g as well as Oracle Real Application Clusters (RAC). trace files. Maintains redundant copies of data to provide high availability. Inherent large file support. For simplicity and easier migration to ASM. an Oracle Database 10g Release 2 database can contain ASM and non-ASM files. When you request to remove a disk. including the new disk. Oracle Database 10g Enterprise Manager can be used to manage ASM disk and file management activities. Capable of leveraging 3rd party multipathing technologies. Performs automatic online redistribution after the incremental addition or removal of storage capacity. Online storage reconfiguration and dynamic rebalancing—ASM permits you to add or remove disks from your disk storage system while the database is operating. ASM automatically assigns filenames when files are created. When you add a disk. RMAN commands enable non-ASM managed files to be relocated to an ASM disk group. which is passed to the database instance. therefore. The former does not process transactions affecting the individual database objects. The impact of the ASM instance on performance of the database instance is minimal. The ASM instance is only involved during the creation or deletion of files and when disk configurations change (such as dropping or adding a disk). Optimized rebalance operations Rolling upgrade and patching support New security features  Separate connect privilege. Unless the server's memory is already at the maximum recommended operating system/DBMS allocation. the average SGA allocation needed by the instance is no more than 64MB. SYSASM. the ASM instance automatically rebalances the disks and provides the necessary information to refresh the extent map in the SGA of the database instance. The ASM instance mounts the disks. When these types of changes occur. the various disk groups and their files are identified. As part of the ASM instance startup procedure. To use ASM files. Of course. this process requires that the ASM instance run concurrently with the database instance. The database instance itself is responsible for any actual input/output operations. New Background Processes of ASM Instance    RBAL: coordinating rebalance activity for disk groups ARBn: performing database the data extent movements GMON: monitoring operations that maintain ASM metadata inside disk groups New Background Processes of Database Instance That Uses ASM   RBAL: performing global opens of the disks in the disk groups ASMB: connecting to foreground processes in ASM instances . and then creates an extent map. different from SYSDBA ASM Instance Introduction ASM doesn't have to be installed in order to install an Oracle database. 64MB should have no impact on the memory available for the database instance. and only shut down after the database instance is closed. there must be at least one ASM instance configured and started prior to starting a database instance that uses ASM files. must contain: INSTANCE_TYPE = ASM The STARTUP command tries to mount the disk groups specified by the initialization parameter ASM_DISKGROUPS. Default ASM SID for a single instance database is +ASM Default SID for ASM on Real Application Clusters is +ASMnode# The initialization parameter file. Starting up an ASM Instance Startup Parameters:    FORCE: Issues a SHUTDOWN ABORT to the ASM instance before restarting it MOUNT. A NULL value causes ASM to search a default path for all disks in the system to which the ASM instance has read/write access. NOMOUNT: Starts up the ASM instance without mounting any disk groups Note:   Set the ORACLE_SID environment variable to the ASM SID. This is the only required parameter.) The difference between ASM Instance and Regular Instance    While it does have an initialization parameter file and a password file.  . the ASM instance starts and warns that no disk groups were mounted. This is the default if no command parameter is specified. OPEN: Mounts the disk groups specified in the ASM_DISKGROUPS initialization parameter.. it has no data dictionary. then no disk groups are mounted. or when the ALTER DISKGROUP ALL MOUNT statement is used. Disk group commands such as CREATE DISKGROUP. May include wildcard characters. which can be a server parameter file. You can then mount disk groups with the ALTER DISKGROUP. Default: NULL. Controls the speed for a rebalance operation. and DROP DISKGROUP are valid only from an ASM instance. since it does not have a control file. but it mounts disk groups. If ASM_DISKGROUPS is blank. ASM_DISKSTRING: A comma-separated list of strings that limits the set of disks that ASM discovers. ASM_DISKGROUPS: A list of the names of disk groups to be mounted by an ASM instance at startup. and therefore all connections to an ASM instance are via SYS and SYSTEM using operating system authentication only. Range: 0 – 11. Default: NULL (If this parameter is not specified.ASM Instance Initialization Parameters     INSTANCE_TYPE: Must be set to ASM.MOUNT command. An ASM instance doen't mount database. ALTER DISKGROUP.. Default: 1. ASM_POWER_LIMIT: The default power for disk rebalancing. Only disks that match one of the strings are discovered. the database instance aborts. SQL> startup ASM instance started Total System Global Area 130023424 bytes Fixed Size 1976920 bytes Variable Size 102880680 bytes ASM Cache 25165824 bytes ASM diskgroups mounted Shutting Down an ASM Instance Shutdown Mode:   NORMAL. IMMEDIATE.Example: % sqlplus /nolog SQL> CONNECT / AS sysdba Connected to an idle instance. ABORT: The ASM instance immediately shuts down without the orderly dismount of disk groups. or TRANSACTIONAL: ASM waits for any in-progress SQL to complete before doing an orderly dismount of all disk groups and shutting down the ASM instance. which is a name common to all nodes in a cluster. . Every ASM disk has an ASM disk name. If any database instances are connected to the ASM instance. Storage is added and removed from disk groups in units of ASM disks. Files in a disk group are striped on the disks using either coarse striping or fine striping. This causes recovery upon the next startup of ASM. Example: % sqlplus /nolog SQL> CONNECT / AS sysdba Connected to an idle instance. the SHUTDOWN command returns an error and leaves the ASM instance running. SQL> shutdown normal ASM diskgroups dismounted ASM instance shutdown Overview of Disk Group    A disk group is a collection of disks managed as a logical unit. If any database instance is connected to the ASM instance. o o Coarse striping spreads files in units of 1MB each across all disks. For files (such as log files) that require low latency. . whose failure would cause the entire set of disks to be unavailable to the group. such as an OLTP environment.. Fine striping spreads files in units of 128KB and is appropriate for traditional data warehouse environments or OLTP systems with low concurrency and maximizes response time for individual I/O requests.. [ [ FAILGROUP failgroup_name ] DISK qualified_disk_clause [. such as a disk controller. . qualified_disk_clause ].. qualified_disk_clause ]. Creating A Disk Group Syntax: CREATE DISKGROUP diskgroup_name [ { HIGH | NORMAL | EXTERNAL } REDUNDANCY ] [ FAILGROUP failgroup_name ] DISK qualified_disk_clause [.. Coarse striping is appropriate for a system with a high degree of concurrent small I/O requests.. ASM provides fine-grained (128 KB) striping Failure Groups and Disk Group Mirroring   A failure group is one or more disks within a disk group that share a common resource. Disk Group Mirroring o Mirror at extent level o Mix primary and mirror extents on each disk o External redundancy: Defers to hardware mirroring o Normal redundancy: – Two-way mirroring – At least two failure groups o High redundancy: – Three-way mirroring – At least three failure groups Disk Group Dynamic Rebalancing      Automatic online rebalance whenever storage configuration changes Only moves data proportional to storage added No need for manual I/O tuning Online migration to new storage Any impact to ongoing database I/O can be controlled by adjusting the value of the initialization parameter ASM_POWER_LIMIT to a lower value. ].. .. UNDROP DISKS This cancels the drop of the disk that was dropped. Altering A Disk Group      ALTER DISKGROUP . ADD FAILGROUP . Example: DROP DISKGROUP dgroup1 including contents. 11 '/devices/disk8'. Deleting A Disk Group Syntax: DROP DISKGROUP diskgroup_name [ { INCLUDING | EXCLUDING } CONTENTS ]... DISK This adds a disk to a failure group and performs an automatic rebalance ALTER DISKGROUP . 10 '/devices/disk7'. 6 '/devices/disk4' 7 FAILGROUP controller2 DISK 8 '/devices/disk5'.. DROP DISK This removes a disk from a failure group within a disk group and performs an automatic rebalance... . 9 '/devices/disk6'. The UNDROP command operates only on pending drops of disks.. ALTER DISKGROUP . ALTER DISKGROUP . ADD This drops a disk from a failure group and adds another disk in the same command... REBALANCE POWER This changes the power limit for this particular rebalance operation ALTER DISKGROUP . not after drop completion.... 4 '/devices/disk2'. 5 '/devices/disk3'. DROP ..Example: SQL> CREATE DISKGROUP dgroup1 NORMAL REDUNDANCY 2 FAILGROUP controller1 DISK 3 '/devices/disk1'. substituting your specific filenames as needed: STARTUP NOMOUNT. 5. you must use the Recovery Manager (RMAN) to move database objects from a non-ASM disk location to an ASM disk group.. Follow these steps to move these objects: 1. 3. Migrating Databases from non-ASM to ASM Migrating Databases from non-ASM to ASM Home >> Reference >> Automatic Storage Management >> Migrating Databases from nonASM to ASM Because ASM files cannot be accessed via the operating system. Edit the SPFILE to use OMF for all file destinations.. Run the following RMAN script. 2.idevelopment. 6. SQL "ALTER DATABASE TEMPFILE '/u1/temp1' DROP". SWITCH DATABASE TO COPY. ALTER DISKGROUP . CHECK ALL This verifies the internal consistency of the disk group. Delete or archive the old database files. Back up the database. ALTER DATABASE MOUNT. ALTER DISKGROUP . 4. MOUNT This makes a disk group available to all instances. Note the filenames of the control files and the online redo log files..   ALTER DISKGROUP . IMMEDIATE.. ALTER DATABASE OPEN RESETLOGS. DISMOUNT This makes a disk group unavailable to all instances. Edit the SPFILE to remove the CONTROL_FILES parameter.info/data/Oracle/DBA_tips/Automatic_Storage_Management/ASM_ 33. RESTORE CONTROLFILE FROM '/u1/c1. BACKUP AS COPY DATABASE FORMAT '+dgroup1'.shtml ASMLIB .. Refer detailed steps to http://www.. 7.ctl'... # Repeat command for all temporary tablespaces SQL "ALTER TABLESPACE temp ADD TEMPFILE". # Repeat command for all online redo log members . or TRANSACTIONAL. SQL "ALTER DATABASE RENAME '/u1/log1' TO '+dgroup1' ". Shut down the database NORMAL. d/oracleasm $ oracleasm -h Usage: oracleasm oracleasm oracleasm oracleasm [--exec-path=<exec_path>] <command> [ <args> ] --exec-path -h -V The basic oracleasm commands are: configure Configure the Oracle Linux ASMLib driver init Load and initialize the ASMLib driver exit Stop the ASMLib driver . configure and manage Oracle Automatic Storage Management (ASM) disks via the Oracle Automatic Storage Management library driver (ASMLib).Linux OS Service 'oracleasm'  Service Name oracleasm  Description The oracleasm service is used to provision. Not needed if Oracle ASM (instance-only) management of ASM group/disk devices is required/preferred.  Nature System service  Configuration File /etc/sysconfig/oracleasm     Oracle Enterprise Linux Version(s) OEL 4 OEL 5 Requirement Optional .needed only if operating system-level management and configuration of Oracle ASM disk devices is required. oracleasm /etc/init. The oracleasm services creates the necessary library interface through which ASM disk devices are made available to Oracle ASM (instance). d/oracleasm querydisk {DISKNAME | devicename} listdisks Use the listdisks option to list the disk names of marked Automatic Storage .d/oracleasm createdisk DISKNAME devicename deletedisk Use the deletedisk option to unmark a named disk device: # /etc/init.d/oracleasm restart createdisk Use the createdisk option to mark a disk device for use with the Automatic Storage Management library driver and give it a name: # /etc/init. The enable option causes the Automatic Storage Management library driver to load when the system starts: # /etc/init. stop. if necessary: # /etc/init. querydisk Use the querydisk option to determine if a disk device or disk name is being used by the Automatic Storage Management library driver: # /etc/init.d/oracleasm configure enable disable Use the disable and enable options to change the actions of the Automatic Storage Management library driver when the system starts. You must delete the disk from the Automatic Storage Management disk group before you unmark it.d/oracleasm deletedisk DISKNAME Caution: Do not use this command to unmark disks that are being used by an Automatic Storage Management disk group. and restart options to load or unload the Automatic Storage Management library driver without restarting the system: # /etc/init.d/oracleasm enable start stop restart Use the start.scandisks status listdisks querydisk createdisk deletedisk renamedisk update-driver Scan the system for Oracle ASMLib disks Display the status of the Oracle ASMLib driver List known Oracle ASMLib disks Determine if a disk belongs to Oracle ASMlib Allocate a device for Oracle ASMLib use Return a device to the operating system Change the label of an Oracle ASMlib disk Download the latest ASMLib driver Option configure Description Use the configure option to reconfigure the Automatic Storage Management library driver. 1 oracle dba 8. $ ll /dev/oracleasm/disks total 0 brw-rw---.d/oracleasm status . 97 Apr brw-rw---.1 oracle dba 8.1 oracle dba 8.9G 85% / 0 0 .3G 0 Used Avail Use% Mounted on 11G 1. 81 Apr brw-rw---. 65 Apr brw-rw---./dev/pts 0 0 .Management library driver disks: # /etc/init./proc/bus/usb 14M 81M 15% /boot 0 250M 0% /dev/shm 4. This is the device discovered by ASMLIB using the string ORCL:*. 113 Apr 28 28 28 28 28 28 28 28 15:20 15:20 15:20 15:20 15:20 15:20 15:20 15:20 VOL001 VOL002 VOL003 VOL004 VOL005 VOL006 VOL007 VOL008  Checking if ASMLIB was installed properly: [root@arlnx2 asm_tar]# /etc/init. 33 Apr brw-rw---. $ df -ha Filesystem /dev/hdc2 none none usbdevfs /dev/hdc1 none /dev/sda1 /dev/sde1 oracleasmfs Size 13G 0 0 0 101M 250M 8.d/oracleasm listdisks scandisks Use the scandisks option to enable cluster nodes to identify which shared disks have been marked as Automatic Storage Management library driver disks on another node: # /etc/init. a special filesystem is created and mounted: /dev/oracleasm.2G 60% /oradata2 6. 49 Apr brw-rw---.1 oracle dba 8.8G 3.1 oracle dba 8.1 oracle dba 8.d/oracleasm scandisks Q&A  Is /dev/oracleasm created? When ASMLIB is configured./dev/oracleasm When command oracleasm createdisk is executed.1 oracle dba 8.4G 8.4G 84% /oradata3 0 0 . a block device is created under /dev/oracleasm/disks./proc 0 0 . 17 Apr brw-rw---.6G 1. 129 Apr brw-rw---.1 oracle dba 8. 1  Listing the ASMLIB disks: $ /etc/init. 33 Apr brw-rw---.1 oracle dba 8. use strace and generate a log file: strace -f -o asm_status. 65 Apr brw-rw---.1 oracle dba 8. 97 Apr brw-rw---. 17 Apr brw-rw---.Checking if ASM is loaded: Checking if /dev/oracleasm is mounted: [ [ OK ] OK ] If the command fails. . but if not. If the file exist the command will return information.out /etc/init. plese execute: strace -f -o asm_listd.d/oracleasm listdisks VOL001 VOL002 VOL003 VOL004 VOL005 VOL006 VOL007 VOL008 $ ll /dev/oracleasm/disks total 0 brw-rw---. 113 Apr 28 28 28 28 28 28 28 28 15:20 15:20 15:20 15:20 15:20 15:20 15:20 15:20 VOL001 VOL002 VOL003 VOL004 VOL005 VOL006 VOL007 VOL008 You will find an entry under /dev/oracleasm/disks. 49 Apr brw-rw---.1 oracle dba 8. This is the block device associated to the physical device.1 oracle dba 8.d/oracleasm listdisks  How to identify the physical disk bound to the ASMLIB disk.1 oracle dba 8.1 oracle dba 8.d/oracleasm status Additional information to verify the installation can be found in note 269194.1 oracle dba 8.out /etc/init.1 oracle dba 8. 81 Apr brw-rw---. 129 Apr brw-rw---. d/oracleasm querydisk /dev/sdc1 Disk "/dev/sdc1" is marked an ASM disk with the label "VOL1" Any error on this command will require using strace: .Use /etc/init.minor numbers which are unique numbers associated to each disk. 33] The command reports the device identified with major.d/oracleasm querydisk <NAME> where NAME is any name under /dev/oracleasm/disks. File /proc/partitions can be used to find the name of the device associated with those numbers: $ more /proc/partitions major minor #blocks running use aveq name rio rmerge rsect ruse wio wmerge wsect wuse 8 0 8891620 sda 39715 78016 941080 417000 156198 242472 3189752 214180 0 420630 631180 8 1 8891376 sda1 39691 77970 940922 416780 156198 242472 3189752 214180 0 420410 630960 8 16 8891620 sdb 87 250 803 740 0 0 0 0 0 740 740 8 17 8891376 sdb1 57 193 632 480 0 0 0 0 0 480 480 8 32 17783250 sdc 745 2993 8321 8300 0 0 0 0 0 5250 8300 8 33 977904 sdc1 87 139 644 1040 0 0 0 0 0 1040 1040 8 34 977920 sdc2 35 193 456 230 0 0 0 0 0 230 230 8 35 1 sdc3 4 0 8 40 0 0 0 0 0 40 40 8 37 977904 sdc5 57 193 632 1240 0 0 0 0 0 1240 1240 8 38 977904 sdc6 57 193 632 1170 0 0 0 0 0 1170 1170 Also connected as root you can run the same command but referencing the physical device: [root@arlnx2 dbs]# /etc/init. [root@arlnx2 asm_tar]# /etc/init.d/oracleasm querydisk -d VOL1 Disk "VOL1" is a valid ASM disk on device [8. d/oracleasm status $> /usr/sbin/oracleasm-discover $> /usr/sbin/oracleasm-discover 'ORCL:*' .library from v$asm_disk.Generic Linux. version 2. PATH LIBRARY -------------------.2 (KABI_V2) ORCL:VOL002 ASM Library .2 (KABI_V2) ORCL:VOL004 ASM Library . please execute the next commands and provide us the output (from each node if this is RAC): $> $> $> $> cat /etc/*release uname -a rpm -qa |grep oracleasm df -ha 2) Check the discovery path (from each node if this is RAC): $> /etc/init.0.d/oracleasm querydisk <NAME>  How to identify if ASMLIB is used or not SQL> select path . version 2.Generic Linux. version 2. version 2.2 (KABI_V2) ORCL:VOL003 ASM Library .2 (KABI_V2) PATH ----------------------------------------------------------------------------------/dev/oracleasm/disks/ASM7 /dev/oracleasm/disks/ASM2 /dev/oracleasm/disks/ASM1 /dev/oracleasm/disks/ASM5 /dev/oracleasm/disks/ASM6 /dev/oracleasm/disks/ASM4 /dev/oracleasm/disks/ASM3 LIBRARY -------------------------System System System System System System System Troubleshooting ASM/ASMLIB issues 1) In order to check if the ASMLIB API is correctly configured.----------------------------------------------------------ORCL:VOL001 ASM Library .out /etc/init.0.Generic Linux.Generic Linux.0.strace -f -o asm_query.0. d/oracleasm scandisks /etc/init.d/oracleasm listdisks /etc/init.html SET MARKUP HTML ON set echo on set pagesize 200 alter session set nls_date_format='DD-MON-YYYY HH24:MI:SS'. select 'THIS ASM REPORT WAS GENERATED AT: ==)> ' .d/oracleasm querydisk <each disk from previous output> ls -l /dev/oracleasm/disks 4) Upload the next files from each node if this is RAC: =)> /var/log/messages* =)> /var/log/oracleasm =)> /etc/sysconfig/oracleasm 5) Please show us the partition table (from each node if this is RAC): $> cat /proc/partitions 6) If you are using multipath devices (mapper devices or emcpower) then show me the output of: $> ls -l /dev/mpath/* $> ls -l /dev/mapper/* $> ls -l /dev/dm-* $> ls -l /dev/emcpower* Or if you have another multipath configuration then list the devices: $> ls -l /dev/<multi path device name>* 7) Finally connect to your ASM instance. execute the next script and upload me the output file (from each node if this is RAC): spool asm<#>. sysdate " " from dual.3) Please check if the ASMLIB devices can be accessed (from each node if this is RAC): $> $> $> $> /etc/init. MACHINE " " from . select 'HOSTNAME ASSOCIATED WITH THIS ASM INSTANCE: ==)> ' . HTML SET MARKUP HTML ON set echo on set pagesize 200 alter session set nls_date_format='DD-MON-YYYY HH24:MI:SS'. select * from V$ASM_ATTRIBUTE. SELECT * FROM V$ASM_CLIENT. select * from v$asm_operation. select * from gv$asm_operation select * from v$version.DISK_NUMBER. . select 'THIS ASM REPORT WAS GENERATED AT: ==)> ' . show show show show show parameter parameter parameter parameter parameter asm cluster instance_type instance_name spfile show sga spool off exit Gather ASM Metadata Connect to your ASM instance(s) and execute the next scripts (on each node if this is RAC): SPOOL ASM_FIRST<instance#>.v$session where program like '%SMON%'. select * from v$asm_diskgroup. sysdate " " from dual. SELECT * FROM V$ASM_DISK ORDER BY GROUP_NUMBER. HTML SET MARKUP HTML ON SET ECHO ON SET PAGESIZE 200 SELECT SELECT SELECT SELECT SELECT SELECT * * * * * * FROM FROM FROM FROM FROM FROM V$ASM_CLIENT. select * from v$asm_operation. SELECT * FROM V$ASM_CLIENT. select * from V$ASM_ATTRIBUTE.FILE_NUMBER.FILE_NUMBER.DISK_NUMBER.ENTRY_NUMBER. V$ASM_DISKGROUP_STAT ORDER BY GROUP_NUMBER.select 'HOSTNAME ASSOCIATED WITH THIS ASM INSTANCE: ==)> ' . V$ASM_TEMPLATE ORDER BY GROUP_NUMBER. V$ASM_DISK_STAT ORDER BY GROUP_NUMBER. V$ASM_FILE ORDER BY GROUP_NUMBER. show show show show show parameter parameter parameter parameter parameter asm cluster instance_type instance_name spfile show sga spool off exit SPOOL ASM_SECOND<instance#>. select * from v$asm_diskgroup.DISK_NUMBER. V$ASM_ALIAS ORDER BY GROUP_NUMBER. select * from v$version. SELECT * FROM V$ASM_DISK ORDER BY GROUP_NUMBER. MACHINE " " from v$session where program like '%SMON%'. select * from gv$asm_operation select * from v$version. show show show show show parameter parameter parameter parameter parameter asm cluster instance_type instance_name spfile SPOOL OFF EXIT . ASM and SRVCTL Start an ASM instance: Syntax: srvctl start asm -n node_name [-i asm_instance_name] [-o start_options] [-c <connect_str> | q] Example: start an ASM instance on the specified node $srvctl start asm -n linuxnode1 Stop an ASM instance: Syntax: srvctl stop asm -n node_name [-i asm_instance_name] [-o stop_options] [-c <connect_str> | q] Example: stop an ASM instance on the specified node $srvctl stop asm -n linuxnode1 immediate Add configuration information (OCR data) about an existing ASM instance: Syntax: srvctl add asm -n node_name -i asm_instance_name -o oracle_home Example: $srvctl add asm -n linuxnode1 -i +ASM1 -o $ORACLE_HOME Remove an ASM instance: Syntax: srvctl remove asm -n node_name [-i asm_instance_name] Enable an ASM instance: . 541956473 ASM generates filenames according to the following scheme: +diskGroupName/databaseName/fileType/fileTypeTag. sample is the database name.and so on.directories. System-generated filename or 'fully qualified filename' Every file created in ASM gets a system-generated filename. performsearches.256. create and remove directories and aliases. dgroup2 is the disk groupname. otherwiseknown as a fully qualified filename. display spaceutilization. The following are some key definitions. Directory . This is analogous to a completepath name in a local file system. you must understandhow these common computing concepts apply to the unique ASMenvironment.ASMCMD works with Automatic Storage Management (ASM) files. and more. An example of a fully qualifiedfilename is the following: +dgroup2/sample/controlfile/Current. Before using ASMCMD. It can list the contents of disk groups. and aliases.Syntax: srvctl enable asm -n node_name [-i ] asm_instance_name Disable an ASM instance: Syntax: srvctl disable asm -n node_name [-i asm_instance_name] Example: $srvctl disable asm -n linuxnod1 -i +ASM1 Show the configuration of an ASM instance: Syntax: srvctl config asm -n node_name Obtain the status of an ASM instance: Syntax: srvctl status asm -n node_name ASM Command-Line Utility (ASMCMD)ASMCMD is a command-line utility that you can use to easily view andmanipulate files and directories within Automatic Storage Management(ASM) disk groups.incarnation In the previous fully qualified filename.file. controlfile is the file type. dgroup1 and dgroup2 . For anASM instance with two disk groups. You create aliases to makeit easier to work with ASM filenames. the current directory is set to root (+). You can create an alias with an ALTER DISKGROUP command or with the . and itcan be part of a tree structure of other directories.257. ASMCMD always shows thecurrent directory as part of its prompt. Itscontents represent the contents of the disk group dgroup1 .541956473Current. You do so with the ALTER DISKGROUP command or with the ASMCMD mkdir command.with the plus sign (+) as the root. ASM creates adirectory hierarchy that corresponds to the structure of the fullyqualified filenames in the disk group. enteringan ls command with the root directory as the current directoryproduces the following output: ASMCMD> lsDGROUP1/DGROUP2/ The following example demonstrates navigating the ASM directory tree(refer to the fully qualified filename shown previously): ASMCMD> cd +dgroup1/sample/controlfileASMCMD> lsCurrent. The directories in this hierarchyare known as system-generated directories.As in other file systems. Your user-createddirectories can have subdirectories. ASMCMD [+] > cd dgroup1/mydirASMCMD [+DGROUP1/MYDIR] > Alias An alias is a filename that is a reference (or pointer) to a system-generated filename. It is similar toa symbolic link in Unix operating systems.When you start ASMCMD. The ASMCMD ls (list directory) command liststhe contents of the current directory.)If you start ASMCMD with the -p flag. The fully qualified filename in fact represents a hierarchy of directories. while the pwd command printsthe name of the current directory. and you can navigate thehierarchy of both system-generated directories and user-generateddirectories with the cd command The following example creates the directory mydir in the disk group dgroup1 : ASMCMD> mkdir +dgroup1/mydir (Note that the directory dgroup1 is a system-generated directory. In each disk group. an ASM directory is a container for files.256.541956475 You can also create your own directories as subdirectories of thesystem-generated directories. but with a more user-friendly name. ASMCMD enables you tomove up and down this directory hierarchy with the cd (changedirectory) command. The following are examples of aliases: +dgroup1/ctl1.f =>+dgroup2/sample/controlfile/Current.f If you run the ASMCMD ls (list directory) with the -l flag. if you do not specify an instance name.mkalias ASMCMDcommand. then -i --the command applies to all of the ASM instances on the node.f+dgroup1/mydir/ctl1. You can create aliases at the disk group level or in any system-generated or user-created subdirectory.: --For all of the SRVCTL commands in this section for which the --option is not required.An alias has at a minimum the disk group name as part of its completepath.541956473 Absolute path and Relative path ######################################################### ####### # Adding/Removing/Managing the configuration of ASM instances ######################################################### ####### --Use the following syntax to add configuration information about an existing ASM instance: srvctl add asm -n node_name -i +asm_instance_name -o oracle_home --Use the following syntax to remove an ASM instance: srvctl remove asm -n node_name [-i +asm_instance_name] --Use the following syntax to enable an ASM instance: srvctl enable asm -n node_name [-i ] +asm_instance_name --Use the following syntax to disable an ASM instance: srvctl disable asm -n node_name [-i +asm_instance_name] --Use the following syntax to start an ASM instance: srvctl start asm -n node_name [-i +asm_instance_name] [-o start_options] --Use the following syntax to stop an ASM instance: srvctl stop asm -n node_name [-i +asm_instance_name] [-o stop_options] --Use the following syntax to show the configuration of an ASM instance: srvctl config asm -n node_name --Use the following syntax to obtain the status of an ASM instance: srvctl status asm -n node_name --P. each alias islisted with the system-generated file that it references.256. ctl1.S. .f+dgroup1/sample/ctl1. group_number.READS.99 col BYTES_WRITTEN format 99999999999999. path. TOTAL_MB. MOUNT_DATE. READS.99 col BYTES_READ format 99999999999999. WRITE_TIME from v$asm_disk order by 3. STATE.B Time in Hundred seconds! col READ_TIME format 9999999999. BYTES_READ. select name. --Quering ASM Disk Groups col name format a25 col DATABASE_COMPATIBILITY format a10 col COMPATIBILITY format a10 select * from v$asm_diskgroup. free_mb from v$asm_diskgroup. state. FREE_MB. FREE_MB. MOUNT_STATUS. group_number.1. --or col PATH format a50 col HEADER_STATUS format a12 col name format a25 --select INCARNATION. MODE_STATUS. type. READ_TIME. --or select name. STATE. READS. TOTAL_MB. ################################### #TUNING and Analysis ################################### --Only Performance Statistics --N. --The status of these processes can be shown by selecting from v$asm_operation. REPAIR_TIMER. TOTAL_MB. WRITES. group_number. WRITES. READ_TIME. total_mb. OS_MB.HEADER_STATUS. READ_TIME. WRITE_TIME. --Quering ASM Disks col PATH format a55 col name format a25 select name.99 select name.99 col WRITE_TIME format 9999999999. FREE_MB. . CREATE_DATE from v$asm_disk. WRITES.################################### # Managing DiskGroup inside ASM: ################################### --Note that adding or dropping disks will initiate a rebalance of the data on the disks. path. BYTES_WRITTEN. name.reference_index rindex FROM v$asm_alias a.XNUM_KFFXP. --List the hierarchical tree of files stored in the diskgroup SELECT concat('+'||gname.DISK_KFFXP Disk#. GROUP_KFFXP from x$kffxp. SELECT GROUP_KFFXP Group#. select max(substr(name. --or SELECT GROUP_KFFXP Group#.group_number = g. XV.XNUM_KFFXP Extent#. XV.group_number) START WITH (mod(pindex.669293645'. XV. 24))) = 0 CONNECT BY PRIOR rindex = pindex. DISK_KFFXP.1.4.AU_KFFXP AU#. XV.272.DISK_KFFXP Disk#. sys_connect_by_path(aname. a. '/')) full_alias_path FROM (SELECT g.CHK_KFFXP. XV. REPAIR_TIMER. XV. --Check the Num of Extents in use per Disk inside one Disk Group. name.XV.DISK_KFFXP Disk#. XV.INDX.ADDR.FLAGS_KFFXP. --Find The File distribution Between Disks SELECT * FROM v$asm_alias WHERE name='PWX_DATA. v$ASM_DISKGROUP gr where GROUP_KFFXP=&group_nr and GROUP_KFFXP=GROUP_NUMBER group by GROUP_KFFXP.INCARN_KFFXP. --or select d. XV.GROUP_NUMBER=XV.WRITE_TIME. X$KFFXP XV where d.AU_KFFXP AU#.GROUP_KFFXP Group#. BYTES_WRITTEN.LXN_KFFXP. XV. XV. BYTES_READ.30)) group_name. XV.DISK_KFFXP and number_kffxp=&File_NUM order by 2.parent_index pindex.669293645').3. count(PXN_KFFXP) extents_per_disk.INST_ID.GROUP_KFFXP and d. power(2.XNUM_KFFXP Extent# FROM X$KFFXP WHERE number_kffxp=&DataFile_Number.SIZE_KFFXP from v$asm_disk d.272. v$asm_diskgroup g WHERE a. XV.AU_KFFXP AU#.DISK_NUMBER=XV. a. XV. XV.COMPOUND_KFFXP. DISK_KFFXP order by GROUP_KFFXP.name aname. XV. a. DISK_KFFXP.PXN_KFFXP.MOUNT_DATE from v$asm_disk order by group_number.NUMBER_KFFXP File_Number. ######################################################### ####### .XNUM_KFFXP Extent# FROM X$KFFXP WHERE number_kffxp=(SELECT file_number FROM v$asm_alias WHERE name='PWX_DATA.name gname. it is only mounted on the local instance.################################### #Create and Modify Disk Group ################################### create diskgroup FRA1 external redundancy disk '/dev/vx/rdsk/oraASMdg/fra1' ATTRIBUTE 'compatible. --Add several disks with a wildcard: alter diskgroup FRA1 add disk '/dev/vx/rdsk/oraASMdg/fra*'. alter diskgroup FRA1 add disk '/dev/vx/rdsk/fra1dg/fra3'. --Add a second disk: alter diskgroup FRA1 add disk '/dev/vx/rdsk/oraASMdg/fra2'. --Drop the entire DiskGroup drop diskgroup DATA1 including contents. --When a new diskgroup is created. .1'. --on +ASM2 : alter diskgroup FRA1 mount. 'compatible. select * from v$asm_operation. alter diskgroup FRA1 check all. alter diskgroup FRA1 drop disk 'FRA1_0003'. --Remove a disk from a diskgroup: alter diskgroup FRA1 drop disk 'FRA1_0002'.1'. --------------------------------------------------------------------------------------alter diskgroup FRA1 drop disk 'FRA1_0002'.rdbms' = '11. --How to DROP the entire DiskGroup when it is in NOMOUNT Status --Generate the dd command which will reset the header of all the --disks belong the GROUP_NUMBER=0!!!! select 'dd if=/dev/zero of=''' ||PATH||''' bs=8192 count=100' from v$asm_disk where GROUP_NUMBER=0. alter diskgroup FRA1 add disk '/dev/vx/rdsk/fra1dg/fra4'.asm' = '11. .ASM directory and all of its subdirectories. . . . --on +ASM2 : alter diskgroup FRA1 mount.exit Command Exits ASMCMD. or the names and attributes of all disk groups.find Command Lists the paths of all occurrences of the specified name (with wildcards) under the specified directory.md_backup Command Creates a backup of all of the mounted disk groups. recursively. .--and only the instance-specific entry for the asm_diskgroups parameter is updated. .file. .mkdir Command Creates ASM directories. --on +ASM1 : create diskgroup FRA1 external redundancy disk '/dev/vx/rdsk/fradg/fra1' ATTRIBUTE 'compatible. .help Command Displays the syntax and description of ASMCMD commands.lsct Command Lists information about current ASM clients. . --By manually mounting the diskgroup on other instances.md_restore Command Restores disk groups from a backup.ls Command Lists the contents of an ASM directory.asm' = '11. .cp Command Enables you to copy files between ASM disk groups on a local instance and remote instances. the asm_diskgroups parameter --on those instances are updated.cd Command Changes the current directory to the specified directory.pwd Command Displays the path of the current ASM directory.1'. . .du Command Displays the total disk space occupied by ASM files in the specified .mkalias Command Creates an alias for system-generated filenames. . --It works even for on going balances!!! alter diskgroup DATA1 rebalance power 10.rdbms' = '11. 'compatible.1'. .lsdg Command Lists all disk groups and their attributes. ######################################################### ####### # New ASM Command Line Utility (ASMCMD) Commands and Options ######################################################### ####### ASMCMD Command Reference: Command Description -------------------. the attributes of the specified . .lsdsk Command Lists disks visible to ASM. 'compatible.' from v$asm_disk where GROUP_NUMBER=0 and rownum<=&Num_Disks_to_add.remap Command Repairs a range of physical blocks on a disk.rm Command Deletes the specified ASM files or directories. .668957419' RESIZE 150M..1'. ------------------------create diskgroup DATA1 external redundancy disk '/dev/vx/rdsk/oraASMdg/fra1' ATTRIBUTE 'compatible. ALTER DATABASE DATAFILE '+DATA1/dbname/datafile/audit.rdbms' = '11. ===== ################################################### ###### 11gR2 GRID Installation on Red Hat Enterprise 5 ###### ################################################### . select 'alter diskgroup DATA1 add disk ''' || PATH || '''. select 'alter diskgroup FRA1 add disk ''' || PATH || '''. . --Remove ASM header select 'dd if=/dev/zero of=''' ||PATH||''' bs=8192 count=100' from v$asm_disk where GROUP_NUMBER=0.1'. kfed read /dev/vx/rdsk/fra1dg/fra1 ######################################################### ####### # CREATE and Manage Tablespaces and Datafiles on ASM ######################################################### ####### CREATE TABLESPACE my_ts DATAFILE '+disk_group_1' SIZE 100M AUTOEXTEND ON. --------.asm' = '11. retaining the file that the alias points to.rmalias Command Deletes the specified alias.259. ALTER TABLESPACE sysaux ADD DATAFILE '+disk_group_1' SIZE 100M.' from v$asm_disk where GROUP_NUMBER=0 and rownum<=&Num_Disks_to_add.kfed tool From Unix Prompt for reading ASM disk header. 81-3.106-3.x86_64.5-24 (x86_64) <<< both ARCH's are required.3.11-7.17.el5.2-42.x86_64.d/oracleasm configure Configuring the Oracle ASM library driver.rpm libgomp-4.1.3.rpm <<< both ARCH's are required.el5. unixODBC-devel-2.1.1.2-42.125-3.2-42.106-3.3-61 (x86_64) <<< both ARCH's are required.3-61 (i386) <<< both ARCH's are required.rpm libaio-devel-0.11-7.el5 (x86_64) <<< both ARCH's are required.5-24.2-42.1.2.x86_64.el5.16. This will configure the on-boot properties of the Oracle ASM library .rpm glibc-devel-2.el5 (x86_64) elfutils-libelf-devel-0.x86_64.rpm <<< both ARCH's are required.5-24 (i686) <<< both ARCH's are required.1.rpm libstdc++-devel-4. glibc-devel-2.rpm <<< both ARCH's are required.1.1.rpm <<< both ARCH's are required.2. make-3.x86_64.6-6.1.3-1.18-92.rpm ################################################### # ASMLib Configuration [root@linux1 /]# /etc/init.x86_64.i386.2 (i386) <<< both ARCH's are required.x86_64.el5.5-24 (x86_64) ksh-20060214-1. glibc-2.1.11-7. unixODBC-devel-2.3. gcc-4.46-0.2.0. elfutils-libelf-0.rpm oracleasmlib-2.x86_64.0.SLE10.6.0.el5 (x86_64) <<< both ARCH's are required.2-1.4-1.106-3. libaio-0.46-0.el5. libstdc++-4.5-24. libstdc++-4.rpm <<< both ARCH's are required.1.3-1.2-42.x86_64.2.2.rpm elfutils-libelf-devel and elfutils-libelf-devel-static glibc-headers-2.1. #ASMLIB packages #Platform depenfent but Kernel independent oracleasm-support-2.rpm <<< both ARCH's are required.50.125-3.106-3.2 (x86_64) <<< both ARCH's are required.x86_64.x86_64. libgcc-4.x86_64. libaio-devel-0.el5.el5 (x86_64) compat-libstdc++-33-3.el5 (i386) <<< both ARCH's are required.1.x86_64.x86_64.rpm oracleasm-2. libgcc-4.11-7.3-1.2-42.6. unixODBC-2.2-42.rpm kernel-headers-2.5-24.rpm #Platform and Kernel depended oracleasm-2.rpm <<< both ARCH's are required.0.12-default-2.x86_64.2-42.x86_64. compat-libstdc++-33-3.125-3.rpm gcc-c++-4.#List of Operating System packages: binutils-2.el5 (i386) <<< both ARCH's are required.7 (x86_64) libaio-0.rpm unixODBC-2. sysstat-7.rpm elfutils-libelf-devel-static-0.el5.i386.6.el5.el5 (x86_64) glibc-2.2. glibc-common-2.x86_64.i386.SLE10.i386.rpm <<< both ARCH's are required.2.1.0.12-smp-2.2.3.16. asmdba.users [root@linux1 /]# useradd -u 1100 -g oinstall -G asmadmin. The following questions will determine whether the driver is loaded on boot and what permissions it will have. Ctrl-C will abort. Default user to own the driver interface []: grid Default group to own the driver interface []: asmdba Start Oracle ASM library driver on boot (y/n) [n]: y Fix permissions of Oracle ASM disks on boot (y/n) [y]: y Writing Oracle ASM library driver configuration [ OK ] Creating /dev/oracleasm mount point [ OK ] Loading module "oracleasm" [ OK ] Mounting ASMlib driver filesystem [ OK ] Scanning system for ASM disks [ OK ] ################################################### # Users and Groups Creation -.asmoper grid [root@linux1 /]# useradd -u 1101 -g oinstall -G asmdba.conf ## Go to the end grid soft nproc 2047 grid hard nproc 16384 grid soft nofile 1024 grid hard nofile 65536 oracle soft nproc 2047 oracle hard nproc 16384 oracle soft nofile 1024 oracle hard nofile 65536 [root@linux1 /]# vi /etc/pam. Hitting without typing an answer will keep that current value.driver.dba oracle ################################################### # Set resource limits [root@linux1 /]# vi /etc/security/limits.groups [root@linux1 [root@linux1 [root@linux1 [root@linux1 [root@linux1 /]# /]# /]# /]# /]# /usr/sbin/groupadd /usr/sbin/groupadd /usr/sbin/groupadd /usr/sbin/groupadd /usr/sbin/groupadd -g -g -g -g -g 1000 1001 1002 1003 1004 oinstall asmadmin dba asmdba asmoper -.so ################################################### # User Profile .d/login session required pam_limits. The current values will be shown in brackets ('[]'). ipv4.rp_filter = 1 # enable ipV6 forwarding .Set ORACLE_BASE After the installation: .168. net. .1.[root@linux1 /]# vi to /etc/profile if [ $USER = "oracle" ] || [ $USER = "grid" ].Unset any ORACLE environment variables like ORACLE_HOME. then ulimit -p 16384 ulimit -n 65536 else ulimit -u 16384 -n 65536 fi umask 022 fi if [ $USER = "root" ]. then umask 022 fi ------------------------------------Additional checks for user profiles Before the installation: .Set ORACLE_HOME.10 10. ################################################### # Network configuration .12 10.11 ################################################### # Kernel Parameters # Disable response to broadcasts.net linux2 linux1-vip.1.168.11 10.1. which needs three IPs registered into the DNS and belong the same subnet used by the public NICs.emilianofusaglia.emilianofusaglia.0. # You do not want yourself becoming a Smurf amplifier.1.emilianofusaglia.Unset any JAVA environment variables like JAVA_HOME.0.0.net linux1-vip linux1-vip.1. and include $ORACLE_HOME/bin at the beginning of the PATH string. then if [ $SHELL = "/bin/ksh" ].all.conf. -Vip and Private IPs as per example from the /etc/hosts of one of the node: 10.1.SCAN Listener component.10 192. PATH.ipv4.net linux2-vip linux1-priv linux2-priv 192.net linux1 linux2.0.emilianofusaglia.13 linux1.icmp_echo_ignore_broadcasts = 1 # enable route verification on all interfaces net. LD_LIBRARY_PATH . forwarding = 1 # Set defaults for BladeFrame # added for Oracle 11g kernel.shmmax = 1/2 of physical RAM.core. 4699 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End /dev/sdh1 1 4700 linux1:/u01 # fdisk -l /dev/sdi Blocks Id System 37747712 83 Linux Disk /dev/sdi: 38. 4699 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sdi1 1 4700 37747712 83 Linux linux1:/u01 # fdisk -l /dev/sdj Disk /dev/sdj: 38.conf.ip_local_port_range = 9000 65500 net.tcp_wmem = 262144 262144 262144 net.rmem_default = 262144 net.ipv4.tcp_rmem = 4194304 4194304 4194304 vm.shmmni = 4096 kernel. 63 sectors/track.ipv6.6 GB.ipv4.#net. 4699 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sdj1 1 4699 37744686 83 Linux linux1:/u01 # linux1:/u01 # fdisk /dev/sdh The number of cylinders for this disk is set to 4699.core. 63 sectors/track. 38654705664 bytes 255 heads.shmall = physical RAM size / pagesize kernel.file-max = 512 x processes (for example 6815744 for 13312 processes) net. 63 sectors/track.wmem_max = 1048576 ################################################### # Create disk partitions and ASM disks linux1:/u01 # fdisk -l /dev/sdh Disk /dev/sdh: 38.core.wmem_default = 262144 net.core.6 GB. but not greater than 4GB kernel.6 GB.sem = 250 32000 100 128 fs. 38654705664 bytes 255 heads.rmem_max = 4194304 net.hugetlb_shm_group=64948 #MIN UDP CONFIG to Review according to Interconnect traffic & config net.ipv4. 38654705664 bytes 255 heads. .all. OS/2 FDISK) Command (m for help): d Selected partition 1 Command (m for help): p Disk /dev/sdh: 38.g.There is nothing wrong with that.6 GB. old versions of LILO) 2) booting and partitioning software from other OSs (e. 63 sectors/track.g.6 GB. 63 sectors/track. 4699 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot /dev/sdh1 Start 1 End 125 Blocks Id System 1004031 83 Linux Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 2 First cylinder (126-4699. DOS FDISK. 63 sectors/track. default 4699): Using default value 4699 Command (m for help): p Disk /dev/sdh: 38. but this is larger than 1024. 38654705664 bytes 255 heads. default 126): Using default value 126 Last cylinder or +size or +sizeM or +sizeK (126-4699. 4699 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System . default 1): 1 Last cylinder or +size or +sizeM or +sizeK (1-4699. and could in certain setups cause problems with: 1) software that runs at boot time (e...6 GB. 38654705664 bytes 255 heads. 38654705664 bytes 255 heads. default 4699): +1024M Command (m for help): p Disk /dev/sdh: 38. 4699 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-4699. 2 #Oracle Base .d/oracleasm createdisk OCR1 /dev/sdh1 Marking disk "/dev/sdh1" as an ASM disk: done linux1:/u01 # /etc/init. Syncing disks. this allows ASM to discover all the new ASM Disks created.d/oracleasm scandisks Scanning system for ASM disks: done linux1:/u01 # -------------------------------------------------After having created all the ASM Disks runs the utility scandisks on all nodes of the cluster.d/oracleasm listdisks DATA1 DATA2 DATA3 OCR1 OCR2 OCR3 linux2:/dev/oracleasm/disks # ################################################### # Create the installation directories #Grid Home mkdir –p /u01/GRID/11./dev/sdh1 /dev/sdh2 1 126 125 1004031 83 Linux 4699 36740655 83 Linux Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. linux2:/dev/oracleasm/disks # /etc/init.2 chown –R grid:oinstall /u01/GRID/11. linux1:/u01 #partprobe ----------------------------------------------Once the disks have been sliced the ASM Disks can be created as showed below in the example linux1:/u01 # /etc/init.2 chmod –R 775 /u01/GRID/11.d/oracleasm scandisks Scanning system for ASM disks: done linux2:/dev/oracleasm/disks # /etc/init.d/oracleasm {start|stop|restart|enable|disable|configure|createdisk|deletedisk|querydisk|listdisks|scandi sks|status} linux1:/u01 # /etc/init.d/oracleasm Usage: /etc/init.d/oracleasm createdisk DATA1 /dev/sdh2 Marking disk "/dev/sdh2" as an ASM disk: done linux1:/u01 # /etc/init. linux2 -verbose ################################################### # Start the Installation /u01/stage/grid > ./runcluvfy.2/cdata # /u01/GRID/11. ######################################################### ####### --Location and status of OCR before starting the test: root@host1:/u01/GRID/11.2 chmod –R 775 /u01/oracle/product/11.2/bin/ocrcheck Status of Oracle Cluster Registry is as follows : Version : 3 Total space (kbytes) : 262120 Used space (kbytes) : 2744 Available space (kbytes) : 259376 ID : 401168391 Device/File Name : +OCRVOTING Device/File integrity check succeeded Device/File not configured Device/File not configured Device/File not configured Device/File not configured .2 chown –R oracle:oinstall /u01/oracle/product/11.2 ################################################### # Run Cluster verify utility /u01/stage/grid > ./runInstaller ######################################################### ####### # How to restore OCR and Voting disk after DiskGroup Corruption on Oracle 11g R2.mkdir –p /u01/oracle chown –R oracle:oinstall /u01/oracle chmod –R 775 /u01/oracle #Oracle Home mkdir –p /u01/oracle/product/11.sh stage -pre crsinst -n linux1. ocr /u01/GRID/11.lun OCRVOTING_0004 /dev/oracle/asm.2/bin/ocrconfig -showbackup host1 host1 host1 host1 2010/01/21 14:17:54 2010/01/21 05:58:31 2010/01/21 01:58:30 2010/01/20 05:58:21 /u01/GRID/11.Cluster registry integrity check succeeded Logical corruption check succeeded --Check the existency of BACKUPS: root@host1:/root # /u01/GRID/11.lun bs=1024 dd if=/tmp/corrupt_disk of=/dev/oracle/asm.2/cdata/cluster01/backup00.28. --Corrupt tht disks belong the Disk group +OCRVOTING: dd if=/tmp/corrupt_disk of=/dev/oracle/asm.-----------------------------------------------------------OCRVOTING_0000 /dev/oracle/asm.25.lun bs=1024 dd if=/tmp/corrupt_disk of=/dev/oracle/asm.2/cdata/cluster01/backup01.2/cdata/cluster01/backup02.lun bs=1024 count=1000 count=1000 count=1000 count=1000 count=1000 --OCR Check after Corruption: root@host1:/tmp # /u01/GRID/11.lun bs=1024 dd if=/tmp/corrupt_disk of=/dev/oracle/asm.26.lun bs=1024 dd if=/tmp/corrupt_disk of=/dev/oracle/asm.ocr /u01/GRID/11.2/bin/ocrcheck Status of Oracle Cluster Registry is as follows : Version : 3 .29.ocr PROT-25: Manual backups for the Oracle Cluster Registry are not available --Identify all the disks belong the Disk group +OCRVOTING: NAME PATH -----------------------------.lun OCRVOTING_0002 /dev/oracle/asm.2/cdata/cluster01/week.26.28.lun 5 rows selected.ocr host1 2010/01/14 23:12:07 /u01/GRID/11.lun OCRVOTING_0001 /dev/oracle/asm.27.2/cdata/cluster01/day.29.ocr /u01/GRID/11.27.lun OCRVOTING_0003 /dev/oracle/asm.25. vip' on 'host1' CRS-2673: Attempting to stop 'ora.dg' on 'host1' succeeded CRS-2673: Attempting to stop 'ora.LISTENER.vip' on 'host1' CRS-2677: Stop of 'ora.db.scan2.vip' on 'host1' succeeded CRS-2677: Stop of 'ora.lsnr' on 'host1' CRS-2677: Stop of 'ora.dg' on 'host1' CRS-2673: Attempting to stop 'ora.OCRVOTING.host2.crsd' on 'host1' CRS-2790: Starting shutdown of Cluster Ready Services-managed resources on 'host1' CRS-2673: Attempting to stop 'ora.scan3.vip' on 'host1' succeeded CRS-2677: Stop of 'ora.Total space (kbytes) : 262120 Used space (kbytes) : 2712 Available space (kbytes) : 259408 ID : 701409037 Device/File Name : +OCRVOTING Device/File integrity check succeeded Device/File not configured Device/File not configured Device/File not configured Device/File not configured Cluster registry integrity check succeeded Logical corruption check succeeded --Stop and Start of database instance after corruption oracle@host1:/u01/oracle/data $ srvctl stop instance -d DB -i DB1 oracle@host1:/u01/oracle/data $ srvctl start instance -d DB -i DB1 --Stop and Start entire Cluster: -host1: root@host1:/tmp # /u01/GRID/11.vip' on 'host1' CRS-2673: Attempting to stop 'ora.vip' on 'host1' CRS-2677: Stop of 'ora.lsnr' on 'host1' succeeded CRS-2673: Attempting to stop 'ora.vip' on 'host1' succeeded .scan3.LISTENER.scan2.host2.host1.host1.OCRVOTING.2/bin/crsctl stop crs CRS-2791: Starting shutdown of Oracle High Availability Services-managed resources on 'host1' CRS-2673: Attempting to stop 'ora.vip' on 'host1' succeeded CRS-2677: Stop of 'ora.db' on 'host1' CRS-2673: Attempting to stop 'ora. DATA1.crsd' on 'host2' CRS-2790: Starting shutdown of Cluster Ready Services-managed resources on 'host2' CRS-2673: Attempting to stop 'ora.dg' on 'host1' succeeded Stop of 'ora.network' on 'host1' Stop of 'ora.ctssd' on 'host1' succeeded Stop of 'ora.asm' on 'host1' Stop of 'ora.eons' on 'host1' succeeded Shutdown of Cluster Ready Services-managed resources on 'host1' has Stop of 'ora.FRA1.crsd' on 'host1' succeeded Attempting to stop 'ora.lsnr' on 'host2' .asm' on 'host1' succeeded Attempting to stop 'ora.LISTENER_SCAN2.diskmon' on 'host1' Attempting to stop 'ora.dg' on 'host1' Attempting to stop 'ora.2/bin/crsctl stop crs CRS-2791: Starting shutdown of Oracle High Availability Services-managed resources on 'host2' CRS-2673: Attempting to stop 'ora.gpnpd' on 'host1' succeeded Stop of 'ora.dg' on 'host1' succeeded Attempting to stop 'ora.diskmon' on 'host1' succeeded Shutdown of Oracle High Availability Services-managed resources on 'host1' has Oracle High Availability Services has been stopped.cssdmonitor' on 'host1' Attempting to stop 'ora.FRA1.cssdmonitor' on 'host1' succeeded Stop of 'ora.net1.network' on 'host1' succeeded Stop of 'ora.db' on 'host1' succeeded Attempting to stop 'ora.gipcd' on 'host1' succeeded Stop of 'ora.db.ons' on 'host1' succeeded Attempting to stop 'ora.evmd' on 'host1' succeeded Stop of 'ora.mdnsd' on 'host1' Attempting to stop 'ora.DATA1. --host2: root@host2:/root # /u01/GRID/11.gpnpd' on 'host1' Attempting to stop 'ora.ons' on 'host1' Attempting to stop 'ora.dg' on 'host1' Stop of 'ora.cssd' on 'host1' Stop of 'ora.mdnsd' on 'host1' succeeded Stop of 'ora.net1.CRS-2677: CRS-2673: CRS-2673: CRS-2677: CRS-2677: CRS-2673: CRS-2677: CRS-2673: CRS-2673: CRS-2677: CRS-2673: CRS-2677: CRS-2677: CRS-2792: completed CRS-2677: CRS-2673: CRS-2673: CRS-2673: CRS-2673: CRS-2673: CRS-2673: CRS-2677: CRS-2677: CRS-2677: CRS-2677: CRS-2677: CRS-2677: CRS-2673: CRS-2677: CRS-2673: CRS-2673: CRS-2677: CRS-2677: CRS-2793: completed CRS-4133: Stop of 'ora.gipcd' on 'host1' Stop of 'ora.eons' on 'host1' Stop of 'ora.evmd' on 'host1' Attempting to stop 'ora.cssd' on 'host1' succeeded Attempting to stop 'ora.asm' on 'host1' Stop of 'ora.ctssd' on 'host1' Attempting to stop 'ora.asm' on 'host1' succeeded Attempting to stop 'ora. LISTENER.LISTENER_SCAN1.vip' on 'host1' succeeded Stop of 'ora.scan3.lsnr' on 'host2' Attempting to stop 'ora.vip' on 'host2' succeeded Attempting to start 'ora.host2.dg' on 'host2' succeeded Stop of 'ora.OCRVOTING.FRA1.scan2.LISTENER.cssdmonitor' on 'host2' Attempting to stop 'ora.lsnr' on 'host2' Attempting to stop 'ora.lsnr' on 'host2' succeeded Attempting to stop 'ora.scan1.host2.vip' on 'host1' succeeded Start of 'ora.scan3.gpnpd' on 'host2' Attempting to stop 'ora.vip' on 'host2' Stop of 'ora.vip' on 'host2' succeeded Attempting to start 'ora.dg' on 'host2' succeeded Stop of 'ora.lsnr' on 'host2' succeeded Attempting to stop 'ora.ctssd' on 'host2' Attempting to stop 'ora.vip' on 'host1' Stop of 'ora.OCRVOTING.net1.vip' on 'host1' succeeded Start of 'ora.lsnr' on 'host2' succeeded Attempting to stop 'ora.lsnr' on 'host2' succeeded Attempting to stop 'ora.DATA1.dg' on 'host2' Stop of 'ora.crsd' on 'host2' succeeded Attempting to stop 'ora.dg' on 'host2' Attempting to stop 'ora.db' on 'host2' Attempting to stop 'ora.dg' on 'host2' Attempting to stop 'ora.db.DATA1.LISTENER_SCAN3.ons' on 'host2' succeeded Attempting to stop 'ora.ons' on 'host2' Attempting to stop 'ora.db' on 'host2' succeeded Attempting to stop 'ora.vip' on 'host2' Stop of 'ora.LISTENER_SCAN2.mdnsd' on 'host2' .asm' on 'host2' succeeded Attempting to stop 'ora.scan2.evmd' on 'host2' Attempting to stop 'ora.network' on 'host2' Stop of 'ora.network' on 'host2' succeeded Stop of 'ora.FRA1.db.LISTENER_SCAN3.scan3.eons' on 'host2' succeeded Shutdown of Cluster Ready Services-managed resources on 'host2' has Stop of 'ora.scan2.scan2.asm' on 'host2' Stop of 'ora.vip' on 'host2' Stop of 'ora.CRS-2673: CRS-2673: CRS-2673: CRS-2673: CRS-2673: CRS-2677: CRS-2673: CRS-2677: CRS-2672: CRS-2677: CRS-2673: CRS-2677: CRS-2673: CRS-2677: CRS-2672: CRS-2677: CRS-2672: CRS-2677: CRS-2673: CRS-2677: CRS-2676: CRS-2676: CRS-2676: CRS-2677: CRS-2677: CRS-2673: CRS-2673: CRS-2677: CRS-2677: CRS-2673: CRS-2677: CRS-2673: CRS-2673: CRS-2677: CRS-2673: CRS-2677: CRS-2677: CRS-2792: completed CRS-2677: CRS-2673: CRS-2673: CRS-2673: CRS-2673: CRS-2673: CRS-2673: Attempting to stop 'ora.scan1.net1.vip' on 'host2' Stop of 'ora.scan3.asm' on 'host2' Attempting to stop 'ora.vip' on 'host1' Stop of 'ora.lsnr' on 'host2' Stop of 'ora.LISTENER_SCAN1.vip' on 'host1' Stop of 'ora.dg' on 'host2' succeeded Attempting to stop 'ora.eons' on 'host2' Stop of 'ora.host2.vip' on 'host2' succeeded Start of 'ora.host2.vip' on 'host2' succeeded Attempting to start 'ora. --host1 root@host1:/root # /u01/GRID/11.diskmon 1 1' for resource 'ora.2/bin/crsctl start crs CRS-4123: Oracle High Availability Services has been started.2/bin/orarootagent.785 [cssd(10123)]CRS-1705:Found 0 configured voting files but 1 voting files are required.log. --CRS Alert log: (Start failed because the Diskgroup is not available) 2010-01-21 16:29:07.log 2010-01-21 16:29:07.2/log/host1/cssd/ocssd.504 [ohasd(9931)]CRS-2757:Command 'Start' timed out waiting for response from the resource 'ora.diskmon'.bin(10113)]CRS-5818:Aborted command 'start for resource: ora. details at (:CSSNM00065:) in /u01/GRID/11. --host2 root@host2:/u01/GRID/11. .gpnpd' on 'host2' succeeded Stop of 'ora.687 [cssd(10622)]CRS-1713:CSSD daemon is started in clustered mode 2010-01-21 16:30:21.diskmon'. 2010-01-21 16:30:09.785 [cssd(10123)]CRS-1603:CSSD on node host1 shutdown by user.cssd' on 'host2' succeeded Attempting to stop 'ora. 2010-01-21 16:29:07.gipcd' on 'host2' Stop of 'ora. Details at (:CRSAGF00113:) in /u01/GRID/11.cssdmonitor' on 'host2' succeeded Stop of 'ora.2/log/host1/agent/ohasd/orarootagent_root/orarootagent_root.evmd' on 'host2' succeeded Stop of 'ora.801 [cssd(10622)]CRS-1705:Found 0 configured voting files but 1 voting files are required.cssd' on 'host2' Stop of 'ora.2/bin/crsctl start crs CRS-4123: Oracle High Availability Services has been started.diskmon' on 'host2' succeeded Shutdown of Oracle High Availability Services-managed resources on 'host2' has Oracle High Availability Services has been stopped.918 [ohasd(9931)]CRS-2765:Resource 'ora.cssdmonitor' has failed on server 'host1'.gipcd' on 'host2' succeeded Stop of 'ora.2/cdata/cluster01 # /u01/GRID/11.asm' on 'host2' succeeded Stop of 'ora. 2010-01-21 16:30:20.2/log/host1/ohasd/ohasd. Details at (:CRSPE00111:) in /u01/GRID/11.log.ctssd' on 'host2' succeeded Attempting to stop 'ora.CRS-2677: CRS-2677: CRS-2677: CRS-2677: CRS-2677: CRS-2677: CRS-2673: CRS-2677: CRS-2673: CRS-2673: CRS-2677: CRS-2677: CRS-2793: completed CRS-4133: Stop of 'ora.diskmon' on 'host2' Attempting to stop 'ora.mdnsd' on 'host2' succeeded Stop of 'ora. 2010-01-21 16:30:05. terminating to ensure data integrity.489 [/u01/GRID/11. root@host1:/tmp # reboot --Start the Cluster in EXLUSIVE Mode in order to recreate ASM Diskgroup: root@host1:/root # /u01/GRID/11.801 [cssd(10622)]CRS-1603:CSSD on node host1 shutdown by user.crsd' on 'host1' failed CRS-2679: Attempting to clean 'ora.mdnsd' on 'host1' succeeded CRS-2672: Attempting to start 'ora.2/log/host1/cssd/ocssd.cssdmonitor' on 'host1' CRS-2676: Start of 'ora.diskmon' on 'host1' CRS-2681: Clean of 'ora.2/bin/crsctl disable crs CRS-4621: Oracle High Availability Services autostart is disabled. --Because all the processes are not STOPPING.diskmon' on 'host1' succeeded .crsd' on 'host1' CRS-4548: Unable to connect to CRSD CRS-2675: Stop of 'ora.gpnpd' on 'host1' succeeded CRS-2672: Attempting to start 'ora. details at (:CSSNM00065:) in /u01/GRID/11.gipcd' on 'host1' CRS-2672: Attempting to start 'ora. CRS-2672: Attempting to start 'ora. disable the cluster AUTO Start and reboot --the server for cleaning all the pending processes.cssd' on 'host1' CRS-2679: Attempting to clean 'ora.gipcd' on 'host1' succeeded CRS-2676: Start of 'ora.crsd' on 'host1' CRS-4548: Unable to connect to CRSD CRS-2678: 'ora.log 2010-01-21 16:30:21. root@host1:/tmp # /u01/GRID/11. CRS-4000: Command Stop failed.2/bin/crsctl stop crs CRS-2791: Starting shutdown of Oracle High Availability Services-managed resources on 'host1' CRS-2673: Attempting to stop 'ora.mdnsd' on 'host1' CRS-2676: Start of 'ora.gpnpd' on 'host1' CRS-2676: Start of 'ora.2/bin/crsctl start crs -excl CRS-4123: Oracle High Availability Services has been started. --host1 STOP CRS because due to Voting Disk unavailability is not running properly: root@host1:/tmp # /u01/GRID/11. or completed with errors. CRS-2795: Shutdown of Oracle High Availability Services-managed resources on 'host1' has failed CRS-4687: Shutdown command has completed with error(s).terminating to ensure data integrity.crsd' on 'host1' has experienced an unrecoverable failure CRS-0267: Human intervention required to resume its availability.cssdmonitor' on 'host1' succeeded CRS-2672: Attempting to start 'ora. 'compatible.25.ctssd' on 'host1' Start of 'ora.asm'='11.crsd' on 'host1' succeeded --Stop ASM and restart it using a pfile example: *.instance_type='asm' *.0.2.29.lun'.asm_diskstring='/dev/oracle/asm*' *.0.0' -compatible.28.lun' -disk '/dev/oracle/asm.sga_target=1G *.0.instance_number=1 +ASM2.0.ora'.0' -compatible.lun'.advm '11.asm' on 'host1' succeeded Attempting to start 'ora.'FRA1' *.2.lun' -disk '/dev/oracle/asm.lun' disk '/dev/oracle/asm.diagnostic_dest='/u01/oracle' +ASM1.0.26.rdbms'='11.2.diskmon' on 'host1' succeeded Start of 'ora.27.rdbms '11.asm' on 'host1' Start of 'ora.0.27. '/dev/oracle/asm.0.0.lun' -redundancy HIGH compatible.28.instance_number=2 *.0'.large_pool_size=12M *. SQL> shut immediate ASM diskgroups dismounted .26.0'.lun'.diskmon' on 'host1' Start of 'ora. '/dev/oracle/asm.crsd' on 'host1' Start of 'ora.2.2. create spfile='+OCRVOTING' from pfile='/tmp/asm_pfile.CRS-2672: CRS-2676: CRS-2676: CRS-2672: CRS-2676: CRS-2672: CRS-2676: CRS-2672: CRS-2676: Attempting to start 'ora. '/dev/oracle/asm.asm_diskgroups='DATA1'.0' --Create the Diskgroup Using SQLPLUS Create Diskgroup and save the ASM spfile inside: create Diskgroup OCRVOTING high redundancy disk '/dev/oracle/asm.shared_pool_size=300M --Recreate ASM Diskgroup --This command FAILS because asmca is not able to update the OCR: asmca -silent -createDiskGroup -diskGroupName OCRVOTING -disk '/dev/oracle/asm.29.25. '/dev/oracle/asm.0.ctssd' on 'host1' succeeded Attempting to start 'ora.lun' -disk '/dev/oracle/asm.0. File created.lun'.processes=500 *.asm '11.lun' ATTRIBUTE 'compatible.sga_max_size=1G *.cssd' on 'host1' succeeded Attempting to start 'ora. Successful addition of voting disk 47812b7f6p034f33bf13490e6e136b8b.2/cdata/cluster01/backup00. Successfully replaced voting disk group with +OCRVOTING.2/bin/ocrcheck Status of Oracle Cluster Registry is as follows : Version : 3 Total space (kbytes) : 262120 Used space (kbytes) : 2712 Available space (kbytes) : 259408 ID : 701409037 Device/File Name : +OCRVOTING Device/File integrity check succeeded Device/File not configured Device/File not configured Device/File not configured Device/File not configured Cluster registry integrity check succeeded Logical corruption check succeeded --Restore the Voting Disk: root@host1:/root # /u01/GRID/11. Successful addition of voting disk 9k6af49d3cd54fc5bf28a2fc3899c8c6. .2/bin/crsctl replace votedisk +OCRVOTING Successful addition of voting disk 7s16f9fbf4b64f74bfy0ee8826f15eb4. Successful addition of voting disk 876eb99563924ff6bfc1defe6865deeb.ASM instance shutdown SQL> startup ASM instance started Total System Global Area 1069252608 bytes Fixed Size 2154936 bytes Variable Size 1041931848 bytes ASM Cache 25165824 bytes ASM diskgroups mounted -.2/bin/ocrconfig -restore /u01/GRID/11.ocr --Check the OCR status after restore: root@host1:/root # /u01/GRID/11. Successful addition of voting disk 12230b5ef41f4fc2bf2cae957f765fb0.Restore OCR from backup: root@host1:/root # /u01/GRID/11. --Check if all the Resources are running: root@host1:/root # /u01/GRID/11.ctssd' on 'host1' succeeded CRS-2677: Stop of 'ora.gpnpd' on 'host1' CRS-2673: Attempting to stop 'ora. --Start CRS on host2 root@host2:/root # /u01/GRID/11.crsd' on 'host1' CRS-2677: Stop of 'ora.2/bin/crsctl stat res -t -------------------------------------------------------------------------------- .mdnsd' on 'host1' CRS-2677: Stop of 'ora.diskmon' on 'host1' CRS-2673: Attempting to stop 'ora.crsd' on 'host1' succeeded CRS-2673: Attempting to stop 'ora.cssd' on 'host1' succeeded CRS-2673: Attempting to stop 'ora.gpnpd' on 'host1' succeeded CRS-2677: Stop of 'ora.2/bin/crsctl start crs CRS-4123: Oracle High Availability Services has been started.ctssd' on 'host1' CRS-2673: Attempting to stop 'ora. --Start CRS on host1 root@host1:/root # /u01/GRID/11.diskmon' on 'host1' succeeded CRS-2793: Shutdown of Oracle High Availability Services-managed resources on 'host1' has completed CRS-4133: Oracle High Availability Services has been stopped.2/bin/crsctl enable crs CRS-4622: Oracle High Availability Services autostart is enabled.CRS-4266: Voting file(s) successfully replaced --Re-enable CRS auto starup root@host1:/root # /u01/GRID/11.2/bin/crsctl stop crs CRS-2791: Starting shutdown of Oracle High Availability Services-managed resources on 'host1' CRS-2673: Attempting to stop 'ora. --Stop CRS on host1 root@host1:/root # /u01/GRID/11.gipcd' on 'host1' succeeded CRS-2677: Stop of 'ora.2/bin/crsctl start crs CRS-4123: Oracle High Availability Services has been started.cssdmonitor' on 'host1' CRS-2673: Attempting to stop 'ora.mdnsd' on 'host1' succeeded CRS-2677: Stop of 'ora.asm' on 'host1' CRS-2673: Attempting to stop 'ora.gipcd' on 'host1' CRS-2677: Stop of 'ora.asm' on 'host1' succeeded CRS-2673: Attempting to stop 'ora.cssd' on 'host1' CRS-2677: Stop of 'ora.cssdmonitor' on 'host1' succeeded CRS-2677: Stop of 'ora. dg ONLINE ONLINE host1 ONLINE ONLINE host2 ora.LISTENER_SCAN2.eons ONLINE ONLINE host1 ONLINE ONLINE host2 ora.LISTENER.db.lsnr 1 ONLINE ONLINE host2 ora.network ONLINE ONLINE host1 ONLINE ONLINE host2 ora.OCRVOTING.db 1 ONLINE ONLINE host1 Open 2 ONLINE ONLINE host2 Open ora.dg ONLINE ONLINE host1 ONLINE ONLINE host2 ora.NAME TARGET STATE SERVER STATE_DETAILS -------------------------------------------------------------------------------Local Resources -------------------------------------------------------------------------------ora.LISTENER_SCAN3.dg ONLINE ONLINE host1 ONLINE ONLINE host2 ora.scan1.LISTENER_SCAN1.gsd OFFLINE OFFLINE host1 OFFLINE OFFLINE host2 ora.FRA1.ons ONLINE ONLINE host1 ONLINE ONLINE host2 -------------------------------------------------------------------------------Cluster Resources -------------------------------------------------------------------------------ora.vip .DATA1.lsnr 1 ONLINE ONLINE host1 ora.asm ONLINE ONLINE host1 Started ONLINE ONLINE host2 Started ora.lsnr ONLINE ONLINE host1 ONLINE ONLINE host2 ora.oc4j 1 OFFLINE OFFLINE ora.lsnr 1 ONLINE ONLINE host2 ora.net1. 2.200.3/bin/crsctl add resource myappvip -type app.2. below an example based on a cluster 11.network).1 [root@lnxcld02 ~]# appvipcfg -h Production Copyright 2007.2.2.user:grid:rx'. 2008.All rights reserved 2012-02-10 14:39:23: Creating Resource Type 2012-02-10 14:39:23: Executing /home/GRID_INFRA/product/11.0.cluster_vip_net1.other::r--.3/bin/crsctl add type app.START_DEPENDENCIES=hard(ora.0.0.2.All rights reserved Unknown option: h Usage: appvipcfg create -network=<network_number> -ip=<ip_address> vipname=<vipname> -user=<user_name>[-group=<group_name>] [-failback=0 | 1] delete -vipname=<vipname> --Example to run as root user: [root@lnxcld02 ~]# appvipcfg create -network=1 -ip=192.network) pullup(ora.3.2. Oracle.pgrp:root:r-x.0.group:oinstall:r-x.network).2.scan3.type -file /home/GRID_INFRA/product/11.scan2.ACL='owner:root: rwx.0.vip 1 ONLINE ora.1 ONLINE ora.net1.appvip_net1.vip 1 ONLINE ora.type 2012-02-10 14:39:26: Create the Resource 2012-02-10 14:39:26: Executing /home/GRID_INFRA/product/11.type -attr "USR_ORA_VIP=192.HOSTING_MEMBERS=lnxcld02.cluster_vip_net1.2.net1.3/bin/crsctl add resource myappvip -type app. 2008.appvip_net1.appvip_net1.vip 1 ONLINE ora.0.type -attr .3/crs/template/appvip.host1.type -file /home/GRID_INFRA/product/11.net1.168.168. Oracle.200 -vipname=myappvip user=grid -group=oinstall Production Copyright 2007.type -basetype ora.host2.2.APPSVIP_FAILBACK=" 2012-02-10 14:39:26: Executing cmd: /home/GRID_INFRA/product/11.type 2012-02-10 14:39:23: Executing cmd: /home/GRID_INFRA/product/11.3/bin/crsctl add type app.vip 1 ONLINE ONLINE ONLINE ONLINE ONLINE ONLINE host1 host2 host2 host1 host2 ######################################################### ########## ## How to add an Application VIP to Oracle Cluster 11gR2 ######################################################### ########## Oracle Clusterware includes the utility appvipcfg which allows to easily create application VIPs.appvip_net1.type -basetype ora.STOP_DEPENDENCIES=hard(ora.3/crs/template/appvip.0. dg ONLINE ONLINE lnxcld01 ONLINE ONLINE lnxcld02 ora.net1.network ONLINE ONLINE lnxcld01 ONLINE ONLINE lnxcld02 ora.STOP_DEPENDENCIES=hard(ora.APPSVIP_FAILBACK=" ######################################################### ##################################### [grid@lnxcld02 trace]$ crsctl stat res -t -------------------------------------------------------------------------------NAME TARGET STATE SERVER STATE_DETAILS -------------------------------------------------------------------------------Local Resources -------------------------------------------------------------------------------ora.200.net1.acfs ONLINE ONLINE lnxcld01 ONLINE ONLINE lnxcld02 -------------------------------------------------------------------------------Cluster Resources -------------------------------------------------------------------------------myappvip 1 ONLINE ONLINE lnxcld02 .asm ONLINE ONLINE lnxcld01 Started ONLINE ONLINE lnxcld02 Started ora.ACL='owner:root: rwx.user:grid:rx'.gsd OFFLINE OFFLINE lnxcld01 OFFLINE OFFLINE lnxcld02 ora.LISTENER.ons ONLINE ONLINE lnxcld01 ONLINE ONLINE lnxcld02 ora.pgrp:root:r-x.group:oinstall:r-x.other::r--.dg ONLINE ONLINE lnxcld01 ONLINE ONLINE lnxcld02 ora.168.lsnr ONLINE ONLINE lnxcld01 ONLINE ONLINE lnxcld02 ora.2.network).FRA1.OCRVOTING.net1.HOSTING_MEMBERS=lnxcld02.network) pullup(ora.network).dg ONLINE ONLINE lnxcld01 ONLINE ONLINE lnxcld02 ora.registry.DATA1."USR_ORA_VIP=192.START_DEPENDENCIES=hard(ora.net1. ora.LISTENER_SCAN1.lsnr 1 ONLINE ONLINE ora.cvu 1 ONLINE ONLINE ora.lnxcld01.vip 1 ONLINE ONLINE ora.lnxcld02.vip 1 ONLINE ONLINE ora.oc4j 1 ONLINE ONLINE ora.scan1.vip 1 ONLINE ONLINE ora.tpolicy.db 1 ONLINE ONLINE 2 ONLINE ONLINE ora.tpolicy.loadbalance_rw.svc 1 ONLINE ONLINE 2 ONLINE ONLINE lnxcld02 lnxcld02 lnxcld01 lnxcld02 lnxcld02 lnxcld02 lnxcld01 lnxcld02 lnxcld01 lnxcld02 Open Open ######################################################### ##################################### [grid@lnxcld02 ~]$ crsctl stat res myappvip -p NAME=myappvip TYPE=app.appvip_net1.type ACL=owner:root:rwx,pgrp:root:r-x,other::r--,group:oinstall:r-x,user:grid:r-x ACTION_FAILURE_TEMPLATE= ACTION_SCRIPT= ACTIVE_PLACEMENT=1 AGENT_FILENAME=%CRS_HOME%/bin/orarootagent%CRS_EXE_SUFFIX% APPSVIP_FAILBACK=0 AUTO_START=restore CARDINALITY=1 CHECK_INTERVAL=1 CHECK_TIMEOUT=30 DEFAULT_TEMPLATE=PROPERTY(RESOURCE_CLASS=vip) DEGREE=1 DESCRIPTION=Application VIP ENABLED=1 FAILOVER_DELAY=0 FAILURE_INTERVAL=0 FAILURE_THRESHOLD=0 GEN_USR_ORA_STATIC_VIP= GEN_USR_ORA_VIP= HOSTING_MEMBERS=lnxcld02 LOAD=1 LOGGING_LEVEL=1 NLS_LANG= NOT_RESTARTING_TEMPLATE= OFFLINE_CHECK_INTERVAL=0 PLACEMENT=balanced PROFILE_CHANGE_TEMPLATE= RESTART_ATTEMPTS=0 SCRIPT_TIMEOUT=60 SERVER_POOLS=* START_DEPENDENCIES=hard(ora.net1.network) pullup(ora.net1.network) START_TIMEOUT=0 STATE_CHANGE_TEMPLATE= STOP_DEPENDENCIES=hard(ora.net1.network) STOP_TIMEOUT=0 TYPE_VERSION=2.1 UPTIME_THRESHOLD=7d USR_ORA_ENV= USR_ORA_VIP=192.168.2.200 VERSION=11.2.0.3.0 ######################################################### ####### # Oracle Clusterware Commands release 11.1 ######################################################### ####### Command Description: crs_getperm Lists the permissions associated with a resource. crs_profile Creates, validates, deletes, and updates an Oracle Clusterware application profile crs_register Registers configuration information for an application with the OCR. crs_relocate Relocates an application profile to another node. crs_setperm Sets permissions associated with a resource. crs_stat Lists the status of an application profile. crs_start Starts applications that have been registered. crs_stop Stops an Oracle Clusterware application. crs_unregister Removes the configuration information for an application profile from the OCR. ######################################################### ####### # START-STOP-STATUS ORACLE CLUSTER ######################################################### ####### --To stop or start oracle clusterware on a node in a managed fashion: -- as root account /etc/init.d/init.crs [stop|start] --or [root@node1 root]# crsctl stop crs --To disable the oracle cluster so it doesn't attempt to start after a reboot, or --to ensure that it will be started automatically on boot: /etc/init.d/init.crs [disable|enable] --or [root@node1 root] # crsctl enable crs --As the oracle user on docrac1, check the status of the Oracle Clusterware /crs/bin/crs_stat -t --Verify that Oracle Clusterware is running on the node [root@node1 root] #crsctl check crs --Check the status of an individual Oracle Clusterware daemon using the following --syntax, where daemon is crsd, cssd, or evmd: [root@node1 root] # crsctl check daemon -- Check the existence and the location of Voting Disk [root@node1 root] # crsctl query css votedisk ##Cluster Verification Utility (CVU) to verify the OCR integrity. Run the --following command, where the -n all argument retrieves a list of all the cluster --nodes that are configured as part of your cluster: [root]# cluvfy comp ocr -n all [-verbose] ##You use the CVU comp nodeapp command to verify the existence of node --applications, namely the virtual IP (VIP), Oracle Notification Services (ONS), and --Global Service Daemon (GSD), on all the nodes. [root]# cluvfy comp nodeapp [ -n node_list] [-verbose] ##To check the settings for the interconnect: --1. In a command window, log in to the operating system as the root user. --2. To verify the accessibility of the cluster nodes, specified by node_list, from the --local node or from any other cluster node, specified by srcnode, use the --component verification command nodereach as follows: [root]# cluvfy comp nodereach -n node_list [ -srcnode node ] [-verbose] ##To verify the connectivity among the nodes through specific network interfaces, [root]# cluvfy comp nodecon -n node_list -i interface_list [-verbose] [root]# cluvfy comp nodecon -n docrac1, docrac2, docrac3 -i eth0 -verbose ###Oracle Clusterware Diagnostics Collection Script --The diagnostics provide additional information so that Oracle Support Services --can resolve problems. It displays the status of the Cluster Synchronization --Services (CSS), Event Manager (EVM), and the Cluster Ready Services (CRS) daemons [root@node1 root] # CRS_home/bin/diagcollection.pl --collect ######################################################### ####### # DEBUGGING OF ORACLE CLUSTERWARE COMPONENTS ######################################################### ####### --1. In a command window, log in to the operating system as the root user. --2. Use the following command to obtain the module names for a component, where --component_name is crs, evm, css or the name of the component for which you --want to enable debugging: # crsctl lsmodules component_name --For example, viewing the modules of the css component might return the following results: # crsctl lsmodules css The following are the CSS modules :: CSSD COMMCRS COMMNS --3. Use CRSCTL as follows, where component_name is the name of the Oracle --Clusterware component for which you want to enable debugging, module is the --name of module, and debugging_level is a number from 1 to 5: # crsctl debug log component module:debugging_level For example, to enable the lowest level of tracing for the CSSD module of the css component, you would use the following command: # crsctl debug log css CSSD:1 --4. After you have obtained the needed trace information, disable debugging by --setting the debugging_level to 0 for the module, as shown in the following example. # crsctl debug log css CSSD:0 ######################################################### ####### # OLSNODES and OIFCFG utility ######################################################### ####### --The OLSNODES command provides the list of nodes and other information --for all nodes participating in the cluster olsnodes [-n] [-i] [-l] [-v] [-g] [-p] -g Logs cluster verification information with more details. -i Lists all nodes participating in the cluster and includes the Virtual Internet Protocol (VIP) address assigned to each node. -l Displays the local node name. -n Lists al nodes participating in the cluster and includes the assigned node numbers. -p Lists all nodes participating in the cluster and includes the private interconnect assigned to each node. -v Logs cluster verification information in verbose mode. ------------------------------------------------------------------------------------Before you invoke OIFCFG, ensure that you have started Oracle Clusterware on at --least the local node and preferably on all nodes if you intend to include the -global --option on the command. OIFCFG ######################################################### ####### # SRVCTL Utility for OCR management ######################################################### ####### --Using srvctl the standard tool for stopping and starting services. The most used commands are srvctl [stop|start] database -d DBNAME srvctl [stop|start] instance -d DBNAME -i SID srcvtl [stop|start] nodeapps -n HOSTNAME --example ./srvctl status asm -n docrac1 ASM instance +ASM1 is running on node docrac1. --Stop all the node applications running in a Oracle Clusterware: ASM instance, RAC instances --node_name is the name of the node: $ CRS_home/crs/bin/srvctl stop nodeapps -n node_name --Stop Oracle Clusterware using [root]# CRS_home/bin/crsctl stop crs --When you use the dd command for making backups of the voting disk. .dmp --Restore Example Using RAW Devices dd if=backup_file_name of=voting_disk_name -. the backup can --be performed while the Cluster Ready Services (CRS) process is active. However. --If your cluster is down. you do not --need to stop the crsd.P.S.######################################################### ####### # VOTING .S. ######################################################### ####### ################################ # Adding/Removing Voting Disk using: crsctl ################################ --Adding Voting Disks crsctl add css votedisk path -Removing Voting Disks crsctl delete css votedisk path --P.bin process before taking a backup of the voting disk. you may corrupt your cluster configuration if --you use the -force option while a cluster node is active. then you can use the -force option to --modify the voting disk configuration when using either of these --commands without interacting with active Oracle Clusterware --daemons.DISKS ######################################################### ####### ################################ #Backup / Restore VOTING Disk ################################ dd if=voting_disk_name of=backup_file_name --Backup Example Using RAW Devices dd if=/dev/sdd1 of=/tmp/voting. --You can dynamically add and remove voting disks after installing Oracle RAC. #################################### #Viewing Available OCR and Backups #################################### --Show the availability of Primary and Secondary OCR files ocrcheck --Show the availability of backup copies ocrconfig -showbackup ################################ #Backup / Restore OCR File ################################ -------------##Backup OCR ---------------Oracle Clusterware automatically creates OCR backups every 4 hours. --The default location for generating backups on Red Hat Linux --systems is CRS_home/cdata/cluster_name --Export the dump file of OCR [root]# ocrconfig -export backup_file_name --Check the status of the OCR: ocrcheck --P. You must restore the OCR from a backup.for at least one copy of the OCR.######################################################### ####### # ORACLE CLUSTER REGISTRY ######################################################### ####### --Oracle RAC environments do not support --more than two OCRs. --If this command does not display the message 'Device/File integrity check succeeded' -.S. then both the primary OCR and the -. ------------------------------------------##Restore OCR using automated Backup file ------------------------------------------- .OCR mirror have failed. a primary OCR and a secondary OCR. --1. or by running the following command: [root]# crsctl start crs --6. Use the Cluster Verification Utility (CVU) to verify the OCR integrity. or by running the following command: [root]# crsctl start crs --4. As the root user. list the available backup files [root]# ocrconfig -showbackup --2. where the -n all argument retrieves a list of all the cluster --nodes that are configured as part of your cluster: [root]# cluvfy comp ocr -n all [-verbose] ################################################ . stop Oracle Clusterware on all the nodes in your Oracle RAC cluster --Repeat this command on each node in your Oracle RAC cluster! [root]# crsctl stop crs --4. where --file_name is the name of the OCR backup file: [root]# ocrdump -backupfile file_name --3. Review the contents of the backup using ocrdump command. Restart Oracle Clusterware on all the nodes in your cluster by --restarting each node. stop Oracle Clusterware on all the nodes in your Oracle RAC cluster --Repeat this command on each node in your Oracle RAC cluster! [root]# crsctl stop crs --2. restore the OCR data by importing the contents of the OCR export file [root]# ocrconfig -import file_name --3. se the Cluster Verification Utility (CVU) to verify the OCR integrity. restore the OCR by applying an OCR backup file that you --identified in Step 1 [root]# ocrconfig -restore file_name --5. Restart Oracle Clusterware on all the nodes in your cluster by --restarting each node. Run the --following command. As the root user. As the root user. As the root user. Run the --following command. where the -n all argument retrieves a list of all the cluster --nodes that are configured as part of your cluster: [root]# cluvfy comp ocr -n all [-verbose] ------------------------------------------##Restore OCR using Export file --------------------------------------------1. # To add a primary or secondary OCR location ################################################ --1. --To remove an OCR location from your Oracle RAC cluster: --1. Use the following command to verify that Oracle Clusterware is running on the --node on which the you are going to perform the replace operation: crsctl check crs --2. such as a redundant array of --independent disks (RAID). then run --the following command on the stopped node to let that node rejoin the cluster --after the node is restarted: ocrconfig -repair ocr [device_name] ######################## # Removing an OCR ######################## --To remove an OCR location. Run the following command as root using either destination_file or disk to --designate the target location of the secondary OCR: ocrconfig -replace ocrmirror destination_file ocrconfig -replace ocrmirror disk --4. Use the OCRCHECK utility to ensure that at least one OCR other than the OCR --that you are removing is online. Run the following command on any node in the cluster to remove one copy of the OCR: ocrconfig -replace ocr ######################################################### ####### # How to install and setup ASMLib packages ######################################################### ####### . at least one OCR must be online. You can remove an OCR --location to reduce OCR-related overhead or to stop mirroring your OCR because you --moved the OCR to a redundant storage system. If any node that is part of your current Oracle RAC cluster is shut down. ocrcheck --2. Run the following command as root using either destination_file or disk to --designate the target location of the primary OCR: ocrconfig -replace ocr destination_file ocrconfig -replace ocr disk --3. rpm ###### List of Platform and Kernel dependent packages ###### oracleasm-2.6 GB.4-1.6. 38654705664 bytes 255 heads.12-default-2. The current values will be shown in brackets ('[]').3-1. 4699 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System .x86_64.d/oracleasm configure Configuring the Oracle ASM library driver.0.<distro>.16.0.rpm oracleasm-2.###### List of Platform depenfent but Kernel independent packages ###### oracleasm-support-2. 63 sectors/track. lrh-node1:/u01 # fdisk -l /dev/sdh Disk /dev/sdh: 38.16.6.rpm oracleasmlib-2. Hitting without typing an answer will keep that current value.rpm -.Having a list of devices dedicated to ASM create one primary partition per disk or LUN using fdisk -. Default user to own the driver interface []: grid Default group to own the driver interface []: asmdba Start Oracle ASM library driver on boot (y/n) [n]: y Fix permissions of Oracle ASM disks on boot (y/n) [y]: y Writing Oracle ASM library driver configuration [ OK ] Creating /dev/oracleasm mount point [ OK ] Loading module "oracleasm" [ OK ] Mounting ASMlib driver filesystem [ OK ] Scanning system for ASM disks [ OK ] ###### Create disk partitions and ASM disks (from one of the nodes of the cluster) ###### -.1.12-smp-2. The following questions will determine whether the driver is loaded on boot and what permissions it will have.46-0.x86_64.x86_64.Install the packages using the command rpm –ivh on all the nodes ###### ASMLib Configuration (to repeat on all nodes of the cluster) ###### [root@lrh-node1 /]# /etc/init.x86_64.command and than use ASMLib utility to implement one ASM Disk per device.3-1.3-1. Ctrl-C will abort.<distro>.0. This will configure the on-boot properties of the Oracle ASM library driver.46-0. 4699 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sdj1 1 4699 37744686 83 Linux lrh-node1:/u01 # lrh-node1:/u01 # fdisk /dev/sdh The number of cylinders for this disk is set to 4699../dev/sdh1 1 4700 37747712 lrh-node1:/u01 # fdisk -l /dev/sdi 83 Linux Disk /dev/sdi: 38.. 63 sectors/track. OS/2 FDISK) Command (m for help): d Selected partition 1 Command (m for help): p Disk /dev/sdh: 38. 38654705664 bytes 255 heads.g. default 4699): +1024M . 4699 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-4699. old versions of LILO) 2) booting and partitioning software from other OSs (e.g. default 1): 1 Last cylinder or +size or +sizeM or +sizeK (1-4699. DOS FDISK. and could in certain setups cause problems with: 1) software that runs at boot time (e. 38654705664 bytes 255 heads. 4699 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sdi1 1 4700 37747712 83 Linux lrh-node1:/u01 # fdisk -l /dev/sdj Disk /dev/sdj: 38. but this is larger than 1024.6 GB.6 GB. 38654705664 bytes 255 heads. 63 sectors/track. 63 sectors/track. There is nothing wrong with that.6 GB. 4699 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot /dev/sdh1 /dev/sdh2 Start 1 126 End Blocks Id System 125 1004031 83 Linux 4699 36740655 83 Linux Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. 38654705664 bytes 255 heads.6 GB. 4699 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot /dev/sdh1 Start 1 End 125 Blocks Id System 1004031 83 Linux Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 2 First cylinder (126-4699. 63 sectors/track. default 4699): Using default value 4699 Command (m for help): p Disk /dev/sdh: 38. Syncing disks.6 GB. 38654705664 bytes 255 heads. 63 sectors/track.d/oracleasm createdisk OCR1 /dev/sdh1 Marking disk "/dev/sdh1" as an ASM disk: done .Command (m for help): p Disk /dev/sdh: 38. default 126): Using default value 126 Last cylinder or +size or +sizeM or +sizeK (126-4699.d/oracleasm Usage: /etc/init.d/oracleasm {start|stop|restart|enable|disable|configure|createdisk|deletedisk|querydisk|listdisks|scandi sks|status} lrh-node1:/u01 # /etc/init. lrh-node1:/u01 #partprobe ###### Once the disks have been sliced the ASM Disks can be created ###### lrh-node1:/u01 # /etc/init. d/oracleasm scandisks Scanning system for ASM disks: done lrh-node1:/u01 # -. lrh-node2:/dev/oracleasm/disks # /etc/init.d/oracleasm listdisks DATA1 DATA2 DATA3 OCR1 OCR2 OCR3 ###### ASM diskstring and diskgroup parameters ###### *.this allows ASM to discover all the new ASM Disks created. -.'FRA1' ######################################################### ####### # M A N A G E O R A C L E R A C D A T A B A S E U S I N G SRVCLT ######################################################### ####### ######################### # Display the Current Policy ######################### --The following command display the current status of the database srvctl config database -d <db_name> -a ################################## # Change the Current Policy to Another Policy ################################## --Use the following SRVCTL command to change the policy srvctl modify database -d <db_name> -y policy_name .asm_diskgroups='OCR_VOT'.After having created all the ASM Disks runs the utility scandisks on all nodes of the cluster.'DATA1'.lrh-node1:/u01 # /etc/init.d/oracleasm scandisks Scanning system for ASM disks: done lrh-node2:/dev/oracleasm/disks # /etc/init.d/oracleasm createdisk DATA1 /dev/sdh2 Marking disk "/dev/sdh2" as an ASM disk: done lrh-node1:/u01 # /etc/init.asm_diskstring='ORCL:*' *. RAC3 ##Enabling and Disabling Services with SRVCTL --Use the following SRVCTL syntax from the command line to enable and disable services: srvctl enable service -d <db_name> -s <service_name> [-i inst_name] srvctl disable service -d <db_name> -s <service_name> [-i inst_name] ## How to relocate service from instance 1 to instance 3: srvctl relocate service -d <db_name> -s <service_name> -i instance1 -t instace3 --Stop/Sart Listener srvctl stop listener -n <hostname> [-l listener_name] --Stop/Start Instance srvctl start instance -d <db_name> -i <instance_name> .######################################################### ####### # Other SRVCTL and SERVICES Management ######################################################### ####### ##Ho to obtain the Statuses of Services with SRVCTL --The following command returns the status of the service running on the database: srvctl status service -d <db_name> -s <service_name> ##How to Start and Stop Services with SRVCTL --Enter the following SRVCTL syntax from the command line: srvctl start service -d database_unique_name [-s service_name_list] [-i inst_name] [-o start_options] srvctl stop service -d database_unique_name -s service_name_list [-i inst_name] [-o start_options] ### Remove and Add Database and Instance to the CRS srvctl remove database -d <db_name> srvctl add database -d <db_name> -o $ORACLE_HOME srvctl add instance -d <db_name> -i <instance_name> -n <hostname> ##Add service to a database with preferred instance RAC01 srvctl add service -d <db_name> -s <service_name> -r RAC1 -a RAC2. emilianofusaglia. ######################################################### #### ########### Duplicate database on 11g from active database ########## ######################################################### #### -.######################################################### ################### How to establish remote connection to a database in restricted or NO MOUNT mode ######################################################### ################### Connections via listener to an instance that is in RESTRICTED status or in NO MOUNT status fail with TNS-12526.net)(PORT = 1522))) (CONNECT_DATA = (UR=A) (SERVICE_NAME = dbtest. DBTEST_PRIV = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = rm01it.emilianofusaglia.Source database = TRAC -. SID may connect to a statically configured handler.net) ) ) Note that the (UR=A) clause is intended to work with a dynamically registered handler so the use of SERVICE_NAME versus SID is preferred. TNS-12527 or TNS-12528 even when supplying the credentials for a privileged account.Duplicate database = TDUP10 ############################## ## PREREQUISITES for Cloning . The lsnrctl services output will show that the service handler for this instance is in state: BLOCKED or RESTRICTED. net) ) ) ######################################################### #### .emilianofusaglia.ora lclus01:/tmp ## Adjust the following pfile parameters: DB_NAME LOG_FILE_NAME_CONVERT DB_FILE_NAME_CONVERT DB_CREATE_FILE_DEST ##Statup nomount and create the spfile: alter system create spfile='+DATA/TDUP10/spfile_TDUP10.emilianofusaglia.0. ######################################################### #### ############################## Network Configuration ############################## ##Listener Static Entry: SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (SID_NAME = PLSExtProc) (ORACLE_HOME = /u01/oracle/product/11.1) (sid_name = TDUP11) ) ) ##TNS entry TDUP10.2.1) (PROGRAM = extproc) ) (SID_DESC = (global_dbname = TDUP10.0. scp /tmp/pfile.emilianofusaglia.2.net = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = loraclu-scan.ora' from pfile'/tmp/pfile.ora'.ora' from spfile.net)(PORT = 1526)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = TDUP10.############################## ## Create the diag structure mkdir -p <diag_directory_DB_Name> ## Generate the PFILE from the Original DB and copy to the target host: alter system create pfile'/tmp/pfile.net) (ORACLE_HOME = /u01/oracle/product/11.emilianofusaglia. dbrac12. MGMT_P2=80% OLTP.dbrac12. MGMT_P2=5% ORA$DIAGNOSTICS.dbrac13 srvctl start service -d dbrac10 -s DBRAC10_OLTP --Create a service for BATCH sessions srvctl add service -d dbrac10 -s DBRAC10_BATCH -r dbrac11.net duplicate target database to TDUP10 from active database DB_FILE_NAME_CONVERT 'TRAC'. MGMT_P2=5% ## ORA$AUTOTASK_SUB_PLAN.emilianofusaglia. MGMT_P3=70% .'TDUP10' skip tablespace POR_READONLY. #cd $ORACLE_HOME/dbs #orapwd file=<password_file_name> password=<sys_password> entries=n ## Add oratab entry <DB_NAME>:<ORACLE_HOME>:N ######################################################### ################ ## How to implement Oracle Resource Manager granting the CONSUMER GROUPS to Clusterware services ## ######################################################### ################ --Create a service for OLTP sessions srvctl add service -d dbrac10 -s DBRAC10_OLTP -r dbrac11. ##Register the database into the Grid Infrastructure srvctl add database -d TDUP10 -o $ORACLE_HOME srvctl add instance -d TDUP10 -i TDUP11 -n lclus01 srvctl add instance -d TDUP10 -i TDUP12 -n lclus02 ##Create the password file on each node using the utility orapwd.dbrac13 srvctl start service -d dbrac10 -s DBRAC10_BATCH ######################################################### ########## ## Resource Plan Design: ## MGMT_P1=75% SYS_GROUP.############################## ##RMAN Duplicate ############################## #rman connect target / connect auxiliary sys/xxxxx@TDUP10. MGMT_P2=10% BATCH. dbms_resource_manager_privs. COMMENT => 'BATCH sessions'). DBMS_RESOURCE_MANAGER. COMMENT => 'ORA$DIAGNOSTICS group'. GROUP_OR_SUBPLAN => 'ORA$DIAGNOSTICS'. DBMS_RESOURCE_MANAGER.'BATCH'. DBMS_RESOURCE_MANAGER. COMMENT => 'BATCH group'.SUBMIT_PENDING_AREA().CREATE_PLAN_DIRECTIVE (PLAN => 'REAL_TIME_PLAN'. DBMS_RESOURCE_MANAGER.CREATE_PLAN_DIRECTIVE (PLAN => 'REAL_TIME_PLAN'. MGMT_P1 => 70). DBMS_RESOURCE_MANAGER.SERVICE_NAME. MGMT_P3 => 70. COMMENT => 'OTHER group'. GROUP_OR_SUBPLAN => 'BATCH'. DBMS_RESOURCE_MANAGER. END. PARALLEL_DEGREE_LIMIT_P1 => 6. 'DBRAC10_BATCH'. DBMS_RESOURCE_MANAGER.CREATE_PLAN_DIRECTIVE (PLAN => 'REAL_TIME_PLAN'.OTHER_GROUPS ######################################################### ########## ## Resource Plan Implementation: BEGIN DBMS_RESOURCE_MANAGER. ACTIVE_SESS_POOL_P1 => 4.CREATE_PENDING_AREA().CATEGORY => 'INTERACTIVE'. DBMS_RESOURCE_MANAGER.CREATE_CONSUMER_GROUP (CONSUMER_GROUP => 'BATCH'. COMMENT => 'SYS group'. 'DBRAC10_OLTP'. DBMS_RESOURCE_MANAGER.CREATE_PLAN(PLAN => 'REAL_TIME_PLAN'. DBMS_RESOURCE_MANAGER. 'BATCH').CREATE_PLAN_DIRECTIVE (PLAN => 'REAL_TIME_PLAN'.SET_CONSUMER_GROUP_MAPPING (DBMS_RESOURCE_MANAGER. COMMENT => 'OLTP sessions'). . MGMT_P4 => 50).FALSE).FALSE). MGMT_P3 => 20).SUBMIT_PENDING_AREA(). MGMT_P2 => 80).CREATE_PLAN_DIRECTIVE (PLAN => 'REAL_TIME_PLAN'. COMMENT => 'OLTP group'. GROUP_OR_SUBPLAN => 'SYS_GROUP'.CREATE_PENDING_AREA().'OLTP'.VALIDATE_PENDING_AREA(). DBMS_RESOURCE_MANAGER.GROUP_OR_SUBPLAN => 'ORA$AUTOTASK_SUB_PLAN'.CREATE_PLAN_DIRECTIVE (PLAN => 'REAL_TIME_PLAN'. COMMENT => 'Respurce Plan for OLTP database'). 'OLTP'). COMMENT => 'ORA$AUTOTASK_SUB_PLAN group'. / ######################################################### ########## ## Grant the Switch to the Users BEGIN DBMS_RESOURCE_MANAGER. DBMS_RESOURCE_MANAGER. MAX_IDLE_TIME => 240). DBMS_RESOURCE_MANAGER. GROUP_OR_SUBPLAN => 'OLTP'.SERVICE_NAME.CLEAR_PENDING_AREA().grant_switch_consumer_group ('PERF_TEST'. GROUP_OR_SUBPLAN => 'OTHER_GROUPS'. dbms_resource_manager_privs. DBMS_RESOURCE_MANAGER.CREATE_CONSUMER_GROUP (CONSUMER_GROUP => 'OLTP'.SET_CONSUMER_GROUP_MAPPING(DBMS_RESOURCE_MANA GER.VALIDATE_PENDING_AREA(). DBMS_RESOURCE_MANAGER.grant_switch_consumer_group ('PERF_TEST'. DBMS_RESOURCE_MANAGER. MGMT_P3 => 10). CATEGORY => 'BATCH'. 'BATCH'. YIELDS.CLEAR_PENDING_AREA(). username. NAME. ACTIVE_SESSIONS. CPU_WAITS. QUEUE_LENGTH.DBMS_RESOURCE_MANAGER. username. CONSUMED_CPU_TIME. ######################################################### ########## ## Example of Group and Plan Deletion: BEGIN DBMS_RESOURCE_MANAGER. CPU_WAIT_TIME. / ######################################################### ########## ## SQL Queries for monitoring Resource Manager utilization: ######################################################### ########## ## Check the service name used by each session select inst_id. EXECUTION_WAITERS. ALTER SYSTEM SET RESOURCE_MANAGER_PLAN = 'FORCE:REAL_TIME_PLAN'. END. / BEGIN DBMS_RESOURCE_MANAGER. / BEGIN DBMS_RESOURCE_MANAGER.DELETE_CONSUMER_GROUP(CONSUMER_GROUP => 'BATCH'). SERVICE_NAME. ACTIVE_SESSION_LIMIT_HIT from gV$RSRC_CONSUMER_GROUP where name in ('SYS_GROUP'. REQUESTS.'OLTP'.1. ## List the Active Resource Consumer Groups: select INST_ID. END. SERVICE_NAME order by order by 2. .'OTHER_GROUPS') order by 2.3. count(*) from gv$session where SERVICE_NAME <>'SYS$BACKGROUND' group by inst_id. END.DELETE_CONSUMER_GROUP(CONSUMER_GROUP => 'OLTP').DELETE_PLAN (PLAN => 'REAL_TIME_PLAN').1. END. / ######################################################### ########## ## Enable the Resource plan with the FORCE Option to avoid the Scheduler window to ## activate a different plan during the job execution. . The load generator opens 70 sessions producing intencive CPU activity. --or ALTER SYSTEM SET RESOURCE_MANAGER_PLAN = 'FORCE:REAL_TIME_PLAN'. which as shown by the reports below do not exceed the 25% od the total server capacity (%Usr column). (for more info about Resource Manager visit ResourceManager) -.Enable Instance Caging: ALTER SYSTEM SET CPU_COUNT=4 SCOPE=BOTH SID='*'. -. ALTER SYSTEM SET cpu_count=16 scope=both sid='*'. FORCE option prevents that the scheduler window activates a different plan during the job execution. This option is specifically thought for shared environments where the database administrator has to guarantee resources to all the instances running on the same hardware. ######################################################### ## ## Instance Caging Test ######################################################### ## Hardware SUN 8 Cores 64 Threads One test database capped to 16 CPU .Enable Resource Manager: ALTER SYSTEM SET RESOURCE_MANAGER_PLAN = 'REAL_TIME_PLAN'.25% of total hardware capacity. ALTER SYSTEM SET RESOURCE_MANAGER_PLAN = 'default_plan'.######################################################### ## ## How to implement Oracle Instance Caging ######################################################### ## Instance Caging allows to dynamically limit the amount of CPUs used by each database instance. 1 24.87 2.57 6.66 1.16 2.0 23.53 2.71 2.21 ----------------------.02 26.1 22.58 4.76 2.0 24.81 28.-------0.11 27.Int-pipe %Usr %Sys %Usr+Sys ----------------------.07 25.26 7.73 3.86 26.92 3.-------------------------------------------------------------------1 676 000000047ECC5BD0 resmgr:cpu quantum Scheduler WAITED KNOWN TIME 11599 11599 43834 2 624 000000047D7D38D0 resmgr:cpu quantum Scheduler WAITED KNOWN TIME 11599 11599 43834 2 395 000000047BCA97A8 resmgr:cpu quantum Scheduler WAITING 11669 -1 11668 0 1 300 000000047C8D6B38 resmgr:cpu quantum Scheduler WAITED KNOWN TIME 11677 11677 589 2 317 00 resmgr:cpu quantum Scheduler WAITED KNOWN TIME 11677 11677 589 1 649 000000047ECC5BD0 resmgr:cpu quantum Scheduler WAITING 14445 -1 14444 0 2 676 000000047D7D38D0 resmgr:cpu quantum Scheduler WAITING 14445 -1 14444 0 1 148 000000047C8D6B38 resmgr:cpu quantum Scheduler WAITING 14827 -1 14826 0 2 1413 000000047D7D36E0 resmgr:cpu quantum Scheduler WAITED KNOWN TIME 18824 18824 98023 1 148 000000047ECC4010 resmgr:cpu quantum Scheduler WAITED KNOWN TIME 18824 18824 98023 1 149 000000047C8D6B38 resmgr:cpu quantum Scheduler WAITING 19122 -1 19121 0 1 69 000000047C8D6B38 resmgr:cpu quantum Scheduler WAITING 19177 -1 19176 0 2 51 000000047BCA97A8 resmgr:cpu quantum Scheduler WAITING 19177 -1 19176 0 2 1106 000000047BCA97A8 PX Deq: Signal ACK RSG Other WAITING 112660 7340 120000 0 .47 3.58 2.0 24.41 If on the Wait Events is present "resmgr:cpu quantum".03 25.-----Avg 22.42 3.53 4.05 25.62 3.76 3.43 1.71 2.1 23.87 27.Core Utilization for Integer pipeline Core.1 24.92 26.64 26.60 4.06 2.36 3.98 2.91 0.1 24.55 28.13 7.14 27.85 5.1 24.27 25.1 23.0 23.79 5.99 25.99 3.08 26.0 23.0 21.1 24.0 22.64 6.87 27.49 3.72 3.0 23. it means that Instance Caging throttled the amount of CPUs available to the system.59 26. INST_ID SID SQL_ADDR EVENT WAIT_CLASS STATE WAIT_MICRO REMAI NG TOT_TIME LAST_WAIT -------------------------------------------------------.56 2. year. Backup and Restore Test ######################################################### ####### --Basic tips for Disk & Tape Backup/Recovery strategy. --If it doesn't exist create it: alter database enable block change tracking using file '+FRA1'. and sequence into a unique and repeatable generated name %h Archived redo log thread number %I DBID %M Month in the Gregorian calendar in the format MM . ########################### # RMAN Format Description ########################### %a Current database activation id %A Zero-filled activation ID %c The copy number of the backup piece within a set of duplexed backup pieces. day.######################################################### ####### ## RMAN Setup. month.bMaximum value is 256 %d Database name %D Current day of the month from the Gregorian calendar in format DD %e Archived log sequence number %f Absolute file number %F Combines the DBID. --To be able to efficiently perform incremental backup check if "Change Block Tracking" is enable: SELECT * FROM V$BLOCK_CHANGE_TRACKING. The counter value starts at 1 and is unique for the lifetime of the control file. month. %%Y translates to the string %Y ######################################################### ####### . CREATE CONTROLFILE initializes the counter at 1. For an image copy of a datafile. For a backup piece. This value starts at 1 for each backup set and is incremented by 1 for each backup piece created. For example. %U means the following: data-D-%d_id-%I_TS%N_FNO-%f_%u %Y Year in this format: YYYY %% Percent (%) character. The combination of %s and %t can be used to form a unique name for the backup set. padded on the right with x characters to a total length of eight characters %N Tablespace name. %T Year. %U is different for image copies and backup pieces. %U is a shorthend for %u_%p_%c and guarantees uniqueness in generated backup filenames.%n Database name. the %p variable must be included in the FORMAT string either explicitly or implicitly within %U. If you restore a backup control file. %p Piece number within the backup set. a 4-byte value derived as the number of seconds elapsed since a fixed reference time. %S Zero-filled sequence number %t Backup set time stamp. Only valid when backing up datafiles as image copies. This number is a counter in the control file that is incremented for each backup set. then duplicate values can result. %r Resetlogs ID %s Backup set number. and day in the Gregorian calendar in the format: YYYYMMDD %u An 8-character name constituted by compressed representations of the backup set or image copy number and the time the backup set or image copy was created %U A system-generated unique filename (default). If a PROXY is specified. ##################### ## RMAN STEUP ##################### connect target / connect catalog usr_catalog/xxxxxx@RMAN_Catalog. delete noprompt expired backup. --RMAN Catalog Maintenance and Backup Validation SHOW ALL. CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '+FRA1/%F'.net)'. run{ ALLOCATE CHANNEL disk1 DEVICE TYPE DISK. CONFIGURE CHANNEL DEVICE TYPE 'SBT_TAPE' RATE 200M PARMS 'ENV=(NB_ORA_POLICY=ora_monthly)' FORMAT 'backup_%d_%T_%U'. CONFIGURE CONTROLFILE AUTOBACKUP ON. allocate channel tape1 type 'SBT_TAPE' PARMS 'ENV=(NB_ORA_CLIENT=lxrm01. crosscheck backup completed before "sysdate-30". . --Full Database backup BACKUP INCREMENTAL LEVEL = 0 DATABASE PLUS ARCHIVELOG NOT BACKED UP 1 TIMES. CONFIGURE DEVICE TYPE DISK PARALLELISM 4 BACKUP TYPE TO BACKUPSET. CONFIGURE SNAPSHOT CONTROLFILE NAME TO '+FRA1/snapcf_dbrm07.emilianofusaglia. --Incremental Database backup BACKUP INCREMENTAL LEVEL = 1 DATABASE PLUS ARCHIVELOG NOT BACKED UP 1 TIMES. } --Rman basic Backup Report SHOW all. CONFIGURE CHANNEL DEVICE TYPE DISK RATE 200M FORMAT '+BACKUP/%d_%T_%U'.net REGISTER DATABASE. delete noprompt obsolete.emilianofusaglia. CONFIGURE BACKUP OPTIMIZATION ON.cf'. CONFIGURE ARCHIVELOG DELETION POLICY TO BACKED UP 1 TIMES TO 'SBT_TAPE'. CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 30 DAYS. list backup summary. CONFIGURE DEFAULT DEVICE TYPE TO 'SBT_TAPE'. -------------------------.------.net connected to recovery catalog database RMAN> restore datafile 9.-------9 ONLINE ONLINE FILE NOT FOUND 0 RMAN> connect target / connected to target database: DBRM07 (DBID=3653795552. SQL> SQL> SQL> select * from v$recover_file.emilianofusaglia. Total System Global Area 4277059584 bytes Fixed Size 2154936 bytes Variable Size 2499812936 bytes Database Buffers 1728053248 bytes Redo Buffers 47038464 bytes Database mounted.######################################################### ####### ## RESTORE TESTS ######################################################### ####### --Restore Datafile from TAPE SQL> startup mount ORACLE instance started. FILE# ONLINE ONLINE_ ERROR CHANGE# TIME ---------.------.11 starting full resync of recovery catalog full resync complete allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=1393 instance=DBRM071 device type=DISK allocated channel: ORA_DISK_2 channel ORA_DISK_2: SID=1422 instance=DBRM071 device type=DISK allocated channel: ORA_DISK_3 .04. not open) RMAN> connect catalog usr_catalog/xxxxxx@RMAN_Catalog. Starting restore at 07.---------. 718385527 archived log for thread 1 with sequence 163 is already on disk as file +FRA1/dbtr07/archivelog/2011_04_06/thread_1_seq_163.717369571 channel ORA_SBT_TAPE_1: reading from backup piece 1eld30qo_1_2 channel ORA_SBT_TAPE_1: piece handle=1eld30qo_1_2 tag=TAG20110406T121520 channel ORA_SBT_TAPE_1: restored backup piece 1 channel ORA_SBT_TAPE_1: restore complete.718385527 archived log for thread 2 with sequence 141 is already on disk as file +FRA1/dbtr07/archivelog/2011_04_06/thread_2_seq_141.04.16655. elapsed time: 00:04:25 starting media recovery archived log for thread 1 with sequence 162 is already on disk as file +FRA1/dbtr07/archivelog/2011_04_06/thread_1_seq_162.718385531 .562.8452.Release 6.11 starting full resync of recovery catalog full resync complete RMAN> recover datafile 9.04.5 (2010120208) channel ORA_SBT_TAPE_1: starting datafile backup set restore channel ORA_SBT_TAPE_1: specifying datafile(s) to restore from backup set channel ORA_SBT_TAPE_1: restoring datafile 00009 to +DATA1/dbtr07/datafile/indxtbs.11 using channel ORA_DISK_1 using channel ORA_DISK_2 using channel ORA_DISK_3 using channel ORA_DISK_4 using channel ORA_DISK_5 using channel ORA_SBT_TAPE_1 channel ORA_SBT_TAPE_1: starting incremental datafile backup set restore channel ORA_SBT_TAPE_1: specifying datafile(s) to restore from backup set destination for restore of datafile 00009: +DATA1/dbtr07/datafile/indxtbs.562.717369571 channel ORA_SBT_TAPE_1: reading from backup piece 13ld31mb_1_2 channel ORA_SBT_TAPE_1: piece handle=13ld30mb_1_2 tag=TAG20110406T121258 channel ORA_SBT_TAPE_1: restored backup piece 1 channel ORA_SBT_TAPE_1: restore complete.4677. Starting recover at 07. elapsed time: 00:04:16 Finished restore at 07.channel ORA_DISK_3: SID=1451 instance=DBRM071 device type=DISK allocated channel: ORA_DISK_4 channel ORA_DISK_4: SID=1480 instance=DBRM071 device type=DISK allocated channel: ORA_DISK_5 channel ORA_DISK_5: SID=1509 instance=DBRM071 device type=DISK allocated channel: ORA_SBT_TAPE_1 channel ORA_SBT_TAPE_1: SID=1538 instance=DBRM071 device type=SBT_TAPE channel ORA_SBT_TAPE_1: Veritas NetBackup for Oracle . archived log for thread 3 with sequence 132 is already on disk as file +FRA1/dbtr07/archivelog/2011_04_06/thread_3_seq_132.5466.718385525 archived log for thread 3 with sequence 133 is already on disk as file +FRA1/dbtr07/archivelog/2011_04_06/thread_3_seq_133.1479.718385525 channel ORA_SBT_TAPE_1: starting archived log restore to default destination channel ORA_SBT_TAPE_1: restoring archived log archived log thread=3 sequence=131 channel ORA_SBT_TAPE_1: reading from backup piece 1hld30r8_1_2 channel ORA_SBT_TAPE_1: piece handle=1hld30r8_1_2 tag=TAG20100507T121535 channel ORA_SBT_TAPE_1: restored backup piece 1 channel ORA_SBT_TAPE_1: restore complete, elapsed time: 00:02:15 archived log file name=+FRA1/dbtr07/archivelog/2011_04_06/thread_3_seq_131.16592.718387087 thread=3 sequence=131 channel ORA_SBT_TAPE_1: starting archived log restore to default destination channel ORA_SBT_TAPE_1: restoring archived log archived log thread=1 sequence=161 channel ORA_SBT_TAPE_1: reading from backup piece 1ild30r8_1_2 channel ORA_SBT_TAPE_1: piece handle=1ild30r8_1_2 tag=TAG20100507T121535 channel ORA_SBT_TAPE_1: restored backup piece 1 channel ORA_SBT_TAPE_1: restore complete, elapsed time: 00:01:58 archived log file name=+FRA1/dbtr07/archivelog/2011_04_06/thread_1_seq_161.13854.718387211 thread=1 sequence=161 channel ORA_SBT_TAPE_1: starting archived log restore to default destination channel ORA_SBT_TAPE_1: restoring archived log archived log thread=2 sequence=140 channel ORA_SBT_TAPE_1: reading from backup piece 1jld30r8_1_2 channel ORA_SBT_TAPE_1: piece handle=1jld30r8_1_2 tag=TAG20100507T121535 channel ORA_SBT_TAPE_1: restored backup piece 1 channel ORA_SBT_TAPE_1: restore complete, elapsed time: 00:01:55 archived log file name=+FRA1/dbtr07/archivelog/2011_04_06/thread_2_seq_140.1819.718387319 thread=2 sequence=140 channel default: deleting archived log(s) archived log file name=+FRA1/dbtr07/archivelog/2011_04_06/thread_1_seq_161.13854.718387211 RECID=824 STAMP=718387211 channel default: deleting archived log(s) archived log file name=+FRA1/dbtr07/archivelog/2011_04_06/thread_2_seq_140.1819.718387319 RECID=825 STAMP=718387319 channel default: deleting archived log(s) archived log file name=+FRA1/dbtr07/archivelog/2011_04_06/thread_3_seq_131.16592.718387087 RECID=823 STAMP=718387086 media recovery complete, elapsed time: 00:00:02 Finished recover at 07.04.11 Data Guard Architecture Below an example of Active Data Guard architecture diagram based on 11g R2, where primary and physical standby are running in RAC. ######################################################### ### ## DATA GUARD IMPLEMENTATION on 11g R1 RAC ## ######################################################### ### --Primary DB: USA10 --Standby DB: EURO10 ############################ --From the Primary Database: alter database force logging; alter alter alter alter alter alter alter alter alter database database database database database database database database database add add add add add add add add add standby standby standby standby standby standby standby standby standby logfile logfile logfile logfile logfile logfile logfile logfile logfile size size size size size size size size size 1G; 1G; 1G; 1G; 1G; 1G; 1G; 1G; 1G; select * from v$standby_log; alter system set parallel_execution_message_size=8192 scope=spfile; alter system set fast_start_mttr_target=3600; ############################ --From the Standby Site: --Dump the pfile and change the following parameters for the Standby: *.control_files='+DATA1/EURO10/CONTROLFILE/CURRENT01.CTR','+FRA1/EURO10/CONTR OLFILE/CURRENT02.CTR' *.db_file_name_convert='/USA10/','/EURO10/' *.log_file_name_convert='/USA10/','/EURO10/' *.db_unique_name='EURO10' --AS this is a single instance RAC _disable_interface_checking = TRUE LISTENER = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = lneuron01.emilianofusaglia.net)(PORT = 1526)) ) alter system set local_listener='LISTENER' scope=spfile sid='EURO11'; --mkdir -p /u01/oracle/admin/EURO10/adump mkdir -p /u01/oracle/diag/rdbms/euro10/EURO11/cdump ######################################################### ############# ################## #Network Congiguration ######################## ######################################################### ############# ########################################## ## Static Listener Entries: ########################################## --Primary Cluster Node 1 SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (SID_NAME = PLSExtProc) (ORACLE_HOME = /u01/oracle/product/11.1.0.7) (PROGRAM = extproc) ) (SID_DESC = (global_dbname = USA10_DGMGRL.emilianofusaglia.net) (ORACLE_HOME = /u01/oracle/product/11.1.0.7) (sid_name = USA11) ) (SID_DESC = (global_dbname = USA10_DGB.emilianofusaglia.net) (ORACLE_HOME = /u01/oracle/product/11.1.0.7) (sid_name = USA11) ) (SID_DESC = (global_dbname = USA10.emilianofusaglia.net) (ORACLE_HOME = /u01/oracle/product/11.1.0.7) (sid_name = USA11) ) ) --Primary Cluster Node 2 SID_LIST_LISTENER = net) (ORACLE_HOME = /u01/oracle/product/11.net) (ORACLE_HOME = /u01/oracle/product/11.(SID_LIST = (SID_DESC = (SID_NAME = PLSExtProc) (ORACLE_HOME = /u01/oracle/product/11.7) (sid_name = USA12) ) (SID_DESC = (global_dbname = USA10.net) (ORACLE_HOME = /u01/oracle/product/11.1.7) (sid_name = USA13) ) .1.emilianofusaglia.1.7) (sid_name = USA13) ) (SID_DESC = (global_dbname = USA10_DGB.0.net) (ORACLE_HOME = /u01/oracle/product/11.7) (sid_name = USA12) ) ) --Primary Cluster Node 3 SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (SID_NAME = PLSExtProc) (ORACLE_HOME = /u01/oracle/product/11.0.net) (ORACLE_HOME = /u01/oracle/product/11.emilianofusaglia.emilianofusaglia.1.1.0.7) (sid_name = USA13) ) (SID_DESC = (global_dbname = USA10.1.0.0.0.emilianofusaglia.emilianofusaglia.0.7) (PROGRAM = extproc) ) (SID_DESC = (global_dbname = USA10_DGMGRL.1.0.1.7) (PROGRAM = extproc) ) (SID_DESC = (global_dbname = USA10_DGMGRL.emilianofusaglia.7) (sid_name = USA12) ) (SID_DESC = (global_dbname = USA10_DGB.net) (ORACLE_HOME = /u01/oracle/product/11. net = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = lneuron01-vip.emilianofusaglia.net)(PORT = .net = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = lneuron01-vip.net) (ORACLE_HOME = /u01/oracle/product/11.) --Standby Cluster Node 1 SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (SID_NAME = PLSExtProc) (ORACLE_HOME = /u01/oracle/product/11.1.emilianofusaglia.emilianofusaglia.net) (ORACLE_HOME = /u01/oracle/product/11.emilianofusaglia.1.1.emilianofusaglia.0.0.1.7) (sid_name = EURO11) ) (SID_DESC = (global_dbname = EURO10_DGB.net) (ORACLE_HOME = /u01/oracle/product/11.7) (PROGRAM = extproc) ) (SID_DESC = (global_dbname = EURO10_DGMGRL.emilianofusaglia.0.net) (INSTANCE_NAME = EURO11) ) ) EURO10.7) (sid_name = EURO11) ) ) ########################################## ##TNS Entries Primary & Standby Cluster ########################################## EURO11.emilianofusaglia.7) (sid_name = EURO11) ) (SID_DESC = (global_dbname = EURO10.emilianofusaglia.0.net)(PORT = 1526)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = EURO10. Create the spfile on ASM Startup nomount exclusive.net)(PORT = 1526)) (ADDRESS = (PROTOCOL = TCP)(HOST = lnusan03-vip.net)(PORT = 1526)) (FAILOVER = on) (LOAD_BALANCE = on) ) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = USA10.stby.emilianofusaglia.emilianofusaglia. # scp /u01/oracle/emiliano/USA10.emilianofusaglia.net)(PORT = 1526)) (ADDRESS = (PROTOCOL = TCP)(HOST = lnusan02-vip.stby.emilianofusaglia.emilianofusaglia.ctl lneuron01:/tmp ### Execute the following steps: Startup nomount pfile='/u01/oracle/emiliano/PFILES/EURO10_for_GD.net) ) ) USA10.ctl'. ## Do not RESTORE the Controlfile automatically DONE by the CLONE Procedure ## Which update also Contro_file parameter into SPFIE!!!! .net = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = lnusan01-vip.emilianofusaglia.1526)) (FAILOVER = on) (LOAD_BALANCE = on) ) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = EURO10.ora'.net) ) ) ########################################## ## Standby Controlfile Setup ## ########################################## alter database create standby controlfile as '/u01/oracle/emiliano/USA10. } ########################################## ## Register the Standby Database to CRS ########################################## srvctl add database -d EURO10 -o $ORACLE_HOME srvctl add instance -d EURO10 -i EURO11 -n lneuron01 ########################################## ## Data Guard Broker Configuration ########################################## . allocate auxiliary channel s1 type disk. duplicate target database for standby from active database dorecover.rman target / RMAN> restore controlfile from '/u01/oracle/emiliano/USA10. allocate auxiliary channel s3 type disk. allocate channel p2 type disk.ctl'. duplicate target database for standby from active database dorecover. allocate channel p4 type disk. --########################################## ## Duplicate the Database ########################################## ##From Primary DB Restore the DB to the Standby Side: rman connect target sys/xxxxxxx@USA10 ----PS No domain for Target connect auxiliary sys/xxxxxxx@EURO10. allocate auxiliary channel s1 type disk.stby. allocate auxiliary channel s4 type disk. allocate auxiliary channel s2 type disk. allocate channel p3 type disk.net ----PS Use domain for Auxiliary run { allocate channel p1 type disk. } --or run { allocate channel p1 type disk.emilianofusaglia. dat'. edit database 'USA10' set property 'LogXptMode' = 'SYNC'. --edit configuration set protection mode as maxperformance. DGMGRL> SWITCHOVER to "EURO10". --edit configuration set protection mode as maxavailability. create configuration 'CONFDG10' as primary database is 'USA10' connect identifier is USA10. exit. add database 'EURO10' as connect identifier is EURO10.emilianofusaglia.dat'. . edit database 'EURO10' set property 'NetTimeout' = '20'. edit database 'USA10' set property 'NetTimeout' = '20'. alter system set dg_broker_config_file2 = '+DATA1/EURO10/DATAGUARDCONFIG/brokerconfig02. --From a primary node connect to the broker and create the configuration #dgmgrl DGMGRL> connect sys/[email protected]'.net.emilianofusaglia. alter system set dg_broker_config_file2 = '+DATA1/USA10/DATAGUARDCONFIG/brokerconfig02. --edit configuration set protection mode as maxavailability.net Connected. enable configuration. --on both databases alter system set dg_broker_start=true. edit database 'EURO10' set property 'LogXptMode' = 'ASYNC'.net. edit configuration set protection mode as maxprotection.dat'. edit database 'USA10' set property 'LogXptMode' = 'ASYNC'.--Primary alter system set dg_broker_config_file1 = '+DATA1/USA10/DATAGUARDCONFIG/brokerconfig01.emilianofusaglia. edit database 'EURO10' set property 'LogXptMode' = 'SYNC'. --Standby alter system set dg_broker_config_file1 = '+DATA1/EURO10/DATAGUARDCONFIG/brokerconfig01. --Start the broker on both databases alter system set dg_broker_start=true. alter system set dg_broker_config_file2 = '+FRA1/TEFOXTR/DATAGUARDCONFIG/brokerconfig02. --Start Recovery edit database 'EURO10' set state = 'APPLY-ON'. edit instance 'USA13' on database 'USA10' set property 'LogArchiveTrace' = '1'.dat'. --From the primary database connect to the broker and create the configuration #dgmgrl DGMGRL> connect sys/xxxxxxx@TEFOXTR. edit instance 'EURO11' on database 'EURO10' set property 'LogArchiveTrace' = '6345'.net --Create the configuration for primary database .--Stop Recovery edit database 'EURO10' set state = 'APPLY-OFF'. --Enabling ArchiveLog Tracing on Primary and Standby Good for Troubleshooting!! edit instance 'USA11' on database 'USA10' set property 'LogArchiveTrace' = '1'.dat'. alter system set dg_broker_config_file2 = '+FRA1/TEFOXZH/DATAGUARDCONFIG/brokerconfig02. edit instance 'USA12' on database 'USA10' set property 'LogArchiveTrace' = '1'. ######################################################### ##################### ################################################### ## How to configure DATA GUARD BROKER ################################################### # Create the data guard broker files --Primary alter system set dg_broker_config_file1 = '+DATA1/TEFOXTR/DATAGUARDCONFIG/brokerconfig01.dat'.emilianofusaglia. --Standby alter system set dg_broker_config_file1 = '+DATA1/TEFOXZH/DATAGUARDCONFIG/brokerconfig01.dat'. edit database 'TEFOXZH' set property 'NetTimeout' = '20'. enable configuration. --or edit database 'TEFOXTR' set property 'LogXptMode' = 'ASYNC'. edit database 'TEFOXZH' set state = 'APPLY-ON' WITH APPLY INSTANCE ='TEFOXZH1'.Switchover command: DGMGRL> SWITCHOVER to "TEFOXZH".net.net. edit configuration set protection mode as maxprotection.emilianofusaglia. edit database 'TEFOXZH' set property 'LogXptMode' = 'SYNC'.emilianofusaglia. --or edit configuration set protection mode as maxavailability. --Setup the properties edit database 'TEFOXTR' set property 'LogXptMode' = 'SYNC'. edit database 'TEFOXZH' set property 'Binding' = 'MANDATORY'. edit instance 'TEFOXZH1' on database 'TEFOXZH' set property 'LogArchiveTrace' = '6345'. --Add standby database add database 'TEFOXZH' as connect identifier is TEFOXZH_DGBHA. --Stop Recovery edit database 'TEFOXZH' set state = 'APPLY-OFF'. -. ######################################################### ## How to display Oracle Cluster name ######################################################### . edit database 'TEFOXZH' set property 'LogXptMode' = 'ASYNC'. edit database 'TEFOXTR' set property 'Binding' = 'MANDATORY'. --Enable ArchiveLog Tracing on Primary and Standby for Troubleshooting edit instance 'TEFOXTR1' on database 'TEFOXTR' set property 'LogArchiveTrace' = '1'. edit database 'TEFOXTR' set property 'NetTimeout' = '20'. --or edit configuration set protection mode as maxperformance. --Start Recovery edit database 'TEFOXZH' set state = 'APPLY-ON'.create configuration 'BRKTEFOX' as primary database is 'TEFOXTR' connect identifier is TEFOXTR_DGBHA. alter alter alter alter alter alter alter alter alter database database database database database database database database database add add add add add add add add add standby standby standby standby standby standby standby standby standby logfile logfile logfile logfile logfile logfile logfile logfile logfile size size size size size size size size size 1G. 1G.2.bin [-n] [-w] where: -n prints the cluster name -w prints the clusterware version in the following format: <major_version>:<minor_version>:<vendor_info> --Cluster Name [grid@lnxcld01 ~]$ cemutlo -n cloud01 --Cluster Version [grid@lnxcld01 ~]$ cemutlo -w 2:1: ######################################################### ### ## DATA GUARD IMPLEMENTATION on 11g R1 RAC ## ######################################################### ### --Primary DB: USA10 --Standby DB: EURO10 ############################ --From the Primary Database: alter database force logging.0. 1G. 1G. 1G. 1G. . 1G. 1G. [grid@lnxcld01 ~]$ cemutlo -h Usage: /GRID_INFRA/product/11.3/bin/cemutlo. 1G.Oracle Clusterware includes the utility cemutlo which provides cluster name and version. CTR'.'/EURO10/' *. ############################ --From the Standby Site: --Dump the pfile and change the following parameters for the Standby: *.CTR' *.emilianofusaglia.log_file_name_convert='/USA10/'. --mkdir -p /u01/oracle/admin/EURO10/adump mkdir -p /u01/oracle/diag/rdbms/euro10/EURO11/cdump ######################################################### ############# ################## #Network Congiguration ######################## ######################################################### ############# ########################################## ## Static Listener Entries: ########################################## --Primary Cluster Node 1 SID_LIST_LISTENER = (SID_LIST = (SID_DESC = . alter system set parallel_execution_message_size=8192 scope=spfile.'/EURO10/' *.db_file_name_convert='/USA10/'.db_unique_name='EURO10' --AS this is a single instance RAC _disable_interface_checking = TRUE LISTENER = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = lneuron01.'+FRA1/EURO10/CONTR OLFILE/CURRENT02.net)(PORT = 1526)) ) alter system set local_listener='LISTENER' scope=spfile sid='EURO11'. alter system set fast_start_mttr_target=3600.select * from v$standby_log.control_files='+DATA1/EURO10/CONTROLFILE/CURRENT01. emilianofusaglia.7) (sid_name = USA12) ) (SID_DESC = (global_dbname = USA10_DGB.7) (sid_name = USA11) ) (SID_DESC = (global_dbname = USA10.0.1.emilianofusaglia.0.1.7) (sid_name = USA11) ) ) --Primary Cluster Node 2 SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (SID_NAME = PLSExtProc) (ORACLE_HOME = /u01/oracle/product/11.net) (ORACLE_HOME = /u01/oracle/product/11.7) (sid_name = USA12) ) (SID_DESC = (global_dbname = USA10.7) (PROGRAM = extproc) ) (SID_DESC = (global_dbname = USA10_DGMGRL.emilianofusaglia.1.net) (ORACLE_HOME = /u01/oracle/product/11.0.0.1.1.net) (ORACLE_HOME = /u01/oracle/product/11.emilianofusaglia.1.net) (ORACLE_HOME = /u01/oracle/product/11.emilianofusaglia.net) (ORACLE_HOME = /u01/oracle/product/11.7) (sid_name = USA11) ) (SID_DESC = (global_dbname = USA10_DGB.7) (PROGRAM = extproc) ) (SID_DESC = (global_dbname = USA10_DGMGRL.0.0.net) (ORACLE_HOME = /u01/oracle/product/11.1.1.0.emilianofusaglia.(SID_NAME = PLSExtProc) (ORACLE_HOME = /u01/oracle/product/11.0.7) (sid_name = USA12) ) ) . net) (ORACLE_HOME = /u01/oracle/product/11.net) (ORACLE_HOME = /u01/oracle/product/11.1.7) .net) (ORACLE_HOME = /u01/oracle/product/11.emilianofusaglia.7) (sid_name = USA13) ) (SID_DESC = (global_dbname = USA10_DGB.0.7) (sid_name = EURO11) ) (SID_DESC = (global_dbname = EURO10_DGB.7) (PROGRAM = extproc) ) (SID_DESC = (global_dbname = EURO10_DGMGRL.1.0.net) (ORACLE_HOME = /u01/oracle/product/11.1.emilianofusaglia.0.1.7) (sid_name = EURO11) ) (SID_DESC = (global_dbname = EURO10.7) (sid_name = USA13) ) (SID_DESC = (global_dbname = USA10.0.emilianofusaglia.net) (ORACLE_HOME = /u01/oracle/product/11.0.0.1.7) (PROGRAM = extproc) ) (SID_DESC = (global_dbname = USA10_DGMGRL.1.emilianofusaglia.net) (ORACLE_HOME = /u01/oracle/product/11.0.7) (sid_name = USA13) ) ) --Standby Cluster Node 1 SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (SID_NAME = PLSExtProc) (ORACLE_HOME = /u01/oracle/product/11.emilianofusaglia.1.emilianofusaglia.--Primary Cluster Node 3 SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (SID_NAME = PLSExtProc) (ORACLE_HOME = /u01/oracle/product/11.1.0. net)(PORT = 1526)) (ADDRESS = (PROTOCOL = TCP)(HOST = lnusan03-vip.emilianofusaglia.net)(PORT = 1526)) (FAILOVER = on) (LOAD_BALANCE = on) ) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = EURO10.net = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = lneuron01-vip.emilianofusaglia.net) ) ) USA10.net = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = lneuron01-vip.(sid_name = EURO11) ) ) ########################################## ##TNS Entries Primary & Standby Cluster ########################################## EURO11.net)(PORT = 1526)) (ADDRESS = (PROTOCOL = TCP)(HOST = lnusan02-vip.emilianofusaglia.emilianofusaglia.emilianofusaglia.emilianofusaglia.emilianofusaglia.net)(PORT = 1526)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = EURO10.emilianofusaglia.net = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = lnusan01-vip.net)(PORT = 1526)) (FAILOVER = on) (LOAD_BALANCE = on) ) (CONNECT_DATA = .net) (INSTANCE_NAME = EURO11) ) ) EURO10.emilianofusaglia.emilianofusaglia. } --or .stby.ctl lneuron01:/tmp ### Execute the following steps: Startup nomount pfile='/u01/oracle/emiliano/PFILES/EURO10_for_GD. allocate auxiliary channel s1 type disk. ## Do not RESTORE the Controlfile automatically DONE by the CLONE Procedure ## Which update also Contro_file parameter into SPFIE!!!! rman target / RMAN> restore controlfile from '/u01/oracle/emiliano/USA10. Create the spfile on ASM Startup nomount exclusive.stby.ctl'.emilianofusaglia. --########################################## ## Duplicate the Database ########################################## ##From Primary DB Restore the DB to the Standby Side: rman connect target sys/xxxxxxx@USA10 ----PS No domain for Target connect auxiliary sys/xxxxxxx@EURO10.(SERVER = DEDICATED) (SERVICE_NAME = USA10. duplicate target database for standby from active database dorecover.ctl'.stby. # scp /u01/oracle/emiliano/USA10.ora'.emilianofusaglia.net ----PS Use domain for Auxiliary run { allocate channel p1 type disk.net) ) ) ########################################## ## Standby Controlfile Setup ## ########################################## alter database create standby controlfile as '/u01/oracle/emiliano/USA10. --Standby alter system set dg_broker_config_file1 = '+DATA1/EURO10/DATAGUARDCONFIG/brokerconfig01. allocate auxiliary channel s1 type disk. --on both databases alter system set dg_broker_start=true. --From a primary node connect to the broker and create the configuration #dgmgrl DGMGRL> connect sys/[email protected]'. allocate auxiliary channel s3 type disk.dat'. } ########################################## ## Register the Standby Database to CRS ########################################## srvctl add database -d EURO10 -o $ORACLE_HOME srvctl add instance -d EURO10 -i EURO11 -n lneuron01 ########################################## ## Data Guard Broker Configuration ########################################## --Primary alter system set dg_broker_config_file1 = '+DATA1/USA10/DATAGUARDCONFIG/brokerconfig01.dat'.run { allocate channel p1 type disk. . duplicate target database for standby from active database dorecover.emilianofusaglia. allocate channel p3 type disk.dat'. alter system set dg_broker_config_file2 = '+DATA1/USA10/DATAGUARDCONFIG/brokerconfig02.net Connected. allocate channel p4 type disk. allocate auxiliary channel s4 type disk. allocate channel p2 type disk. allocate auxiliary channel s2 type disk. alter system set dg_broker_config_file2 = '+DATA1/EURO10/DATAGUARDCONFIG/brokerconfig02. net. edit instance 'USA12' on database 'USA10' set property 'LogArchiveTrace' = '1'. --Enabling ArchiveLog Tracing on Primary and Standby Good for Troubleshooting!! edit instance 'USA11' on database 'USA10' set property 'LogArchiveTrace' = '1'. edit database 'EURO10' set property 'NetTimeout' = '20'. --Stop Recovery edit database 'EURO10' set state = 'APPLY-OFF'. edit instance 'EURO11' on database 'EURO10' set property 'LogArchiveTrace' = '6345'.emilianofusaglia. triple check the results if you are using it as part of your backup strategy. edit database 'USA10' set property 'NetTimeout' = '20'. 2008 Update 21-Sep-2011: It’s definitely was a bug in an early 11g release. --edit configuration set protection mode as maxperformance.create configuration 'CONFDG10' as primary database is 'USA10' connect identifier is USA10. add database 'EURO10' as connect identifier is EURO10. edit configuration set protection mode as maxprotection. DGMGRL> SWITCHOVER to "EURO10". ######################################################### ##################### Oracle ASM 11g: Does the ASMCMD cp Command Really Work? Posted by Alex Gorbachev on Apr 8. Don’t forget to test regularly! . As cp command does work in the latest release. --edit configuration set protection mode as maxavailability. edit database 'EURO10' set property 'LogXptMode' = 'ASYNC'. Nevertheless. --Start Recovery edit database 'EURO10' set state = 'APPLY-ON'. edit database 'USA10' set property 'LogXptMode' = 'SYNC'. edit database 'USA10' set property 'LogXptMode' = 'ASYNC'. --edit configuration set protection mode as maxavailability. edit database 'EURO10' set property 'LogXptMode' = 'SYNC'. edit instance 'USA13' on database 'USA10' set property 'LogArchiveTrace' = '1'.net. exit.emilianofusaglia. enable configuration. While working on a Collaborate 08 presentation on Oracle 11g new features out-of-the-box. Okay... The only way to copy files to or from an ASM diskgroup was either to use RMAN. ASMCMD> exit [oracle@lh8 ~]$ dd if=/dev/zero of=/home/oracle/test2..file +DG2 source /home/oracle/test2. MOUNTED EXTERN N 512 4096 1048576 2048.bash_profile' ORA-15056: additional error message ORA-17503: ksfdopn:DGGetFileAttr15 Failed to open file /home/oracle/.bash_profile +dg2/test.bash_profile target +dg2/test. or use the DBMS_FILE_TRANSFER package. to configure XDB for FTP access.bash_profile ORA-27046: file size is not a multiple of logical block size Additional information: 1 ORA-06512: at "SYS. Let‘s try to do it in multiples of diskgroup blocks: ASMCMD> lsdg State Type Rebal Sector Block AU Total_MB. I was verifying new commands in Oracle ASM 11g‘s asmcmd utility. line 207 ORA-06512: at line 3 (DBD ERROR: OCIStmtExecute) . No wonder that the cp command is the most popular addition to asmcmd tool in Oracle ASM 11g: the hardest barrier to convincing my customers to use ASM has been the inability to access the files and copy them to the OS filesystem using the command-line copy command.. it had not been implemented. MOUNTED NORMAL N 512 4096 2097152 200... Customers wanted to ―feel‖ the files and be able to easily manipulate them. Oracle ASM 10g Release 2 added the handy asmcmd utility. but even though everyone expected a copy command there.file' ORA-15056: additional error message ORA-19762: invalid file type DGGetFileAttr20 ORA-06512: at "SYS. First.file bs=4k count=10 10+0 records in 10+0 records out [oracle@lh8 ~]$ asmcmd ASMCMD> cp /home/oracle/test2. I tried to copy a single text file to an ASM diskgroup: ASMCMD> cp /home/oracle/. every ASM administrator has been dreaming of a simple command line tool to copy files between ASM diskgroups and other filesystems. .file ASMCMD-08012: can not determine file type for file>'/home/oracle/.X$DBMS_DISKGROUP".file source /home/oracle/. .Since the introduction of ASM in Oracle 10g Release 1.X$DBMS_DISKGROUP".file ASMCMD-08012: can not determine file type for file->'/home/oracle/test2.file target +DG2/test2. line 207 ORA-06512: at line 3 (DBD ERROR: OCIStmtExecute) Hmm . It turned our that copying files from or to ASM is still a problem. ctl target +dg2/backup. copy committed.ctl2 source /tmp/backup. I‘m not surprised again — I kind of expected it to place it somewhere into DB_UNKNOWN like RMAN does when recovering SPFILE from autobackup. file.ctl => +DG2/ASMTESTING/BACKUPSET/TESTING. line 207 ORA-06512: at line 3 (DBD ERROR: OCIStmtExecute) Now. Not that I‘m very surprised — I expected that ASM would ―automagically‖ try to place all files based on OMF standards and templates. it‘s deja-vu.X$DBMS_DISKGROUP". only templates and rules for database files in 11g. that is odd. Perhaps I need to register this file with the database (i.ctl2 source +dg2/backup. It seems I can‘t put any file to ASM. channel ORA_DISK_1: finished piece 1 at 06-APR-08 piece handle=/tmp/backup. ASMCMD> cp /tmp/backup.ctl2 ASMCMD-08012: can not determine file type for file->'/tmp/backup.651356493 Alright.ctl source /tmp/backup. For some reason.1 oracle dba 9797632 Apr 6 20:20 /tmp/backup.256.. /tmp/backup. ...ctl' current controlfile. +DG2/backup. That seems to work. ASMCMD> ls -l +dg2/backup.ctl2 +dg2/backup. let me try to backup a controlfile to a filesystem and copy it to ASM: RMAN> backup format '/tmp/backup..ctl +dg2/backup.ctl target /tmp/backup. There are. in the controlfile)? Let‘s ask RMAN to catalog this file: [oracle@lh8 ~]$ ls -l /tmp/backup. Right. We can be patient and forgive this for the first release.ctl. except that ASM chose a bizarre location.Oops.ctl tag=TAG20080406T202034 comment=NONE channel ORA_DISK_1: backup set complete. copy committed. ASMTESTING seems to be reasonable.. ... file.ctl2 . Let‘s try to copy it to a filesystem and back: ASMCMD> cp +dg2/backup. In the best Oracle traditions of keeping things consistent.ctl2 copying file(s).ctl copying file(s). ASMCMD> cp /tmp/backup. elapsed time: 00:00:03 .e.ctl2..ctl2 target +dg2/backup.ctl /tmp/backup.1 oracle dba 9797632 Apr 6 20:22 /tmp/backup.ctl -rw-r----.. however..ctl Type Redund Striped Time Sys Name N backup.ctl* -rw-r----. Was it a hard-coded leftover from the test implementation of the cp command? I wouldn‘t be surprised.ctl2' ORA-15056: additional error message ORA-19762: invalid file type DGGetFileAttr20 ORA-06512: at "SYS. .. file.651275203 +dg2/asm_copy source +dg1/db11g/controlfile/Current.ctl3 source +dg2/backup.651358725 . from the filesystem to ASM.ctl +dg2/backup.. please share your experience.. Let‘s try to simply copy a current controlfile within ASM: ASMCMD> cp +dg1/db11g/controlfile/Current. If anyone has been able to test the ASMCMD cp command in 11g. both files are actually corrupted.651275203 target +dg2/asm_copy copying file(s). I should note that I did ask my old good friends. copy committed. file. RMAN> catalog start with '+dg2'.258.. . . ASMCMD> ls -l +dg2/asm_copy Type Redund Striped Sys N +DG2/ASMTESTING/CONTROLFILE/TESTING....ctl3 RMAN-07517: Reason: The file header is corrupted Hey. but they came back empty. Alright. Metalink and Google. . about ASMCMD-08012 and the like.ctl3.ctl target +dg2/backup. List of Files Which Where Not Cataloged ======================================= File Name: /tmp/backup.... +DG2/asm_copy. +DG2/backup.ctl2 RMAN-07517: Reason: The file header is corrupted So the file got corrupted while copying from ASM to a filesystem? Okay. Let‘s try an ASM -> ASM copy: ASMCMD> cp +dg2/backup. List of Files Which Where Not Cataloged ======================================= File Name: +dg2/asm_copy RMAN-07517: Reason: The file header is corrupted Time Name asm_copy => These results are disappointing — I couldn‘t make the cp command work even a single time.RMAN> catalog start with '/tmp/backup..256.256. .ctl RMAN-07517: Reason: The file header is corrupted File Name: +dg2/backup.. RMAN> catalog start with '+dg2'.ctl2'. so the corruption occurred in the first copy. .. List of Files Which Where Not Cataloged ======================================= File Name: +dg2/backup. copy committed.ctl3 copying file(s).
Copyright © 2024 DOKUMEN.SITE Inc.