Oracle 11gR2 Core DBA Course-1
Oracle 11gR2 Core DBA Course-1
Oracle 11gR2 Core DBA Course-1
By,
Kumar
OCP - 11g
OCE - 11g
OCP - 12c
OrSkl Education Oracle Database Administration - I www.OrSkl.com
Content:
1. Install Oracle database
∙ Software's introduction
∙ OEL installation
∙ OS Network configuration
∙ Putty configuration
∙ OS - pre requisites
∙ Install Oracle software
∙ Install oracle network configuration
∙ Install oracle database
∙ Demonstrate connecting method to database ∙
purpose of oraenv
∙ start/stop listener and database
∙ purpose of /etc/oratab file
2. Oracle database Architecture
∙ Connecting to a Server
∙ Oracle Database Architecture: Overview
∙ Connecting to the Database
∙ Interacting with an Oracle Database
∙ Oracle Database Server Structures
∙ Oracle Database Memory Structures
∙ Database Buffer Cache
∙ Redo Log Buffer
∙ Shared Pool
∙ Allocation and Reuse of Memory in the Shared Pool ∙
Large Pool
∙ Java Pool and Streams Pool
∙ Process Architecture
∙ Database Writer Process (DBWn)
∙ LogWriter Process (LGWR)
∙ Checkpoint Process (CKPT)
∙ System Monitor Process (SMON)
∙ PMON
∙ RECO
∙ ARCn
∙ Redo Cycle
∙ Other background processes
∙ Server process and buffer cache
∙ Introduction to Storage architecture Linux Installation 3.
Storage Architecture
∙ Logical and Physical Database Structures
∙ Tablespaces and Data Files
∙ SYSTEM and SYSAUX Tablespaces
∙ Segments, Extents, and Blocks
www.orskl.com Page 2
OrSkl Education Oracle Database Administration - I www.OrSkl.com
www.orskl.com Page 3
OrSkl Education Oracle Database Administration - I www.OrSkl.com
www.orskl.com Page 4
OrSkl Education Oracle Database Administration - I www.OrSkl.com
∙ Changing an Undo Tablespace to a Fixed Size 11.
Database Maintenance & Performance Management ∙
Terminology
∙ Oracle Optimizer: Overview
∙ Optimizer Statistics
∙ Statistic Levels
∙ Preferences for Gathering Statistics
∙ Automatic Workload Repository(AWR)
∙ AWR Infrastructure
∙ Baselines
∙ Managing the AWR
∙ Automatic Database Diagnostic Monitor (ADDM) ∙
Advisory Framework
∙ Automated Maintenance Tasks
∙ Performance Monitoring
∙ Managing Memory Components
∙ Dynamic Performance Statistics
∙ Troubleshooting and Tuning Views
∙ Invalid and Unusable Objects
12. Backup and Recovery Concepts
∙ Part of Your Job
∙ Categories of Failure
∙ Statement Failure
∙ User Process Failure
∙ Network Failure
∙ User Error
∙ Instance Failure
∙ Understanding Instance Recovery
∙ Phases of Instance Recovery
∙ Media Failure
∙ Configuring for Recoverability
∙ Configuring the Flash Recovery Area
∙ Multiplexing Control Files
∙ Redo Log Files
∙ Archive Log Files
∙ Enabling ARCHIVELOG Mode
13. Performing Database Backups
∙ Backup Solutions: Overview
∙ Oracle Secure Backup
∙ User-Managed Backup
∙ Terminology
∙ Differential Incremental level 1
∙ Cumulative Incremental level 1
∙ Recovery Manager (RMAN)
∙ Configuring Backup Settings
www.orskl.com Page 5
OrSkl Education Oracle Database Administration - I www.OrSkl.com
www.orskl.com Page 6
OrSkl Education Oracle Database Administration - I www.OrSkl.com
∙ Softwares introduction
1. VMware workstation
6. Putty
∙ OEL installation
∙ OS Network configuration
∙ Putty configuration
∙ OS - pre requisites
OS pre-requisites : root
- Disable Firewall
- create /etc/oraInst.loc
www.orskl.com Page 7
OrSkl Education Oracle Database Administration - I www.OrSkl.com
- entry to /etc/hosts
- disable SELINUX
To do:
groupadd oinstall
groupadd dba
passwd oracle
vi /etc/oraInst.loc
inventory_loc=/oracle/orainventory
install_group=oinstall
inst_group=oinstall
vi /etc/sysctl.conf
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 1054504960
kernel.shmmni = 4096
www.orskl.com Page 8
OrSkl Education Oracle Database Administration - I www.OrSkl.com
net.core.rmem_default=262144
net.core.rmem_max=4194304
net.core.wmem_default=262144
net.core.wmem_max=1048586
/sbin/sysctl -p
• Hardware check
df -h /tmp
• RPM's installation
vi /etc/security/limits.conf
vi /etc/hosts
192.168.122.20 OEL-11g
• Disable SELINUX
vi /etc/sysconfig/selinux
www.orskl.com Page 9
OrSkl Education Oracle Database Administration - I www.OrSkl.com
unzip <zipName>
cd database
./runInstaller
cd $ORACLE_HOME/bin
./netca
cd $ORACLE_HOME/bin
./dbca
[oracle@OEL-11g ~]$
/usr/lib/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/oracle/bin
[oracle@OEL-11g ~]$
www.orskl.com Page 10
OrSkl Education Oracle Database Administration - I www.OrSkl.com
ORADB
/oracle/base
/oracle/base/product/11.2.0/db
/usr/lib/qt
3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/oracle/bin:/oracle/base/product/11.2.0/
db/bin
Connected to:
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
/oracle/base/product/11.2.0/db/bin/sqlplus
www.orskl.com Page 11
OrSkl Education Oracle Database Administration - I www.OrSkl.com
[email protected]'s password:
[oracle@OEL-11g ~]$
Connected to:
the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> startup;^C
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
www.orskl.com Page 12
OrSkl Education Oracle Database Administration - I www.OrSkl.com
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=OEL-11g)(PORT=1521)))
Connected to:
the Partitioning, OLAP, Data Mining and Real Application Testing options
Database dismounted.
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@OEL-11g ~]$ su
Password:
[root@OEL-11g oracle]#
www.orskl.com Page 13
OrSkl Education Oracle Database Administration - I www.OrSkl.com
colon, ':', is used as the field terminator. A new line terminates # the
# $ORACLE_SID:$ORACLE_HOME:<N|Y>:
#
# The first and second fields are the system identifier and home #
the dbstart utility that the database should , "Y", or should not, #
ORADB:/oracle/base/product/11.2.0/db:N
www.orskl.com Page 14
OrSkl Education Oracle Database Administration - I www.OrSkl.com 2. Oracle database
Architecture
∙ Connecting to a Server
The Oracle relational database management system(RDBMS) provides an open, comprehensive, integrated
approach to information management.
www.orskl.com Page 15
OrSkl Education Oracle Database Administration - I www.OrSkl.com
www.orskl.com Page 16
OrSkl Education Oracle Database Administration - I www.OrSkl.com
www.orskl.com Page 17
OrSkl Education Oracle Database Administration - I www.OrSkl.com
∙ Shared Pool
∙ Is a portion of the SGA
∙ Contains:
– Library cache - That will all the queries that runs in the database. It used LRU algorithm to clean up
space.
— Shared SQL area
– Data dictionary cache: Details of all the objects and their permissions in the database.
– Control structures
∙ Large Pool
www.orskl.com Page 18
OrSkl Education Oracle Database Administration - I www.OrSkl.com
• User process
– Is started when a database user or a batch process connects to Oracle Database
• Database processes
– Server process: Connects to the Oracle instance and is started when a user establishes a session. It is
also called PGA
– Background processes: Are started when an Oracle instance is started
www.orskl.com Page 19
OrSkl Education Oracle Database Administration - I www.OrSkl.com
www.orskl.com Page 20
OrSkl Education Oracle Database Administration - I www.OrSkl.com
∙ RECO
www.orskl.com Page 21
OrSkl Education Oracle Database Administration - I www.OrSkl.com
∙ ARCn
• Copy redo log files to a designated storage device after a log switch has occurred
• Can collect transaction redo data and transmit that data to standby destinations
www.orskl.com Page 22
OrSkl Education Oracle Database Administration - I www.OrSkl.com
∙ Redo Cycle
∙ Other background processes
• MMON: Performs manageability-related background tasks
• MMNL: Performs frequent and light weight manageability-related tasks
• MMAN: Performs automatic memory management tasks
• CJQ0: Runs user jobs used in batch processing
• QMNx: Monitors the Streams Advanced Queuing message queues
www.orskl.com Page 23
OrSkl Education Oracle Database Administration - I www.OrSkl.com
∙ Introduction to Storage architecture
The files that constitute an Oracle database are organized into the following:
• Control files: Contain data about the database itself (that is, physical database structure information). These files
are critical to the database. Without them, you cannot open data files to access the data in the database.
www.orskl.com Page 24
OrSkl Education Oracle Database Administration - I www.OrSkl.com
• Data files: Contain the user or application data of the database, as well as metadata and the data dictionary
FILE_NAME
--------------------------------------------------------------------------------
/oradata/ORADB/app_tbs1.dbf
/oradata/ORADB/app_tbs2.dbf
/oradata/ORADB/users01.dbf
/oradata/ORADB/undotbs01.dbf
/oradata/ORADB/sysaux01.dbf
/oradata/ORADB/system01.dbf
• Online redo log files: Allow for instance recovery of the database. If the database server crashes and does not
lose any data files, the instance can recover the database with the information in these files.
MEMBER
--------------------------------------------------------------------------------
/oradata/ORADB/redo03.log
/oradata/ORADB/redo02.log
/oradata/ORADB/redo01.log
www.orskl.com Page 25
OrSkl Education Oracle Database Administration - I www.OrSkl.com
The following additional files are important to the successful running of the database:
• Parameter file: Is used to define how the instance is configured when it starts up
COUNT(*)
----------
348
Naming convention : init<DBNAME>.ora
Default location: $ORACLE_HOME/dbs
COUNT(*)
----------
347
• Password file: Allows sysdba, sysoper, and sysasm to connect remotely to the database and perform
administrative tasks
• Backup files: Are used for database recovery. You typically restore a backup file when a media failure or user error
has damaged or deleted the original file.
• Archived redo log files: Contain an ongoing history of the data changes (redo) that are generated by the instance.
Using these files and a backup of the database, you can recover a lost data file. That is, archive logs enable the
recovery of restored data files.
NAME
--------------------------------------------------------------------------------
/oradata/fra/ORADB/archivelog/2015_02_17/o1_mf_1_11_bg6bhqt3_.arc
• Trace files: Each server and background process can write to an associated trace file. When an internal error is
detected by a process, the process dumps information about the error to its trace file. Some of the information
written to a trace file is intended for the database administrator, whereas other information is for Oracle Support
Services.
BDUMP: background dump - It is used for backuground processes to write their status
SQL> show parameter background_dump
UDUMP: User dump - It is same location as bdump from 11g, If end user enables any monitoring in the database eg:
SQL trace then log file are written into this area.
SQL> show parameter user_dump
CDUMP: Core dump - Any memory related issues are captured to this location
SQL> show parameter core
• Alert log file: These are special trace entries. The alert log of a database is a chronological log of messages and
errors. Each instance has one alert log file. Oracle recommends that you review this periodically.
www.orskl.com Page 27
OrSkl Education Oracle Database Administration - I www.OrSkl.com
3. Storage Architecture
Tablespaces
A database is divided into logical storage units called tablespaces, which group related logical structures
together. For example, tablespaces commonly group all of an application’s objects to simplify some
administrative operations. You may have a tablespace for application data and an additional one for application
indexes.
Schemas
A schema is a collection of database objects that are owned by a database user. Schema objects are the logical
structures that directly refer to the database’s data. Schema objects include such structures as tables, views,
sequences, stored procedures, synonyms, indexes, clusters, and database links. In general, schema objects
include everything that your application creates in the database.
Data Blocks
At the finest level of granularity, an Oracle database’s data is stored in data blocks. One data block corresponds
to a specific number of bytes of physical database space on the disk. A data block sizeis specified for each
tablespace when it is created. A database uses and allocates free database space in Oracle data blocks.
Extents
The next level of logical database space is an extent. An extent is a specific number of contiguous data blocks
(obtained in a single allocation) that are used to store a specific type of information.
Segments
www.orskl.com Page 28
OrSkl Education Oracle Database Administration - I www.OrSkl.com
The level of logical database storage above an extent is called a segment. A segment is a set of extents that are
allocated for a certain logical structure. Different types of segments include:
• Data segments: Each non clustered, non-index-organized table has a data segment, with the exception of
external tables, global temporary tables, and partitioned tables in which each table has one or more segments.
All of the table’s data is stored in the extents of its data segment. For a partitioned table, each partition has a
data segment. Each cluster has a data segment. The data of every table in the cluster is stored in the cluster’s
data segment.
• Index segments: Each index has an index segment that stores all of its data. For a partitioned index, each
partition has an index segment.
• Undo segments: One UNDO tablespace is created for each database instance. This tablespace contains
numerous undo segments to temporarily store undo information. The information in an undo segment is used
to generate read-consistent database information and, during database recovery, to roll back uncommitted
transactions for users.
• Temporary segments: Temporary segments are created by the Oracle database when a SQL statement needs
a temporary work area to complete execution. When the statement finishes execution, the temporary
segment’s extents are returned to the instance for future use. Specify either a default temporary tablespace for
every user, or a default temporary tablespace that is used database-wide.
The Oracle database dynamically allocates space. When the existing extents of a segment are full,additional
extents are added. Because extents are allocated as needed, the extents of a segment may or may not be
contiguous on the disk.
NAME
------------------------------
SYSTEM
SYSAUX
UNDOTBS1
USERS
APP_TBS
TEMP
www.orskl.com Page 29
OrSkl Education Oracle Database Administration - I www.OrSkl.com
FILE_NAME TABLESPACE
------------------------------ ----------
/oradata/ORADB/app_tbs1.dbf APP_TBS
/oradata/ORADB/app_tbs2.dbf APP_TBS
/oradata/ORADB/users01.dbf USERS
/oradata/ORADB/undotbs01.dbf UNDOTBS1
/oradata/ORADB/sysaux01.dbf SYSAUX
/oradata/ORADB/system01.dbf SYSTEM
• The SYSTEM and SYSAUX tablespaces are mandatory tablespaces that are created at the time of database
creation. They must be online.
• The SYSTEM tablespace is used for core functionality (for example, data dictionary tables). • The
auxiliary SYSAUX tablespace is used for additional database components (such as the Enterprise
Manager Repository and for your AWR snapshots).
• Server parameter file (SPFILE): This is the preferred type of initialization parameter file. It is a binary file that
can be written to and read by the database server and must not be edited manually. It resides in the server on
which the Oracle database is executing; it is persistent across shutdown and startup. The default name of this
file, which is automatically sought at startup, is spfile<SID>.ora.
• Text initialization parameter file: This type of initialization parameter file can be read by the database server,
but it is not written to by the server. The initialization parameter settings must be set and changed manually by
using a text editor so that they are persistent across shutdown and startup. The default name of this file (which
is automatically sought at startup if an SPFILE is not found) is init<SID>.ora.
Location: $ORACLE_HOME/dbs
www.orskl.com Page 31
OrSkl Education Oracle Database Administration - I www.OrSkl.com
*.compatible='11.2.0.0.0'
*.control_files='/oradata/ORADB/control01.ctl','/oradata/ORADB/control02
.ctl'#Restore Controlfile
*.db_block_size=8192
*.db_create_file_dest='/oradata'
*.db_domain=''
*.db_name='ORADB'
*.db_recovery_file_dest_size=4294967296
*.db_recovery_file_dest='/oradata/fra'
*.diagnostic_dest='/oracle/base'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=ORADBXDB)'
*.log_archive_dest_1=''
*.memory_max_target=419430400
*.memory_target=419430400
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.resource_limit=TRUE
*.service_names='ORADB'
*.sessions=170
*.sga_max_size=419430400
*.undo_tablespace='UNDOTBS1
• Dynamic parameters:
– Can be changed while database is online
– Can be altered at:
— Session level
www.orskl.com Page 33
OrSkl Education Oracle Database Administration - I www.OrSkl.com
— System level
– Are valid for duration of session or based on SCOPE setting
– Are changed by using ALTER SESSION and ALTER SYSTEM commands
• SCOPE=SPFILE: The change is applied in the server parameter file only. No change is made to the current instance.
For both dynamic and static parameters, the change is effective at the next startup and is persistent. This is the only
SCOPE specification allowed for static parameters.
• SCOPE=MEMORY: The change is applied in memory only. The change is made to the current instance and is
effective immediately. For dynamic parameters, the effect is immediate but not persistent because the server
parameter file is not updated. For static parameters, this specification is not allowed.
• SCOPE=BOTH: The change is applied in both the server parameter file and memory. The change is made to the
current instance and is effective immediately. For dynamic parameters, the effect is persistent because the server
parameter file is updated. For static parameters, this specification is not allowed.
ERROR at line 1:
ERROR at line 1:
System altered.
aq_tm_processes integer 1
www.orskl.com Page 34
OrSkl Education Oracle Database Administration - I www.OrSkl.com
db_writer_processes integer 1
gcs_server_processes integer 0
global_txn_processes integer 1
log_archive_max_processes integer 4
processes integer 200
SQL> startup;
Database mounted.
Database opened.
aq_tm_processes integer 1
db_writer_processes integer 1
gcs_server_processes integer 0
global_txn_processes integer 1
log_archive_max_processes integer 4
www.orskl.com Page 35
OrSkl Education Oracle Database Administration - I www.OrSkl.com
NAME
--------------------------------------------------------------------------------
ISSYS_MOD
---------
processes
FALSE
NAME
--------------------------------------------------------------------------------
ISSYS_MOD
---------
db_recovery_file_dest_size
IMMEDIATE
db_recovery_file_dest_siz^C
www.orskl.com Page 36
OrSkl Education Oracle Database Administration - I www.OrSkl.com
SQL>
System altered.
SQL>
System altered.
SQL>
System altered.
www.orskl.com Page 37
OrSkl Education Oracle Database Administration - I www.OrSkl.com
SQL> alter system set db_recovery_file_dest_size=2G scope=memory;
System altered.
SQL>
SQL>
SQL>
SQL>
aq_tm_processes integer 1
db_writer_processes integer 1
gcs_server_processes integer 0
global_txn_processes integer 1
log_archive_max_processes integer 4
SQL>
ERROR at line 1:
ERROR at line 1:
System altered.
aq_tm_processes integer 1
db_writer_processes integer 1
gcs_server_processes integer 0
global_txn_processes integer 1
log_archive_max_processes integer 4
Database closed.
Database dismounted.
www.orskl.com Page 39
OrSkl Education Oracle Database Administration - I www.OrSkl.com
SQL> startupl
SQL> startup;
Database mounted.
Database opened.
aq_tm_processes integer 1
db_writer_processes integer 1
gcs_server_processes integer 0
global_txn_processes integer 1
log_archive_max_processes integer 4
www.orskl.com Page 40
OrSkl Education Oracle Database Administration - I www.OrSkl.com
SQL>
spfile string
SQL>
SQL>
SQL>
ERROR at line 1:
ERROR at line 1:
www.orskl.com Page 41
OrSkl Education Oracle Database Administration - I www.OrSkl.com
SQL>
System altered.
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
ORADB.__db_cache_size=343932928
ORADB.__java_pool_size=4194304
ORADB.__large_pool_size=4194304
ORADB.__pga_aggregate_target=339738624
ORADB.__sga_target=507510784
ORADB.__shared_io_pool_size=0
ORADB.__shared_pool_size=146800640
ORADB.__streams_pool_size=0
*.audit_file_dest='/oracle/base/admin/ORADB/adump'
*.audit_trail='db'
*.compatible='11.2.0.0.0'
*.control_files='/oradata/ORADB/control01.ctl','/oradata/ORADB/control02.ctl'
*.db_block_size=8192
*.db_domain=''
www.orskl.com Page 42
OrSkl Education Oracle Database Administration - I www.OrSkl.com
*.db_name='ORADB'
*.diagnostic_dest='/oracle/base'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=ORADBXDB)'
*.memory_target=847249408
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sessions=170
*.undo_tablespace='UNDOTBS1'
*.db_recovery_file_dest_size=1G
[oracle@OEL-11g dbs]$
[oracle@OEL-11g dbs]$
Connected to:
the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> alter system set processes=170 scope=memory;
ERROR at line 1:
www.orskl.com Page 43
OrSkl Education Oracle Database Administration - I www.OrSkl.com
ERROR at line 1:
ERROR at line 1:
Database closed.
Database dismounted.
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
ORADB.__db_cache_size=343932928
ORADB.__java_pool_size=4194304
ORADB.__large_pool_size=4194304
www.orskl.com Page 44
OrSkl Education Oracle Database Administration - I www.OrSkl.com
ORADB.__pga_aggregate_target=339738624
ORADB.__sga_target=507510784
ORADB.__shared_io_pool_size=0
ORADB.__shared_pool_size=146800640
ORADB.__streams_pool_size=0
*.audit_file_dest='/oracle/base/admin/ORADB/adump'
*.audit_trail='db'
*.compatible='11.2.0.0.0'
*.control_files='/oradata/ORADB/control01.ctl','/oradata/ORADB/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='ORADB'
*.diagnostic_dest='/oracle/base'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=ORADBXDB)'
*.memory_target=847249408
*.open_cursors=300
*.processes=170
*.remote_login_passwordfile='EXCLUSIVE'
*.sessions=170
*.undo_tablespace='UNDOTBS1'
*.db_recovery_file_dest_size=1G
www.orskl.com Page 45
OrSkl Education Oracle Database Administration - I www.OrSkl.com
SQL> startup;
Database mounted.
Database opened.
aq_tm_processes integer 1
db_writer_processes integer 1
gcs_server_processes integer 0
global_txn_processes integer 1
log_archive_max_processes integer 4
File created.
SQL> exit
www.orskl.com Page 46
OrSkl Education Oracle Database Administration - I www.OrSkl.com
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
total 40
Connected to:
the Partitioning, OLAP, Data Mining and Real Application Testing options SQL>
create spfile from pfile;
File created.
total 28
www.orskl.com Page 47
OrSkl Education Oracle Database Administration - I www.OrSkl.com
Connected to:
the Partitioning, OLAP, Data Mining and Real Application Testing options
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup;
Database mounted.
Database opened.
www.orskl.com Page 48
OrSkl Education Oracle Database Administration - I www.OrSkl.com
/dbs/spfileORADB.ora
SQL>
File created.
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
total 28
-rw-r--r-- 1 oracle oinstall 2851 May 15 2009 init.ora
www.orskl.com Page 49
OrSkl Education Oracle Database Administration - I www.OrSkl.com 5. Database Startup and
Shutdown
SQL> startup;
Database opened.
Database closed.
Database dismounted.
SQL> alter^C
www.orskl.com Page 51
OrSkl Education Oracle Database Administration - I www.OrSkl.com
bytes SQL>
Database altered.
SQL>
Database altered.
SQL> shutdown immediate;
Database closed.
Database dismounted.
bytes
www.orskl.com Page 52
OrSkl Education Oracle Database Administration - I www.OrSkl.com
Database mounted.
SQL>
Database altered.
Database closed.
Database dismounted.
STATUS
------------
STARTED
Database altered.
www.orskl.com Page 53
OrSkl Education Oracle Database Administration - I www.OrSkl.com
SQL>
STATUS
------------
MOUNTED
Database altered.
STATUS
------------
OPEN
∙ Shutdown Options
www.orskl.com Page 54
OrSkl Education Oracle Database Administration - I www.OrSkl.com
Shutdown
shutdown immediate
shutdown abort
shutdown transactional - RAC environment
SQL> shutdown;
Database closed.
Database dismounted.
SQL> startup;
5136384 bytes
www.orskl.com Page 55
OrSkl Education Oracle Database Administration - I www.OrSkl.com
Database mounted.
Database opened.
Database closed.
Database dismounted.
SQL> startup;
Database opened.
SQL>
SQL> startup;
www.orskl.com Page 56
OrSkl Education Oracle Database Administration - I www.OrSkl.com
Database opened.
ORADB/trace
rollback_segments string
transactions_per_rollback_segment integer 5
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
www.orskl.com Page 57
OrSkl Education Oracle Database Administration - I www.OrSkl.com
Provide access to information about changing states of the instance memory structures
• Sessions
• File states
• Locks
• Backup status
• SQL execution
SQL> -- v$instance
SQL> -- v$database
SQL> -- v$tablespace
SQL> -- v$datafile
STATUS INSTANCE_NAME
------------ ----------------
OPEN ORADB
NAME
--------------------------------------------------------------------------------
VALUE
www.orskl.com Page 58
OrSkl Education Oracle Database Administration - I www.OrSkl.com
--------------------------------------------------------------------------------
control_files
/oradata/ORADB/control01.ctl
control_files
/oradata/ORADB/control02.ctl
NAME
--------------------------------------------------------------------------------
/oradata/ORADB/system01.dbf
/oradata/ORADB/sysaux01.dbf
/oradata/ORADB/undotbs01.dbf
/oradata/ORADB/users01.dbf
/oradata/ORADB/users11.dbf
/oradata/ORADB/rcat1.dbf
6 rows selected.
ADDR RAW(4)
KADDR RAW(4)
SID NUMBER
TYPE VARCHAR2(2)
www.orskl.com Page 59
OrSkl Education Oracle Database Administration - I www.OrSkl.com
ID1 NUMBER
ID2 NUMBER
LMODE NUMBER
REQUEST NUMBER
CTIME NUMBER
BLOCK NUMBER
• Read consistency is not guaranteed on these views because the data is dynamic.
Usage Examples
Database closed.
Database dismounted.
www.orskl.com Page 60
OrSkl Education Oracle Database Administration - I www.OrSkl.com
STATUS
------------
STARTED
ERROR at line 1:
Database altered.
NAME
--------------------------------------------------------------------------------
/oradata/ORADB/system01.dbf
/oradata/ORADB/sysaux01.dbf
/oradata/ORADB/undotbs01.dbf
/oradata/ORADB/users01.dbf
/oradata/ORADB/users11.dbf
/oradata/ORADB/rcat1.dbf
6 rows selected.
www.orskl.com Page 61
OrSkl Education Oracle Database Administration - I www.OrSkl.com
NAME VARCHAR2(30)
OBJECT_ID NUMBER
TYPE VARCHAR2(5)
TABLE_NUM NUMBER
COUNT(*)
----------
2013
Data Dictionary
dictionary --
Data dictionary views are residing in your system tablespace. If you want to query a data dictionary view, you
will have get the database open.
SQL> -- dba_data_files
SQL> -- dba_temp_files
SQL> -- dba_tables
SQL> -- dba_objects
ERROR at line 1:
ORA-01219: database not open: queries allowed on fixed tables/views only
Database altered.
COUNT(*)
----------
2832
COUNT(*)
----------
2832
COUNT(*)
----------
2832
COUNT(*)
----------
982
www.orskl.com Page 63
OrSkl Education Oracle Database Administration - I www.OrSkl.com
Connected.
ERROR at line 1:
----------
99
COUNT(*)
----------
Table created.
COUNT(*)
----------
www.orskl.com Page 64
OrSkl Education Oracle Database Administration - I www.OrSkl.com
COUNT(*)
----------
www.orskl.com Page 65
OrSkl Education Oracle Database Administration - I www.OrSkl.com
To make a client or middle-tier connection, Oracle Net requires the client to know the:
∙ User Sessions
www.orskl.com Page 66
OrSkl Education Oracle Database Administration - I www.OrSkl.com
∙ Tools for Configuring and Managing the Oracle Network •
• Command line
lsnrctl
LSNRCTL> help
$ lsnrctl start
www.orskl.com Page 67
OrSkl Education Oracle Database Administration - I www.OrSkl.com
$ lsnrctl status
LSNRCTL> start
LSNRCTL> status
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
------------------------
Alias LISTENER
SNMP OFF
Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=OEL-11g)(PORT=1521)))
Services Summary...
www.orskl.com Page 68
OrSkl Education Oracle Database Administration - I www.OrSkl.com
LSNRCTL> help
set* show*
Static Listener
www.orskl.com Page 69
OrSkl Education Oracle Database Administration - I www.OrSkl.com
lsnr_oradb =
(DESCRIPTION =
SID_LIST_lsnr_oradb =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = ORADB)
(ORACLE_HOME = /oracle/base/product/11.2.0/db)
(SID_NAME = ORADB)
(SERVICE_NAME = ORADB)
Dynamic Listener
- Name LISTENER
• Dynamic service registration: Oracle8i and later instances automatically register with the default listener on
database startup. No additional listener configuration is required for the default listener.
• Static service registration: Earlier releases of the Oracle database do not automatically register with the
listener and, therefore, require that the listener configuration file contain a list of all database services that the
listener will serve. You may still choose to use static service registration with newer releases if:
- Your listener is not on the default port of 1521, and you do not want to configure
www.orskl.com Page 70
OrSkl Education Oracle Database Administration - I www.OrSkl.com
∙ Naming methods
1. Hostname/IP address
2. Port number - listener
Easy Connect
• Is enabled by default
– Connect-time failover
– Source routing
– Load balancing
C:\Users\Hai>sqlplus system/Oracle123@//192.168.122.20:1521/ORADB
www.orskl.com Page 71
OrSkl Education Oracle Database Administration - I www.OrSkl.com
∙ Local Naming
– Connect-time failover
– Source routing
– Load balancing
CLIENT_ORA=
(DESCRIPTION =
(ADDRESS_LIST =
(CONNECT_DATA =
(SERVER = dedicated)
(SERVICE_NAME = ORADB)
C:\Users\Hai>sqlplus system/Oracle123@CLIENT_ORA
∙ Directory Naming
www.orskl.com Page 72
OrSkl Education Oracle Database Administration - I www.OrSkl.com
• Includes:
• Ensures connectivity between the client and the Oracle Net Listener
www.orskl.com Page 73
OrSkl Education Oracle Database Administration - I www.OrSkl.com
tnsping db.us.oracle.com:1521/dba11g
tnsping orcl
• Sending data or messages between sites requires network configuration on both sites.
– Database links
USING '<connect_string_for_remote_db>';
SQL> create database link DB_LINK_TEST connect to system identified by Oracle123 using 'TEST1';
Database link created.
www.orskl.com Page 74
OrSkl Education Oracle Database Administration - I www.OrSkl.com
NAME
--------------------------------------------------------------------------------
/oradata/ORADB/system01.dbf
/oradata/ORADB/sysaux01.dbf
/oradata/ORADB/undotbs01.dbf
/oradata/ORADB/users01.dbf
/oradata/ORADB/users11.dbf
/oradata/ORADB/rcat1.dbf
6 rows selected.
NAME
--------------------------------------------------------------------------------
+DATA/oradb/datafile/system.257.871201587
+DATA/oradb/datafile/sysaux.258.871201623
+DATA/oradb/datafile/undotbs1.259.871201647
+DATA/oradb/datafile/users.261.871201653
∙ Storage Structures
SEGMENT_NAME
--------------------------------------------------------------------------------
SEGMENT_TYPE BYTES/1024
------------------ ----------
DEPT
TABLE 64
www.orskl.com Page 76
OrSkl Education Oracle Database Administration - I www.OrSkl.com
Table created.
1 row created.
SQL> commit;
Commit complete.
SEGMENT_NAME
--------------------------------------------------------------------------------
SEGMENT_TYPE BYTES/1024
------------------ ----------
TEST
TABLE 64
SQL> select * from test;
C1
----------
1
www.orskl.com Page 77
OrSkl Education Oracle Database Administration - I www.OrSkl.com
1 row created.
SQL> commit;
Commit complete.
SEGMENT_NAME
--------------------------------------------------------------------------------
SEGMENT_TYPE BYTES/1024
------------------ ----------
TEST
TABLE 64
The Oracle database stores data logically in tablespaces and physically in data files.
• Tablespaces:
– Can belong to only one database
– Consist of one or more data files
– Are further divided into logical units of storage (Segments)
• Data files:
– Can belong to only one tablespace and one database
– Are a repository for schema object data
www.orskl.com Page 78
OrSkl Education Oracle Database Administration - I www.OrSkl.com
• Dictionary-managed tablespace:
– Free extents are managed by Oracle.
– Appropriate tables are updated when extents are allocated or unallocated in your
SYSTEM/SYSAUX tablespaces.
– These tablespaces are supported only for backward compatibility.
Tablespace created.
Tablespace created.
FILE_NAME
--------------------------------------------------------------------------------
/oradata/ORADB/test21.dbf
/oradata/ORADB/test22.dbf
• SYSTEM
• SYSAUX
• TEMP
• UNDOTBS1
• USERS --- optional
• EXAMPLE --- optional
∙ Dropping Tablespaces
SQL> drop tablespace TEST including contents and datafiles;
Tablespace dropped.
Tablespace dropped.
www.orskl.com Page 79
OrSkl Education Oracle Database Administration - I www.OrSkl.com