Hi All,
With each newer version of Oracle from Oracle 8i to Oracle 11g rman features are enchanced making it more and more powerful and thereby simplifying backup and recovery process to large extent.
The new feature of Oracle 11g makes rman more powerful by automatically detecting the failure, advising how to recover from failure and then actually recovering from failure.
For e.g.
Letz say my database consists of following datafiles
-bash-3.00$ cd /oracle/product/oradata/OTM/datafile/
-bash-3.00$ ls -lart
total 2096616
drwxr-x— 5 oracle oinstall 4096 Oct 15 16:30 ..
-rw-r—– 1 oracle oinstall 40902656 Nov 23 11:26 o1_mf_temp_3k6l2q8q_.tmp
-rw-r—– 1 oracle oinstall 5251072 Nov 23 13:11 o1_mf_users_3ndztqcd_.dbf
drwxr-x— 2 oracle oinstall 4096 Nov 23 16:42 .
-rw-r—– 1 oracle oinstall 492838912 Nov 23 16:42 o1_mf_undotbs1_3k6l2hkr_.dbf
-rw-r—– 1 oracle oinstall 104865792 Nov 23 16:43 o1_mf_test_3nffdoxh_.dbf
-rw-r—– 1 oracle oinstall 734011392 Nov 23 16:44 o1_mf_system_3k6l1shq_.dbf
-rw-r—– 1 oracle oinstall 770514944 Nov 23 16:44 o1_mf_sysaux_3k6l2bqf_.dbf
Let us say by mistake someone deletes the o1_mf_test_3nffdoxh_.dbf or the file gets corrupted.
-bash-3.00$ rm -rf o1_mf_test_3nffdoxh_.dbf
Now I detect the failure when I try to perform a transaction accessing that database or when I try to shutdown the database , I get the following error
-bash-3.00$ sqlplus
SQL*Plus: Release 11.1.0.6.0 – Production on Fri Nov 23 16:46:00 2007
Copyright (c) 1982, 2007, Oracle. All rights reserved.
Enter user-name: / as sysdba
Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 – Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> shutdown immediate
ORA-01116: error in opening database file 5
ORA-01110: data file 5: ‘/oracle/product/oradata/OTM/datafile/o1_mf_test_3nffdoxh_.dbf’
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 – Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Now we can use rman to detect the failure as shown below
-bash-3.00$ rman target /
Recovery Manager: Release 11.1.0.6.0 – Production on Fri Nov 23 16:46:15 2007
Copyright (c) 1982, 2007, Oracle. All rights reserved.
connected to target database: OTM (DBID=811910212)
RMAN> list failure;
using target database control file instead of recovery catalog
List of Database Failures
=========================
Failure ID Priority Status Time Detected Summary
———- ——– ——— ————- ——-
1242 HIGH OPEN 23-NOV-07 One or more non-system datafiles are missing
Now we can ask rman to advise us to repair the failure as shown.
RMAN> advise failure;
List of Database Failures
=========================
Failure ID Priority Status Time Detected Summary
———- ——– ——— ————- ——-
1242 HIGH OPEN 23-NOV-07 One or more non-system datafiles are missing
analyzing automatic repair options; this may take some time
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=1640 device type=DISK
analyzing automatic repair options complete
Mandatory Manual Actions
========================
no manual actions available
Optional Manual Actions
=======================
1. If file /oracle/product/oradata/OTM/datafile/o1_mf_test_3nffdoxh_.dbf was unintentionally renamed or moved, restore it
Automated Repair Options
========================
Option Repair Description
—— ——————
1 Restore and recover datafile 5
Strategy: The repair includes complete media recovery with no data loss
Repair script: /oracle/product/diag/rdbms/otm/OTM/hm/reco_1550806931.hm
As shown above rman by itself prepares the script which can be used to repair the failure. To view the content of the script use the following commandd
RMAN> repair failure preview;
Strategy: The repair includes complete media recovery with no data loss
Repair script: /oracle/product/diag/rdbms/otm/OTM/hm/reco_1550806931.hm
contents of repair script:
# restore and recover datafile
sql ‘alter database datafile 5 offline’;
restore datafile 5;
recover datafile 5;
sql ‘alter database datafile 5 online’;
Finally to repair the failure using rman we use the following command
RMAN> repair failure;
Strategy: The repair includes complete media recovery with no data loss
Repair script: /oracle/product/diag/rdbms/otm/OTM/hm/reco_1550806931.hm
contents of repair script:
# restore and recover datafile
sql ‘alter database datafile 5 offline’;
restore datafile 5;
recover datafile 5;
sql ‘alter database datafile 5 online’;
Do you really want to execute the above repair (enter YES or NO)? YES
executing repair script
sql statement: alter database datafile 5 offline
Starting restore at 23-NOV-07
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00005 to /oracle/product/oradata/OTM/datafile/o1_mf_test_3nffdoxh_.dbf
channel ORA_DISK_1: reading from backup piece /oracle/1mj173au_1_1
channel ORA_DISK_1: piece handle=/oracle/1mj173au_1_1 tag=TAG20071116T164612
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:07
Finished restore at 23-NOV-07
Starting recover at 23-NOV-07
using channel ORA_DISK_1
starting media recovery
archived log for thread 1 with sequence 111 is already on disk as file /oracle/product/flash_recovery_area/OTM/archivelog/2007_11_22/o1_mf_1_111_3n9o59by_.arc
archived log for thread 1 with sequence 112 is already on disk as file /oracle/product/flash_recovery_area/OTM/archivelog/2007_11_22/o1_mf_1_112_3nbdyxbh_.arc
archived log for thread 1 with sequence 113 is already on disk as file /oracle/product/flash_recovery_area/OTM/archivelog/2007_11_22/o1_mf_1_113_3nc2wt57_.arc
archived log for thread 1 with sequence 114 is already on disk as file /oracle/product/flash_recovery_area/OTM/archivelog/2007_11_22/o1_mf_1_114_3nccpz0p_.arc
archived log for thread 1 with sequence 115 is already on disk as file /oracle/product/flash_recovery_area/OTM/archivelog/2007_11_23/o1_mf_1_115_3ncmyrhb_.arc
archived log for thread 1 with sequence 116 is already on disk as file /oracle/product/flash_recovery_area/OTM/archivelog/2007_11_23/o1_mf_1_116_3nd5stp7_.arc
archived log for thread 1 with sequence 117 is already on disk as file /oracle/product/flash_recovery_area/OTM/archivelog/2007_11_23/o1_mf_1_117_3ndxlsp4_.arc
archived log file name=/oracle/product/flash_recovery_area/OTM/archivelog/2007_11_22/o1_mf_1_111_3n9o59by_.arc thread=1 sequence=111
archived log file name=/oracle/product/flash_recovery_area/OTM/archivelog/2007_11_22/o1_mf_1_112_3nbdyxbh_.arc thread=1 sequence=112
archived log file name=/oracle/product/flash_recovery_area/OTM/archivelog/2007_11_22/o1_mf_1_113_3nc2wt57_.arc thread=1 sequence=113
archived log file name=/oracle/product/flash_recovery_area/OTM/archivelog/2007_11_22/o1_mf_1_114_3nccpz0p_.arc thread=1 sequence=114
archived log file name=/oracle/product/flash_recovery_area/OTM/archivelog/2007_11_23/o1_mf_1_115_3ncmyrhb_.arc thread=1 sequence=115
media recovery complete, elapsed time: 00:00:47
Finished recover at 23-NOV-07
sql statement: alter database datafile 5 online
repair failure complete
RMAN> exit
Recovery Manager complete.
20) What is the location of init<SID>.ora file for windows system and for unix system?
The default location of init<SID>.ora file is %ORACLE_HOME%/database folder for Windows while it is $ORACLE_HOME/dbs for UNIX System.
21) What is the use of init<SID>.ora file in Oracle Database?
init<SID>.ora Files contains all the parameters which is used to configure the Oracle Instance.
For e.g
shared_pool_size parameter in init<SID>.ora decides the size of shared pool
large_pool parameter decides the size of large pool.
22) Can the parameter of init file be changed dynamically?
No, the parameters of the init<SID>.ora does not take effect on the fly when the database
is running. To change the parameter we need to modify the parameter in init<SID>.ora
and then stop the database and start the database with the modified pfile.
23) How can we start the database with pfile which is
located in the non default location?
To start the database with pfile located in the non default location
i.e (Not in %oracle_home%/database OR $ORACLE_HOME/ dbs) we can use the following command at SQL prompt
SQL> startup pfile=<location of pfile>
24) Which parameter determines the location control files in oracle database?
CONTROL_FILES parameter decides the location of control files in oracle database.
25) What are Instance specific parameters and how are they defined in init<SID>.ora?
In RAC (Real Application Cluster) which is a Oracle HA(High Availability) Feature we can have multiple oracle instance configured on different nodes which can access the same database located in shared storage area. These instances configured on different nodes can be configured differently by using these instance specific parameters. These instance specific parameters are defined in init<SID>.ora as
Letz say the database name is ORCL
Instance1 SID: ORCL1
Instance 2 SID:ORCL2
initORCL1.ora
ORCL1.undo_tablespace=UNDOTBS1
ORCL2.undo_tablespace=UNDOTBS2
26) What is spfile<SID>.ora?
In Oracle 9i, spfile<SID>.ora was introduced as a replacement for init<SID>.ora in which
some of databaseparameters can be changed dynamically
without shutting down the database.
Spfile<SID>.ora is a binary file and cannot be modified manually
27) How can we create spfile from pfile and vice versa?
In the server set oracle_sid environment variable to the SID name
Log in to the database with sys as sysdba user
and fire the following query at the SQL prompt
SQL> create spfile from pfile;
File created
SQL> create pfile from spfile;
File created
By firing the above command the spfile/pfile is created in the default location i.e %oracle_home%/database in Windows and
$ORACLE_HOME/dbs
28) How can we dynamically change the parameter with spfile<SID>.ora?
To dynamically change the database parameter your database must be started with spfile<SID>.ora
log into the datbase with sys as sysdba
and fire the following query
SQL> alter system set <parameter name>=<value> scope=both;
If the parameter cannot be modified on the fly use the following command
SQL> alter system set <parameter-name>=<value> scope=spfile;
29) When you give startup to start the database and if both spfile and pfile are present in
default location which file is used to start the database?
When the oracle starts the instance it looks the following files in the specified order
1)spfile<SID>.ora
2) spfile.ora
3)init<SID>.ora
4) init.ora
If it finds spfile<SID>.ora it will start the database using that but if it is not
present it will look for spfile.ora file. If that file is also not present it looks for init<SID>.ora
and so on.
30) how can we create pointer to other init/spfile?
We can use
IFILE= ’<location of the pfile>’
SPFILE=’<location of spfile>’
parameters to create pointer to init/spfile which are located at some other location.
Hi All,
I was trying using Oracle Enterprise Manager to start the database/Listener and when I tried to start the database/listener through OEM i got the following error
RemoteOperationException: ERROR: NMO not setuid-root (Unix-only)
Later on I discovered that the error was since the root.sh script was not run properly.
Then i tried to rerun the root.sh which is located in $ORACLE_HOME/root.sh the
above error disapperad. It was because the improper permissions on oracle binaries in particular nmo,nmhs,nmb binaries.
Later on after running the root.sh the following permission were giving the nmo,nmhs and nmb binaries
-rwsr-s— 1 root oinstall 23744 Oct 15 16:17 nmo
-rwsr-x— 1 root oinstall 46480 Oct 15 16:17 nmhs
-rwsr-s— 1 root oinstall 17256 Oct 15 16:17 nmb
Here ‘s’ stands for that SUID bit is set for this binaries
#!/bin/bash
ORACLE_SID=OTM;export ORACLE_SID
echo $ORACLE_SID
echo “Please Specify the kind of backup you want to take”
echo “1) COLD BACKUP”
echo “2) HOT BACKUP”
echo “3) EXPORT BACKUP”
echo “Enter your option”
read option
while [ $option -gt 3 ]||[ $option -le 0 ]
do
echo “Please Enter the correct option”
read option
done
case $option in
1|2) echo “You are taking rman backup of DB”
rman target sys/sys @/oracle/product/11g/rman_backup_$option.txt;exit;;
3) echo “You are taking export backup of DB”
exp system/sys file=/oracle/exp_dat.dmp log=/oracle/exp_dat.log full=y;
exit;;
esac
exit
The above script can call anyone of the following rman script depending upon the user who wants take cold or hot backup
The content of rman_backup_1.txt
run {
shutdown immediate;
startup mount;
allocate channel dup1 device type disk;
allocate channel dup2 device type disk;
backup format ‘/oracle/%U’ database;
release channel dup1;
release channel dup2;
alter database open;
}
The content of rman_backup_2.txt
run {
allocate channel dup1 device type disk;
allocate channel dup2 device type disk;
backup format ‘/oracle/%U’ database;
backup format ‘/oracle/arch_%U’ archivelog all;
backup format ‘/oracle/ctl_%U’ current controlfile;
release channel dup1;
release channel dup2;
}
1) To use hot backup and clone the database the
production database has to be in archivelog mode.
2) Create a new init.ora from the production
database’s init.ora file and make the required
modifications like the location of bdump,udump,
cdump,log_archive_dest_1,instance_name,db_name and
also make sure the folders are physically present
at the OS level(i.e create them).
3) On the target machine (i.e where the clone database has been created)
we have to create a new service as well as the password file.
Commands for the same are:-
C:oracleora92bin>oradim -new -sid <new SID>
C:oracleora92database>orapwd file=PWD<new_sid>.ora password=sys
4) Now on your production database fire the following command
to create a trace of the controlfile
SQL>alter database backup controlfile to trace;
This will create a trace file in your udump folder
(kindly check the time to make sure it is the latest trace file).
5) Open the trace file which was created in step 4 and
make the following modifications
a) Change the
CREATE CONTROLFILE REUSE DATABASE “<production database name>” NORESETLOGS
TO
CREATE CONTROLFILE SET DATABASE “<new database name>” RESETLOGS ARCHIVELOG
b) Change all directories in the create controlfile clause
to point to the correct directories for the new target database, if necessary
c) Leave “only” the CREATE CONTROLFILE clause. The other statements,
like the recover command, will be done manually.
Be sure you also remove the STARTUP NOMOUNT command.
So remove all the other statements other then the script starting
with CREATE CONTROLFILE …and ending with CHARACTER SET WE8MSWIN1252;
After making the modifications save the changed script
as a sql file (i.e for example like create_contol.sql)
and send it to the target machine.
6) Now on the produstion database
we begin the hot backup procedure
To find out the datafile associated with each tablespace
fire the following query
SQL>select file_name,tablespace_name from dba_data_files;
SQL>alter tablespace <tablespace_name> begin backup;
Copy all the datafiles associated with this tablespace
to the required location as specified in the CREATE CONTROLFILE script.
After copying is over fire the following command to end the backup
SQL>alter tablespace <tablespace_name> end backup;
Do this for all the tablespaces.
7) After all the datafiles have been copied and no more tablespace
is in backup mode fire the following query to archive the current logfile;
SQL>alter system archive log current;
These were the steps to be performed on the production database
except for step 3 which needs to be performed on the target machine.
The following steps needs to be performed on the target machine.
On the target machine log into SQL with the following commands
C:>set oracle_sid=<new_database_sid>
C:>sqlplus
and then enter the username and password.
9) Ater logging into the sql prompt startup the database in nomount phase
with the modified init file.
SQL>startup nomount pfile=<location of the modified init file>
10) After the instance is started then we have to run the script
to create the controlfile.
SQL>@<location of the create controlfile sql script>
11) After the command has been executed successfully and
the controlfile is created then we have to recover the database
using the following command.
SQL>recover database until cancel using backup controlfile;
It will ask for the archives which were generated in the production database
during the hot backup and till the latest archive.Kindly copy those
archives to the target machine at the loaction
specified by the log_archive_dest_1 parameter in init file
.
12) After recovery is completed then open the database with resetlogs option.
SQL>alter database open resetlogs;
Now after this command completed successfully your clone database is ready.
11) What is the use of the large Pool?
Large pool is mainly used to offload some burden of caching
from shared pool.
Large pool is a memory structure used during rman backup
with multiple channel location.
It is also used when DBWR I/O slaves are configured.
Finally most importantly it is used to store UGA(user global area) when database is configured in shared server configuration.
Without large pool being configured all these information would be stored in shared pool thereby
reducing the library hit ratio of shared pool and
degrading the performance
12) What is the use of java pool?
Java Pool is mainly used to load Java class and
libraries in oracle database
13) What is Dedicated Server Configuration?
In case of dedicated server configuration for each client which
tries to connect to the database
a user process is generated in the client machine and
when this client gets authenticated by the listener at the server,
the listener spawns a server process which fires the queries and fetches
the data from the database on behalf of the user process on the client.
Also this server process is dedicated to that particular client only and
serves only the request of that particular client
Hence such type of confirguration is called as
dedicated server process. The dedicated server configuration
requires more resources viz memory but provides better perfromance
14) What is Shared Server Configuration ?
In Shared Server Configuration when the client tries
to connect to database a user process is spawned at
the client machine.This client is authenticated by the listener on the
database server and handed over to the dispatcher.
There are normally few dispatcher pre spawned when the instance is started dependinding on the dispatchers
parameter in init<SID>.ora
The Dispatcher places the request from client to the
common request queue placed in the sga.
The idle shared server which are also pre spawned
will pick the request from request queue service
the request and place it in the response queue
which is dedicated to each dispatcher.
The Shared server configuration requires less resources
like memory scarely and is the
favourite configuration for internet application
where large users connect to database
15) Where is the Session Information stored in case of dedicated server configuration?
In case of the Dedicated server Configuration the session
information is stored in PGA.For each session which is established
a dedicated server process is spawned. And for each dedicated server process a memory structure called as PGA
(Program Global Area) is
allocated. This PGA memory is used to store bind variable information,
cursors and session information for that particular session.
16) Where is the Session Information stored in Shared Server Configuration?
In case of the Shared server Configuration the session information
is stored in Shared pool.
Because in shared server confirguration all the session are not linked
to same shared server during the entire period of the session.
17) Where is Shared Server Configuration used in Oracle Database?
The Shared Server is used in internet application
where large users connect to database.
It is also used in application where not all the users connect or
hit the database simultaneously
Shared server Confirguration is based on the concept that between
two consequent queries fired by a particular session on the database
there is a idle time for server process and this idle time is
used to serve request from other clients.
18) Which process starts the shared server process dynamically?
In shared server confirguration initially shared servers
specified by shared_server parameter in init<SID>.ora is started at instance startup.
But as the load on the shared server process
increases background process PMON starts the shared server process dynamically .
19) What is the maximum of number of shared servers which can be started by PMON?
The max number shared server processes which can be started by PMON is decided by
max_shared_servers parameter in init.ora
1) What is the default location for init<SID>.ora file or spfile<SID>.ora for a database?
The default location for the spfile or init file of the database is in
%ORACLE_HOME%/database folder in Windows and
$ORACLE_HOME/dbs directory in case of Unix systems.
2) what is the use of oracle inventory?
Oracle inventory stores the information of all the
Oracle products installed in the system.
The OUI(Oracle Universal Installer) uses this oraInventory to
determine all the product versions which are installed in the system.
3) How to determine the location of Oracle Inventory on Unix systems?
In Solaris system there exists a file called oraInst.loc in the location
/var/opt/oracle/oratab. This file stores the information of the location of oraInventory.
While in case of HP UX oraInst.loc is located in
/etc/oratab directory which gives the location of oraInventory.
4) What is an Oracle Server?
Oracle Server consists of Oracle Instance and Oracle Database.
5) What is an Oracle Instance?
An Oracle Instance consists of Memory structures
(SGA/PGA) and background processes.
The Memory structure include sga nd pga.
SGA consists of shared pool,db buffer cache,log buffer
and optionally large pool and java pool
PGA is used to store bind variable,cursor,sort variables
There 5 mandatory background processes viz PMON,SMON,DBWR,LGWR,CKPT
and other background process also constitute the oracle instance like ARCH,RECO
6) What is the use of shared pool?
Shared pool is used to cache recently used sql statements so as to reduce the overall response time of the sql query if they are executed consequently by the same of diffrent user. Shared pool consists of library cache,row cache and uga(in case of shared server configuration).Shared pool is flushed using LRU algorithm
7) What is use of libarary cache?
It is used to cache execution plan of the recently executed sql queries
so that subsequent execution of the same queries can be faster
8) what is the use of row cache?
It is use to cache the data dictionary information stored into system tablespace.
9)What is the use of the DB Buffer Cache?
The DB Buffer cache is used to cache most recently accessed data.
The tables,indexes which stores the data in the datafiles in oracle database.Caching the data in the SGA make the execution of the query faster and reduces the response time.
DB buffer cache is also based on LRU algorithm.
10) What is the use of log buffer?
Log buffer is used to store redo information generated while manipulating the data in the
oracle database.Redo information is used for recovery. The redo information is flushed from
log buffer to online redo log files of the Oracle Database in the circular fashion.
Hi All,
Today we encountered a strange error i.e ora-23421 when trying
to remove a job from the job queue.
When we try to query the job in dba_jobs queue we found the job with job#=1
to be present
also when the job was running when we queried dba_job_running we found job
with job#=1
But when we try to remove the job using dbms_job package we got the above
error ora-23421.
SQL> conn sys as sysdba
SQL> exec dbms_job.remove(1);
ora-23421 job number 1 is not a job in job queue
All the above activities were carried out by logging as sysdba user.
In other words we tried to remove the job which was was created and scheduled
by some other user with sysdba user and as a result we got the above error.
Later on we queried priv_user column of the dba_jobs view for that job and
logged into the database with that user and removed the job with the same
dbms_job package
and the job was removed succesfully.
Hi All,
Today while performing manual migration of the database to 10gr2 we encountered the following error while trying to run catupgrd.sql script as shown below
SQL> spool upgrade.log
SQL> @catupgrd.sql
SP2-0734: unknown command beginning “catupgrd.s…” – rest of line ignored
Later on we discovered that error was due to OS which was unix and following line needs to be added to the .profile of the oracle to solve the problem
if [ “$TERM” = “” ]
then
eval ` tset -s -Q -m ‘:?hp’ `
else
eval ` tset -s -Q `
fi
stty erase “^H” kill “^U” intr “^C” eof “^D”
stty hupcl ixon ixoff
tabs
Alternatively we could solve the problem by typing the following command
$stty kill Ctrl-u
$sqlplus
SQL> spool upgrade.log
SQL> @catupgrd.sql
The stty kill Ctrl-U solved the problem.
Hi All,
Today One of my collegue had gone to install Oracle 9.2.0.4 on linux x86-64bit on AMD 64 bit. But to his suprise the OUI hanged when copying a file naeet.o
when the installation was only 17% over. Later if found that it was a bug with 9204 OUI on linux x86-64 on amd 64.
So the workaround for that is to set an environment variable called
LD_ASSUME_KERNEL to 2.4.21 before running the runInstaller script.
$LD_ASSUME_KERNEL = 2.4.21
$export LD_ASSUME_KERNEL
$./runInstaller
After setting the above variable the installation went through but it started
giving make file errors during relinking.
So to solve that problem we opened a new terminel where environment variable
LD_ASSUME_KERNEL was not set and
we tried to relink the oracle binaries as shown
$echo $LD_ASSUME_KERNEL
$cd $ORACLE_HOME/bin
$relink all
and there was no error found when manually relinking the oracle binaries and
the installation went through sucessfully.
Later when we applied the 9207 patch we followed the same above procedure
and 9207 patch was also applied sucessfully.
Also it is advisable to check all the pre requistes as given in metalink Docs.
Alternatively the above error can also be solved by invoking the OUI of 9206
and using the product.jar of 9204 to install 9204.