Documente Academic
Documente Profesional
Documente Cultură
1)
Using DBCA (Database Configuration Assistant)
Installation of Oracle Database using Database Configuration Assistant.
Hardware Configuration
Host Machine Configuration:
Machine name (hostname) : ora11g.home.com
IP address : 10.0.2.15
Machine Architecture : Oracle Linux 5.5 (x86)
Memory ( RAM) :1.6 GB
Environment : Virtual ( Oracle Virtual machine 4.3)
Physical Disks:
Hard Drive Partition Size (MB) Type Mount point
/dev/sda /dev/sda1 5120 Swap
/dev/sda2 40960 primary /
Oracle Configuration:
Oracle User/groups:
O/S user Primary Group Secondary Groups Home directory
Oracle oinstall dba, oper /home/oracle
Oracle Database:
Software Component Database name Global database name
Oracle Database ora11g ora11g.home.com
Pre Installation
Prerequisite checks:
Component Command Description
Physical Ram #grep MemTotal /proc/meminfo Oracle needs minimum of 1GB
ram so we have 1.6 GB
Swap space #grep SwapTotal /proc/meminfo As per oracle documentation
ram up to 2GB needs swap
space= 2*ram
Ram up to 8 GB needs swap
space = ram
ram > 8GB swap space =
0.75*ram
So in our case we have 5GB
Temp space #df h /temp Oracle installation needs 400
MB of temp space as we have
40 GB
Oracle installation #df h /u01 Space requirement for Oracle
space Software:
Enterprise Edition 2.5G
Standard Edition 2.3G
Custom (max) 3G
So in our case we have 40 GB
Kernel Parameters:
Oracle Database 11g Release 2 for Linux requires the kernel parameter settings shown below as
per the oracle documentation:
kernel.shmmax = 4294967295
kernel.shmall = 2097152
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
fs.file-max = 6815744
fs.aio-max-nr = 1048576
Above parameters are to be amended by editing file /etc/sysctl.conf. With amending of the above
parameters in file the kernel should be reloaded as by issuing command:
#sysctl p
Resource Limits:
As per to improve the performance of the oracle software and database the resource limits of the
o/s must be edited.
The shell limits for the user Oracle are set as per Oracle by editing file /etc/security/limits.conf
as:
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
Where "nproc" is the maximum number of processes available to the user and "nofiles" is the
number of open file descriptors.
The following line to the /etc/pam.d/login file need to be appended, if it does not already exist.
session required pam_limits.so
Required rpm packages:
The Oracle Universal Installer (OUI) performs checks on the machine during installation to
verify that it meets the appropriate operating system package requirements. To ensure that these
checks complete successfully, the software requirements to install before starting the Oracle
install are:
binutils-2.17.50.0.6
compat-libstdc++-33-3.2.3
elfutils-libelf-0.125
elfutils-libelf-devel-0.125
elfutils-libelf-devel-static-0.125
gcc-4.1.2
gcc-c++-4.1.2
glibc-2.5-24
glibc-common-2.5
glibc-devel-2.52
glibc-headers-2.5
kernel-headers-2.6.18
ksh-20060214
libaio-0.3.106
libaio-devel-0.3.106
libgcc-4.1.2
libgomp-4.1.2
libstdc++-4.1.2
libstdc++-devel-4.1.2
make-3.81
pdksh-5.2.14
sysstat-7.0.2
unixODBC-2.2.11
unixODBC-devel-2.2.11
Environmental Variables:
The environmental variables for the oracle Database are set as editing the file .bash_profile as :
TMP=/tmp; export TMP
TMPDIR=$TMP; export TMPDIR
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib;
export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib;
export CLASSPATH
Welcome window:
Choose security updates window:
Select the installation type:
Select the Grid type:
Select the product languages:
Select the installation type:
Specify the oracle base and oracle home directories:
Specify the directory for Inventory:
Supply the privilege operating system groups:
Prerequisite check:
Issue the command netca in terminal window and select the listener configuration button
Specify the memory parameters, character sets, block size for oracle database:
Overview the files that are created by dbca as part of oracle database installation:
Check the radio button for creating a template for database creation and other scripts:
Overview the summary of oracle database installation:
@./synonyms.SQL
Again issued the SEVERE: Failed to unlock all This is due to the change of profile
same command to EM-related accounts parameters used by oem accounts sysman
configure and inatall and dbsnmp so I set to defaults the profile :
oem default and monitoring_profile
Again try to recreate Listener is not up or database This due to not proper configuration of
the oem service is not registered with it. listner
Tried to configure the The port is currently used by As I was not able to select any port so
lister another component this is due to network problem and is due
not proper entry in /etc/hosts file so I
provide the fully qualified name as
10.0.2.15 ora11g.home.con ora11g
Again tried to install Object already exists This is due to the oem was configured
oem successfully but not installed so first need
to delete the configuration
So I drop the oem Successfully deleted
configuration as:
emca -deconfig
dbcontrol db -repos
drop
Finally I again No error messages Successfully installed
installed the oem
using oem as:
emca -config
dbcontrol db -repos
create
Checked the status of No error messages The instance of oracle oem is currently
oem dbconsole as: running
emctl status
dbconsole
Stopped dbconsole
and restarted as:
emctl stop dbconsole
emctl start dbconsole
Installation of oracle database manually with
create statement
Installation of oracle database manually with create database statement.
As per installation I configured the oracle binaries and all required perquisites, users and
directories and started the installation of oracle database manually with following steps as:
Created the initial parameter file as:
db_name='ora11g'
db_domain=home.com
db_block_size=8192
memory_target=700m
processes=100
open_cursors=300
remote_login_passwordfile='EXCLUSIVE'
undo_tablespace='UNDOTBS1'
compatible ='11.2.0'
audit_trail ='db'
db_recovery_file_dest_size=5g
db_recovery_file_dest=/u01/app/oracle/ora11g/flash_recovery_area'
audit_file_dest='/u01/app/oracle/ora11g/admin/adump'
diagnostic_dest=/u01/app/oracle/ora11g/diag'
control_files = (/u01/app/oracle/ora11g/oradata/control1.ctl')
And logging in sqlplus as sys user and started the database instance and issued the above
statement.
After successfully installation of two scripts on another script is runned as a system user as:
@$ORACLE_HOME/sqlplus/admin/pupbld.sql
LISTNER_ORA11G =
( ADDRESS = ( PROTOCOL=IPC)(KEY=ipc))
With the new oracle home the database versions binaries of release 11.2.0.3 is installed using
OUI .
Started the upgrade of the oracle database using the database configuration assistant by issuing
following command as:
$dbua
With the issue of above command the upgrade of database started and snapshots of the upgrades
are as:
The upgrade of oracle enterprise manager using dbca requires oracle listener to be running:
Specify if move datafiles as part of upgrade:
Specify the location for flash recovery and its size as:
Overview the upgrade summary as:
Perform Upgrade as:
View of the upgrade results:
With the successful upgrade of database check the status of the database instance and select
version of currently running database:
Check the status of the database control and log in into the oem if it is successfully installed or
not:
Manually upgrade of Oracle database
Manually upgrade of oracle database.
Upgrade database Details:
S.N Current version of database Version to upgrade
1 Oracle database ( 11.2.0.1) Oracle database (11.2.0.3)
With the new oracle home the database versions binaries of release 11.2.0.3 is installed using
OUI .
Compatibility Matrix:
Minimum version of the oracle database software that can be directly upgraded to oracle 11g
release 2. So before starting the database version must be the following:
S.N Source Database Target Database
1 9.2.0.8 or higher 11.2.x
2 10.1.0.5 or higher 11.2.x
3 10.2.0.2 or higher 11.2.x
4 11.1.0.6 or higher 11.2.x
Furthermore the following database software version will require an indirect upgrade paths. In
case DBA needs to do double effort, because two upgrades are needed.
S.N Source Database Upgrade Path Target Database
1 7.3.3 or lower 7.3.4 => 9.2.0.8 11.2.x
2 8.0.5 or lower 8.0.6 => 9.2.0.8 11.2.x
3 8.1.7 or lower 8.1.7.4 => 10.2.0.4 11.2.x
4 9.0.1.3 or lower 9.0.1.4 => 10.2.0.4 11.2.x
5 9.2.0.7 or lower 9.2.0.8 => 11.2.X
Starting Upgrade:
The manually upgrade of the oracle database consists of three parts of which are:
Pre-upgrade checks
Upgrade
Post upgrade
Pre upgrade checks:
1. Gather information:
The pre upgrade checks for upgrade of the database is done by running the script provided by the
oracle in $ORACLE_HOME/rdbms/admin/utl112i.sql of newly installed oracle software i.e.
11.2.0.3 as.
> spool upgrade_11.2.0.2.log
>@utlu112i.sql
>spool off
With the generated pre upgrade log file, it had no error messages and the all tablespaces are fine
for upgrades , components like Oracle catalog views, Oracle packages and types EM repository
will be upgraded was reported by log file.
There were warning in the log file that your recycle bin must be empty so I empty the recycle bin
of oracle using following command.
>purge DBA_RECYCLEBIN;
In addition the log reported that the memory_max_target value must be raised to 600M.
3. Generation of pfile:
The pfile is generated for listing all the initialization parameters that is used by the current
database. So for generating pfile from spfile of currnet database first the oracle database listener
is stopped as:
>lsnrctl stop
With stopping of listener the pfile is generated either form memory or from spfile so I generated
from spfile as:
>create pfile from spfile;
4. Perform backup:
The backup is optional but it is good practice to backup your database before performing any
changes and upgrades to your database. So that if anything goes wrong during any process I can
restore and recover my database. So I performed cold back up using rman as:
>rman target /
>run {
>shutdown immediate;
>startup mount;
>backup database;
>}
Upgrade Database.
With the necessary pre upgrade checks now the database is ready for upgrade so logged into the
sqlplus of the database software (11.2.0.3) as sys user and started database with upgrade mode
and ran the script provide by the oracle in directory $ORACLE_HOME/rdbms/catupgrd.sql. The
log of script is spooled. The commands are:
>cd $ORACLE_HOME/rdbms/
>sqlplus /as sysdba
>startup upgrade
>set echo on
>spool upgrade.log
>@catupgrd.sql
>spool.off
As the script runned successfully now errors ware reported during the upgrade.
Post Upgrade.
1.Post upgrade status:
The database is started and the post-upgrade status tool provide by the oracle in
$ORACLE_HOME/rdbms/admin/utlu112s.sql is ran which provides a summary of the upgrade
at the end of the spool tag. It displays the status of the database components in the upgraded
database and the time required to complete each component upgrade. Any errors that occur
during the upgrade are listed with each component and must be addressed. The script is run as:
>sqlplus /as sysdba
>startup force
>@utlu112s.sql
The execution of the script completed successfully and no error report was listed.
2. Rcompile the invalid objects:
The invalid objects were recompiled by running the scrip utlrp.sql as
>@utrp.sql
4. Create spfile
The spfile is generated from the previously generated and edited pfile as form sqlplus:
>create spfile from pfile;
5. Oem configuration
The oracle enterprise manager is configured for the newly upgrade database. So before
configuring the status of oem is checked as:
>emctl status dbconsole
If it reports any error then it is necessary to first remove the components and reconfigure and
install it as:
>emca dconfig dbcontrol db repos drop
>emca config dbcontrol db repos create
So as frist I dropped the em repository and again reconfigured the database control.
Autoextend tablespace:
Offline and online:
A tablespace can be brought to offline or online. If the status of the tablespace is offline, then no
users can access it. Generally a tablespace is brought to offline before performing maintenance
or recovery on the datafiles associated with that tablespace.
S.N Command Description
1 alter tablespace demo offline; Changes the tablespace demo to offline and
no operations are allowed.
2 alter tablespace demo online; Changes the tablespace demo to online for
normal operation.
Temporary tablespaces:
A temporary tablespace contains transient data that persists only for the duration of the session.
Temporary tablespaces can improve the concurrency of multiple sort operations that do not fit in
memory and can improve the efficiency of space management operations during sorts.
S.N Command Description
1 create temporary tablespace tempo tempfile Creates temporary tablespace name
'/u02/oracle/data/lmtemp01.dbf' tempo with datafile of size 2om with
size 20m uniform size
extent management local uniform size 16m;
2 alter database temporary tablespace tempo Makes the tempo as the default
default; tablespace.
DB_CREATE_FILE_DEST
DB_CREATE_ONLINE_LOG_DEST_1
DB_CREATE_ONLINE_LOG_DEST_2
DB_RECOVERY_FILE_DEST
The DB_CREATE_FILE_DEST parameter specifies a default location for all datafiles. The
DB_CREATE_ONLINE_LOG_DEST_n parameters specify a default location for online redo
log files. DB_RECOVERY_FILE_DEST sets up a default location for archive redo log files and
backup files. As well as setting default file locations, OMF will generate filenames and (by
default) set the file sizes. Setting these parameters can greatly simplify file-related operations.
Having enabled OMF, it can always be overridden by specifying a datafile name on the
CREATE TABLESPACE command.
Account Status:
Every user account has a certain status, as listed in the ACCOUNT_STATUS column of
DBA_USERS. There are nine possibilities:
S.N Status Description
open the account is available for use.
2 locked this indicates that the dba deliberately locked the
account. no user can connect to a locked account.
3 expired this indicates that the lifetime has expired. passwords
can have a limited lifetime. no user can connect to an
expired account until the password is reset.
4 expired & locked not only has the account been locked, but its password
has also expired.
5 expired (grace) this indicates that the grace periods in effect. a
password need not expire immediately when its
lifetime ends; it may be configured with a grace period
during which users connecting to the account have the
opportunity to change the password.
6 locked (timed) this indicates that the account is locked because of
failed login attempts. an account can be configured to
lock automatically for a period after an incorrect
password is presented a certain number of times.
7 expired & locked (timed) this indicates that the account is locked of failed login
attempts and lifetime has expired.
8 expired (grace) & locked the account is locked due to attempts to log in more
than grace limit with incorrect password
9 expired (grace) & locked
(timed)
All of these privileges can be handled with two simple SQL commands. The GRANT command
gives a particular privilege to a user or role, while the REVOKE command takes away a specific
privilege.
S.N Command Description
1 grant insert, update, delete grant INSERT, UPDATE, and DELETE privileges on
on test to dralmostright. a table called test to a user name dralmostright. So the
user can now insert , update and delete rows in table
test but not select until user is granted select privileges.
2 grant all on suppliers to Grant all privileges ( insert, update, delete, references,
smith; index , alter, select ) on schema object suppliers to user
smith.
3 revoke delete on suppliers revoke DELETE privileges on a table called suppliers
from soni; from a user named soni.
4 revoke all on suppliers revoke all privileges on a table called suppliers from a
from soni; user named soni.
Managing and controlling privileges is made easier by using roles, which are named groups of
related privileges. A role can be created and can be granted with object and system privileges
and assign the role to different users.
S.N Command Description
1 create role master Creates a role named master.
2 grant select, insert, delete Grants the role master privileges to select insert and
on emp to master delete rows on emp table.
3 create role smart identified The command specifies that the enabling of the role
by smart requires authentication by password.
4 revoke master from Withdraw the role granted to the user dralmostright
dralmostright
Scenario:
Assume that the HR schema is being used as a repository for data to be used by three groups of
staff. Managerial staff have full access, senior clerical staff have limited access, and junior
clerical staff have very restricted access. So this can be implemented as:
Resource Limits:
The limits that can be applied to resource usage (also known as kernel limits) are listed as below:
S.N Component Description
1 sessions_per_user The number of concurrent logins that can be made to
the same user account. Sessions attempting to log in
with the same user name when this limit is reached
will be blocked.
2 cpu_per_session The cpu time (in centiseconds) that a sessions server
process is allowed to use before the session is
forcibly terminated.
3 cpu_per_call The cpu time (in centiseconds) that a sessions server
process is allowed to use to execute one sql statement
before the statement is forcibly terminated
4 logical_reads_per_session The number of blocks that can be read by a session
(irrespective of whether they were in the database
buffer cache or read from disk) before the session is
forcibly terminated
5 logical_reads_per_call The number of blocks that can be read by a single
statement (irrespective of whether they were in the
database buffer cache or read from disk) before the
statement is forcibly terminated.
6 private_sga For sessions connected through the shared server
architecture, the number of kilobytes that the session
is allowed to take in the sga for session data
7 connect_time In minutes, the maximum duration of a session before
the session is forcibly terminated.
8 idle_time In minutes, the maximum time a session can be idle
before the session is forcibly terminated.
9 composite_limit A weighted sum of cpu_per_session, connect_time,
logical_reads_per_session, and private_sga
Database Auditing:
Before setting up database auditing, the AUDIT_TRAIL instance parameter must be set. This
has six possible values:
S.N Value Description
1 none (or false) Database auditing is disabled, no matter what auditing you
attempt to configure.
2 os audit records will be written to the operating systems audit trail
the application log on windows, or the audit_file_dest directory
on unix
3 db The audit records are written to a data dictionary table,
sys.aud$. there are views that let you see the contents of this
table
4 db_extended As db, but including the sql statements with bind variables that
generated the audit records.
5 xml as os, but formatted with xml tags
6 xml_extended As xml, but with the sql statements and bind variables.
Database auditing is configured using the AUDIT command.Use of privileges can be audited
with, for example.
S.N Command Description
1 audit create any trigger; will generate one audit record for every session that
violates an audit condition, irrespective of the
number of times it violates the condition, i.e every
time a user issue a create trigger statement it is
tracked by database as type set by parameter
audit_trail
2 audit insert on hr.employees Generate a audit record whenever the insert is
whenever successful; successful to table hr.employees.
3 audit session whenever not Generate audit record whenever user tries to login
successful; with incorrect password or login attempt fail.
Opening the backup.txt file and issuing the commands in it, performs the complete user managed
backup. Including the online redo log file members in the backup is strictly optional if the
database is shutdown cleanly because with clean shutdown the database is properly check
pointed and all files are in consistent state.
RMAN backup and restore operations are carried out by server processes known as channels. A
channel is either of type disk (meaning that it can read and write backups on disk) or of type
SBT_TAPE (meaning that it is capable of reading and writing backups stored on a tape device).