Beruflich Dokumente
Kultur Dokumente
2. Press the "tab" key to move focus to the "Skip" key, then press the "Enter" key to
continue.
5. Select the relevant keyboard setting, then click the "Next" button.
7. Check the "Review and modify partitioning layout" option, then allow the installer
to automatically partition the disk by clicking on the "Next" button
9. The installer will list the default partitioning scheme for your size disk.
The following screen shots show the actions I take for small test installations
10. Edit the "/boot" partition, setting it to "150M" and "Fixed size", then click the "OK"
button
11. The "/root" and "/swap" partitions are part of a volume group.
12. Edit the "/root" partition, setting it to "8000 MB", then click the "OK" button.
13.Edit the "swap" partition, setting it to "2048M", then click the "OK" button.
If you need additional swap space, simply make this partition bigger.
14. The partitions screen should now looks something like the following picture, then
click the "Next" button.
15. Accept the boot loader settings by clicking the "Next" button.
16. Configure the network interface with the apropriate settings. This can be done
automatically using DHCP, or manually.
17. If you are not using DHCP, enter the appropriate IP addess and subnet mask,
then click the "OK" button.
18. If you are not using DHCP, enter the host name, gateway and DNS information,
then click the "Next" button.
20. Select the relevant city by clicking on the map. Click on the "Next" button to
proceed.
21.Enter a root password for the server, then click the "Next" button to proceed.
22.Select the "Customize now" option and the appropriate installation type and click
the "Next" button.
23. The "Package Group Selection" screen allows you to select the required package
groups, and individual packages within the details section. When you've made your
selection, click the "Next" button.
25. Click the "Continue" button on the "Required Install Media" screen.
26. During the installation phase, enter the appropriate CDs as requested.
30. On the Firewall screen, choose the "Disabled" option and click the "Forward"
button.
32. On the SELinux screen, choose the "Disabled" option and click the "Forward"
button.
34. Accept the default setting on the Kdump screen by clicking the "Forward" button.
35. Adjust the Date and Time settings if necessary, and click the "Forward" Button.
36. If you have a Red Hat Network account, you can enter it here and register your
system. Alternatively, you can pick the "No, I prefer to register at a later time" option
and click the "Forward" button to avoid this step.
37. Create an additional system user if required, and click the "Next" button.
38. If you chose not to define an additional system user, click the "Continue" button
on the resulting warning dialog.
42. Once the system has rebooted, you are presented with the login screen.
43. Once logged in, you are ready to use the desktop.
Between 1 GB and 2 GB
Between 2 GB and 8 GB
More than 8 GB
/proc/meminfo
df h /tmp
Making Directories
To make directories, execute:
su - root
mkdir p /app/oracle/product/10.2.0/ [u01 if needed]
Checking Kernel Parameters
To see all kernel parameters, execute:
su - root
sysctl a
The options for sysctl are as follows:
-a List all the currently available string or integer values. This is
the default, if no parameters are given to sysctl.
Verify that the kernel parameters shown in the following table are set to values
greater than or equal to the recommended value shown. Do not change the value of
any kernel parameter on a system where it is already higher than listed as minimum
requirement.
Parameter
Value
File
semmsl
250
/proc/sys/kernel/sem
semmns
32000
semopm
100
semmni
128
shmall
2097152
/proc/sys/kernel/shmall
shmmax
/proc/sys/kernel/shmmax
Parameter
Value
File
shmmni
4096
/proc/sys/kernel/shmmni
file-max
65536
/proc/sys/fs/file-max
ip_local_port_range Minimum:1024
/proc/sys/net/ipv4/ip_local_port_range
Maximum: 65000
rmem_default
1048576
/proc/sys/net/core/rmem_default
rmem_max
1048576
/proc/sys/net/core/rmem_max
wmem_default
262144
/proc/sys/net/core/wmem_default
wmem_max
262144
/proc/sys/net/core/wmem_max
We added the following lines to the /etc/sysctl.conf file which is used during the
boot process:
# Kernel Parameters for Oracle 10.2.0
kernel.shmall = 2097152
kernel.shmmax = 2147483648
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.file-max = 65536
net.ipv4.ip_local_port_range = 1024 65000
net.core.rmem_default = 1048576
net.core.rmem_max = 1048576
net.core.wmem_default = 262144
net.core.wmem_max = 262144
Creating Oracle Groups
To create the oracle group(s), execute the following commands:
su root
groupadd <groupname> [For Primary Group]
groupadd <groupname> [For Secondary Group .If Needed]
Creating Oracle User Account
To create the oracle account execute the following commands:
su root
useradd c "Oracle Owner" g oinstall G dba d
/app/oracle/product/10.2.0/
oracle
ORACLE_SID=GENTIC
LISTENER_NAME=$ORACLE_SID
ORACLE_BASE=/export/home/oracle
ORACLE_HOME=$ORACLE_BASE/product/10.2.0
ORACLE_DOC=$ORACLE_HOME/doc
LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
TNS_ADMIN=/export/home/oracle/admin/sqlnet
export
export
export
export
export
export
PATH=$ORACLE_HOME/bin:$PATH
NLS_LANG=american_america.al32utf8
ORA_NLS10=$ORACLE_HOME/nls/data
TEMP=/tmp
TMPDIR=/tmp
EDITOR=vi
./runInstaller
The DBCA screen will appear. Please follow the wizard to install the oracle on your
machine.
$ cd /app/oracle/admin/xyz
$ mkdir adump cdump bdump dpdump pfile udump script
Create/modify init.ora file under pfile
Modify the following parameters in init.ora file according to your need
db_name, background_dump_dest,core_dump_dest,user_dump_dest ,
control_files , db_recovery_file_dest , audit_file_dest, SERVICE
Create folders for physical files ( Datafiles, Redofiles, Controlfiles,etc.,)
$ cd
/app/oracle/oradata/<db_name>
(Example db_name=xyz)
$ mkdir xyz
Create the password for the database
$ cd /app/oracle/product/10.2.0/dbs/
$ export ORACLE_SID=<db_name>
$ orapwd file=oraxyzpw password=xyz
entries=3
force=y
Connect to SQLPLUS
$ sqlplus /nolog
SQL> connect sys as sysdba
Password: xyz
Startup the Instance
SQL> startup pfile=/app/oracle/admin/<db_name>/pfile/init.ora
nomount
Note: Please ensure that the name given in init.ora file and database creation
script are same
NOARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 2
MAXDATAFILES 240
MAXINSTANCES 1
MAXLOGHISTORY 113
LOGFILE
GROUP 1 ('/u03/oradata/oldlsq/log1a.dbf',
'/u03/oradata/olslsq/log1b.dbf') SIZE 30M,
GROUP 2 ('/u04/oradata/oldlsq/log2a.dbf',
'/u04/oradata/oldlsq/log2b.dbf') SIZE 30M
DATAFILE
'/u01/oradata/oldlsq/system01.dbf',
'/u01/oradata/oldlsq/mydatabase.dbf'
;
# Recovery is required if any of the datafiles are restored
# backups, or if the last shutdown was not normal or
immediate.
RECOVER DATABASE
# Database can now be opened normally.
ALTER DATABASE OPEN;
Shutdown the target database
Copy all data files into the new directories on the new server.
You may change the file names if you want, but you must edit the controlfile to reflect
the new data files names on the new server.
cp
cp
cp
cp
/u01/oradata/oldlsq/*
/u01/oradata/oldlsq/*
/u03/oradata/oldlsq/*
/u04/oradata/oldlsq/*
newhost:/u01/oradata/newlsq
newhost:/u01/oradata/newlsq
newhost:/u03/oradata/newlsq
newhost:/u04/oradata/newlsq
Copy and Edit the Control file Using the output syntax from STEP 1, modify
the controlfile creation script by changing the following:
Old:
CREATE CONTROLFILE REUSE DATABASE "OLDLSQ" NORESETLOGS
New:
CREATE CONTROLFILE SET DATABASE "NEWLSQ" RESETLOGS
Remove the recover database and alter database open syntax
Description
V$TABLESPACE
View
Description
DBA_TABLESPACES,
USER_TABLESPACES
DBA_TABLESPACE_GROUPS
DBA_SEGMENTS,
USER_SEGMENTS
V$DATAFILE
V$TEMPFILE
DBA_DATA_FILES
DBA_TEMP_FILES
V$TEMP_EXTENT_MAP
V$TEMP_EXTENT_POOL
V$TEMP_SPACE_HEADER
DBA_USERS
DBA_TS_QUOTAS
V$SORT_SEGMENT
View
Description
instance. The view is only updated when the
tablespace is of the TEMPORARY type.
V$TEMPSEG_USAGE
After the SYSTEM tablespace is migrated to locally managed, any dictionarymanaged tablespaces in the database cannot be made read/write. If you want to be
able to use the dictionary-managed tablespaces in read/write mode, then Oracle
recommends that you first migrate these tablespaces to locally managed before
migrating the SYSTEM tablespace.
Listing Tablespaces and Default Storage Parameters
SQL>SELECT TABLESPACE_NAME "TABLESPACE",INITIAL_EXTENT
INITIAL_EXT",NEXT_EXTENT "NEXT_EXT",MIN_EXTENTS "MIN_EXT",
MAX_EXTENTS "MAX_EXT",PCT_INCREASE FROM DBA_TABLESPACES;
Temporary Tablespaces
Creating a Locally Managed Temporary Tablespace
SQL>CREATE TEMPORARY TABLESPACE lmtemp TEMPFILE
'/u02/oracle/data/lmtemp01.dbf' SIZE 20M REUSE EXTENT
MANAGEMENT LOCAL UNIFORM SIZE 16M;
Altering a Locally Managed Temporary Tablespace
SQL>ALTER TABLESPACE lmtemp
ADD TEMPFILE '/u02/oracle/data/lmtemp02.dbf' SIZE 18M
REUSE;
SQL>ALTER TABLESPACE lmtemp TEMPFILE OFFLINE;
SQL>ALTER TABLESPACE lmtemp TEMPFILE ONLINE;
SQL>ALTER DATABASE TEMPFILE '/u02/oracle/data/lmtemp02.dbf'
OFFLINE;
SQL>ALTER DATABASE TEMPFILE '/u02/oracle/data/lmtemp02.dbf'
ONLINE;
Description
V$UNDOSTAT
V$ROLLSTAT
V$TRANSACTION
DBA_UNDO_EXTENTS Shows the status and size of each extent in the undo
tablespace.
DBA_HIST_UNDOSTAT Contains
statistical
information.
snapshots
of
V$UNDOSTAT
The following example shows the results of a query on the V$UNDOSTAT view.
SQL>SELECT TO_CHAR(BEGIN_TIME, 'MM/DD/YYYY HH24:MI:SS')
BEGIN_TIME, TO_CHAR(END_TIME, 'MM/DD/YYYY HH24:MI:SS')
END_TIME,
UNDOTSN, UNDOBLKS, TXNCOUNT, MAXCONCURRENCY AS "MAXCON"
FROM v$UNDOSTAT WHERE rownum <= 144;
LOG_MODE
-----------NOARCHIVELOG
In INIT.ora file add the following parameter
############################
# Archive Log Destinations -benr(10/15/04)
############################
log_archive_dest_1='location=/u02/oradata/cuddle/archive'
log_archive_start=TRUE
Note that we're not actually required to specify the location of the log destination, but
if you don't it'll end up in strange places (in my test it went to $ORACLE_HOME/dbs
making a mess). You can specify as many as 10 diffrent archive log destinations by
using the paramters log_archive_dest_1 through log_archive_dest_10. Remember, if
you run out of space in your archive log destination the database will shut down!
Now we can startup the database in mount mode and put it in archivelog mode.
SQL> startup mount
ORACLE instance started.
SQL> alter database archivelog;
Database altered.
SQL> alter database open;
Database altered.
There are several system views that can provide us with information regarding
archives, such as:
V$DATABASE
Identifies whether the database is in ARCHIVELOG or NOARCHIVELOG
mode and whether MANUAL (archiving mode) has been specified.
V$ARCHIVED_LOG
Displays historical archived log information from the control file. If you use a
recovery catalog, the RC_ARCHIVED_LOG view contains similar information.
V$ARCHIVE_DEST
Describes the current instance, all archive destinations, and the current value,
mode, and status of these destinations.
V$ARCHIVE_PROCESSES
Displays information about the state of the various archive processes for an
instance.
V$BACKUP_REDOLOG
Contains information about any backups of archived logs. If you use a
recovery catalog, the RC_BACKUP_REDOLOG contains similar information.
V$LOG
Displays all redo log groups for the database and indicates which need to be
archived.
V$LOG_HISTORY
Contains log history information such as which logs have been archived and
the SCN range for each archived log.
Using these tables we can verify that we are infact in ARCHIVELOG mode:
SQL> select log_mode from v$database;
LOG_MODE
-----------ARCHIVELOG
SQL> select DEST_NAME,STATUS,DESTINATION from V$ARCHIVE_DEST;
The CREATE CONTROLFILE Statement (It needed only you want to recreate a
control file)
CREATE CONTROLFILE
SET DATABASE <db name>
LOGFILE GROUP 1 ('/u01/oracle/<db name>/redo01_01.log',
'/u01/oracle/<db name>/redo01_02.log'),
GROUP 2 ('/u01/oracle/<db name>/redo02_01.log',
'/u01/oracle/<db name>/redo02_02.log'),
GROUP 3 ('/u01/oracle/<db name>/redo03_01.log',
'/u01/oracle/<db name>/redo03_02.log')
RESETLOGS
DATAFILE '/u01/oracle/<db name>/system01.dbf' SIZE 3M,
'/u01/oracle/<db name>/rbs01.dbs' SIZE 5M,
'/u01/oracle/<db name>/users01.dbs' SIZE 5M,
'/u01/oracle/prod/temp01.dbs' SIZE 5M
MAXLOGFILES 50
MAXLOGMEMBERS 3
MAXLOGHISTORY 400
MAXDATAFILES 200
MAXINSTANCES 6
ARCHIVELOG;
View
Description
V$DATABASE
V$CONTROLFILE
Description
V$LOG
Displays the redo log file information from the control file
V$LOGFILE
V$LOG_HISTORY
did not need the additional privileges CONNECT used to provide. Instead, only
CREATE SESSION was actually needed, and in fact that is the only privilege
CONNECT presently retains.
Specifying a Name
Within each database, a user name must be unique with respect to other user
names and roles. A user and role cannot have the same name. Furthermore, each
user has an associated schema. Within a schema, each schema object must have a
unique name.
Assigning a Default Tablespace
Each user should have a default tablespace. When a user creates a schema object
and specifies no tablespace to contain it, Oracle Database stores the object in the
default user tablespace.
Assigning Tablespace Quotas
By default, a user has no quota on any tablespace in the database. If the user has
the privilege to create a schema object, then you must assign a quota to allow the
user to create objects. Minimally, assign users a quota for the default tablespace,
and additional quotas for other tablespaces in which they can create objects.
Assigning a Temporary Tablespace
Each user also should be assigned a temporary tablespace. When a user executes a
SQL statement that requires a temporary segment, Oracle stores the segment in the
user's temporary tablespace. These temporary segments are created by the system
when doing sorts or joins and are owned by SYS, which has resource privileges in all
tablespaces.
Note:
If your SYSTEM tablespace is locally managed, then users must be assigned a
specific default (locally managed) temporary tablespace. They may not be allowed to
default to using the SYSTEM tablespace because temporary objects cannot be
placed in permanent locally managed tablespaces.
Specifying a Profile
You also specify a profile when you create a user. A profile is a set of limits on
database resources and password access to the database. If no profile is specified,
then the user is assigned a default profile.
Description
DBA_USERS
ALL_USERS
USER_USERS
DBA_TS_QUOTAS
USER_TS_QUOTAS
USER_PASSWORD_LIMITS Describes the password profile parameters that are
assigned to the user
View
Description
RESOURCE_COST
V$SESSION
V$SESSTAT
V$STATNAME
PROXY_USERS
If you examine the DBA_TAB_PRIVS view, then you will see that hr is shown as the
grantor of the privilege:
SQL> SELECT GRANTEE, OWNER, GRANTOR, PRIVILEGE, GRANTABLE
FROM DBA_TAB_PRIVS WHERE TABLE_NAME = 'EMPLOYEES' and OWNER =
'HR';
SQL>GRANT SELECT ON hr.employees TO clark;
Granting Privileges on Columns
SQL>GRANT INSERT (acct_no) ON accounts TO scott;
SQL>GRANT INSERT(ename, job) ON emp TO jfee, tsmith;
Revoking User Privileges and Roles
Revoking System Privileges and Roles
SQL>REVOKE CREATE TABLE, accts_rec FROM tsmith;
Revoking Object Privileges
SQL>REVOKE SELECT, insert ON emp FROM jfee, tsmith;
SQL>REVOKE ALL ON dept FROM human_resources;
Revoking Object Privileges on Behalf of the Object Owner
SQL>REVOKE
Description
DBA_COL_PRIVS
ALL_COL_PRIVS
USER_COL_PRIVS
ALL_COL_PRIVS_MADE
ALL view lists column object grants for which the current
user is object owner or grantor. USER view describes
USER_COL_PRIVS_MADE column object grants for which the current user is the
grantor.
ALL_COL_PRIVS_RECD
ALL_TAB_PRIVS_MADE
ALL view lists the all object grants made by the current
user or made on the objects owned by the current user.
USER_TAB_PRIVS_MADE USER view lists grants on all objects owned by the
current user.
ALL_TAB_PRIVS_RECD
View
Description
DBA_ROLES
DBA_ROLE_PRIVS
USER_ROLE_PRIVS
DBA_SYS_PRIVS
USER_SYS_PRIVS
ROLE_ROLE_PRIVS
ROLE_SYS_PRIVS
ROLE_TAB_PRIVS
SESSION_PRIVS
SESSION_ROLES
This view lists the roles that are currently enabled to the
user.
FROM DBA_COL_PRIVS;
Listing the Current Privilege Domain of Your Session
SQL>SELECT * FROM SESSION_ROLES;
SQL>SELECT * FROM SESSION_PRIVS;
Listing Roles of the Database
SQL>SELECT * FROM DBA_ROLES;
Listing Information About the Privilege Domains of Roles
SQL>SELECT GRANTED_ROLE, ADMIN_OPTION
FROM ROLE_ROLE_PRIVS
WHERE ROLE = 'SYSTEM_ADMIN';
SQL>SELECT * FROM ROLE_SYS_PRIVS WHERE ROLE =
'SECURITY_ADMIN';
SQL>SELECT TABLE_NAME, PRIVILEGE FROM ROLE_TAB_PRIVS
WHERE ROLE = 'SECURITY_ADMIN';
Cold Backup
V$datafile Lists all the data files used in the database
SQL>select name from v$datafile;
Backup the control file and perform a trace of the control file using
SQL>alter database backup controlfile to
'/u10/backup/control.ctl';
SQL>alter database backup controlfile to trace;
Init.ora and config.ora Located under $ORACLE_HOME/dbs directory
Shut down the database
SQL>shutdown
Perform a backup
$cp /u01/oracle/users01.dbf /u10/backup
You can perform the backup of the Init.ora and config.ora files as follows:
$cp $ORACLE_HOME/dbs/init.ora /u10/backup
Hot Backup
Put the tablespace in the Backup mode and copy the data files.
SQL>alter tablespace USERS begin backup;
SQL>select file_name from dba_data_files
where tablespace_name='USERS';
$cp /u01/oracle/users01.dbf /u10/backup
$cp /u01/oracle/users02.dbf /u10/backup
The following command ends the backup process and puts the tablespace back in
normal mode.
SQL>alter tablespace USERS end backup;
You have to repeat this process for all tablespaces. You can get the list of
tablespaces by using the following SQL statement:
SQL>select tablespace_name from dba_tablespaces;
Back up the control and Init.ora files.
SQL>alter database backup controlfile to
'/u10/backup/control.ctl';
You can copy the Init.ora file to a backup location using
$cp $ORACLE_HOME/dbs/initorcl.ora /u10/backup
Stop archiving.
SQL>alter system switch logfile;
SQL>alter system archive log stop;
The first command switches redo log file and the second command stops the
archiver process.
Export :
Keyword
USERID
BUFFER
FILE
COMPRESS
GRANTS
INDEXES
ROWS
CONSTRAINTS
CONSISTENT
LOG
STATISTICS
DIRECT
FEEDBACK
HELP
MLS
FULL
OWNER
TABLES
RECORDLENGTH
INCTYPE
RECORD
PARFILE
Description (Default)
username/password
size of data buffer
output file (EXPDAT.DMP)
import into one extent (Y)
export grants (Y)
export indexes(Y)
export data rows (Y)
export table constraints (Y)
cross-table consistency (N)
log file of screen output (None)
analyze objects (ESTIMATE)
Bypass the SQLcommand processing layer (N) (new in
Oracle8)
Show a process meter (a dot) every X rows exported (0
Xvalue)
Shows help listing
MLS_LABEL_FORMAT Used with secure Oracle; we
won't cover these.
export entire file (N)
list of owner usernames
list of table names
length of IO record
incremental export type
track incr. export (Y)
parameter file name
IMPORT
Keyword
USERID
BUFFER
FILE
SHOW
IGNORE
RECORDLENGTH
GRANTS
INDEXES
ROWS
LOG
INDEXFILE
FULL
FROMUSER
TOUSER
TABLES
FEEDBACK
INCTYPE
COMMIT
PARFILE
DESTROY
CHARSET
Description (Default)
username/password
size of data buffer
Output file (EXPDAT.DMP)
just list file contents (N)
Ignore create errors (N)
length of IOrecord
Import grants (Y)
Import indexes (Y)
Import data rows (Y)
log file of screen output
write table/index info to specified file
Import entire file (N)
list of owner usernames
list of usernames
list of table names
Provide dot status graph (0)
incremental import type
commit array insert (N)
parameter file name
overwrite tablespace data (N)
char. set of export file (NLS_LANG)
EXPORT DP
Example: expdp scott/tiger DIRECTORY=dmpdir DUMPFILE=scott.dmp
Keyword
Description(Default)
ATTACH
CONTENT
DIRECTORY
DUMPFILE
ESTIMATE
ESTIMATE_ONLY
EXCLUDE
FILESIZE
FLASHBACK_SCN
FLASHBACK_TIME
FULL
HELP
INCLUDE
JOB_NAME
LOGFILE
NETWORK_LINK
NOLOGFILE
PARALLEL
PARFILE
QUERY
SCHEMAS
STATUS
TABLES
schema only.
TABLESPACES
TRANSPORT_FULL_CHECK
TRANSPORT_TABLESPACES
VERSION
IMPORT DP
Example: impdp scott/tiger DIRECTORY=dmpdir DUMPFILE=scott.dmp
Keyword
Description(Default)
ATTACH
CONTENT
DIRECTORY
DUMPFILE
ESTIMATE
ESTIMATE_ONLY
EXCLUDE
FILESIZE
FLASHBACK_SCN
FLASHBACK_TIME
FULL
HELP
INCLUDE
JOB_NAME
LOGFILE
NETWORK_LINK
NOLOGFILE
PARALLEL
PARFILE
QUERY
SCHEMAS
STATUS
TABLES
TABLESPACES
TRANSPORT_FULL_CHECK
TRANSPORT_TABLESPACES
VERSION
REMAP_DATAFILE
REMAP_SCHEMA
REMAP_TABLESPACE
REUSE_DATAFILES
SKIP_UNUSABLE_INDEXES
SQLFILE
STREAMS_CONFIGURATION
TABLE_EXISTS_ACTION
TRANSFORM
TRANSPORT_DATAFILES
In each case, the loss of a primary file and the restore of a backup has the following
implications for media recovery.
If you lose . . .
One
or
datafiles
Then . . .
more You must restore them from a backup and perform media
recovery. Recovery is required whenever the checkpoint SCN in
the datafile header does not match the checkpoint SCN for the
datafile that is recorded in the control file.
All copies of the You must restore a backup control file and then open the
If you lose . . .
Then . . .
Note:
Restore and recovery of Oracle-managed files is no different from restore and
recovery of user-named files.
Determining Which Datafiles Require Recovery
Use the following SQL*Plus commands to format the output of the query:
COL DF# FORMAT 999
COL DF_NAME FORMAT A35
COL TBSP_NAME FORMAT A7
COL STATUS FORMAT A7
COL ERROR FORMAT A10
COL CHANGE# FORMAT 99999999
SELECT r.FILE# AS df#, d.NAME AS df_name, t.NAME AS tbsp_name,
d.STATUS, r.ERROR, r.CHANGE#, r.TIME
FROM V$RECOVER_FILE r, V$DATAFILE d, V$TABLESPACE t
Status of
Status of
Online Logs Datafiles
Restore Procedure
Available
Current
Unavailable
Current
Available
Backup
Unavailable
Backup
If you . . .
Then . . .
If you . . .
Then . . .
BACKUP CONTROLFILE TO
TRACE before you made a
structural change to the database
Note:
If your character set is not the default US7ASCII, then you must specify the
character set as an argument to the CREATE CONTROLFILE statement. The
database character set is written to the alert log at startup. The character set
information is also recorded in the BACKUP CONTROLFILE TO TRACE output.
To create a new control file:
Start the database in NOMOUNT mode. For example, enter:
SQL>STARTUP NOMOUNT
Create the control file with the CREATE CONTROLFILE statement, specifying the
NORESETLOGS option. The following example assumes that the character set is
the default US7ASCII:
CREATE CONTROLFILE REUSE DATABASE SALES NORESETLOGS ARCHIVELOG
MAXLOGFILES 32
MAXLOGMEMBERS 2
MAXDATAFILES 32
MAXINSTANCES 16
MAXLOGHISTORY 1600
LOGFILE
GROUP 1 (
'/diska/prod/sales/db/log1t1.dbf',
'/diskb/prod/sales/db/log1t2.dbf'
) SIZE 100K
GROUP 2 (
'/diska/prod/sales/db/log2t1.dbf',
'/diskb/prod/sales/db/log2t2.dbf'
) SIZE 100K,
DATAFILE
'/diska/prod/sales/db/database1.dbf',
'/diskb/prod/sales/db/filea.dbf';
After creating the control file, the instance mounts the database.
Recover the database as normal (without specifying the USING BACKUP
CONTROLFILE clause):
SQL>RECOVER DATABASE
Open the database after recovery completes (RESETLOGS option not required):
SQL>ALTER DATABASE OPEN;
Immediately back up the control file. The following SQL statement backs up a
database's control file to /backup/control01.dbf:
SQL>ALTER DATABASE BACKUP CONTROLFILE TO
'/backup/control01.dbf' REUSE;
SQL>RECOVER DATABASE
Open the database.
SQL>ALTER DATABASE OPEN;
Recovering When Archived Logs Are in the Default Location
Recovering when the archived logs are in their default location is the simplest case.
As a log is needed, the database suggests the filename. If you are running
nonautomatic media recovery with SQL*Plus, then the output is displayed in this
format:
ORA-00279: Change #### generated at DD/MM/YY HH:MM:SS needed
for thread#
ORA-00289: Suggestion : logfile
ORA-00280: Change #### for thread # is in sequence #
Specify log: [<RET> for suggested | AUTO | FROM logsource |
CANCEL ]
For example, SQL*Plus displays output similar to the following:
ORA-00279: change 53577 generated at 11/26/02 19:20:58 needed
for thread 1
ORA-00289: suggestion :
/oracle/oradata/trgt/arch/arcr_1_802.arc
ORA-00280: change 53577 for thread 1 is in sequence #802
Specify log: [<RET> for suggested | AUTO | FROM logsource |
CANCEL ]
Similar messages are returned when you use an ALTER DATABASE ... RECOVER
statement. However, no prompt is displayed.
The database constructs suggested archived log filenames by concatenating the
current values of the initialization parameters LOG_ARCHIVE_DEST_n (where n is
the
highest
value
among
all
enabled,
local
destinations)
and
LOG_ARCHIVE_FORMAT and using log history data from the control file. The
following are possible settings:
LOG_ARCHIVE_DEST_1 = 'LOCATION = /oracle/oradata/trgt/arch/'
LOG_ARCHIVE_FORMAT = arcr_%t_%s.arc
SQL>SELECT NAME FROM V$ARCHIVED_LOG;
Thus, if all the required archived log files are mounted at the
LOG_ARCHIVE_DEST_1 destination, and if the value for LOG_ARCHIVE_FORMAT
is never altered, then the database can suggest and apply log files to complete
media recovery automatically.
Error
Possible Cause
Solution
ORA-27037:
Entered
wrong Reenter correct filename.
unable to obtain filename.
Restore backup archived redo log.
file status
Log is missing.
ORA-27047:
The log may have If you can locate an uncorrupted or
unable to read been partially written complete log copy, then apply the intact
the header block or become corrupted. copy and continue recovery.
of file
If no copy of the log exists and you know
the time of the last valid redo entry, then
you use incomplete recovery. Restore
backups and restart recovery.
Then . . .
Datafiles
in
the Database
SYSTEM tablespace or down.
datafiles with active
undo segments.
Datafiles not in the
SYSTEM tablespace or
datafiles that do not
contain active rollback
or undo segments.
Affected datafiles
are taken offline,
but the database
stays open.
database stops recovery when applying the redo record for the added files and lets
you confirm the filenames.
For example, suppose the following sequence of events occurs:
You back up the database.You create a new tablespace containing two datafiles:
/oracle/oradata/trgt/test01.dbf and /oracle/oradata/trgt/test02.dbf.
You later restore a backup control file and perform media recovery through the
CREATE TABLESPACE operation.
You may see the following error when applying the CREATE TABLESPACE redo
data:
ORA-00283:
ORA-01244:
recovery
ORA-01110:
ORA-01110:
The control file contains the name of the damaged file (that is, the control file
is current, or is a backup taken after the damaged datafile was added to the
database)
Note:
You cannot re-create any of the datafiles for the SYSTEM tablespace by using the
CREATE DATAFILE clause of the ALTER DATABASE statement because the
necessary redo is not available.
To re-create a datafile for recovery:
Create a new, empty datafile to replace a damaged datafile that has no
corresponding
backup.
For
example,
assume
that
the
datafile
?/oradata/trgt/users01.dbf has been damaged, and no backup is available. The
following statement re-creates the original datafile (same size) on disk2:
SQL>ALTER DATABASE CREATE DATAFILE
'?/oradata/trgt/users01.dbf' AS /disk2/users01.dbf';
This statement creates an empty file that is the same size as the lost file. The
database looks at information in the control file and the data dictionary to obtain size
information. The old datafile is renamed as the new datafile.
Perform media recovery on the empty datafile. For example, enter:
SQL>RECOVER DATAFILE '/disk2/users01.dbf'
All archived logs written after the original datafile was created must be applied to the
new, empty version of the lost datafile during recovery.
Recovering Through RESETLOGS with Created Control File: Scenario
You can recover backups through an OPEN RESETLOGS so long as:
You have a current, backup, or created control file that knows about the prior
incarnations
You have all available archived redo logs
If you need to re-create the control file, the trace file generated by ALTER
DATABASE BACKUP CONTROLFILE TO TRACE will contain the necessary
commands
to
re-construct
the
complete
incarnation
history.
The
Description
UNUSED
Status
Description
CURRENT
The online redo log is active, that is, needed for instance
recovery, and it is the log to which the database is currently
writing. The redo log can be open or closed.
ACTIVE
The online redo log is active, that is, needed for instance
recovery, but is not the log to which the database is
currently writing.It may be in use for block recovery, and
may or may not be archived.
CLEARING
CLEARING_CURRENT The current log is being cleared of a closed thread. The log
can stay in this status if there is some failure in the switch
such as an I/O error writing the new log header.
INACTIVE
If the hardware problem is temporary, then correct it. The log writer process
accesses the previously unavailable online redo log files as if the problem
never existed.
If the hardware problem is permanent, then drop the damaged member and
add a new member by using the following procedure.
Note:
The newly added member provides no redundancy until the log group is
reused.
Locate the filename of the damaged member in V$LOGFILE. The status is
INVALID if the file is inaccessible:
Inactive
Active
It is needed
crash recovery
Current
It is the log that the Attempt to clear the log; if impossible, then you must
If
the
group
is . . .
Then . . .
database
is restore a backup and perform incomplete recovery
currently writing to up to the most recent available redo log.
Your first task is to determine whether the damaged group is active or inactive.
Locate the filename of the lost redo log in V$LOGFILE and then look for the
group number corresponding to it. For example, enter:
SQL>SELECT GROUP#, STATUS, MEMBER FROM V$LOGFILE;
Determine which groups are active. For example, enter:
SQL>SELECT GROUP#, MEMBERS, STATUS, ARCHIVED
FROM V$LOG;
Losing an Inactive Online Redo Log Group
If all members of an online redo log group with INACTIVE status are damaged, then
the procedure depends on whether you can fix the media problem that damaged the
inactive redo log group.
If the failure
is . . .
Then . . .
Temporary
Fix the problem. LGWR can reuse the redo log group when required.
Permanent
The damaged inactive online redo log group eventually halts normal
database operation. Reinitialize the damaged group manually by
issuing the ALTER DATABASE CLEAR LOGFILE statement as
described in this section.
To clear an inactive, online redo log group that has been archived, use the following
procedure:
If the database is shut down, then start a new instance and mount the
database:
SQL>STARTUP MOUNT
Reinitialize the damaged log group. For example, to clear redo log group 2,
issue the following statement:
SQL>ALTER DATABASE CLEAR LOGFILE GROUP 2;
RMAN
Data Dictionary Objects
DBA_HIST_INSTANCE_RECOVERY
GV_$RECOVERY_STATUS
DBA_RECOVERABLE_SCRIPT
V_$FLASH_RECOVERY_AREA_USAGE
DBA_RECOVERABLE_SCRIPT_BLOCKS
V_$INSTANCE_RECOVERY
DBA_RECOVERABLE_SCRIPT_ERRORS
V_$RECOVER_FILE
DBA_RECOVERABLE_SCRIPT_PARAMS
V_$RECOVERY_FILE_DEST
GV_$INSTANCE_RECOVERY
V_$RECOVERY_FILE_STATUS
GV_$RECOVER_FILE
V_$RECOVERY_LOG
GV_$RECOVERY_FILE_STATUS
V_$RECOVERY_PROGRESS
GV_$RECOVERY_LOG
V_$RECOVERY_STATUS
GV_$RECOVERY_PROGRESS
Format Directives
Format
Description
%a
%A
Zero-filled activation ID
%c
The copy number of the backup piece within a set of duplexed backup
pieces.bMaximum value is 256
%d
Database name
%D
%e
%f
%F
Combines the DBID, day, month, year, and sequence into a unique and
repeatable generated name
%h
%I
DBID
%M
%n
%N
%p
Piece number within the backup set. This value starts at 1 for each backup
set and is incremented by 1 for each backup piece created. If a PROXY is
specified, the %p variable must be included in the FORMAT string either
explicitly or implicitly within %U.
%r
Resetlogs ID
%s
Backup set number. This number is a counter in the control file that is
incremented for each backup set. The counter value starts at 1 and is unique
for the lifetime of the control file. If you restore a backup control file, then
duplicate values can result. CREATE CONTROLFILE initializes the counter
at 1.
%S
%t
Backup set time stamp, a 4-byte value derived as the number of seconds
elapsed since a fixed reference time. The combination of %s and %t can be
used to form a unique name for the backup set.
%T
Year, month, and day in the Gregorian calendar in the format: YYYYMMDD
%u
%U
%Y
%%
$ sqlplus / as sysdba
SQL> CREATE TABLESPACE cat_tbs;
SQL> CREATE USER repoomega
IDENTIFIED BY oracle1
DEFAULT TABLESPACE cat_tbs
TEMPORARY TABLESPACE temp
QUOTA UNLIMITED ON cat_tbs;
RMAN> GRANT create session TO repoomega
RMAN> GRANT recovery_catalog_owner TO repoomega;
RMAN> GRANT execute ON dbms_stats TO repoomega; -- for demos
-- in the operating system shell
$ rman target / catalog repoomega/oracle1@repos
RMAN>SHOW ALL;
Configuring the parameters for RMAN
For Example:
RMAN>
RMAN>
copy;
RMAN>
RMAN>
RUN {
ALLOCATE CHANNEL d1 DEVICE TYPE DISK FORMAT '/u01/backups/
%U';
ALLOCATE CHANNEL d2 DEVICE TYPE DISK FORMAT '/u02/backups/
%U';
BACKUP DATABASE PLUS ARCHIVELOG;
RELEASE CHANNEL;
}
Allocate Maintenance Channel
RMAN> ALLOCATE CHANNEL FOR MAINTENANCE DEVICE TYPE DISK;
BACKUP
Back up a database, tablespace, datafile (current or copy), control file (current or
copy), SPFILE, archived log, or backup set.
BACKUP <BackupOperand> CHANNEL '<channel_id>' CHECK LOGICAL
COPIES <integer>
CUMULATIVE DEVICE TYPE <deviceSpecifier> DISKRATIO <integer>
DURATION
<FileNameConversionSpecification> FILERPERSET <integer> FORCE
< AUXILIARY FORMAT <formatSpec, NEW> | FORMAT <formatSpec>
<forRecoveryOfSpec>
FULL
<keep option>
MAXSETSIZE <sizeSpec>
<notBackedUpSpec>
NO CHECKSUM NO EXCLUDE POOL <integer> PROXY [ONLY] REUSE
SECTION SIZE <sizeSpec> <skipSpec>
TAG '<tag_name>' VALIDATE
BACKUP AS BACKUPSET
RMAN>BACKUP AS BACKUPSET DEVICE TYPE <device_identifier>
COPIES <integer>
DATABASE FORMAT '<location_and_format>' ....
RMAN>BACKUP AS BACKUPSET (DATAFILE 3, 4, 5, 6, 7) (DATAFILE 8,
9);
RMAN>BACKUP AS BACKUPSET DATAFILE 3, 4, 5, 6, 7, 8, 9;
RMAN > BACKUP INCREMENTAL LEVEL 1 FOR RECOVER OF COPY WITH TAG
'incr_upd' DATABASE FORMAT '/oradata/rman/161932/inc_%d_%T_%t_
%s_%p';
RUN {
RECOVER COPY OF DATABASE WITH TAG 'incr_update' UNTIL TIME
'SYSDATE-7';
BACKUP INCREMENTAL LEVEL 1 FOR RECOVER OF COPY WITH TAG
'incr_upd'
DATABASE;
}
BACKUP INCREMENTAL
RMAN>BACKUP INCREMENTAL LEVEL 0 DATABASE;
RMAN>BACKUP INCREMENTAL LEVEL 1 CUMULATIVE DATABASE;
RMAN>BACKUP INCREMENTAL LEVEL 1 DIFFERENTIAL TABLESPACE users;
6. exit;
7. rman target /
8. restore datafile '<datafile_name>';
9. recover datafile '<datafile_name>';
10. sql 'alter tablespace <tablespace_name> online';
Recovery of a Datafile that has no backups (database is up).
If a non system datafile that was not backed up since the last backup is missing,
recovery can be performed if all archived logs since the creation of the missing
datafile exist. Since the database is up you can check the tablespace name and put
it offline. The option offline immediate is used to avoid that the update of the datafile
header.
Pre requisites: All relevant archived logs.
1. sqlplus '/ as sysdba'
2. alter tablespace <tablespace_name> offline immediate;
3. alter database create datafile '/user/oradata/u01/dbtst/newdata01.dbf;
4. exit
5. rman target /
6. recover tablespace <tablespace_name>;
7. sql 'alter tablespace <tablespace_name> online';
If the create datafile command needs to be executed to place the datafile on a
location different than the original use:
alter database create datafile '/user/oradata/u01/dbtst/newdata01.dbf' as
'/user/oradata/u02/dbtst/newdata01.dbf'
Restore and Recovery of a Datafile to a different location. Database is up.
If a non system datafile is missing and its original location not available, restore
can be made to a different location and recovery performed. Pre requisites: All
relevant archived logs, complete cold or hot backup.
1. Use OS commands to restore the missing or corrupted datafile to the new
location, ie:
cp -p /user/backup/uman/user01.dbf /user/oradata/u02/dbtst/user01.dbf
2. alter tablespace <tablespace_name> offline immediate;
3. alter tablespace <tablespace_name> rename datafile
'/user/oradata/u01/dbtst/user01.dbf' to '/user/oradata/u02/dbtst/user01.dbf';
4. rman target /
5. recover tablespace <tablespace_name>;
6. sql 'alter tablespace <tablespace_name> online';
Control File Recovery
Always multiplex your controlfiles. If you loose only one controlfile you can replace it
with the one you have in place, and startup the Database. If both controlfiles are
missing, the database will crash. Pre requisites: A backup of your controlfile and all
relevant archived logs. When using Rman alway set configuration parameter
autobackup of controlfile to ON. You will need the dbid to restore the controlfile,
get it from the name of the backed up controlfile. It is the number following the 'c-' at
the start of the name.
1. rman target /
2. set dbid <dbid#>
3. startup nomount;
4. restore controlfile from autobackup;
5. alter database mount;
6. recover database;
7. alter database open resetlogs;
8. make a new complete backup, as the database is open in a new incarnation and
previous archived log are not relevant.
Incomplete Recovery, Until Time/Sequence/Cancel
Incomplete recovery may be necessaire when the database crash and needs to be
recovered, and in the recovery process you find that an archived log is missing. In
this case recovery can only be made until the sequence before the one that is
missing.
Another scenario for incomplete recovery occurs when an important object was
dropped or incorrect data was committed on it. In this case recovery needs to be
performed until before the object was dropped. Pre requisites: A full closed or open
database backup and archived logs, the time or sequence that the 'until' recovery
needs to be performed.
1. If the database is open, shutdown it to perform full restore.
2. rman target \
3. startup mount;
4. restore database;
5. recover database until sequence 8 thread 1; # you must pass the thread, if a
single instance will always be 1.
6. alter database open resetlogs;
7. make a new complete backup, as the database is open in a new incarnation and
previous archived log are not relevant.
Alternatively you may use instead of until sequence, until time, ie: '2004-1228:01:01:10'.