Ramana Ora
Ramana Ora
Ramana Ora
Commands
Posted by Narashim Reddy .R on September 23, 2009
Knowing basic Unix commands should allow you to navigate your Unix system, confirm current
system status and manage files or directories.
Getting help
Unix users
cd – change directory
pwd – confirm current directory
ln – make links and symlinks to files and directories
mkdir – make new directory
rmdir – remove empty directories
Process management
ps – process information
top - show tasks and system status
This is a very handy material. You may be doing recovery but have you done
mistakes in doing so.. say forget commands or sequence of commands to be
written.. Here is a material worth for collection.
Your feedback is most welcome..
BACKUP PROCEDURES :
Criteria :
Cold backup :
Use the operating system command to take the backup of these files.
File System Backup : Generally its frequency should be low. It will act as a backup
for all the files (Oracle+O.S.+Other). It will be needed if all the disks crash. If you
are creating important files on server then its frequency should be increased as
decided by the site incharge.
Hot backup:
In init.ora, search for parameter control_files to find the name of control file for
that database. Query the v$datafiles views to find the names of datafiles
associated with the database.
Use the operating system command to take the backup of these files.*
Use the operating system command to take the backup of these files. *
Logical Backup:
On month end, take complete database export and remove previously stored
cumulative export logical backups.
Cartridges Strategy :
If you are taking complete database export then use three different sets of
cartridges ( Grand father , Father and Son concepts .) on three different days .
And rotate these cartridges again .
For Incremental Backups use six different sets of cartridges on six different days
. And rotate these cartridges again after successfully completion of Cummulative
database export backup .
For Cummulative Backups use different cartridges in every week and rotate those
cartridges in the next month after successfully completion of Complete database
export backup.
Recovery :
In day to day operation the most common type of failure is table drop or partial
data loss in any table or instance failure. Using export backed up dump file
(expdat.dmp) one can recover first two type of problems.
For instance failure, simply restart the database, oracle will automatically recover
the database (Instance recovery).
For more complicated type of problems like media crash (data file loss etc.), please
refer to annexure-1.
Cold backup :
In init.ora, search for parameter control_files to find the name of control
file for that database. Query the v$datafiles and v$logfiles views to find the
names
of datafiles and redo logfiles associated with the database. Use the operating
system
command to take the backup of these files. Ideally this backup should be taken
daily.
Logical Backup:
On month end, take complete database export and remove previously stored
cumulative export logical backups.
Either of the above option can be implemented at the site but order of prefrence
should be first try [1], if not then use [2] else last option should be [3]
Cartridges Strategy :
If you are taking complete database export then use three different sets of
cartridges ( Grand father , Father and Son concepts .) on three different days .
And rotate these cartridges again .
For Incremental Backups use six different sets of cartridges on six different days
. And rotate these cartridges again after successfully completion of Cummulative
database export backup .
For Cummulative Backups use different cartridges in every week and rotate those
cartridges in the next month after successfully completion of Complete database
export backup.
Recovery :
It is a very important process and it should be done very carefully. In day to day
operation the most common type of failure is table drop or partial data loss in any
table or instance failure. Using export backed up dump file (expdat.dmp) one can
recover first two type of problems. For instance failure, simply restart the
database, oracle will automatically recover the database (Instance recovery). For
more complicated type of problems like media crash (data file loss etc.), please
refer to annexure-1.
In Unix :
or
tar -cvf /
In Unix :
or
tar -cvf /
In Window NT :
In Unix :
[a] cpio -icBv < [/dev/rmt0.1|/dev/rmt0]
or
cpio -icBv “[pattern]” < [/dev/rmt0.1|/dev/rmt0]
[b] tar -xvf < [/dev/rmt0.1|/dev/rmt0]
In Window NT :
Use restore utility to copy the necessary files from backup device.
Annexure – 1
SCENARIO
[1] Database startup fails with errors :
ora 1157 can not identify datafile
ora 1110 give the name of datafile which is missing.
REQUIREMENT
[1] The script which will recreate the objects in the datafile like script which will
create indexex.
NON-ESSENTIAL DATAFILES
DATAFILE OF INDEX TABLESPACE, TEMPORARY TABLESPACE.
SOLUTION
Shutdown the database.(shutdown immediate).
Take complete backup of current database.
Startup mount
Query the v$recover_file view along with v$datafile with a join on file# and note
down the name of file
say it is /prodebs/test/ind.dbf.
Alter database datafile ‘/prodebs/test/ind.dbf’ offline;
(if database is in noarchivwlog mode command will be
Alter database datafile ‘/prodebs/test/ind.dbf’ offline drop; )
Alter database open;
Drop tablespace user_index including contents;
Create tablespace user_index
datafile ‘/prodebs/test/ind.dbf’ size 1M;
Run the script which will built indexes*.
Shutdown the database and take backup if necessary.
Startup.
SCENARIO
Database opens neatly but in alert log two error messages are logged with errors :
(error from lgwr. Error is also written in lgwr trace file)
ora 313 open failed for members ..
ora 312 name of redo log memeber missing
ora 7360 OS error
ora 321 Can not update logfile header
SOLUTION
———————————————————————————————–
3. RECOVER A LOST DATAFILE WITH NO BACKUP AND ALL ARCHIVED
LOG FILES
SCENARIO
Database startup fails with errors :
ora 1157 can not identify datafile
ora 1110 give the name of datafile which is missing.
REQUIREMENT
For full recovery, database should be in archivelog mode.
SOLUTION
SCENARIO
Database startup fails with errors :
ora 1157 can not identify datafile
ora 1110 give the name of datafile which is missing.
REQUIREMENT
For full recovery, database should be in archivelog mode.
SOLUTION
———————————————————————————————–
5. RECOVER A LOST DATAFILE WITH BACKUP AND MISSING ARCHIVED
LOG FILES.
SCENARIO
Database startup fails with errors :
ora 1157 can not identify datafile
ora 1110 give the name of datafile which is missing.
REQUIREMENT
For recovery, database should be in archivelog mode.
CONDITION
Recovery will be incomplete.
SOLUTION
———————————————————————————————–
6. LOSS OF DATAFILE WHEN THE DATABASE IS IN NOARCHIVELOG MODE
WITH NO LOGICAL BACKUP AND RECOVERY.
SCENARIO
Database startup fails with errors : (a) on monday morning (b) on thursday
ora 1157 can not identify datafile
ora 1110 give the name of datafile which is missing and found to be user data file.
There is no export and import backup (Logical backup).
Cold backup is taken once in every week . Here backup is taken on every sunday and
this is the last activity
on sunday.
Problem has occured on (a) on monday morning (b) on thursday.
Here data file (s) associated with user tablespace is (are) lost.
TIME TAKEN IN RECOVERY
DATABASE WILL BE READY FOR USE IN MIN 30 mins.
SOLUTION when Problem has occured on (a) on thursday morning. Here data loss
will occur.
SCENARIO
Database startup fails with errors on thursday morning.
ora 1157 can not identify datafile
ora 1110 give the name of datafile which is missing and found to be user data file.
There is export and import backup. (Logical backup).
Strategy : So along with coldback up a complete database backup is also taken.
(i) After this on everyday, an incremental backup is also taken.
(ii) After this on everyday, complete database backup is also taken.
Cold backup is taken once in every week . Here backup is taken on every sunday and
this is the last activity
on sunday.
Here data file (s) associated with user tablespace is (are) lost.
[ii] SOLUTION when Problem has occured on thursday morning and daily complete
database logical
backup is taken.
SCENARIO
Database startup fails with errors on thursday morning.
ora 1157 can not identify datafile
ora 1110 give the name of datafile which is missing and found to be user data file.
Cold backup is taken once in every week . Here backup is taken on every sunday and
this is the last activity
on sunday.
Here data file (s) associated with system tablespace is (are) lost.
SOLUTION
Shutdown the database.(shutdown).
Take complete backup of current database.
Copy the missing system database file(s).
Startup mount exclusive;
recover database;
alter database open;
Database is ready for use.
SCENARIO
Database startup fails with errors on thursday morning.
ora 1157 can not identify datafile
ora 1110 give the name of datafile which is missing and found to be user data file.
Cold backup is taken once in every week . Here backup is taken on every sunday and
this is the last activity
on sunday.
Here data file (s) associated with user tablespace is (are) lost.
* If multiple datafiles are lost use parallel recovery method (from muliple terminal
use the same method for different files).
SCENARIO
Database startup fails with errors on thursday morning.
ora 1157 can not identify datafile
ora 1110 give the name of datafile which is missing and found to be user data file.
Cold backup is taken once in every week . Here backup is taken on every sunday and
this is the last activity
on sunday.
Datafile(s) associated with rollback segment tablespace is (are) lost.
11. LOSS OF UNARCHIVED ONLINE LOG FILES WHEN THEY ARE NOT
MIRRORED WHEN THE DATABASE IS IN ARCHIVE LOG MODE AND
RECOVERY.
SCENARIO
Database startup fails with errors on thursday morning.
ora 1157 can not identify datafile
ora 1110 give the name of datafile which is missing and found to be user data file.
Cold backup is taken once in every week . Here backup is taken on every sunday and
this is the last activity
on sunday.
All the online redo log files are lost.
All the data files and current control files are intact.
SOLUTION –
SCENARIO
While taking hot backup, database crashes.
(a) When Oracle Version is 7.2 or more.
(b) When Oracle Version is 7.1.
SCENARIO
[a] Loss of control file when it is mirrored.
[b] Loss of control file when there is a backup and it is not mirrored but not
before last reset log option.
[c] Loss of control file when there is no backup and it is not mirrored (total loss).
NB : Loss of control file when there is a backup and it is not mirrored but it is
before last reset log option.
(suppose database is open on day x with alter database startup resetlogs.So your
control file should
be before xth day )
SOLUTION – (Loss of control file when there is a backup and it is not mirrored)
SCENARIO
Space management when :
(a) Oracle Version is 7.2 or more.
(b) Oracle Version is 7.1.
Oracle Error is : ora 00376 file # can not be read at this time.
ora 01110 name of datafile.
[a] Restore the datafile and apply recovery. Resizing is not possible.
Events
[1]
a- Cold backup is taken.
b- Loss of redo log file.and media recovery. At this moment, a backup is taken.
c- Loss of data file
[2]
a- Cold backup is taken.
b- Loss of redo log file.and media recovery. At this moment, a backup is not taken.
c- Loss of data file .
SOLUTION – [1]
SOLUTION – [2]-i
Disadvantage : All the data will be lost that was entered in datafile 5;
SOLUTION – [2]-ii
16. LOSS OF DATA FILE WHEN THE DATABASE IS IN ARCHIVE LOG MODE
AND RECOVERY.
SCENARIO
Database startup fails with errors on thursday morning.
ora 1157 can not identify datafile
ora 1110 give the name of datafile which is missing and found to be user data file.
Cold backup is taken once in every week . Here backup is taken on every sunday and
this is the last activity
on sunday.
Datafile(s) associated with user tablespace is (are) permanently lost.
SOLUTION –
SCENARIO
Database startup fails with errors on thursday morning.
ora 1157 can not identify datafile
ora 1110 give the name of datafile which is missing and found to be user data file.
Cold backup is taken once in every week . Here backup is taken on every sunday and
this is the last activity
on sunday.
Datafile(s) associated with user tablespace is (are) permanently lost.
SOLUTION –
SCENARIO
Database startup fails with errors on thursday morning.
ora 1157 can not identify datafile
ora 1110 give the name of datafile which is missing and found to be user data file.
Cold backup is taken once in every week . Here backup is taken on every sunday and
this is the last activity
on sunday.
Datafile(s) associated with user tablespace is (are) permanently lost.
SOLUTION – 1
SOLUTION – 2 (better)
Internals of Shared Pool
Posted by Narashim Reddy .R on October 30, 2009
This article is intended to provide a inside view and working of Shared Pool and its
solution since Oracle 7 version thru Oracle 10g Release 2.
It is fundamentally to serve the metadata cache. Shared pool helps execute SQL
and PLSQL.
SQL Area
V$SQLAREA table contains all the data of this sql area and also provides a list of
statistics on shared SQL area and contains one row per SQL string. It provides
statistics on SQL statements that are in memory, parsed, and ready for execution.
PL/SQL MPCODE
The “compiled” form a PL/SQL is called PCODE, which stands for pseudo code, and
is interpreted at runtime by the PL/SQL engine. That is, it is not really compiled; it
is just pre-compiled. There is also a machine dependent form of pseudo code used
in some cases called MPCODE. (Source Steve Adams – 1999 – Questions and
Answers)
PL/SQL DIANA
sql area:PLSQL
sql area:KOKA related to Pseudo code cursor – No document defines or talks about
this piece of sql area.
Library cache:
Please query v$librarycache and under namespace column all the following are
listed.
BODY
CLUSTER
INDEX
JAVA DATA
JAVA RESOURCE
JAVA SOURCE
OBJECT
PIPE
SQL AREA
TABLE/PROCEDURE
TRIGGER
Row cache:
dc_awr_control
dc_constraints
dc_database_links
dc_files
dc_free_extents
dc_global_oids
dc_hintsets
dc_histogram_data
dc_histogram_defs
dc_object_grants
dc_object_ids
dc_objects
dc_outlines
dc_partition_scns
dc_profiles
dc_qmc_cache_entries
dc_qmc_ldap_cache_entries
dc_rollback_segments
dc_segments
dc_sequences
dc_table_scns
dc_tablespace_quotas
dc_tablespaces
dc_used_extents
dc_usernames
dc_users
kqlsubheap_object
outstanding_alerts
qmtmrcin_cache_entries
qmtmrcip_cache_entries
qmtmrciq_cache_entries
qmtmrctn_cache_entries
qmtmrctp_cache_entries
qmtmrctq_cache_entries
rule_fast_operators
rule_info
rule_or_piece
There are new background processes introduced by Oracle in Oracle 10g in R1 and
R2. They are
The Memory Monitor Light (MMNL) process is a new process in 10g which works
with the Automatic Workload Repository new feature (AWR) to write out full
statistics buffers to disk as needed.
The memory monitor (MMON) process was introduced in 10g and is associated with
the Automatic Workload Repository new features used for automatic problem
detection and self-tuning. MMON writes out the required statistics for AWR on a
scheduled basis.
ASH is a circular buffer and is an integral part of shared pool. Oracle Metalink Doc
ID Note: 243132.1
Size of ASH Circular Buffer = Max [Min [ #CPUs * 2 MB, 5% of Shared Pool Size,
30MB ], 1MB ]
05. If it is a parallel slave, not waiting for the PX_IDLE wait event.
So will not see any info if a process is waitting for “SQL*Net message from client”.
select SESSION_ID,
NAME,
P1,
P2,
P3,
WAIT_TIME,
CURRENT_OBJ#,
CURRENT_FILE#,
CURRENT_BLOCK#
v$event_name enm
where ash.event#=enm.event#
And many more stuff is stored in the Shared Pool of every Oracle Instance.
The SHARED_POOL has at the highest level has 2 kinds of structures. The first
structure is PERMANENT structure which is not alterable as has been spawned by
Oracle Instance Startup and its stay in the SHARED_POOL is not negotiable.
01. When new objects are referenced they need to be brought into memory and
they need memory allocation
02. So re-creatable objects are aged out and pushed out of memory
03. Objects are made up of chunks of memory and when they are created the
process checks for contiguous required space
05. If the available free memory is not sufficient to create a contiguous required
chunk, Oracle throws up error ORA-04031
01. One is explicit cursor – created by PL/SQL explicitly in the declarative section
and then managed and closed in the executable/run section of the PL/SQL object.
For queries that return more than one row, one can explicitly declare a cursor to
process the rows individually.
02. PL/SQL implicitly declares a cursor for all SQL data manipulation statements,
including queries that return only one row.
03. All the SELECT statements issued are managed by the implicit cursors.
When a cursor is closed, the cursor information is moved into session’s closed
cursor cache in User Global Area (UGA). The Shared pool maintains the handles in
hashed chains. SESSION_CACHED_CURSORS is the parameter that controls the
number. The default value for this in Oracle 10.2.0.2.0 is 0 (zero) and in the later
versions, it was said that the same is set to 50.
How it works?
When a cursor is opened, the session process hashes pthe SQL statement and
performs a hash lookup in the closed cursor cache in the session memory (UGA) and
if found the same is moved to open cursors and then no parsing is required.
If the cursor is not found in the session, the hash value is used to search the hash
chains in the shared pool for the cursor handle. This search is registered as hard
parse.
If the cursor handle is found and the cursor has not aged out, the cursor is
executed. This is a soft parse.
If some part of the cursor has aged out of the shared pool
Or
If the cursor does not exist in the shared pool, then the cursor is reconstructed.
This is called hard parse. The cursor reconstruction requires a lookup of the
metadata for the dependent objects such as tables, indexes, extents and
sequences.
If the metadata for these objects does not already cached in the shared pool,
recursive SQL is generated to fetch the information from the data dictionary.
How the cache in the shared pool is protected from being over written?
LATCH#
RMAN takes care of all underlying database procedures before and after backup
or restore, freeing dependency on OS and SQL*Plus scripts. It provides a common
interface for backup tasks across different host operating systems, and offers
features not available through user-managed methods, such as binary file
compression, parallelization of backup/recovery data streams, backup files
retention policy, and detailed history of all backups.
First introduced in the Oracle8 Database, RMAN has since been updated with
numerous enhancements in Oracle9i, including block media recovery, autobackup of
control files, and resumable backup/recovery in case of failure. With the latest
release of RMAN in Oracle Database 10g, a host of new features allow the DBA to:
· Better organize backups with flash recovery area
· Optimize incremental backup performance via block change tracking
· Reduce the number of full backups to perform with incrementally updated
backups
· Administer backup sets and image copies with Enterprise Manager
· Easily convert tablespaces across platforms
The RMAN environment consists of the utilities and databases that play a role in
backing up your data. At a minimum, the environment for RMAN must include the
following:
· The target database to be backed up
· The RMAN client, which interprets backup and recovery commands, directs
server sessions to execute those commands, and records your backup and recovery
activity in the target database control file.
Target Database
The target database is the database that you are backing up, restoring, or
recovering with RMAN.
RMAN Client
RMAN can take interactive input or read input from plain text files (called
command files). RMAN then communicates with one or more server processes on
the target database server which actually perform the work. You can also access
RMAN through the Enterprise Manager; for details see Oracle Enterprise Manager
Administrator’s Guide.
The RMAN executable is typically installed in the same directory as the other
database executables. On Unix systems, for example, the RMAN executable is
located in $ORACLE_HOME/bin.
RMAN Repository
RMAN maintains metadata about the target database and its backup and recovery
operations in the RMAN repository. Among other things, RMAN stores information
about its own configuration settings, the target database schema, archived redo
logs, and all backup files on disk or tape. RMAN’s LIST, REPORT, and SHOW
commands display RMAN repository information.
RMAN repository data is always stored in the control file of the target database.
The CONTROL_FILE_RECORD_KEEP_TIME initialization parameter controls how
long backup records are kept in the control file before those records are re-used
to hold information about more recent backups. The repository can also be kept in
a recovery catalog, a separate database that keeps historical data on backup
activities much longer than the control file and preserves backup information if
the control file is lost.
The Automatic Disk-Based Backup and Recovery feature simplifies managing disk
space and files related to backup and recovery, by managing all backup and
recovery related files in a flash recovery area. You set the flash recovery area
size and location, using the DB_RECOVERY_FILE_DEST and
DB_RECOVERY_FILE_DEST_SIZE initialization parameters. You also specify a
retention policy that dictates when backups may be discarded.
RMAN then manages your backup storage, deleting obsolete backups and backups
already copied to tape when space is needed, but keeping as many backups on disk
as space permits. This minimizes restores from tape during data recovery
operations to shorten restore and recovery times.
Recovery Catalog
In addition to RMAN repository records, the recovery catalog can also hold RMAN
stored scripts, sequences of RMAN commands for common backup tasks.
Centralized storage of scripts in the recovery catalog can be more convenient than
working with command files.
Except for stored scripts, all of RMAN’s features work equally well with or without
a recovery catalog. For more information on the recovery catalog see Oracle
Database Backup and Recovery Advanced User’s Guide.
Media Managers
To access sequential media devices like tape libraries, RMAN uses third-party
media management software. A media manager controls these devices during
backup and recovery, managing the loading, labeling and unloading of media, among
other functions. Oracle Corporation’s Backup Solutions Program (BSP) works with
vendors to help them produce media management software for their devices. For
enterprises that already use media management software in their enterprise, many
of those software products can be directly integrated with RMAN. Contact your
media management software vendor for details about whether they participate in
the BSP and have an RMAN-compatible media management layer.
3. Comprehensive reporting
Using special V$ views, users can retrieve information on all currently executing
and completed RMAN backup jobs, as well as details on all backed up files and
obsolete backup sets. This output can also be easily viewed in Enterprise Manager,
under Backup Set Management.
Here I list the Dictionary Views that can one oracle dba & appsdba use most of the
times.
Data Dictionary
Which users are in the database password file:
V$PWFILE_USERS
Where values set in the init.ora file can be viewed – all parameters:
V$PARAMETER
Script used to create the objects that comprise the data dictionary:
catalog.sql
SELECT_CATALOG_ROLE
DBA_OBJECTS
DBA_TABLES
DBA_INDEXES
DBA_VIEWS
DBA_SEQUENCES
DBA_USERS
DBA_CONS_COLUMNS
Information about all columns that have indexes on them in the database:
DBA_IND_COLUMNS
DBA_TAB_COLUMNS
DBA_ROLES
DBA_TAB_PRIVS
Information about all system privileges granted to all users in the database:
DBA_SYS_PRIVS
DBA_SOURCE
DBA_TRIGGERS
ROLE_TAB_PRIVS
ROLE_SYS_PRIVS
Information about roles granted to roles
ROLE_ROLE_PRIVS
DBA_TABLESPACES
DBA_PROFILES
V$PARAMETER
V$DATABASE
V$SYSSTAT
Most information about the performance for individual user sessions is stored
here:
V$SESSION , V$SESSTAT
V$LOG, V$LOGFILE
V$DATAFILE
Basic information about control files, and the two columns it has:
When the control file was created, Sequence Number, most recent SCN:
V$DATABASE
V$CONTROLFILE_RECORD_SECTION
To see the names and locations of all control files in the db? (2)
V$PARAMETER. V$CONTROLFILE
Temporary Segments:
DBA_SEGMENTS
segments, and sort segment high-water mark information. Space usage allocation
V$SORT_SEGMENT
V$SORT_USAGE
V$SESSION
DBA_TEMP_FILES
V$TEMPFILE
Storage Structures
A summary view, contains all types of segments and their storage parameters,
DBA_SEGMENTS
DBA_TS_QUOTAS
Segment name, type, owner, total bytes of extent, name of tablespace storing the
extent:
DBA_EXTENTS
DBA_FREE_SPACE
The location of free space in the tablespace that has been coalesced:
DBA_FREE_SPACE_COALESCED
DBA_DATAFILES
Performance view for information for datafiles for every tablespace
V$DATAFILE
DBA_EXTENTS
DBA_OBJECTS
High water mark, all storage settings for a table, and statistics collected as part
DBA_TABLES
DBA_TAB_COLUMNS
To determine how many columns are marked unused for later removal?
DBA_UNUSED_COL_TABS
INDEX_STATS
DBA_ID_COLUMNS
The dynamic view to show whether the index is being used in a meaningful way?
V$OBJECT_USAGE
DBA_CONS_COLUMNS
To see the constraints associated with a particular table:
DBA_CONSTRAINTS
DBA_USERS
To all objects, which objects belong to which users, how many objects a user has
created?
DBA_OBJECTS
DBA_PROFILES
RESOURCE_COST
USER_RESOURCE_LIMITS
DBA_SYS_PRIVS
DBA_TAB_PRIVS
Shows all privileges in this session available to you as the current user:
SESSION_PRIVS
Views for audits currently taking place are created by this script:
cataudit.sql
a list of audit entries generated by the exists option of the audit command:
DBA_AUDIT_EXISTS
DBA_AUDIT_OBJECT
DBA_AUDIT_SESSION
DBA_AUDIT_STATEMENT
A list of all entries in the AUD$ table collected by the audit command:
DBA_AUDIT_TRAIL
To determine the roles available in the database, the names of all the roles on the
DBA_ROLES
DBA_ROLE_PRIVS
All the roles and the roles that are granted to them:
ROLE_ROLE_PRIVS
DBA_SYS_PRIVS
ROLE_TAB_PRIVS
SESSION_ROLES
DBA_TAB_PRIVS
NLS_DATABASE_PARAMETERS
« RAC FAQ
Cost Based Optimizer (CBO) and Database Statistics »
SQL Quick Reference
Posted by Narashim Reddy .R on September 10, 2009
1 Votes
SQL Syntax
Statement
AND / OR SELECT column_name(s) FROM table_name
WHERE condition AND|OR condition
ALTER ALTER TABLE table_name ADD column_name
TABLE datatype or ALTER TABLE table_name DROP
COLUMN column_name
Purpose
In this tutorial, you learn how to install Oracle Database 11g on Linux.
Topics
Overview
Summary
Note: Alternatively, you can place the cursor over an individual icon in the following steps to
load and viewonly the screenshot associated with that step. You can hide an individual
screenshot by clicking it.
Overview
Using the Oracle Universal Installer, you install the Oracle Database 11g software and create a
database.
To install the Oracle software, you must use the Oracle Universal installer.
1. For this installation, you need either the DVDs or a downloaded version of the DVDs. In this tutorial, you
install from the downloaded version. From the directory where the DVD files were unzipped, open a
terminal window and enter the following:
./runInstaller.sh
2. The product you want to install is Oracle Database 11g. Make sure the product is selected and click
Next.
2. You will perform a basic installation with a starter database. Enter orcl for the Global Database Name
and oracle for Database Password and Confirm Password. Then, click Next.
3. You need to specify your Inventory directory. The location should be set to
/u01/app/oracle/oraInventory. Accept the default Operating System group name, oinstall. Then, click
Next.
4. The installer now verifies that the system meets all the minimum requirements for installing and
configuring the chosen product. Please correct any reported errors before continuing. When the check
5. Oracle Configuration Manager allows you to associate your configuration information with your Metalink
account. You can choose to enable it on this window. Then, click Next.
5.
Review the Summary window to verify what is to be installed. Then, click Install.
6.
The progress window appears.
7.
The Configuration Assistants window appears.
8.
Your database is now being created.
9.
When the database has been created, you can unlock the users you want to use. Click OK.
10.
You need to execute orainstRoot.sh and root.sh as the root user.
11. Open a terminal window and enter the following commands. Follow the prompts as instructed.
su -
<rootpassword>
cd /u01/app/oracle/oraInventory
./orainstRoot.sh
cd ../product/11.1.0/db_1
./root.sh
exit
exit
12.
Switch back to the Universal Installer and click OK.
13.
Click Exit. Click Yes to confirm exit.
To test that your installation completed successfully, perform the following steps:
Because Enterprise Manager Database Control is a secure site, you need a certificate. Select the
Accept this certificate permanently option, and then click OK.
2.
Enter system as the User Name and oracle as the Password, and then click Login.
3.
The Database Control Home Page appears. Your installation was successful.
Summary
In this tutorial, you learned how to install and test the Oracle Database 11g installation on Linux.
Rate This
Database closed.
Database dismounted.
SQL> !
——————
——————
*.log_archive_dest=’/home/oracle/tarun4/archive’
*.log_archive_format=’arch_%t_%r_%s.arc’
*.log_archive_start=true
——————-
——————-
:wq!
[oracle@reddy dbs]$ cd
Enter password:
File created.
Database mounted.
Database altered.
Database altered.
ARCHIVE
——-
STARTED
Database closed.
Database dismounted.
Database mounted.
Database altered.
Database altered.
ARCHIVE
——-
STOPPED
« Table Space Management
Archived Redo Log Files Management »
DataFile Management
Posted by Narashim Reddy .R on August 16, 2009
Rate This
NAME
——————————————————————————–
10 5 ONLINE 10485760
/home/oracle/tarun4/datafiles/users01.dbf
Database altered.
NAME
——————————————————————————–
10 5 RECOVER 10485760
/home/oracle/tarun4/datafiles/users01.dbf
NAME
——————————————————————————–
10 5 OFFLINE 10485760
/home/oracle/tarun4/datafiles/users01.dbf
Database altered.
NAME
——————————————————————————–
10 5 ONLINE 10485760
/home/oracle/tarun4/datafiles/users01.dbf
FILE_NAME
/home/oracle/tarun4/datafiles/users.dbf
—————————— —————
USERS 100
Database altered.
TABLESPACE_NAME BYTES/1024/1024
—————————— —————
USERS 50
FILE_NAME
————————————————————————————————————————————
————————————————
/home/oracle/tarun4/datafiles/users.dbf
Tablespace altered.
FILE_NAME
————————————————————————————————————————————
————————————————
/home/oracle/tarun4/datafiles/users.dbf
/home/oracle/tarun4/datafiles/users1.dbf
FILE_NAME
————————————————————————————————————————————
————————————————
/home/oracle/tarun4/datafiles/users.dbf
/home/oracle/tarun4/datafiles/users1.dbf
Tablespace altered.
SQL> !
Tablespace altered.
Tablespace altered.
————————————————————————————————————————————
————————————————
/home/oracle/tarun4/datafiles/users.dbf
/home/oracle/tarun4/datafiles/users01.dbf
« RMAN
DataFile Management »
Table Space Management
Posted by Narashim Reddy .R on August 16, 2009
Rate This
Tablespace created.
Tablespace created.
Tablespace created.
INITIAL_EXTENT
————–
65536
INITIAL_EXTENT
————–
2097152
Table created.
SEGMENT_NAME
——————————————————————————–
EMP_TEST2
0 65536 16
SQL> create table emp_test3(c1 number) tablespace test3;
Table created.
SEGMENT_NAME
——————————————————————————–
EMP_TEST3
0 2097152 512
Table created.
SEGMENT_NAME
——————————————————————————–
EMP_TEST2
0 65536 16
EMP_TEST4
0 65536 16
EMP_TEST4
1 65536 16
SEGMENT_NAME
——————————————————————————–
EMP_TEST4
2 65536 16
EMP_TEST4
3 65536 16
EMP_TEST4
4 65536 16
SEGMENT_NAME
——————————————————————————–
EMP_TEST4
5 65536 16
EMP_TEST4
6 65536 16
EMP_TEST4
7 65536 16
SEGMENT_NAME
——————————————————————————–
EMP_TEST4
8 65536 16
EMP_TEST4
9 65536 16
EMP_TEST4
10 65536 16
SEGMENT_NAME
——————————————————————————–
EMP_TEST4
11 65536 16
EMP_TEST4
12 65536 16
EMP_TEST4
13 65536 16
SEGMENT_NAME
——————————————————————————–
EMP_TEST4
14 65536 16
EMP_TEST4
15 65536 16
17 rows selected.
Table created.
SEGMENT_NAME
——————————————————————————–
EMP_TEST3
0 2097152 512
EMP_TEST5
0 2097152 512
test2;
Table created.
SEGMENT_NAME
——————————————————————————–
EMP_TEST2
0 65536 16
EMP_TEST4
0 65536 16
EMP_TEST4
1 65536 16
SEGMENT_NAME
——————————————————————————–
EMP_TEST4
2 65536 16
EMP_TEST4
3 65536 16
EMP_TEST4
4 65536 16
SEGMENT_NAME
——————————————————————————–
EMP_TEST4
5 65536 16
EMP_TEST4
6 65536 16
EMP_TEST4
7 65536 16
SEGMENT_NAME
——————————————————————————–
EMP_TEST4
8 65536 16
EMP_TEST4
9 65536 16
EMP_TEST4
10 65536 16
SEGMENT_NAME
——————————————————————————–
EMP_TEST4
11 65536 16
EMP_TEST4
12 65536 16
EMP_TEST4
13 65536 16
SEGMENT_NAME
——————————————————————————–
EMP_TEST4
14 65536 16
EMP_TEST4
15 65536 16
EMP_TEST6
0 1048576 256
SEGMENT_NAME
——————————————————————————–
EMP_TEST6
1 1048576 256
19 rows selected.
Table created.
SEGMENT_NAME
——————————————————————————–
EMP_TEST3
0 2097152 512
EMP_TEST7
0 2097152 512
EMP_TEST5
0 2097152 512
Table created.
SEGMENT_NAME
——————————————————————————–
EMP_TEST3
0 2097152 512
EMP_TEST7
0 2097152 512
EMP_TEST5
0 2097152 512
Table created.
——————————————————————————–
EMP_TEST2
0 65536 16
EMP_TEST4
0 65536 16
EMP_TEST4
1 65536 16
SEGMENT_NAME
——————————————————————————–
EMP_TEST4
2 65536 16
EMP_TEST4
3 65536 16
EMP_TEST4
4 65536 16
SEGMENT_NAME
——————————————————————————–
EMP_TEST4
5 65536 16
EMP_TEST4
6 65536 16
EMP_TEST4
7 65536 16
SEGMENT_NAME
——————————————————————————–
EMP_TEST4
8 65536 16
EMP_TEST4
9 65536 16
EMP_TEST4
10 65536 16
SEGMENT_NAME
——————————————————————————–
EXTENT_ID BYTES BLOCKS
EMP_TEST4
11 65536 16
EMP_TEST4
12 65536 16
EMP_TEST4
13 65536 16
SEGMENT_NAME
——————————————————————————–
EMP_TEST4
14 65536 16
EMP_TEST4
15 65536 16
EMP_TEST8
0 1048576 256
SEGMENT_NAME
——————————————————————————–
EMP_TEST8
1 1048576 256
EMP_TEST8
2 1048576 256
EMP_TEST6
0 1048576 256
SEGMENT_NAME
——————————————————————————–
EMP_TEST6
1 1048576 256
22 rows selected.
Table created.
SEGMENT_NAME
——————————————————————————–
EMP_TEST3
0 2097152 512
EMP_TEST7
0 2097152 512
EMP_TEST9
0 2097152 512
SEGMENT_NAME
——————————————————————————–
EMP_TEST9
1 2097152 512
EMP_TEST5
0 2097152 512
Table created.
SEGMENT_NAME
——————————————————————————–
EXTENT_ID BYTES BLOCKS
EMP_TEST2
0 65536 16
EMP_TEST4
0 65536 16
EMP_TEST4
1 65536 16
SEGMENT_NAME
——————————————————————————–
EMP_TEST4
2 65536 16
EMP_TEST4
3 65536 16
EMP_TEST4
4 65536 16
SEGMENT_NAME
——————————————————————————–
EMP_TEST4
5 65536 16
EMP_TEST4
6 65536 16
EMP_TEST4
7 65536 16
SEGMENT_NAME
——————————————————————————–
EMP_TEST4
8 65536 16
EMP_TEST4
9 65536 16
EMP_TEST4
10 65536 16
SEGMENT_NAME
——————————————————————————–
11 65536 16
EMP_TEST4
12 65536 16
EMP_TEST4
13 65536 16
SEGMENT_NAME
——————————————————————————–
EMP_TEST4
14 65536 16
EMP_TEST4
15 65536 16
EMP_TEST1
0 1048576 256
SEGMENT_NAME
——————————————————————————–
EMP_TEST1
1 1048576 256
EMP_TEST1
2 1048576 256
EMP_TEST1
3 1048576 256
SEGMENT_NAME
——————————————————————————–
EMP_TEST8
0 1048576 256
EMP_TEST8
1 1048576 256
EMP_TEST8
2 1048576 256
SEGMENT_NAME
——————————————————————————–
EMP_TEST6
0 1048576 256
EMP_TEST6
1 1048576 256
26 rows selected.
Table created.
SEGMENT_NAME
——————————————————————————–
EMP_TEST3
0 2097152 512
EMP_TEST10
0 2097152 512
EMP_TEST10
1 2097152 512
SEGMENT_NAME
——————————————————————————–
0 2097152 512
EMP_TEST9
0 2097152 512
EMP_TEST9
1 2097152 512
SEGMENT_NAME
——————————————————————————–
EMP_TEST5
0 2097152 512
7 rows selected.
Tablespace created.
Tablespace created.
dba_tablespaces;
10 rows selected.
FILE_NAME
————————————————————————————————————————————
——————
/home/oracle/tarun4/datafiles/rman01.dbf
/home/oracle/tarun4/datafiles/undotbs1.dbf
FILE_NAME
————————————————————————————————————————————
——————
/home/oracle/tarun4/datafiles/system01.dbf
/home/oracle/tarun4/datafiles/users.dbf
/home/oracle/tarun4/datafiles/test02.dbf
FILE_NAME
————————————————————————————————————————————
——————
/home/oracle/tarun4/datafiles/test03.dbf
8 rows selected.
PROPERTY_NAME
——————————
PROPERTY_VALUE
————————————————————————————————————————————
——————
DESCRIPTION
————————————————————————————————————————————
——————
DEFAULT_TEMP_TABLESPACE
TEMP
PROPERTY_NAME
——————————
PROPERTY_VALUE
————————————————————————————————————————————
——————
DESCRIPTION
————————————————————————————————————————————
——————
DEFAULT_PERMANENT_TABLESPACE
SYSTEM
FILE_NAME
————————————————————————————————————————————
————————————————
/home/oracle/tarun4/datafiles/temp02.dbf
/home/oracle/tarun4/datafiles/temp01.dbf
TABLESPACE_NAME SUM(BYTES)
—————————— ———-
UNDOTBS1 487129088
SYSAUX 307298304
RMAN_TBS 12255232
reddy 104726528
TEST3 35651584
USERS 62652416
UNDO07 51052544
SYSTEM 289865728
TEST2 41877504
9 rows selected.
TABLESPACE_NAME SUM(BYTES)
—————————— ———-
USERS 62652416
NAME
————————————————————————————————————————————
————————————————
/home/oracle/tarun4/datafiles/temp02.dbf
/home/oracle/tarun4/datafiles/temp01.dbf
NAME
————————————————————————————————————————————
————————————————
/home/oracle/tarun4/datafiles/undotbs1.dbf
/home/oracle/tarun4/datafiles/sysaux01.dbf
NAME
————————————————————————————————————————————
————————————————
/home/oracle/tarun4/datafiles/rman01.dbf
/home/oracle/tarun4/datafiles/users.dbf
/home/oracle/tarun4/datafiles/test02.dbf
NAME
————————————————————————————————————————————
————————————————
/home/oracle/tarun4/datafiles/undo07.dbf
8 rows selected.
Tablespace created.
———- —————————— — —
0 SYSTEM YES NO
1 UNDOTBS1 YES NO
2 SYSAUX YES NO
4 RMAN_TBS YES NO
3 TEMP NO NO
5 USERS YES NO
6 TEST2 YES NO
7 TEST3 YES NO
8 TEMP1 NO NO
9 UNDO07 YES NO
ERROR at line 1:
user_segments
user_tables
user_extents
FILE_NAME
/home/oracle/tarun4/datafiles/users.dbf
—————————— —————
USERS 100
Database altered.
TABLESPACE_NAME BYTES/1024/1024
—————————— —————
USERS 50
FILE_NAME
————————————————————————————————————————————
————————————————
/home/oracle/tarun4/datafiles/users.dbf
Tablespace altered.
FILE_NAME
————————————————————————————————————————————
————————————————
/home/oracle/tarun4/datafiles/users.dbf
/home/oracle/tarun4/datafiles/users1.dbf
FILE_NAME
————————————————————————————————————————————
————————————————
/home/oracle/tarun4/datafiles/users.dbf
/home/oracle/tarun4/datafiles/users1.dbf
Tablespace altered.
SQL> !
Tablespace altered.
Tablespace altered.
————————————————————————————————————————————
————————————————
/home/oracle/tarun4/datafiles/users.dbf
/home/oracle/tarun4/datafiles/users01.dbf
TABLE_NAME
——————————
TEST
TABLE_NAME
——————————
EMP_TEST2
EMP_TEST4
EMP_TEST1
EMP_TEST8
EMP_TEST6
Table altered.
——————————
TEST
EMP_TEST2
TABLE_NAME
——————————
EMP_TEST4
EMP_TEST1
EMP_TEST8
EMP_TEST6
Tablespace altered.
Tablespace altered.
*
ERROR at line 1:
Tablespace altered.
1 row created.
Tablespace altered.
ERROR at line 1:
Tablespace altered.
1 row created.
FILE_NAME
————————————————————————————————————————————
————————————————
/home/oracle/tarun4/datafiles/users.dbf
5 AVAILABLE ONLINE
/home/oracle/tarun4/datafiles/users01.dbf
10 AVAILABLE ONLINE
Database altered.
SQL> select file_name,file_id,status, online_status from dba_data_files where
tablespace_name=’USERS’;
FILE_NAME
————————————————————————————————————————————
————————————————
/home/oracle/tarun4/datafiles/users.dbf
5 AVAILABLE RECOVER
/home/oracle/tarun4/datafiles/users01.dbf
10 AVAILABLE ONLINE
FILE_NAME
————————————————————————————————————————————
————————————————
/home/oracle/tarun4/datafiles/users.dbf
5 AVAILABLE OFFLINE
/home/oracle/tarun4/datafiles/users01.dbf
10 AVAILABLE ONLINE
Database altered.
Tablespace altered.
TABLESPACE_NAME
——————————
SYSTEM
UNDOTBS1
SYSAUX
TEMP
RMAN_TBS
USERS
TEST2
TEST1
TEMP1
UNDO07
reddy
11 rows selected.
Follow the Rules when Renaming a Tablespace:
Tablespace altered.
Nologging DDL statement won’t be records in the redo logfiles but DML statement
records in the redo logfiles.
Tablespace altered.
Dropping Tablespace:
TABLESPACE_NAME
——————————
SYSTEM
UNDOTBS1
SYSAUX
TEMP
RMAN_TBS
USERS
TEST2
TEST1
TEMP1
UNDO07
reddy
11 rows selected.
Removes the entry of tablespace from controlfile, physical files are present at OS
Level.
Tablespace dropped.
Tablespace dropped.
SQL> drop tablespace test2 including contents and datafiles cascade constraints;
Tablespace dropped.
TABLESPACE_NAME
——————————
SYSTEM
UNDOTBS1
SYSAUX
TEMP
RMAN_TBS
USERS
TEMP1
UNDO07
reddy
9 rows selected.
NAME
————————————————————————————————————————————
————————————————
/home/oracle/tarun4/datafiles/system01.dbf
/home/oracle/tarun4/datafiles/undotbs1.dbf
/home/oracle/tarun4/datafiles/sysaux01.dbf
/home/oracle/tarun4/datafiles/rman01.dbf
/home/oracle/tarun4/datafiles/users.dbf
/home/oracle/tarun4/datafiles/undo07.dbf
/home/oracle/tarun4/datafiles/bigfile.dbf
/home/oracle/tarun4/datafiles/users01.dbf
8 rows selected.
SQL> !
[oracle@reddy datafiles]$ ls
1-you will need to create another Tablespace with a smaller Datafile size
3-Check that there’s no active Undo Segments in your Database using this
query
REDO LOGFILE MANAGEMENT
REDO LOGFILE MANAGEMENT
Views in Redologs:
v$log->Status,Groups
MEMBER
———————————————————————————————————————
———————————
IS_
2 ONLINE
/home/oracle/tarun4/datafiles/redo02.log
NO
1 ONLINE
/home/oracle/tarun4/datafiles/redo01.log
NO
Database altered.
2 ‘/home/oracle/tarun4/datafiles/redo07.log’ to group 2;
Database altered.
Database altered.
Note:
*On dropping group it just updates the controlfile, the physical files are not removed and it as to
be removed using OS commands.
Database altered.
Note:
*You must force a logfile switch before you can drop the member.
*On dropping group it just updates the controlfile, the physical files are not removed and it as to
be removed using OS commands.
Clearing Online Redo Logfiles:
Alter database clear logfile command can used to reinitialize an online redo logfile.
Database altered.
Note:
*You can’t clear a group if it is current. Current Redo Logfile needed for crash recovery of
instance tarun4 (thread 1).
Use the unarchived Keyword to avoid archiving the corrupted online redo logfile.
Database altered.
Note:
*You can’t clear a group if it is current. Current Redo Logfile needed for crash recovery of
instance tarun4 (thread 1).
Database closed.
Database dismounted.
SQL> !
[oracle@reddy datafiles]$ ls
exit
Database mounted.
Database altered.
Database altered.
MEMBER
——————————————————————————–
IS_
—
2 ONLINE
/home/oracle/tarun4/datafiles/redo02.log
NO
1 ONLINE
/home/oracle/tarun4/datafiles/redo01.log
NO
MEMBER
——————————————————————————–
IS_
2 ONLINE
/home/oracle/redo07.log
NO
v$log view:
The following items are the most common values for the status column:
.Unused:Indicates that the online redo logfile group has never been written to.
This is the state of an online redo logfile that was just added.
.Current:Indicates the current online redo logfile group.This implies that the online redo logfile
group is active.
.Active:Indicates that the online redo logfile group is active but is not the current online redo
logfile group.It is needed for crash/instance recovery.
.Inactive:Indicates that the online redo logfile group is no longer needed for instance recovery.
v$logfile view:
Oracle architecture
1 Votes
ORACLE ARCHITECTURE
Oracle Server:
Oracle Database:
2 from v$database;
FLASHBACK_ON,DB_UNIQUE_NAME,PLATFORM_ID ,
NO RUBRICS 10 DISABLED
Oracle Instance:
User Process:
A Database User who needs to request information from the Database must first
The connection is requested using a Database interface tool, such as SQL*PLUS, and
beginning the User Process.
Server Process:
Once a User has established a connection, a Server Process is Started to Handle the User
Process request.
A Server Process can be either Dedicated Server Process or Shared Server Process.
In a Dedicated Server environment, the Server Process Handles the request of a Single
User Process.
In a Shared Server environment, the Server Process Handles the request of Several User
Process.
Physical Structure
DataFiles:
NAME
——————————————————————————–
10 5 ONLINE 10485760
/home/oracle/tarun4/datafiles/users01.dbf
——————————————————————————–
/home/oracle/tarun4/datafiles/bigfile.dbf
ControlFiles:
/home/oracle/tarun4/control/c1.ctl
NO 16384 440
/home/oracle/tarun4/control/c2.ctl
NO 16384 440
RedologFiles:
NO
1 ONLINE /home/oracle/tarun4/datafiles/redo01.log
NO
3 ONLINE /home/oracle/tarun4/datafiles/redo03.log
NO
NO
Password File:
—————————— —– —–
A1 TRUE FALSE
Creating Passwordfile:
password=—- entries=5
Parameter File:
NAME TYPE
———————————— ———–
VALUE
——————————
spfile string
/home/oracle/oracle/product/10
.2.0/db_1/dbs/spfiletarun4.ora
————————————————————————————-
————————————————————————————-
————————————————————————————–
————————————————————————————–
*.background_dump_dest=’/home/oracle/tarun4/bdump’
*.compatible=’10.2.0.1.0′
*.control_files=’/home/oracle/tarun4/control/c1.ctl’
*.db_block_size=4096
*.db_cache_size=62914560
*.db_name=’RUBRICS’
*.log_archive_dest=’/home/oracle/tarun4/archive’
*.log_archive_format=’arch_%t_%r_%s.arc’
*.remote_login_passwordfile=’exclusive’
*.shared_pool_size=232m
*.undo_management=’auto’
*.user_dump_dest=’/home/oracle/tarun4/udump’
Archived RedoLogFiles:
Are offline copies of the online RedologFiles that may be necessary to recover from
media failures.
It is an Optional file which will be created only if the database is in Archivelog mode.
By default it will be No Archivelog mode.
If Archivelog feature is enabled then every log switch in the redologfile generates a
Archivelog file and the generated Archivelog file will be placed in Archive destination.
Each switch in redolog will have one archive file.The switch may be either
What ever the contents present in the redologfile at the time of logswitch will be size of
Archivelog file.
/home/oracle/tarun4/archive/arch_1_672425039_01.arc
/home/oracle/tarun4/archive/arch_1_672425039_02.arc
LOGICAL STRUCTURE
TABLESPACE
SEGMENT
EXTENT
BLOCK
LOGICAL STRUCTURE:
Dictates how the Physical space of a database is used.
A Logical Structure hierarchy exists as follows:
A tablespace contains one or more segments.
An extent is made up of Logical blocks.
A block is the smallest unit for read and write operations.
The Oracle Server enables fine-grained control of disk space use through tablespace and
Logical Storage Structures, including segments,extents, and data blocks.
TABLESPACE:
An Oracle database can be logically grouped into smaller logical areas of space known as
tablespaces.
Tablespace may logically contain a single type of segment or different type of segments.
SEGMENT:
A Segment is the space allocated for a specific Logical storage structure within a
Tablespace.
A tablespace may consists of one or more Segments.
A Segment cannot span tablespaces; however, a Segment can span multiple data
EXTENT:
BLOCK:
The Oracle Server manages the storage space in the data files in units called Oracle
blocks or data blocks.
Oracle data block are the smallest units of storage that the Oracle Server can allocate,read
or write.
The Standard data block size for an Oracle database is specified by the
DB_BLOCK_SIZE initialization parameter when the database is created.
The Maximum data block size is dependent on the operating system.
Oracle blocks are made up of multiple block sizes.
Oracle supports 5 block sizes 2k,4k,8k,16k,32k.
The data block size should be a multiple of the operating system block size to avoid
unnecessary I/O.
CONTROL FILE MANAGEMENT
Posted by Narashim Reddy .R on July 29, 2009
Rate This
Note:
Before proceeding take Full Backup of Control and Datafiles in All the cases.
Multiplexing(P file):
Enter password:
SQL> startup;
Database mounted.
Database opened.
NAME
——————————————————————————
/home/oracle/rub/control/c1.ctl
Database closed.
Database dismounted.
SQL> !
[oracle@reddy control]$ ls
c1.ctl
[oracle@reddy control]$ ls
c1.ctl c2.ctl
*.background_dump_dest=’/home/oracle/rub/bdump’
*.compatible=’10.2.0.1.0′
*.control_files=’/home/oracle/rub/control/c1.ctl’,'/home/oracle/rub/control/c2.ctl’
*.db_block_size=4096
*.db_name=’rub7′
*.log_archive_dest=’/home/oracle/rub/archive’
*.log_archive_format=’arch_%t_%r_%s.arc’
*.log_archive_start=true
*.remote_login_passwordfile=’exclusive’
*.shared_pool_size=250m
*.undo_management=’auto’
*.user_dump_dest=’/home/oracle/rub/udump’
timed_statistics=true
:wq!
[oracle@reddy dbs]$ cd
Enter password:
File created.
SQL> startup;
Database mounted.
Database opened.
SQL> select name from v$controlfile;
NAME
——————————————————————————-
/home/oracle/rub/control/c1.ctl
/home/oracle/rub/control/c2.ctl
Multiplexing(SP file):
Enter password:
Connected to:
NAME
——————————————————————————–
/home/oracle/rub/control/c1.ctl
System altered.
Database closed.
Database dismounted.
File created.
SQL> !
[oracle@reddy control]$ ls
c1.ctl
[oracle@reddy control]$ ls
c1.ctl c2.ctl
[oracle@reddy control]$ cd
Enter password:
SQL> startup;
Database mounted.
Database opened.
NAME
——————————————————————————–
/home/oracle/rub/control/c1.ctl
/home/oracle/rub/control/c2.ctl
Enter password:
SQL> startup;
Database mounted.
Database opened.
Database altered.
Database closed.
Database dismounted.
SQL> !
To remove the unwanted lines use the commands (esc :set nu, (n.no) dd)
1 STARTUP NOMOUNT
2 CREATE CONTROLFILE REUSE DATABASE “RUB7″ NORESETLOGS
ARCHIVELOG
3 MAXLOGFILES 4
4 MAXLOGMEMBERS 4
5 MAXDATAFILES 100
6 MAXINSTANCES 1
7 MAXLOGHISTORY 292
8 LOGFILE
11 — STANDBY LOGFILE
12 DATAFILE
13 ‘/home/oracle/rub/datafiles/system01.dbf’,
14 ‘/home/oracle/rub/datafiles/undotbs1.dbf’,
15 ‘/home/oracle/rub/datafiles/sysaux01.dbf’,
16 ‘/home/oracle/rub/datafiles/users01.dbf’
18 ;
[oracle@reddy control]$ ls
[oracle@reddy control]$
[oracle@reddy control]$ sqlplus sys as sysdba
Enter password:
SQL> @/home/oracle/rub/udump/reddy.sql
Database altered.
Enter password:
Connected to:
Database altered.
Database closed.
Database dismounted.
SQL> !
1 STARTUP NOMOUNT
ARCHIVELOG
3 MAXLOGFILES 8
4 MAXLOGMEMBERS 4
5 MAXDATAFILES 100
6 MAXINSTANCES 1
7 MAXLOGHISTORY 292
8 LOGFILE
11 — STANDBY LOGFILE
12 DATAFILE
13 ‘/home/oracle/rub/datafiles/system01.dbf’,
14 ‘/home/oracle/rub/datafiles/undotbs1.dbf’,
15 ‘/home/oracle/rub/datafiles/sysaux01.dbf’,
16 ‘/home/oracle/rub/datafiles/users01.dbf’
18 ;
[oracle@reddy udump]$ cd
[oracle@reddy control]$ ls
c1.ctl c2.ctl
Enter password:
Connected to an idle instance.
SQL> @/home/oracle/rub/udump/reddy1.sql
Database altered.
Enter password:
SQL> startup;
Database mounted.
Database opened.
NAME
———
RUB7
Database altered.
Database closed.
Database dismounted.
SQL> !
1 STARTUP NOMOUNT
ARCHIVELOG
3 MAXLOGFILES 8
4 MAXLOGMEMBERS 4
5 MAXDATAFILES 100
6 MAXINSTANCES 1
7 MAXLOGHISTORY 292
8 LOGFILE
11 — STANDBY LOGFILE
12 DATAFILE
13 ‘/home/oracle/rub/datafiles/system01.dbf’,
14 ‘/home/oracle/rub/datafiles/undotbs1.dbf’,
15 ‘/home/oracle/rub/datafiles/sysaux01.dbf’,
16 ‘/home/oracle/rub/datafiles/users01.dbf’
18;
: x
*.background_dump_dest=’/home/oracle/rub/bdump’
*.compatible=’10.2.0.1.0′
*.control_files=’/home/oracle/rub/control/c1.ctl’
*.db_block_size=4096
*.db_name=’rub’
*.log_archive_dest=’/home/oracle/rub/archive’
*.log_archive_format=’arch_%t_%r_%s.arc’
*.log_archive_start=true
*.remote_login_passwordfile=’exclusive’
*.shared_pool_size=250m
*.undo_management=’auto’
*.user_dump_dest=’/home/oracle/rub/udump’
timed_statistics=true
[oracle@reddy control]$ ls
c1.ctl c2.ctl
[oracle@reddy control]$ rm -rf *.ctl
[oracle@reddy control]$ ls
Enter password:
File created.
SQL> @/home/oracle/rub/udump/reddy2.sql
Database altered.
NAME
———
RUB
PASSWORD FILE MANAGEMENT
Posted by Narashim Reddy .R on July 28, 2009
Rate This
To make a normal user as super user password file is required.User needs SYSDBA privilege.
[oracle@reddy~]$ vi /home/oracle/oracle/product/10.2.0/db_1/dbs/inittarun4.ora
’none’ ->Default
remote_os_roles=true
:wq!
Creating Passwordfile:
SQL> startup;
Connected.
—————————— —– —–
SYS TRUE TRUE
A1 TRUE FALSE
Installation steps
Posted by Narashim Reddy .R on July 28, 2009
Rate This
Installation steps:
Pre-Installation:
– - – - – - – -
– - – - – - – -
kernel.shmmax=536870912
kernel.semmsl=250
kernel.semopm=100
kernel.fs.file-max=44278
:wq!
(b)Create a Group
[oracle@reddy ~]$ groupadd dba
[oracle@reddy ~]$ df -h
Installation:
[oracle@reddy database]$ ls
doc install response runInstaller stage welcome.html
Post-Installation:
# .bash_profile
. ~/.bashrc
fi
PATH=$PATH:$HOME/bin
ORACLE_HOME=/home/oracle/oracle/product/10.2.0/db_1
LD_LIBRARY_PATH=$ORACLE_HOME/lib
PATH=$ORACLE_HOME/bin:$PATH
:wq!
(or)
Enter password:
SQL>
LISTENER CONFIGURATION STEPS
Posted by Narashim Reddy .R on July 28, 2009
Rate This
GLOBAL_NAME
RUB7
[oracle@reddy ~]$ cd
/home/oracle/oracle/product/10.2.0/db_1/network/admin/
[oracle@reddy admin]$ ls
listener.ora tnsnames.ora
-PROFILE
-SERVICE NAMING
-LISTENERS(Select)
LISTENER NAME:Listener
Host:(Local IP address)
Port:1521
:rub7
SID:rub
File
exit
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = rub7)
(ORACLE_HOME = /home/oracle/oracle/product/10.2.0/db_1)
(SID_NAME = rub)
)
)
LISTENER =
(DESCRIPTION =
)
:wq!
[oracle@reddy admin]$ cd
LSNRCTL> status
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)
(HOST=192.168.1.9)(PORT=1521)))
TNS-00511: No listener
LSNRCTL> start
————————
Alias LISTENER
SNMP OFF
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.9)
(PORT=1521)))
Services Summary…
LSNRCTL> stop
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)
(HOST=192.168.1.9)(PORT=1521)))
LSNRCTL> exit
[oracle@reddy ~]$
DATABASE CREATION
Posted by Narashim Reddy .R on July 27, 2009
Rate This
STEPS:
# .bash_profile
. ~/.bashrc
fi
PATH=$PATH:$HOME/bin
ORACLE_HOME=/home/oracle/oracle/product/10.2.0/db_1
LD_LIBRARY_PATH=$ORACLE_HOME/lib
PATH=$ORACLE_HOME/bin:$PATH
:wq!
*.background_dump_dest=’/home/oracle/rub/bdump’
*.compatible=’10.2.0.1.0′
*.control_files=’/home/oracle/rub/control/c1.ctl’
*.db_block_size=4096
*.db_name=’rub7′
*.log_archive_dest=’/home/oracle/rub/archive’
*.log_archive_format=’arch_%t_%r_%s.arc’
*.log_archive_start=true
*.remote_login_passwordfile=’exclusive’
*.shared_pool_size=250m
*.undo_management=’auto’
*.user_dump_dest=’/home/oracle/rub/udump’
:wq!
[oracle@reddy rub]$ ls
maxlogfiles 4
maxlogmembers 4
maxloghistory 10
maxinstances 1
datafile ‘/home/oracle/rub/datafiles/undotbs1.dbf’
:wq!
[oracle@reddy rub]$ cd
SQL> @/home/oracle/rub/dbc.sql
SQL> @?/rdbms/admin/catalog.sql
SQL> @?/rdbms/admin/catproc.sql
DATABASE CREATION »
Cloning an Oracle Database
Posted by Narashim Reddy .R on July 27, 2009
1 Votes
Table of Contents
1. Purpose of the document
2. Document Usage
3. Overview of the Procedure
3.1 Introduction
3.2 Environments
3.3 Assumption
3.4 Cloning Process
3.4.1 Steps to be followed in Primary database:
3.4.2 Steps to be followed in the Secondary database server:
5. Conclusion
1. This document illustrates a process to clone an Oracle database using hot backup. The
following sections are covered in this document
Overview
Environments
Assumptions
Cloning process
2. Document Usage
This document can be useful for any Oracle DBA for cloning an Oracle database. Generally
cloning databases with the help of source database hot backup is a standard process to effectively
and efficiently create a replica of the source database. The process illustrated in this document
can be used by any DBA who wants to create a replica of an Oracle database with the help of hot
backup and the associated archive logs.
Cloning database is one of the routine DBA activities. Any DBA who administers various
environments and is supporting the application development team for database activities has to
periodically synchronize the acceptance/testing/development with the Production data.
This frequency of synchronization depends upon the business and application development
teams requirements. Generally this process can be done with the below mentioned procedures
1)EXPORT/IMPORT utilities
2)DATA PUMP
3)Cold Backup Restoration
4)Hot Backup Recovery
Each of the above mentioned process has got its own pros and cons. To state a few vital reasons
why Hot backup recovery process is chosen widely
3.2 Environments
3.3 Assumption
2)LSN number
Where SID is the instance name given above in the edited pfile
3) In the control file trace Use the “SET #2. RESTLOGS case” CREATE CONTROLFILE
section (Since we don’t use the primary database redolog files, we use this option). In that
section Copy from “CREATE CONTROLFILE” to “CHARACTER SET ” to another file.
Save the file as cr_control.sql
4) Move the ftp ed Hot backup DATAFILE from temporary location of specific location as
specified in the control file cr_control.sql
5) Move the archived logs from temporary location to the location specified in log_archive_dest
in pfile
6) If Windows,
ORADIM -NEW -SID sid | -SRVC service [-INTPWD password] [-MAXUSERS number] [-
STARTMODE a|m] [-PFILE file] [-TIMEOUT secs]
SET ORACLE_SID=
Sqlplus “/ as sysdba”
7) If UNIX,
EXPORT ORACLE_SID=
Sqlplus “/ as sysdba”
STARTUP NOMOUNT
If Windows
@/cr_control.sql
If Unix
@\cr_control.sql if in Unix
9) Recover the database using backup control file. In the SQL> prompt give
10)The recovery process will keep prompting for archive logs. Give return for each prompt of
archive log.
Since the required archive logs from Primary database are restored in archive_log_dest of
secondary, it will get applied for every return you give in the prompt.
Once the recovery process prompts for the archive log with the LSN number noted in the
Primary database,
Database opened.
SHUTDOWN IMMEDIATE;
STARTUP;
TNS CONFIGURATION STEPS
Posted by Narashim Reddy .R on July 28, 2009
Rate This
[oracle@reddy admin]$ ls
-LOCAL
-PROFILE
-SERVICE NAMING(Select)
-LISTENERS
next
next
next
finish
File
exit
RUBRICS =
(DESCRIPTION =
(ADDRESS_LIST =
)
(CONNECT_DATA =
)
:wq!
Enter password:
SQL>