Sunteți pe pagina 1din 32

ORACLE 11g

1) Introduction
2) Fundamentals
3) Logical and physical structure
4) Oracle Engine, Database Creation
a. tablespace
b. Dump folders SQL
5) Backups & Recovery
6) RMAN
7) Performance tuning
a. AWR
8) Refresh and Cloning:
9) Partial recovery
10) Advanced Topics (ASM, AWR, ADDM, RAC)
11) UNIX
12) Listener
13) standby database/materialized views/
14) Data Guard
15) ASM
16) OEM
17) Patch update
18) Create SQL

Oracle is Sequential storage.


VERITAS

My Solaris User & password


1. root laxman
2. Oracle oracle
3. OEM User name: Sys password oracle

1
DBA job types:
1. Production : support phone call 24*7…Error find out, service request (SR)
2. Development: Database creation, Installations
3. Application support DBA: Writing PL/SQL …..Reports generating, adding columns.

Accessing data can be done by SQL, Shell scripting, and PERL.

UNIX flavors:

1. Linux: again red hat, Opensuse flavors


2. HP UX: 11-11 or 11-23
3. IBM AIX:
4. Sun Solaris:10

Oracle versioning:

Format: Version, release, OS, Patch set

9i 9.2.0.1, 9.2.0.8
10g 10.2.0.3
11g 11.1.07 11.2.0

How to access to Database?

Putty
SQL Developer by Oracle
TOAD
OEM (High; Monitoring)

Oracle:

2
Oracle is a Relational Database Management System (RDBMS), which uses Relational Data Model to store its database and SQL
(commonly abbreviated as Structured Query Language) to process the stored data

Physical structure:

Memory will measure in blocks (Block is nothing but unit)


1 k=1024 bytes.
Minimum memory unit is Block. 8k.
Extent: Oracle specific, no of blocks
Segments: groups of extents, however, each extent can contain data from only one data file.

The high water mark is the boundary between used and unused space in a segment.

Oracle stores data logically in tablespace, and physically in Datafiles.


Physical: Data Blocks  Extents  Segments 
• Extent contain contiguous of blocks.
• Oracle allocates space for segments in units of one extent. When the existing extents of a segment are full, Oracle allocates
another extent for that segment. Because extents are allocated as needed, the extents of a segment may or may not be
contiguous on disk.
• For segments, extents may or may not be contiguous on disk. A segment can include extents from more than one file; that is a
segment can span Datafiles.
• Each extent can contain data from only one datafile.
• Block size can declared using DB_BLOCK_SIZE

Logical structure:

Tablespace: group of Datafiles.


A segment and all its extents are stored in Tablespace. Index, clusters

Data Blocks:

3
• Oracle manages the storage space in Datafiles of a database in units called data blocks.
• Data block is the smallest unit of data used by a database.
• In physical, OS level, all data is stored in bytes. Each OS has a block size. Oracle requests data in multiples of oracle data
blocks.
Logical: Table, Tablespace

Dictionary tablespace and locally managed tablespace:


Tablespaces that record extent allocation in the data dictionary are called dictionary managed tablespaces, and tablespaces that record
extent allocation in the tablespace header, are called locally managed tablespaces. Click
In "dictionary managed" mode, Free space is recorded in the SYS.FET$ table, and used space in the SYS.UET$ table.
In “Locally managed” mode, each tablespace manages has its own free and used space within a bitmap structure stored in one of the

tablespace's data files. Each bit corresponds to a database block or group of blocks.
SQL>select tablespace_name,extent_management from dba_tablespaces;

Converting Dictionary to locally managed

The DBMS_SPACE_ADMIN package allows DBAs to quickly and easily convert between LMT and DMT mode. Look at these
examples:

SQL> exec dbms_space_admin.Tablespace_Migrate_TO_Local('ts1');

Oracle Server:

An Oracle server includes an Oracle Instance and an Oracle database.

Oracle Instance Physical structure:

It contains Memory and processes. When a database is started on a database server (regardless of the type of computer), Oracle
allocates a memory area called the SGA and starts one or more Oracle processes.

4
The basic memory structures associated with Oracle instance include:

1. System Global Area (SGA), which is shared by all server and background processes.
2. Program Global Areas (PGA), which is private to each server and background process; there is one PGA for each process.
Sometimes we call it as Personal Global Area.

Before 11g, we have to allocate memory for SGA and PGA separately. But in 11g, this oracle instance will allocate memory
dynamically to its PGA, and SGA. So, we have to allocate just to complete instance.

System Global Area or Shared Global Area or SGA:

SGA is a shared memory region allocated by Oracle that contain data and control information for the Oracle instance.

SGA will allocate memory dynamically for each part of its SGA

1. Shared pool: Used to allocate memory for SQL and PL/SQL execution
 Library Cache: It will check syntax, semantics and parsing.
 Data Dictionary Cache: Here it will check user privileges such as login, authorizations and table existence.
2. Keep Cache (Optional): It stores frequent queries.
3. DB buffer cache:
4. Redo Log Buffer Cache: It holds the changes in database for recovery. It will store all queries, except SELECT
statements. Default size 50M

The primary function of the redo log is to record all changes made to data. If a failure prevents modified data from
being written to the Datafiles, then the changes can be obtained from the redo log, so work is never lost.

To protect against a failure involving the redo log itself, Oracle allows a multiplexed redo log so that two or more
copies of the redo log can be maintained on different disks.

The process of applying the redo log during a recovery operation is called rolling forward

5
5. Java pool (Optional): used for java objects and other java execution memory
6. Large Pool (Optional)
7. Keep pool (Optional): it will store frequent queires.

All SGA components allocate and deallocate space in units of granules. Oracle Database tracks SGA memory use in internal numbers
of granules for each SGA component.

6
Syntax/Semantics and parsing

User privileges Table exist/not?

Main processes:
LGWR: log-writer process (Redo Log Buffer Redo Log files)

7
PMON: it is responsible for recovery if user process fails. It will rollback uncommitted transactions. It will cleanup database buffer
cache for freeing resources that were allocated to a process.
Every 3 seconds.
SMON: Systems monitor process
If Oracle crashed hard with a power failure, the SMON process is attached at startup time, and detects any uncompleted work, using
the rollback segments to recover the transactions. In addition, SMON performs periodic cleanup of temporary segments that are no
longer needed, and also perform tablespace operations, coalescing contiguous free extents into larger extents.
SMON is responsible for instance recovery and also sometimes startup.
Wakeup for every 5 minutes.

DBWn: database writer processes


It will write all changes present in buffer cache to Datafiles.

Modified or new data is not necessarily written to a datafile immediately. To reduce the amount of disk access and to increase
performance, data is pooled in memory and written to the appropriate Datafiles all at once, as determined by the database writer
process (DBWn) background process.

CKPT:

Oracle Database Structure:

Oracle database contain Contains Datafiles, Redo files, and Control files.

Every database must contain minimum of 3 Datafiles.


Control file contain location of redo log files, and Datafiles.

Concepts:

Automatic Shared Memory Management:

8
In previous database releases, a database administrator (DBA) was required to manually specify different SGA component sizes by
setting a number of initialization parameters, including the SHARED_POOL_SIZE, DB_CACHE_SIZE, JAVA_POOL_SIZE, and
LARGE_POOL_SIZE parameters.

Oracle Database 10g includes the Automatic Shared Memory Management feature which simplifies the SGA memory
management significantly. In Oracle Database 10g, a DBA can simply specify the total amount of SGA memory available to an
instance using the SGA_TARGET initialization parameter and the Oracle Database will automatically (Dynamically) distribute this
memory among various subcomponents to ensure most effective memory utilization.

Startup Database: There are 3 steps to start database.


1. Startup nomount:
In the nomount phase, the database reads the server parameter file (SPfile/Pfile) and starts up the Oracle Instance, but
the database is not yet associated with the newly started instance. This is usually used in cases where you need to re-
create the control file.
2. Startup mount: it will connect data files.
MOUNT dbname
Mounts a database but does not open it.
Dbname is the name of the database to mount or open. If no database name is specified, the database name is taken
from the initialization parameter DB_NAME.
3. Startup open.

Startup/Shutdown using OEM


Shutdown database:

1. SHUTDOWN NORMAL

No new connections are allowed after the statement is issued.


Before the database is shut down, Oracle waits for all currently connected users to disconnect from the database
2. SHUTDOWN IMMEDIATE
This is better option to shutdown database. It will give message to all the users/connections.

9
• To initiate an automated and unattended backup
• When a power shutdown is going to occur soon
• When use get this message, user must commit or rollback all his transactions within time.
• No new connections are allowed, nor are new transactions allowed to be started, after the statement is issued.
• Any uncommitted transactions are rolled back. (If long uncommitted transactions exist, this method of
shutdown might not complete quickly, despite its name.)
• Oracle does not wait for users currently connected to the database to disconnect. Oracle implicitly rolls back
active transactions and disconnects all connected users.
Shutting Down with the TRANSACTIONAL Option

When you want to perform a planned shutdown of an instance while allowing active transactions to complete first, use the
SHUTDOWN command with the TRANSACTIONAL option:
SHUTDOWN TRANSACTIONAL
Transactional database shutdown proceeds with the following conditions:
• No new connections are allowed, nor are new transactions allowed to be started, after the statement is issued.
• After all transactions have completed, any client still connected to the instance is disconnected.
• At this point, the instance shuts down just as it would when a SHUTDOWN IMMEDIATE statement is submitted.
The next startup of the database will not require any instance recovery procedures.
A transactional shutdown prevents clients from losing work, and at the same time, does not require all users to log off.

3. SHUTDOWN ABORT

You can shut down a database instantaneously by aborting the database's instance. If possible, perform this type of shutdown
only in the following situations:

o The database or one of its applications is functioning irregularly and none of the other types of shutdown works.
o You need to shut down the database instantaneously (for example, if you know a power shutdown is going to occur in
one minute).
o You experience problems when starting a database instance.

10
o When you must do a database shutdown by aborting transactions and user connections, issue the SHUTDOWN command
with the ABORT option:
o An aborted database shutdown proceeds with the following conditions:
o No new connections are allowed, nor are new transactions allowed to be started, after the statement is issued.
o Current client SQL statements being processed by Oracle are immediately terminated.
o Uncommitted transactions are not rolled back.
o Oracle does not wait for users currently connected to the database to disconnect. Oracle implicitly disconnects all
connected users.

The next startup of the database will require instance recovery procedures.

More commands Examples

To start an instance using the standard parameter file, mount the default database, and open the database, enter
STARTUP or STARTUP OPEN database
To start an instance using the standard parameter file, mount the default database, and open the database, enter
STARTUP FORCE RESTRICT MOUNT
Force means restart
Restrict-when some maintenance is going on and
To start an instance using the parameter file TESTPARM without mounting the database, enter
STARTUP PFILE=testparm NOMOUNT
To shutdown a particular database, immediately restart and open it, allow access only to users with the RESTRICTED SESSION
privilege, and use the parameter file MYINIT.ORA.
STARTUP FORCE RESTRICT PFILE=myinit.ora OPEN database

Oracle Database creation:

First we will setup Oracle Home, Oracle Base, and Oracle SID.

Oracle Home: a directory where Oracle software is installed. Top directory.


App/oracle/product/10.0.2/

11
Oracle Base: ORACLE_BASE is an environment variable used as base directory.
/app/Oracle
Oracle SID: The Oracle System identifier is used to uniquely identify a particular database on a system. For this reason, one cannot
have more than one database with the same SID on a computer system.

Linux: Export ORACLE_SID=orcl


Windows: set ORACLE_SID=orcl

We can create database in two ways


1. Manual
2. DBCA (GUI)
Generally in real-time we will use DBCA only. To know how in deeply with installation, it’s better to start with manual
database creation.

Dump folders:

A Dump: Audit files


B Dump: Background
C Dump: Core Dump; it will store all oracle internal errors.
U Dump: User Dump; it will store user bugs/errors. All these bugs genereally solved by Oracle support team.

It will create alert files and Trace log.


In oracle 11g, A dump, and B Dump were replaced by BP Dump.

Tablespace:

When we creating a database, it will automatically creates following tablespaces


1. SYSTEM:
Every oracle database contains a tablespace named SYSTEM, is always online when the database is open.
SYSTEM tablespace always contains the data dictionary tables for the entire database. DD tables resides in datafile 1.
All space usage is managed by bitmap segment in 1st part of 1st datafile

12
2. SYSAUX
It is an auxiliary tablespace to the SYSTEM tablespace Many database components use the SYSAUX tablespace as the default
location to store data.
It is centralized location for database metadata that does not reside in the SYSTEM tablespace.
3. UNDO
These are special tablespaces used solely for storing undo information. Undo tablespaces are used for rolling back transactions.
Each oracle instance is assigned to only one undo tablespace at a time. But we can have nu number of undo tablespaces.
4. TEMP
More than 1 tablespace can be online and active in a database. (after 10g, new concept tablespace group)
When SYSTEM tablespace is locally manages, it is must to define one temporary tablespace when creating tablespace.
If SYSTEM is dictionary managed and we do not define temp tablespace, then SYSTEM is still used for default temporary
storage. However we will receive a warning in ALERT LOG saying that tt is recommended.
5. BIGFILE
Bigilfe tablespace eases database administration because it consists of only 1 datafile with max of 128TB.
One datafile with larger size will take more time compared to number of Datafiles with same size.

Manual Database creation:

1. Create folders for dump files, data files (Datafiles in Admin folder)
2. Create P file
3. Set ORACLE_HOME, and ORACLE_SID or set .oraenv
4. Set PATH=$PATH:$ORACLE_HOME/bin or create spfile
5. Login to sqlplus
sqlplus ‘/as sysdba
6. Instance up
Startup nomount pfile=’/…../pfile.ora’;
7. DB creation
@/…./createdb.sql
8. Running default oracle scripts
@/u01/oracle/rdbms/admin/catalog.sql
@/u01/oracle/rdbms/admin/catproc.sql

13
And after that login as system
SQL>connect system/manager
and run following script
SQL>@/..11.2.0/sqlplus/admin/pubbuild.sql
And again login to sysdba
Connect sys as sysdba

DBCA:
GUI..Just follow the screens…first it will ask for HOME and SID.

To login to database:

$ ORACLE_SID=LAXMAN
$ ORACLE_HOME=/u01/app/product/11.2.0
$ export ORACLE_HOME
$ export ORACLE_SID
$ PATH=$PATH:$ORACLE_HOME/bin
$ export PATH
1. $ sqlplus '/as sysdba' or Sqlplus /as sysdba
And
startup pfile=’…/pfile.ora’;
Or
We can create sp file, once you login to sqlplus it will search for sp file

To create spfile
Create spfile from pfile=’….’;

After creation of database:

1. To check databae status

14
Select * from v$instance
2. To check Datafiles
Select file_name, tablespace_name from dba_data_files;
By default oracle will generate 3 datafiles called system, sysaux, undo.dbf
3. To add tablespace to database
CREATE TABLESPACE my_tablespace DATAFILE ’/u01/oracle/oradata/data01.dbf’ size 100M;
4. To add datafile to tablespace
Alter tablespace <name> add datafile ‘…./newdf.dbf’ size 100M;
5. Rename tablespace
Alter tablespace ts1 rename to ts1new
After installation to check components installed
6. Select comp_name,version,status,= from dba_registry
Some links psoug OnlineAppsDBA

Transaction Management:

SQL statement executing successfully means following tasks.

Parsed
Found to be valid statement
Run without any error.

Committing SQL statement can be done in two ways.

1. Implicitly: Normal termination of application or completion of DDL operation.


2. Explicitly: giving COMMIT command
Statement level Rollback:

Creating users for oracle:

15
In a database, there are various types of users which have different responsibilities and rights. The main categories are: Two user accounts are
automatically created with the database and granted the DBA role. These two user accounts are:

SYS (initial password: CHANGE_ON_INSTALL)

SYSTEM (initial password: MANAGER)

Creating new user:


create user customer identified by customer default tablespace tbs_data temporary tablespace tb_temp

Backup & Recovery:


Loss of Bank debit card (Imagine if you don’t have net banking) and you want to know amount in account.
Restoration: last stmt
Recovery: transactions after the stmt (By checking bills, receipts)

There are two types of backups


1. Logical: reading a set of database records and writing them to XML binary file. Data pump is tool
a. Data Pump Export
b. Data Pump Import: reads the dump file created by Data Bump Export and executes the commands/scripts such as
Create Table, Insert.

2. Physical: We will use RMAN to take physical backups; optionally we can write scripts to take physical backups.

There are 2 types of backups in physical


1. Cold (Offline): backup when DB shutdown (not at the time of failure)
2. Hot (Online)

Cold Backup: In cold backup we will shutdown the database and we will take the backup. But it is not consistent.
When taking a cold backup of the database, ensure that database polling is disabled before shutting down the database.
Otherwise, the database will still be opened by the Oracle Fail Safe.
Must mount mode
Hot Backup: no need to shutdown database. It works only if archive log is active.

16
To check archive log status
SQL> archive log list;
If it is “No Active mode” then
Shutdown the database and again startup in mount stage;
SQL>Shutdown immediately;
SQL>startup mount;
Then run following command
SQL> alter database archivelog;
Now again bring database into open mode
SQL> alter database open;
Now list the files to do backup
SQL> select file_name, tablespace_name from dba_data_files;
SQL> alter tablespace users begin backup;

Tablespace altered.

SQL> host cp /u01/app/…..df1.dbf /u01/app/backup/


SQL> alter tablespace users end backup;
SQL>EXIT
-----Incomplete-----

RMAN: Recovery manager

$ rman target / (By default no catalog mode; control_file_record_keep_time)

There are two types of backups in RMAN


1. Full backup
2. Incremental
Incremental 0 means full backup, Levels 1, 2, 3
If it is in mount mode. Is nothing but cold backup
If u do in open mode, then its hard backup

17
It backups only control files, Datafiles, archived redo log files; but not redo log files

Advantages over traditional backup:

1. True incremental
2. Tape support: all major backup systems support inside RMAN. We need Media Management Layer (3rd party software).
3. Multiple I/o channel
4. Compression
5. Block level backup: only we can restore particular backup
6. Skip unused blocks
7. Open database backups: without using open/end backup. Must be archivelog mode
8. Block level recovery
9. Cataloging: a record of RMAN backups stored in target database control file, and optionally in recovery catalog stored in other
database.
10. Platform independent: RMAN scripts can save in recovery catalog for retrieval during a backup session.

11. Duplicate command


Backup Types:

1. Consistent and inconsistent


2. Full and incremental
3. Image copies
4. Backup sets and backup pieces
Backup sets are logical and backup pieces are physical (binary files).
5. Compressed backups

Options in RMAN: Link1


NLS_LANG and NLS_DATE_FORMAT.
1. Setting up a repository
To do RMAN backup in catalog mode, we need one database dedicated to RMAN with one user and tablespace.
a. Create tablespace

18
SQL> CREATE TABLESPACE my_tablespace DATAFILE ’/u01/oracle/oradata/data01.dbf’ size 100M;
b. Create rman user and allocate default tablespace (also account Unlock)
c. Grant permission to user for recovery_catalog_owner
SQL>GRANT RECOVERY_CATALOG_OWNER TO rman;
SQL>alter user rman default tablespace tbsp1 quota unlimited on tbsp1
d. Then connect to RMAN (SID is RMAN database) (possible error: if no listener found then enter command $ lstnrctl
start / or check listener status by $lstnrctl status )
$rman catalog user/password@DatabaseName
Or
$rman catalog user@Database (then it will ask for password)

Output: Connected to recovery catalog database


Recovery catalog is not installed
Now we will create catalog

RMAN> create catalog <tablespace ts_rman>


Output: recovery catalog created
NOTE: SID set to target database
2. Registering a database
$rman target / catalog username/password@RMAN Database_name
3. RMAN>register database;

database registered in recovery catalog


starting full resync of recovery catalog
full resync complete

Optional commands in RMAN:

1. Retension policy: set RMAN to ..days to keep backup by using following command
RMAN>configure retension policy to recovery window of 4 days;
By default it is off, whenever RMAN need space, it will delete old backups.

19
2. Device type: by default it is disk, v can chance this type to tape
RMAN> Configure channel device type sbt
Params=’ENV= (<vendor specific>)’;
NOTE: sbt is device type used for tape, default is Disk
3. Control file Autobackup
RMAN> configure controlfile autobackup on;
4. Backup compression
RMAN>configure device type disk backup to compressed backupset;
We backup database level, tablespace level, datafile level. Whenever we do backup these, it will backup control file and spfile
automatically (if auto controlfile backup is ON).

ASM backup can do only by RMAN tool.

Performance tuning:

There are two types of tuning.

1. SQL Tuning: To check SQL query

a. Auto Tracing: it will just imagine by reading query. (exit poll)


SQL>Set Autotrace traceonly; then it will give execution plan for query.
Explain plan for <query>
Then it will store results in following table.
UTLXPLS.SQL - Shows plan table output for serial processing
UTLXPLP.SQL - Shows plan table output with parallel execution columns

Then select * from table.


It is only for current session.

b. SQL Trace: it will execute query really and gives the exact result with proofs. (real poll)
1. If we want to SQL trace for current session (and also we can set identifier to identify later)

20
Alter session set sql_trace =true;
Alter session set tracefile_identifier=myidentifier;
2. To trace other session
First find out SID and serial number of process by using command
SQL> select sid, serial# from sys.v_$session where ...
Then enable tracing for particular process
SQL> ALTER SYSTEM SET timed_statistics = true;
SQL> execute dbms_system.set_sql_trace_in_session(8, 13607, true);
Then execute
SQL>execute dbms_system.set_sql_trace_in_session(8,13607, false);
To trace an entire database
SQL>ALTER SYSTEM SET sql_trace = true SCOPE=MEMORY;

It will create one trace file in Udump with “xx.trc” binary content
To read .trc file, oracle providing tool called TKProf, and it will generate all contents in text file.

TKprof located in ORACLE_HOME/bin directory.


$ Tkprof lax.trc lax.txt
SQL Tuning adviser: if we don’t have OEM;

2. System Tuning: To check entire database.

There are some reasons to slower database operations


1. Application: problem with SQL query, so need to tune the query.
2. Database: less buffer size,
3. Network: network delays (network class, I/O class)

Statspack; Up to 9i; it will take snapshot of complete database for every x minutes.
Statspack won’t install by default when installing oracle, we have to create 1 user and generate scripts to install.
After 9i statspack was replaced by AWR from 10g.

21
For every snapshot, it will assign one ID.

Its better if more logical reads (nothing but reads from cache)

AWR (Automatic workload repository) (background lo running default.)

It will install by default when installing oracle.


Oradebug tool and AWR tool are used to

There are 2 types algorithms/optimizer up to Oracle 9i to execute SQL query.

1. Rule based: we will give rule, whatever the result or


2. Cost based: oracle will decide what search is better such as indexes or PK.
It is based on statistics
We will generate stats for tables; and it will store in system file.
If there are more insertions and deletions in database then we have to analyze stats weekly.

Weight events: where database waiting more. Is there any need of creating Indexes? Why it is not using existing indexes?
AWR is html file
AWR Reports Analysis:

ADDM: automatic database Diagnostic Monitoring: just give 2 screenshots; based on data captured on AWR, ADDM diagnose
the performance and major issues.
ADDM text format file
ADDM file contains which query consuming more time. Like 100% impact. Just send it to developers
Do we need SQL Tuning?
----------
Oracle Enterprise Manager (OEM): Maximum we will use only for production.
SQL adviser
It will suggest efficient SQL query also

22
SQL tuning analyzer, dbms analyzer

Partial Recovery:

Export tool: for user table backup


Import same….

1. If one table is dropped, but database is running good. (Table is logical; it contains 1 or more Datafiles).
2. If we want to recover one single table we must create auxiliary database (nothing but temp table) and apply archive log.
3. If we want to backup just one user tables.
It is nothing but partial recovery…
Export Username/pwd@dbName
Import uname/pwd@db for recovery

Replaced by “Data Pump” in 11g…. Same as export, import

Standby database:

Data Guard
We always maintain one stand by database to production.
For any query, oracle will write necessary actions to both production database and stand by database.
It is replica of original database.
It is mainly for disaster recovery.
Whenever we want to work with production database (upgrading, pat installation, shutdown) then we will up the standby database
and shutdown the actual database. After done with standby database, again we will up the actual db and down standby.

General ga mount lo…production db down ayyinappudu idi open chestam.


We will use high bandwidth for standby DB.

Max Protection mode: it will update both prod DB and Standby DB, then commited/inserted. (network delay, failure)
Max Availability mode: only prod database updates and it will give commited, then in backend it will update standby DB.

23
Max Performance mode: it will give transaction committed statement to user immediately, not a matter Standby is updated or not?
Generally we will use max performance.

Data guard is for disaster recovery


In 11g oracle active data guard
It will updates standby database as happens in database.

Materialized views:

Object
We will create materialized view at development database, with customized separate tables, and also one materialized log in the
original (production) database. 1st we will send all data to MV, after that changed data (just like incremental backup).
It is mainly to analyze production data. Performance, cost.
Create dblink (username, password)

We will create dblink between source & destinations.


First we will create refresh (full backup)

Listener:

$ lstnrctl start / or check listener status by $lstnrctl status

If remote connection wants to connect database, a database must be configure its Oracle Net listener.
We will create Listener with ip address, port number for each database.
Application will send request with ip address, port number, listener will connect to particular database
TNS entry
Home/network/admin/listener.ora target database
Home/network/admin/Tnsnames.ora client
For each host only 1 listener (on 1 host, any number of dbs)
V can create any number of TNS entries

24
Generally oracle create automatically when DB installing, or we will configure using “netca” (just like DBCA)
TNSNames.ora in client system with database ip address, port number
Listener.ora on server

Oracle client windows lo install cheyyali…chesi..solaris lo unna

No need of listener for TOAD SQLPLUS

Protocols and default ports available for Listeners


• TCP 1521
• TCPS
• IPC
• NMP
Listener.ora contains four parts.
• Header section
• Protocol address list
• Instance definitions
• Operational parameters

To connect remote database, user needs following


• Need Server name/hostname
• Port
• Database
• TNS entries at client
Descriptor: Contain network location, and identification of service. These will generate automatically by netca

Data Dictionary:

STSTEM tablespace contain data dictionary.

25
Data dictionary views:
V$ views are dynamic, use it in database mount or open stage. (Single)
Dba_ views are static; used when only database open mode. Only when DB is open. (Plural)

ASM
ASM lets combine disks, storage, volumes into single pool storage just like volume manager does.
It will provide automatic high performance environment.
Automatically stripes data across storage.
Balances I/O.
ASM cluster file system (ACFS)

OEM:
Mylistener

My OEM User name: Sys password oracle (user: DBSNMP)


To run OEM
Listener and dbconsole process must be running
To check listener status
$ lsnrctl start / or check listener status by $lstnrctl status
To check dbconsole status from ORACLE_HOME/bin
$./emctl status dbconsole
And to start
$./emctl start dbconsole

RAC:

To login from one node to another node, we will use ssh<hostnae><command>


Each node in RAC requires

26
• Has a minimum of 3 IP addresses: one for public network, one for private network interconnect, and a virtual IP address to
support faster failover in the event of node failure.
• at least 2 network cards, one is to connect public network for client communication, and other one is for private network
traffic between nodes in cluster
Some points:
• ORACLE_SID is unique on each node.
• Groups oinstall and dba must exist on each node with oracle user
• Both ssh and scp are configured for all nodes in cluster. (rsh and rcp?)
• ASMLib is library for Linux is a support library for ASM instances in Oracle 10g and later.
• Database and recovery files will use ASM disks configured with ASMLib. OCR and voting disks will use raw devices
(Oracle recommended).
NOTE: OCFS is alternative to raw and ASM disks. can be used to store both database files and executables on a common
shared file system.

Oracle Cluster File System (OCFS):


To install the oracle software, some platforms such as Linux, require OCFS version 2.x or later.
The shared file system /u01 use this OCFS2 to share the oracle executable files among nodes in the cluster and causes saving
installation time and duplication of the same executables on each node in cluster.

Steps to create RAC


1. Cluster Ready Service (CRS: 250MB) is the clustering solution that can be used on all major platforms.
Installation in its Home directory.(CRS_HOME)
2. Oracle software installation
3. Creating instance on each node
Raw devices?
Cluster Ready Services:
We have to configure two particular locations that are used by cluster itself which will use raw devices.
1. Oracle Cluster Registry (OCR disk: Min 256 MB): it is metadata repository. it will store its metadata and 256MB min
space is required.
2. Voting disk: contains info about nodes weather nodes are up or down, so that v can shutdown node

27
Both these OCR and voting disk must be on separate raw devices. Used by CRS.

 When user requested for data, first instance checks cache, if not then it will pull up from data file. (Reading data from cache is
logical read, and reading from storage/Datafiles is physical read; logical read are good for better performance.)

Patch Update:
Metalink.oracle.com
Patches & UpdatesPatch searchyou can search by patch ID or Number or Advance search
For Advance searchProduct is RDBMS Server
And select Release and OS Click Search
(For Example for Oracle 10.2.0.110.2.0.4 on Linux server; Patch ID is 4518443
1. Stand alone patch
2. patch set: combination of patches

Steps:
1. Download the Patch
2. Uninstall the patch (It will create folder with patch ID)
3. Must read ReadMe file before updating contains in directory. (it contains, what bug is fixing, steps, Oracle Version)
4. If we use “opatch apply” command to apply, no need to shutdown database.

Creating tables

PL/SQL: Procedural Language Structured Query Language.

SQL>create table employee (id char(9) not null,lastname varchar(10),salary number(10,2),hired date, primary key(id));
SQL> insert into employee values(1,'lucky',200, date '2007-01-01');
UNIX
1. If you want change folder owner (generally Unix admin people will do)
chown –R oracle:dba /….

28
2. For search and replace in vi editor (s-search; g-replace)
1,$ s/old…word/new…word/g
3. To remove file
rm filename
4. To remove folder that contain files
rm –R folder_name
5. List of users
cat /etc/passwd
6. To delete user
userdel username
7. To see ip addresses
cat /etc/hosts
Q: ssh –oracle db

Oracle Commands:

2. To find list of databases


Solaris: Cat /var/opt/oracle/oratab (oratab must have readwrite permissions, chmod 755 /etc/oratab from root)
UNIX: cat /etc/oratab
3. To find list of users
Cat /etc/passwd
SQL> select * from all_users;
4. To create p file from spfile
Create pfile=’/…../pfile.ora’ from spfile;
5. SQL> set linesize 200;
6. SQL> column file_name format a60;
7. To view list of port numbers
$ORACLE_HOME/install/portlist.ini

8. SQL> Screen Col name for a45

29
9. To findout abt sharedpool desc v$shared_pool_advice; working

10. v$db_cache_advice working

11. To find out Redo Log buffer size

SQL>Show parameters log_buffer;

12. for all commands


select table_name from dict where table_name like 'v$buffer'

13. To view datafiles select table_name from dict where table_name lke ' working
14. desc dba_data_files
15. select name,bytes/1024/1024 from v$datafile;
16. select distinct pool from v$sgastat; or select * from v$sgastat;
17. desc v$sgaas
18. to findout startup time
Select to_char(startup_time, 'HH24:MI DD-MON-YY') "Startup time" from v$instance
19. Ps –ef | grep PMON to see list of instaces running
20. To set editor
SQL>define_editor=vi
21.

Questions:
1. When we will use dictionary managed tablespace?
2. UNDO tablespace is default or we have to create manually?
3. . oraenv? .bash profile?
4. Oracle Instance MOUNT lo opens? Or only open mode.
5. When changing values, old values written to UNDO before COMMIT. And what happens to UNDO after COMMIT
6. If OS supports disk mirroring, control files can also mirrored. What mirroring means?
7. Retention

30
8. Instance recovery only in RAC configuration?
9. Tablespace repository
10. Cursors/Index
11. Do we need to start listener manually or it will start automatically when database created/startup?
If we use dbca, it will configure automatically.
12. Net service name? tnsnames.ora? Listener.ora where they exist? Service??
13. 1 datafile with auto extend? Adding more Datafiles??? Which one is better?
14. Streams (Golden gate purchased by oracle)
15. DBA_HIST tables,
16. wait event analysis; Oracle Wait Interface,
17. Stats Pack (9i) = AWR (10g)
18. We have normal database and now want to change RAC. What are the sets to take??
19. Standby Database/materialized view/DataGuard
20. Disk mirroring
21. OEM Grid
22. Crontab –Unix job scheduler
23. DBS files?

Requirements:

1. Four Main Responsibilities:


1)Creation of Oracle database objects
2)Working with development of business projects
3)Backup and Recovery
4)Database refreshing
2. Install, maintain and troubleshoot relational databases and data replication processes.
3. Enterprise Manager Grid

Changing HOST name


Explain plan

31
TOP

32

S-ar putea să vă placă și