Professional Documents
Culture Documents
Kiran K
kirankollepalli@yahoo.co.in
Oracle 10g Certified Professional
1
Contents
●
Introduction to Grid
●
Storage Enhancements
●
Network Enhancements
●
Backup and Recovery
●
Flashback Features
●
Automatic Storage Management
●
SelfManaged Database
●
Miscellaneous Features
2
Oracle 10g
Introduction to Grid Computing
3
How DBA's Spend their time?
4
Database Management Challenges
5
Oracle 10g Solution
6
How 10g DBA's Spend Time...
7
What is Grid Computing?
●
What is Oracle 10g?
– The Oracle GRID architecture pools large number of servers,
storage and networks into a flexible, on demand computing
resource for enterprise computing needs.
– This infrastructure continually analyzes demand for resource
and adjusts supply accordingly
– It offers High Availability and Scalability
– It is flexible than Clustered Systems
8
Grid Infrastructure
• Applications
• Application
servers
• Database
servers
• Storage:
Use cheap and fast
clustered server blades
9
Installation Enhancements
●
Much Faster
●
Does the preinstallation checks
●
Installation CD's
– One Database
– Two Grid
– One Client
– One Cluster
– One Companion
●
JVM, JDBC, Examples, SQLJ, Middle tier components, etc
10
Installation Requirements
– Hardware:
RAM 1GB (10g R2)
Processor P4
Swap 1GB
– Kernel Parameters:
kernel.sem = 256 256000 100 1024
kernel.shmmax = 550000000
net.core.rmem_default = 262144
net.core.rmem_max = 262144
net.core.wmem_default = 262144
net.core.wmem_max = 262144
fs.filemax = 65536
net.ipv4.ip_local_port_range = 1024 65000
11
Oracle 10g
General Storage Enhancements
12
Architectural Enhancements
●
New memory component – Streams Pool (dynamic)
●
Java pool – Dynamic component
●
Background Processes:
– MMAN – Memory Manager
– MMON – Manageability Monitor
– MMNL – Manageability Monitor Light
– RVWR – Recovery Writer
– CTWR – Change Tracking Writer
13
Tablespace Enhancements
●
Default tablespaces created:
– SYSTEM: Container of Data Dictionary
– SYSAUX: (in 10g)
●
Reduce load on System
●
Cannot rename / drop
●
v$sysaux_occupants
●
use PL/SQL package to move occupant
14
Sysaux Occupants
●
Automatic workload repository(AWR) statistics
– Enterprise Manager
– Oracle OLAP (online analytical processing applications)
– Oracle Text (Multimedia content)
– Oracle Ultra Search (extended search within database)
– Oracle Data Mining (tools / algorithms for data mining)
– Log Miner
– Scheduler
– etc
15
Types of Tablespaces
●
System / NonSystem
●
Permanent / Temporary
●
Dictionary Managed / Locally Managed
●
Undo Tablespace
●
Small file / Big file (10g)
●
Temporary tablespace groups
16
BigFile Tablespace
●
Max datafiles in a database is 64k. Now, it is overcome:
8k block size – 32 TB / 32k block size – 128 TB
●
Supported only for LMT with Segment Management
Auto
– Create [bigfile | smallfile ] tablespace <name>
datafile '<path/filename>' size <kb, mb, gb, tb>;
– Create database
... set default bigfile tablespace;
– Alter database set default bigfile tablespace;
17
Temporary Tablespace Groups
●
Contains one or more tempfiles
●
Create temporary tablespace ...
tempfile ... tablespace group group1;
●
Alter tablespace temptbs tablespace group group2;
●
Alter tablespace temptbs tablespace group ' ' ;
●
Alter database <dbname> default temporary tablespace
group2; Making group2 as default temporary tablespace
●
View: dba_tablespace_groups
18
Rename Tablespaces
●
Alter tablespace <name> rename to <newname>;
– Compatible=10.0 or higher
– Cannot rename SYSTEM / SYSAUX
– Cannot rename offline tablespace
19
Dropping Datafiles
●
Alter tablespace drop datafile '<path/name>' ;
●
Alter tablespace drop tempfile '<path/name>' ;
●
Restrictions:
– Database must be open
– Datafile / tempfile must be empty
– Cannot drop first / only datafile
– Cannot drop datafiles from readonly tablespace
– Cannot drop datafiles from SYSTEM tablespace
20
Archivelog Parameters
– log_archive_start [obsolete from 10g]
– log_archive_format = %d_%t_%s_%r.arc
●
%r will represent the RESETLOGS SCN number
●
Will not make the old archivelog files obsolete
21
Undo Enhancements
●
Create undo tablespace undotbs02
datafile '<path/filename>' size <size> [autoextend on]
[ retention {guarantee | noguarantee} ];
– ORA1555 Error is eliminated
– Enhanced to support Flashback features
22
Resumable Space Management
●
In 9i, it was restricted to session level
●
Now it can be enabled at Instance Level
– RESUMABLE_TIMEOUT = 7200
– RESUMABLE_TIMEOUT = 0 will disable the feature
23
Partitioned Indexes
●
Create index PART_IDX on Emp(EmpNo)
Global
Partition by Range(EmpNo)
(Partition Part1 values less than (500) tablespace TBS1,
Partition Part2 values less than (1000) tablespace TBS2,
Partition Part3 values less than (Maxvalue) tablespace TBS3
);
●
Create index PART_IDX on Emp(EmpNo)
Global
Partition by Hash(EmpNo) 10g Feature
Partitions 4
Store in (TBS1, TBS2, TBS3, TBS4);
24
Oracle 10g
Networking Enhancements
25
Naming Methods
●
Easy Connect:
– Can specify different port number
– No configuration required on the client
– Reduces administrative work
●
sqlplus scott/tiger@localhost:1529/wisedba.co.in
●
sqlnet.ora
NAMES.DIRECTORY_PATH= (EZCONNECT)
26
Enterprise Manager DB Control
●
Very much enhanced
●
Is invoked through a browser
●
Powerful / Simple / Easy tool
●
Easier to manage database
●
Steps:
●
emca repos create
●
emca config dbcontrol db
●
emctl {start | stop | status } dbconsole
27
Oracle 10g
Faster Backup and Recovery
28
Logical Backup through Datapump
– Will replace Exp / Imp in future releases. Imp will be retained
for migration purposes
– Enables to transfer data at very high speeds than exp/imp
– Lets you to estimate job times and manage jobs effectively
– Dump file is the proprietary format of Datapump
– Ability to restart data pump jobs
– Parallel execution capabilities
– Ability to attach to running jobs
– Network mode of operations
29
Datapump Features
– Datapump is entirely based on server
– Uses DBMS_DATAPUMP, DBMS_METADATA
– More meaningful parameters than Exp / Imp
– More secure – needs permissions on server directories
– Datapump Job:
●
Master Process (MCP) – DMnn – Create and manage job
●
Worker Process – DWnn – Actual performer, depends on parallelism
●
Shadow Process – Create the master table and master process
●
Client Process – call the Datapump's API
30
Datapump Export Parameters
●
Directory ●
Parallel
●
Dumpfile (expdat.dmp) ●
Exclude(constraints, indexes,
●
Filesize grants)
●
Parfile
●
Include
●
Logfile (export.log)
●
Query ●
Interactive mode (ctrl+c)
●
Nologfile
●
Estimate_only ●
Kill_job
●
Full
●
Network_link ●
Stop_job
●
Schemas
●
Attach ●
Continue_client
●
Tables
●
Jobname ●
Start_job
●
Content(all, data_only,
●
Status
metadata_only)
31
Modes of Export
– Table Mode Export:
●
expdp user1/user1 tables=emp directory=dir1 dumpfile=emp.dmp
job_name=emp_expdp content=data_only
– Schema Mode Export: (EXP_FULL_DATABASE)
●
expdp system/manager schema=user1, user2 dumpfile=dir1:sch1%
U.dmp, dir2:sch2%U.dmp logfile=expschema.log parallel=2
job_name=schema_export
– Full Export: (EXP_FULL_DATABASE)
●
expdp system/manager full=y directory=dir1 dumpfile=fullexp.dmp
job_name=fullexport
32
Datapump Import
– Reads information from valid Export Dump file
– Required to do Recovery of tables / schemas / tablespaces /
database
– 15 to 30 times faster than traditional import job
33
Datapump Import Parameters
●
Parfile
●
Directory
●
Dumpfile
●
Logfile
●
Nologfile
●
SQLFILE (INDEXFILE in imp)
●
Reuse_datafiles=y
●
Content=Data_only, All, Metadata_only
●
Exclude
●
Include
●
Table_Exists_Action=(Skip, Append, Truncate, Replace)
34
Datapump Import Parameters (cont)
●
Job_name
●
Status
●
Parallel
●
Table
●
Schemas
●
Full
●
Remap_Schema
●
Remap_datafile
●
Remap_Tablespace
●
Network_Link
35
Examples
– impdp system/manager Directory=dir1 dumpfile=expdat.dmp
Sqlfile=finance.sql
– impdp system/manager dumpfile=dir1:expdat.dmp
Remap_schema=HR:OE similar to fromuser / touser in
imp
– impdp hr/hr Remap_tablespace='example_tbs':'new_tbs'
directory=dump_dir1 parallel=2 job_name=tbsjob
dumpfile=employees.dmp nologfile=y
36
Monitoring Datapump Jobs
●
Dba_datapump_jobs
●
Dba_datapump_sessions
select sid, serial# from v$session s, dba_datapump_sessions d where
s.saddr=d.saddr ;
●
v$session_longops
select sid,serial#, sofar, totalwork from v$session_longops where
opname='MYJOB';
●
v$session
37
Transportable Tablespace
●
Limitations prior to 10g
●
Must have same hardware platform
●
Must have same operating system
38
Converting Tablespace
●
select * from v$transportable_platform;
●
select platform_name from v$database;
●
select tablespace_name, plugged_in from dba_tablespaces;
– Conversion using RMAN:
●
RMAN> convert tablespace users to platform 'HPUX (64bit)'
format '/tmp/%U'; tablespace must be read only mode
●
RMAN> convert tablespace users to platform 'Microsoft Windows IA
(32bit)' ;
●
RMAN> convert datafile '/home/users.dbf' from platform='HPUX
(64bit)' to platform='Linux IA (32bit)'
●
RMAN> convert database to platform 'Linux IA (32bit)';
database must be opened in read only mode
39
DBMS_File_Transfer
– Create or replace directory sourcedir as
'/home/oracle10g/wisedba/data';
– Create or replace directory backupdir as
'/home/oracle10g/wisedba/backup';
– Exec dbms_file_transfer.copy_file
('sourcedir','users01.dbf','backupdir','users01.bak');
40
Oracle 10g
Go back with Flashback
41
Flashback Enhancements
●
Flash Recovery Area
●
Flashback Database
●
Flashback Drop
●
Flashback Table
●
Flashback Query
●
Flashback Versions Query
●
Flashback Transaction Query
42
Flash Recovery Area
●
Serves as the default storage area for all files related to
backup and recovery operations
●
Let Oracle take care of your backups
●
Simply designate the disk space as Flash Recovery Area,
specify the area's maximum size, and let Oracle know
how long you want to retain the backuprelated
information
●
Oracle manages backup related files including Archive
logs, Control files, and other files
43
Flashback Database
●
Lets you to recover from logical corruptions (not media
failure). Avoids restoring of backup datafiles
●
Once Flashback database is enabled, images of each alter
block in datafiles are copied from memory to the new
flashback logs (stored in Flash Recovery Area)
●
RVWR process writes the contents of flashback buffer to
the Flashback database logs
●
The before images are used to reconstruct a database
back in time
44
Flashback Database Example
●
Select count(*) from emp; > 10,000
●
Select current_scn from v$database; > 682021
●
Select count(*) from emp; > 20,000
●
Shutdown
●
Startup mount
●
Flashback database to SCN 682021;
●
Alter database open Resetlogs;
●
Select count(*) from emp; >10,000
45
Flashback Drop
●
Oracle 10g finally takes this hazard, you cannot
mistakenly drop a table!!
●
If you have dropped a table with “Drop table Emp” and
you realize you wanted the table back, you don't have to
perform database pointintime recovery
●
When you drop a table, Oracle simply renames it and
stores the table and its dependent objects in the
database's RECYCLE BIN
46
Recycle Bin
●
To query your dropped table:
– Show recyclebin
– Views: USER_RECYCLEBIN, RECYCLEBIN,
DBA_RECYCLEBIN
– Select * from tab; > Shows dropped tables with a system
generated unique name
●
Restoring table drop:
– Flashback table Emp to before drop;
47
Flashback Table
●
Lets you to perform an online, pointintime recovery on
one / more tables
●
Lets you restore an earlier state of a table to recover from
human / application errors
●
Relies on Undo Data
●
Not supported for SYS user
●
Must have flashback any table or flashback object
privilege on the table
●
Must enable Row Movement on the table(RowId changes)
48
Flashback Table Commands
●
Alter table Emp enable row movement;
●
Flashback table Emp to scn 711087;
●
Flashback table Emp to timestamp to_timestamp('04Sep2006
08:00:00', 'ddmonyyyy HH24:MI:SS');
●
If the flashback results aren't satisfactory, you can again Flashback
to current SCN
49
Flashback Query
●
Perform queries on the database at a target time in the
past
●
Relies on Undo Data
●
Use the command: Select ... as of ...
●
Can use SCN number or Timestamp
●
Oracle retrieves only committed data in the as of the time
specified
●
In Oracle 9i, dbms_flashback package was used to do
flashback query
50
Flashback Query (contd)
●
Select * from Emp as of Timestamp to_timestamp('03Sep2006
22:40:00','ddmonyyyy hh24:mi:ss') where Ename='SMITH';
●
Select * from Emp as of SCN 712388;
●
Insert into Emp (Select * from Emp as of scn 712388)
51
Flashback Versions Query
●
Enables users to query the history of a given row in a
table
●
Oracle returns different committed versions of a row
between two SCNs or two Timestamps
●
Relies on Undo Data
52
Flashback Versions Query (contd)
●
Select versions_xid, versions_startscn, versions_starttime,
versions_endscn, versions_endtime, versions_operation, Empno,
Ename, Sal from Emp VERSIONS between SCN minvalue and
maxvalue as of SCN 712388 where Empno=7369
53
Flashback Transaction Query
●
Lets you to identify which transaction or transactions
were responsible for certain changes during a certain
period
●
View: Flashback_Transaction_Query
●
Enables to correct logical errors
●
Enables to Audit the transactions
●
Can avoid usage of LogMiner – where Oracle must read
entire redo log files to get necessary information
54
Example Output
SELECT OPERATION, START_SCN, LOGON_USER, UNDO_SQL FROM
FLASHBACK_TRANSACTION_QUERY WHERE XID = HEXTORAW
('0300040062010000');
OPERATION START_SCN LOGON_USER UNDO_SQL
INSERT 711140 SCOTT delete from "SCOTT"."EMP1" where ROWID =
'AAAC5ZAAAAAAAAAAAA';
SELECT UNDO_SQL FROM FLASHBACK_TRANSACTION_QUERY WHERE
TABLE_OWNER = 'SCOTT'
UNDO_SQL
insert into "SCOTT"."EMP"("EMPNO","ENAME","JOB","MGR","HIREDATE","SAL","COMM","DEPTNO") values
('7369','SMITH','CLERK','7902',TO_DATE('17dec1980:00:00:00', ' ddmonyyyy:hh24:mi:ss'),'800',NULL,'20');
delete from "SCOTT"."EMP" where ROWID = 'AAAC5ZAAAAAAAAAAAA';
insert into "SCOTT"."EMP"("EMPNO","ENAME","JOB","MGR","HIREDATE","SAL","COMM","
DEPTNO") values ('7934','MILLER','CLERK','7782',TO_DATE('23jan1982:00:00:00',
'ddmonyyyy:hh24:mi:ss'),'1300',NULL,'10');
... ... ...
55
Oracle 10g
Enhanced Recovery Manager (RMAN)
56
RMAN Enhancements
– Can backup Database, Tablespace, Datafiles, Control files,
Archive log files, SP File, and also the Flash Recovery Area
– Global and Local scripts can be created for routine jobs
– Can easily catalog the files if metadata information is lost
– RMAN supports binary compression of backups. No extra
uncompression steps are required during recovery.
– Automatic channel failover will be done by RMAN, if one of
the channel on which RMAN is performing a backup fails
– Incremental level of backup are possible (which is much faster
in Oracle 10g with Change Track Writing)
57
RMAN Enhancements (contd)
– Configuration
●
Configure encryption for database on;
●
Configure device type disk backup type to { copy | backupset };
●
Configure device type disk backup type to compressed backupset;
– Backup
●
Backup recovery files;
●
Backup recovery area;
●
Backup as backupset database;
●
Backup as copy database;
●
Backup as compressed backupset tablespace users;
58
Incremental Backups
●
Fast Incremental Backups:
●
Alter database { enable | disable } block change tracking using file
'/home/flash/changetrack.log' reuse;
– Background process CTWR is in charge of writing the block
changes information to the change tracking file.
●
V$BLOCK_CHANGE_TRACKING
●
V$BACKUP_DATAFILE
59
Rolling Forward of Image Copies
●
Regularly create incremental backups of your database
and apply them to the image copy
●
run {
Recover copy of database with tag "fullcopy";
Backup incremental level 2 for recover of copy with tag "fullcopy"
database; }
●
Either for complete or pointintime recovery, you can
restore the datafiles from the incrementally updated
datafile copies, and apply changes from the most recent
incremental backup
●
Saves time required for recovery
60
Go back to Previous Incarnation
●
Pointintime recovery to previous incarnation is possible
through RMAN
●
It is not possible to restore one datafile of previous
incarnation, you must restore the whole database
RMAN> List incarnation;
●
Perform incomplete recovery to go back to previous
incarnation
61
Oracle 10g
Simplified management with ASM
62
Automatic Storage Management
●
Oracle finally automates your disk and file management
tasks
●
Enables to bypass thirdparty LVMs
●
Oracle takes care of Mirroring and Stripping
●
Optimizes database storage layout for better performance
●
ASM is built on top of OMF which much further
simplifies the administration overhead
63
Benefits of ASM
●
Prevents disk fragmentation
●
ASM will manage – datafiles, control files, redo log files,
archive logs, RMAN backups and so on
●
DBA has to deal with only few diskgroups instead of
numerous files
●
Performs mirroring and striping. Automatically balances
I/O load
●
Helps to maintain redundant copies for fault tolerance
●
ASM is FREE!!
64
ASM Architecture
65
Oracle 10g
The SelfManaged Database
66
Automatic Database
●
Automatic Workload Repository (AWR)
●
Automatic Database Diagnostic Monitor (ADDM)
●
Automatic Shared Memory Management
●
Automatic Optimizer Statistics Collection
67
AWR
●
Oracle10g is truly SelfManaging database, AWR is the
heart of it. Automatic Workload Repository (AWR) will
collection performance statistics automatically
●
AWR stores the database in Sysaux tablespace. It keeps
both current temporary statistics and permanent historical
statistics
●
Dynamic views are only till the database shutdown
●
AWR stores the database for future comparisions
●
ADDM relies on the snapshots for diagnosis
68
AWR (contd)
●
MMON (Manageability Monitor)
– Captures statistics through periodic snapshots
– Transfers memory version of AWR statistics to disk on regular
basis
●
MMNL (Manageability Monitor Light)
– Performs lightweight tasks
– Captures Session information for Automatic Session History
– Flush ASH data to disk if ASH buffer fills up
69
ADDM
●
AWR collects database at regular intervals
●
Automatic Database Diagnostic Monitor (ADDM)
analyzes this data regularly every hour
●
ADDM analysis are stored in Sysaux tablespace
●
Provides detailed information about the root cause of
performance problems
●
It is selfdiagnostic engine built into Oracle 10g
●
ADDM is also dependent on MMON to get read statistics
directly from SGA
70
ADDM Benefits
●
Identifies root cause
●
Produces automatic performance diagnostic reports
●
Very little performance overhead
●
Diagnosis is based on Oracle's expert tuning knowledge
for decades
●
ADDM runs automatically after each AWR snapshot
●
Oracle enables ADDM feature by default
●
Statistics_level = Typical or All
●
Timed_Statistics = True
71
ASMM
●
Automatically allocate and deallocate memory for each
of the memory pools based on the load
●
Less chance of running out of shared pool memory
●
Optimal usage of available memory
●
Performance Improvement
●
Automatic Shared Memory Management (ASMM) is
enable by setting the parameter SGA_TARGET to a non
zero value (lesser than sga_max_size)
72
ASMM (contd)
●
Statistics_Level must be Typical or All. MMAN process
performs all necessary resizing
●
ASMM manages the following components
automatically:
●
Buffer Cache
●
Shared Pool
●
Large Pool
●
Java Pool
●
Oracle internally uses memory tuning algorithm ( 0 to
Optimum value)
73
ASMM (contd)
●
To disable automatic management, set SGA_Target to 0
●
Use Spfile rather than Pfile if you want Oracle to
remember the sizes of the automatically tuned memory
components across an instance shutdown
●
View to check the current size of autotuned components:
v$sga_dynamic_components
74
Automatic Statistics Collection
●
Normally, Oracle checks the optimizer statistics to select
the best execution plan with the least cost
●
Optimizer cannot function properly if you do not feed up
todate statisitcs
●
Poor statistics mean nonoptimal execution plan
●
Oracle recommends that you let the database collect
optimizer statistics automatically through Automatic
Optimizer Statistics Collection
75
Automatic Statistics Collection (cont)
●
Statistics include:
●
Table Statistics
●
Column Statistics
●
Index Statisitcs
●
System Statistics
76
Oracle 10g
Miscellaneous Features
77
Misc Features
●
Database Alerts:
– DBAs generally use SQL scripts to alert them when abnormal
conditions occur
– Oracle 10g has built in system for alerts
– Oracle 10g users indicators called Metrics which will show the
rate of change of a cumulative statistic
– MMON process collects database metrics continuously and
automatically saves them in SGA
78
Misc Features (contd)
●
Job Scheduler:
– Scheduler is required to run automated tasks
– Oracle 10g has built in feature to perform some routine tasks
all by itself
– Scheduler user PL/SQL programs for scheduling and
managing database
– Using scheduler you can run PL/SQL Stored procedures, Java
stored procedures, C functions, SQL Scripts, Windows Scripts
or Unix Scripts
79
Misc Features (contd)
●
Drop Database:
– Drop the database along with all the physical files
– Startup restrict
– Drop database
80
Misc Features (contd)
●
Advisory Framework:
– Oracle 10g provides server advisors to provide you with
automatic performance details about various subsystems of the
database
– Oracle has built a Common Manageability Structure that
makes easy to manage the advisors
– All the advisors get their raw data from AWR
– ADDM recommends using the management advisors on an ad
hoc basis, whenever a performance problem needs a deeper
analysis. DBAs can also use it for analysis
81
Misc Features (contd)
●
Advisory Framework (contd):
– Memory Related
●
Buffer Cache Advisor
Library Cache Advisor
PGA Advisor
– Space Related
●
Segment Advisor
Undo Advisor
– Tuning Related
●
SQL Tuning Advisor
SQL Access Advisor
82
Summary
●
General Storage Enhancements
●
Enterprise Manager DB Control
●
Backup and Recovery Enhancements
●
Flashback Features
●
Automatic Storage Management
●
SelfManaged Database
●
Miscellaneous Features
83