//
database.
//
//
db_32K_cache_size) parameters.
RMAN's
backup performance by recording changed blocks in each datafile in a change tracking file.
If change tracking is enabled, RMAN uses the change trackingfile to identify changed blocks
for incremental backup, thus avoiding the need to scan every block in the datafile.
One change tracking file is created for the whole database. By default, the
change tracking file is created as an Oracle managed file in DB_CREATE_FILE_DEST. We can
also specify the name of the block change tracking file, placing it in any desired location.
Using change tracking in no way changes the commands used to perform incremental
backups, and the change trackingfiles themselves generally require little maintenance after
initial configuration.
From Oracle 10g, the background process Block Change Tracking Writer (CTWR) will do the
job of writing modified block details to block change tracking file.
In a Real Applications Clusters (RAC) environment, the change tracking file must be located
on shared storage accessible from all nodes in the cluster.
Although RMAN does not support backup and recovery of the change-tracking file itself, if
the whole database or a subset needs to be restored and recovered, then recovery has no
user-visible effect on change tracking. After the restore and recovery, the
change tracking file is cleared, and starts recording block changes again. The
next incremental backup after any recovery is able to use change-tracking data.
After enabling change tracking, the first level 0 incremental backup still has to scan the
entire datafile, as the changetracking file does not yet reflect the status of the blocks.
Subsequent incremental backup that use this level 0 as parent will take advantage of the
change tracking file.
To store the change tracking file in the database area, set DB_CREATE_FILE_DEST in the
target database. Then issue the following SQL statement to enable change tracking:
SQL> ALTER DATABASE ENABLE BLOCK CHANGE TRACKING;
We can also create the change tracking file in a desired location, using the following SQL
statement:
SQL> ALTER DATABASE ENABLE BLOCK CHANGE TRACKING USING FILE
'/u02/rman/rman_change_track.f';
The REUSE option tells Oracle to overwrite any existing file with the specified name.
If you choose this method, you will lose the contents of the change tracking file. Until the
next time you complete a level 0 incremental backup, RMAN will have to scan the entire file.
Typically, the space required for block change tracking is approximately 1/30,000 the size of
the data blocks to be tracked. The following two factors that may cause the file to be larger
than this estimate suggests:
To avoid overhead of allocating space as database grows, the change tracking file
size starts at 10MB, and new space is allocated in 10MB increments. Thus, for
any database up to approximately 300GB the file size is no smaller than 10MB, for up to
approximately 600GB the file size is no smaller than 20MB, and so on.
For each datafile, a minimum of 320K of space is allocated in the change tracking
file, regardless of the size ofthe file. Thus, if you have a large number of relatively small
datafiles, the change tracking file is larger than for databases with a smaller number of
larger datafiles containing the same data.
RAC BASICS
Volume Manager:
In computer storage, logical volume management or LVM provides a method of allocating space
on mass-storage devices that is more flexible than conventional partitioning schemes. In particular, a
volume manager can concatenate, stripe together or otherwise combine partitions into larger virtual
ones that administrators can re-size or move, potentially without interrupting system use.
The Volume Manager builds virtual devices called volumes on top of physical disks. Volumes are
accessed by a UNIX file system, a database, or other applications in the same way physical disk
partitions would be accessed. Volumes are composed of other virtual objects that can be manipulated
to change the volume's configuration. Volumes and their virtual components are referred to as Volume
Manager objects. Volume Manager objects can be manipulated in a variety of ways to optimize
performance, provide redundancy of data, and perform backups or other administrative tasks on one or
more physical disks without interrupting applications. As a result, data availability and disk subsystem
throughput are improved.
Large file systems require the capacity of several disks, but most file systems must be created on a
single device. A hardware RAID device is one solution to this problem. A hardware RAID device appears
as a single device while in fact containing several disk drives internally. There are other excellent
benefits of hardware RAID, but it is an expensive solution if one simply needs to make many small disks
look like a single big disk. Volume managers are the software solution to this problem. A volume
manager is typically a mid-level block device driver (often called a volume driver) which makes many
disks appear as a single logical disk. In addition to existing in the kernel's block I/O path, a volume
manager requires user level programs to configure and manage partitions and volumes. The virtualized
storage perspective produced by volume managers is so useful that often all storage, including
hardware RAID, is controlled with a volume manager.
A physical disk is the underlying storage device (media), which may or may not be under Volume
Manager control. A physical disk can be accessed using a device name such as c#b#t#d#, where c# is the
controller, b# is the bus, t# is the target ID, and d# is the disk number.
A physical disk can be divided into one or more partitions. The partition number, or s#, is given at the
end of the device name
Storage Area Network (SAN) is a high-speed network or subnetwork whose primary purpose is to
transfer data between computer and storage systems. A storage device is a machine that contains
nothing but a disk or disks for storing data. A SAN consists of a communication infrastructure, which
provides physical connections; and a management layer, which organizes the connections, storage
elements, and computer systems so that data transfer is secure and robust.
Typically, a storage area network is part of the overall network of computing resources for an
enterprise. A storage area network is usually clustered in close proximity to other computing resources
but may also extend to remote locations for backup and archival storage. SANs support disk mirroring,
backup and restore, archival and retrieval of archived data, data migration from one storage device to
another, and the sharing of data among different servers in a network. SANs can incorporate
subnetworks with network-attached storage (NAS) systems.
There are a few SAN technologies available in today's implementations, such as IBM's optical fiber
ESCON which is enhanced by FICON architecture, or the newer Fibre Channel technology. High speed
Ethernet is also used in the storage Area Network for connection. SCSI and iSCSI are popular
technologies used in the Storage Area Network.
SAN's architecture works in a way that makes all storage devices available to all servers on
a LAN or WAN. As more storage devices are added to a SAN, they too will be accessible from any server
in the larger network. A Storage Area Network can be anything from two servers on a network
accessing a central pool of storage devices to several thousand servers accessing many millions of
megabytes of storage.
Internet Small Computer System Interface (iSCSI) is a TCP/IP-based protocol for establishing and
managing connections between IP-based storage devices, hosts and clients, which is called Storage
Area Network (SAN). The SAN makes possible to use the SCSI protocol in network infrastructures for
high-speed data transfer at the block level between multiple elements of data storage networks.
The architecture of the SCSI is based on the client/server model, which is mostly implemented in an
environment where devices are very close to each other and connected with SCSI buses. Encapsulation
and reliable delivery of bulk data transactions between initiators and targets through the TCP/IP
network is the main function of the iSCSI. iSCSI provides mechanism for encapsulating SCSI commands
on an IP network and operates on top of TCP.
For today - SAN (Storage Area Network), the key requirements of data communication are: 1)
Consolidation of data storage systems, 2) Data backup, 3) Server clusterization, 4) Replication, 5) Data
recovery in emergency conditions. In addition, SAN is likely geographic distribution over multiple LANs
and WANs with various technologies. All operations must be conducted in a secure environment and
with QoS. iSCSI is designed to perform the above functions in the TCP/IP network safely and with
proper QoS.
iSCSI Address and Naming Conventions: An iSCSI node is an identifier of SCSI devices (in a network
entity) available through the network. Each iSCSI node has a unique iSCSI name (up to 255 bytes) which
is formed according to the rules adopted for Internet nodes.
iSCSI Session Management: The iSCSI session consists of a Login Phase and a Full Feature Phase which
is completed with a special command.
iSCSI Error Handling: Because of a high probability of errors in data delivery in some IP networks,
especially WAN, where the iSCSI can work, the protocol provides a great deal of measures for handling
errors.
iSCSI Security: As the iSCSI can be used in networks where data can be accessed illegally, the
protocol allows different security methods.
By carrying SCSI commands over IP networks, iSCSI is used to facilitate data transfers over intranets
and to manage storage over long distances. iSCSI can be used to transmit data over local area
networks (LANs), wide area networks (WANs), or the Internet and can enable location-independent
data storage and retrieval.
The protocol allows clients (called initiators(In the relationship between your computer and the storage
device, your computer is called an initiator because it initiates the connection to the device, which is
called a target.)) to send SCSI commands (CDBs) to SCSI storage devices (targets) on remote servers. It
is a storage area network (SAN) protocol, allowing organizations to consolidate storage into data center
storage arrays while providing hosts (such as database and web servers) with the illusion of locally
attached disks. Unlike traditional Fibre Channel, which requires special-purpose cabling, iSCSI can be
run over long distances using existing network infrastructure.
Oracle Clusterware :
Oracle Clusterware is software that enables servers to operate together as if they are one server. Each
server looks like any standalone server. However, each server has additional processes that
communicate with each other so the separate servers appear as if they are one server to applications
and end users. In addition Oracle Clusterware enables the protection of any Oracle application or any
other kind of application within a cluster.
A cluster is a group of independent servers used in a network that cooperate as a single system.
Clustering is a technique used to create a highly available and easily scalable environment. Cluster
software is the software running on each of these servers that provides the intelligence, which enables
the coordinated cooperation of those servers. If one of the cluster servers fails, the work previously
running on that server can be restarted on another available server in the cluster.
Clusterware monitors all components like instances and listeners. There are two important components
in Oracle clusterware, Voting Disk and OCR (Oracle Cluster Registry). Voting disk and the OCR is
created on shared storage during Oracle Clusterware installation process.
OCR File :- Cluster configuration information is maintained in Oracle Cluster Registry file. OCR relies
on a distributed shared-cache architecture for optimizing queries against the cluster repository. Each
node in the cluster maintains an in-memory copy of OCR, along with an OCR process that accesses its
OCR cache.
When OCR client application needs to update the OCR, they communicate through their local OCR
process to the OCR process that is performing input/output (I/O) for writing to the repository on disk.
The OCR client applications are Oracle Universal Installer (OUI), SRVCTL, Enterprise Manger (EM),
Database Configuration Assistant (DBCA), Database Upgrade Assistant(DBUA), NetCA and Virtual Internet
Protocol Configuration assistant (VIPCA). OCR also maintains dependency and status information for
application resources defined within CRS, specifically databases, instances, services and node
applications.
Note:- The name of the configuration file is ocr.loc and the configuration file variable is ocrconfig.loc
Oracle Cluster Registry (OCR) :- resides on shared storage and maintains information about cluster
configuration and information about cluster database. OCR contains information like which database
instances run on which nodes and which services runs on which database. The OCR also manages
information about processes that Oracle Clusterware controls. The OCR stores configuration
information in a series of key-value pairs within a directory tree structure. The OCR must reside on
shared disk that is accessible by all of the nodes in your cluster. The Oracle Clusterware can multiplex
the OCR and Oracle recommends that you use this feature to ensure cluster high availability.
Note:- You can replace a failed OCR online, and you can update the OCR through supported APIs such as
Enterprise Manager, the Server Control Utility (SRVCTL), or the Database Configuration Assistant (DBCA
Voting Disk: - Manages cluster membership by way of a health check and arbitrates cluster ownership
among the instances in case of network failures. RAC uses the voting disk to determine which instances
are members of a cluster. The voting disk must reside on shared disk. For high availability, Oracle
recommends that you have multiple voting disks. The Oracle Clusterware enables multiple voting disks.
There isnt really any useful data kept in the voting disk. So, if you lose voting disks, you can simply
add them back without losing any data. But, of course, losing voting disks can lead to node reboots. If
you lose all voting disks, then you will have to keep the CRS daemons down, then only you can add the
voting disks
Cache Fusion:
Cache Fusion is disk less cache coherency mechanism in Oracle RAC that provides copies of data
blocks directly from one instances memory cache (in which that block is available) to other instance
(instance which is request for specific data block). Cache Fusion provides single buffer cache (for all
instances in cluster) through interconnect.
In Single Node oracle database, an instance looking for data block first checks in cache, if block is not
in cache then goes to disk to pull block from disk to cache and return block to client.
In RAC Database there is remote cache so instance should look not only in local cache (cache local to
instance) but on remote cache (cache on remote instance). If cache is available in local cache then it
should return data block from local cache; if data block is not in local cache, instead of going to disk it
should first go to remote cache (remote instance) to check if block is available in local cache (via
interconnect)
This is because accessing data block from remote cache is faster than accessing it from disk.
Heart Beat:
A heartbeat is a polling mechanism, similar to a ping, that monitors the availability of other servers in
a RAC system. The heartbeat is a type of polling mechanism that is sent over the cluster interconnect
to ensure that all RAC nodes are available.
The heartbeat is part of the clusterware node monitoring. When a node does not respond to a
heartbeat signal, the instance is assumed to have crashed and it is "evicted"(expelled or quit) from the
cluster.
Public IP: The public IP address name must be resolvable to the hostname. You can register both the
public IP and the VIP address with the DNS. If you do not have a DNS, then you must make sure that
both public IP addresses are in the node /etc/hosts file (for all cluster nodes)
Private IP: A private IP address for each node serves as the private interconnect address for internode
cluster communication only. Oracle RAC requires "private IP" addresses to manage the CRS, the
clusterware heartbeat process and the cache fusion layer
Virtual IP: A public internet protocol (IP) address for each node, to be used as the Virtual IP address
(VIP) for client connections. If a node fails, then Oracle Clusterware fails over the VIP address to an
available node. This address should be in the/etc/hosts file on any node. The VIP should not be in use
at the time of the installation, because this is an IP address that Oracle Clusterware manages. Oracle
uses a Virtual IP (VIP) for database access. The VIP must be on the same subnet as the public IP
address. The VIP is used for RAC failover (TAF).
DNS SERVER: The Domain Name System (DNS)is a standard technology for managing the names of Web
sites and other Internet domains. DNS technology allows you to type names into your Web browser
like redshoretech.com and your computer to automatically find that address on the Internet. A key
element of the DNS is a worldwide collection of DNS servers.
A DNS server is any computer registered to join the Domain Name System. A DNS server runs specialpurpose networking software, features a public IP address, and contains a database of network names
and addresses for other Internet hosts.
If suppose we got a large storage array, and requirement is to not allow one server to use all storage
spaces, so it need to divided into logical units as LUN(Logical Unit Number). So LUN allow us slice
storage array into usable storage chunks and present same to server. LUN basically refer to either a
entire physical volume or subset of larger physical disk or volume. LUN represent logical abstraction or
you can say virtual layer between physical disk and application. A LUN is scsi concept.
As we know most storage devices use SCSI command set to communicate. In simple words you can say
the devices which are connected via SCSI parallel bus are controlled with SCSI command set.
A LUN on a scsi parallel bus is is used to electrically address the devices. Multiple devices appear on
single connection because of LUN. So finally I can say for a system admin LUN is a uniquely identifiable
storage device.
Overview of Inventory
The inventory is a very important part of the Oracle Universal Installer. This is where OUI keeps all
information regarding the products installed on a specific machine.
There are two ypes of inventories
1)Global or Central Inventory:- The Global Inventory records the physical location of Oracle
products installed on the machine, such as ORACLE_HOMES (RDBMS and IAS) or JRE. It does
not have any information about the detail of patches applied to each ORACLE_HOMEs.
The Global Inventory gets updated every time you install or de-install an ORACLE_HOME on
the machine, be it through OUI Installer, Rapid Install, or Rapid Clone.
Note: If you need to delete an ORACLE_HOME, you should always do it through the OUI deinstaller in order to keep the Global Inventory synchronized.
Pointer File:-Pointer File is user to know the location of Global Inventory.Location of pointer file is
/etc/oraInst.loc. By looking into the contents of pointer file we can know the location of global
inventory.
2)Local Inventory:- Local inventory contains information of installed softwares which are specific to
single ORACLE_HOME.There is one Local Inventory per ORACLE_HOME. It is physically located inside the
ORACLE_HOME at $ORACLE_HOME/inventory and contains the detail of the patch level for that
ORACLE_HOME.
The Local Inventory gets updated whenever a patch is applied to the ORACLE_HOME, using OUI.
If the Local Inventory becomes corrupt or is lost, this is very difficult to recover, and may result in
having to reinstall the ORACLE_HOME and re-apply all patchsets and patches.
Instance name=RLINK
hostname=mydbt4db4
datafile location=/u03/oradata/RLINK, /u02/oradata/RLINK
Redolog file location=/u03/oradata/RLINK
Archive log file location=/u02/oradata/arch_RLINK
RLINK
[oracle@mydbt4db4 ~]$
If the duplicate is going to happen on different server, move the backup pieces to a new server using
commands like ftp,scp etc
8) Connect to the auxiliary instance from RMAN and perform the rman duplicate as follows
rman auxiliary /
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
{
sql clone "create spfile from memory";
}
.
.
.
.
.
executing Memory Script
contents of Memory Script:
{
Alter clone database open resetlogs;
}
executing Memory Script
database opened
Finished Duplicate Db at 26-NOV-12
Instance name=TLINK
hostname=mydbt4db4
datafile location=/u03/oradata/TLINK, /u02/oradata/TLINK
Redolog file location=/u03/oradata/TLINK
Archive log file location=/u02/oradata/arch_TLINK
Note: Before proceeding with active duplication ,rman should be fully configured
on
Source side with or without catalog database.
db_file_name_convert='/u03/oradata/DLINK','/u03/oradata/TLINK','/u02/oradata/DLINK','/u02/
oradata/TLINK'
)
)
SID_LIST_TLINK =
(SID_LIST =
(SID_DESC =
(ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1)
(SID_NAME = TLINK)
)
)
SID_LIST_DLINK =
(SID_LIST =
(SID_DESC =
(ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1)
(SID_NAME = DLINK)
)
)
[oracle@mydbt4db2 admin]$ lsnrctl start DLINK
to_tLINK=
(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=mydbt4db4.redLINKtech.com)(PORT=1526))
(CONNECT_DATA=
(SID=TLINK)
)
)
[oracle@mydbt4db4 admin]$ tnsping to_dLINK
TNS Ping Utility for Linux: Version 11.2.0.1.0 - Production on 26-NOV-2012 14:15:40
Copyright (c) 1997, 2009, Oracle. All rights reserved.
Used parameter files:
TNS Ping Utility for Linux: Version 11.2.0.1.0 - Production on 26-NOV-2012 14:15:51
Copyright (c) 1997, 2009, Oracle. All rights reserved.
Used parameter files:
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION= (ADDRESS=(PROTOCOL=tcp)
(HOST=mydbt4db4.redLINKtech.com)(PORT=1526)) (CONNECT_DATA= (SID=TLINK)))
OK (50 msec)
TNS Ping Utility for Linux: Version 11.2.0.1.0 - Production on 26-NOV-2012 02:27:09
instance requires a text-based initialization parameter file, then this file must exist on the
same host that runs the RMAN client application.
In this bulletin we are doing duplicate database from the auxiliary server. Look at the
example :
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
database opened
Finished Duplicate Db at 26-NOV-12
RMAN>
SQL> startup;
ORACLE instance started.
Database opened.
*
ERROR at line 1:
ORA-25153: Temporary Tablespace is Empty
ORA-06512: at line 1
Note :- If you get ORA-25153 error then you need to assign a default temporary tablespace to database.
I f you get any output other than no rows selected then we cannot export tablespace , we need to go
through that output and we should take appropriate actions.
SQL>exit.
In destination
SQL> startup;
ORACLE instance started.
TABLESPACE_NAME
---
------------------------------
NO
SYSTEM
NO
SYSAUX
NO
UNDOTBS1
NO
TEMPTS1
YES
TTS
* Enables management of database objects without specifying mount points and filenames.
* Supports large files.
The ASM instance shares the Oracle home with the database instance. If you plan on running multiple
database instances on the server the ASM instance should be installed in a separate Oracle home.
ASM can be configured using two methods of creating disks:
a) Using asmlib
b) Using rawdevices.
Before we proceed with the installation/configuration of ASM,it is always better to skid through the
below contents,and make yourself aware of the same:
1) DISK PARITIONING:
A) To check the paritions available on your machine,use the command > fdisk -l
B) To parition the current available filesystem,follow the below:
# fdisk /dev/sda
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content wont be recoverable.
The number of cylinders for this disk is set to 1305.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Warning: invalid flag 00000 of partition table 4 will be corrected by w(rite)
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-1305, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-1305, default 1305):
Using default value 1305
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
#
#To check what packages/drivers are installed on your system, use the below command:
rpm qa | grep i oracleasm
With the software installed, configure the ASM kernel module.
# /etc/init.d/oracleasm configure
Configuring the Oracle ASM library driver.
This will configure the on-boot properties of the Oracle ASM library
driver. The following questions will determine whether the driver is
loaded on boot and what permissions it will have. The current values
will be shown in brackets ([]). Hitting without typing an
answer will keep that current value. Ctrl-C will abort.
Default user to own the driver interface []: oracle
Default group to own the driver interface []: oinstall
Start Oracle ASM library driver on boot (y/n) [n]: y
Fix permissions of Oracle ASM disks on boot (y/n) [y]:
Writing Oracle ASM library driver configuration: [ OK ]
Creating /dev/oracleasm mount point: [ OK ]
Loading module oracleasm: [ OK ]
Mounting ASMlib driver filesystem: [ OK ]
Scanning system for ASM disks: [ OK ]
#
Once the kernel module is loaded, stamp (or label) the partitions created earlier as ASM disks.
# /etc/init.d/oracleasm createdisk VOL1 /dev/sda1
Marking disk /dev/sdb1 as an ASM disk: [ OK ]
# /etc/init.d/oracleasm createdisk VOL2 /dev/sdb1
Marking disk /dev/sdc1 as an ASM disk: [ OK ]
# /etc/init.d/oracleasm createdisk VOL3 /dev/sdc1
Marking disk /dev/sdd1 as an ASM disk: [ OK ]
#
If this were a RAC installation, the disks would only be stamped by one node. The other nodes would
just scan for the disks.
# /etc/init.d/oracleasm scandisks
Scanning system for ASM disks: [ OK ]
#
The stamped disks are listed as follows.
# /etc/init.d/oracleasm listdisks
VOL1
VOL2
VOL3
#
The disks are now ready to be used by ASM.
To administer the Automatic Storage Management library driver and disks, use the oracleasm
initialization script with different options, as follows:
# /etc/init.d/oracleasm configure
# /etc/init.d/oracleasm enable
# /etc/init.d/oracleasm restart
# /etc/init.d/oracleasm createdisk DISKNAME devicename
# /etc/init.d/oracleasm deletedisk DISKNAME
Caution: Do not use this command to unmark disks that are being used by an Automatic Storage
Management disk group. You must drop the disk from the Automatic Storage Management disk group
before you unmark it.
querydisk
Use the querydisk option to determine whether a disk device or disk name is being used by the
Automatic Storage Management library driver:
# /etc/init.d/oracleasm querydisk {DISKNAME | devicename}
listdisks
Use the listdisks option to list the disk names of marked Automatic Storage Management library driver
disks:
# /etc/init.d/oracleasm listdisks
scandisks
Use the scandisks option to enable cluster nodes to identify which shared disks have been marked as
Automatic Storage Management library driver disks on another node:
# /etc/init.d/oracleasm scandisks
Raw Device Setup
This step is only necessary if you want ASM to access the disks as raw devices.
Edit the /etc/sysconfig/rawdevices file, adding the following lines.
/dev/raw/raw1 /dev/sda1
/dev/raw/raw2 /dev/sdb1
/dev/raw/raw3 /dev/sdc1
Restart the rawdevices service using the following command.
root@localhost ~]# service rawdevices restart
Assigning devices:
/dev/raw/raw1 > /dev/sda1
/dev/raw/raw1: bound to major 8, minor 3
/dev/raw/raw2 > /dev/sdb1
/dev/raw/raw2: bound to major 8, minor 7
/dev/raw/raw3 > /dev/sdc1
/dev/raw/raw3: bound to major 8, minor 8
done
[root@localhost ~]#
Run the following commands and add them the /etc/rc.local file.
chown oracle:oinstall /dev/raw/raw1
chown oracle:oinstall /dev/raw/raw2
chown oracle:oinstall /dev/raw/raw3
chmod 600 /dev/raw/raw1
chmod 600 /dev/raw/raw2
chmod 600 /dev/raw/raw3
The ASM raw device disks are now configured.
ASM CREATION:
Creation of the ASM instance is the same, regardless of the use of ASMLib or raw devices. When using
ASMLib, the candidate disks are listed using the stamp associated with them, while the raw devices are
listed using their device name.
To configure an ASM instance, start the Database Configuration Assistant by issuing the ./runInstaller
command as the oracle user. On the Welcome screen, click the Next button.
Select the Advanced Installation, then click the Next Button.
Select the Configure Automatic Storage Management option, then click the Next Button.
On the next page, when using raw devices, the candidate discs are listed using the device names. So
check the devices and redundancy (High, normal and external) as per your requirement.
click on change disk discovery path and search with string > /dev/raw/* (Only for linux)
On the ASM Disk Groups screen. Click the Finish button.
Click the Yes button to perform another operation.
You are now ready to create a database instance using ASM.
ASM Instance creation:
After you configure the kernel parameters and Bash profile, performing the following.
$ export ORACLE_SID=+ASM
$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 Production on Sat Jul 6 14:01:06 2011
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 Production
With the Partitioning, OLAP and Data Mining options
SQL> alter system register;
System altered.
SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 Pr oduction
With the Partitioning, OLAP and Data Mining options
$
DATABASE CREATION:
Go back to the DBCA and create a custom database in the normal way, selecting the Automatic
Storage Management (ASM) storage option.
Enter the ASM password if prompted, then click the OK button.
Select the DATA disk group, then clicking the Next button.
Accept the default Oracle-Managed Files database location by clicking the Next button.
Enable the Flash Recovery Area and Archiving, using the +DATA disk group for both.
Continue with the rest of the DBCA, selecting the required options along the way.
To create an ASM instance first create a file called init+ASM.ora in the /tmp directory containing the
following information.
INSTANCE_TYPE=ASM
Next, using SQL*Plus connect to the ide instance.
export ORACLE_SID=+ASM
sqlplus / as sysdba
Create an spfile using the contents of the init+ASM.ora file.
SQL> CREATE SPFILE FROM PFILE=/tmp/init+ASM.ora;
File created.
Finally, start the instance with the NOMOUNT option.
SQL> startup nomount
ASM instance started
Total System Global Area 125829120 bytes
Fixed Size 1301456 bytes
Variable Size 124527664 bytes
Database Buffers 0 bytes
Redo Buffers 0 bytes
SQL>
The ASM instance is now ready to use for creating and mounting disk groups. To shutdown the ASM
instance issue the following command.
SQL> shutdown
ASM instance shutdown
SQL>
Once an ASM instance is present disk groups can be used for the following parameters in database
instances (INSTANCE_TYPE=RDBMS) to allow ASM file creation:
*
*
*
*
*
*
*
DB_CREATE_FILE_DEST
DB_CREATE_ONLINE_LOG_DEST_n
DB_RECOVERY_FILE_DEST
CONTROL_FILES
LOG_ARCHIVE_DEST_n
LOG_ARCHIVE_DEST
STANDBY_ARCHIVE_DEST
eno.ename;
Exit When
Page 14 of 259
C1 %notfound;----commit;
end loop;
end;
The cursor having query as SELECT .... FOR UPDATE gets closed after COMMIT/ROLLBACK.
The cursor having query as SELECT.... does not get closed even after COMMIT/ROLLBACK.
15. Explain the usage of WHERE CURRENT OF clause in cursors ?
WHERE CURRENT OF clause in an UPDATE,DELETE statement refers to the latest row fetched from
a
cursor.
Database Triggers
16. What is a database trigger ? Name some usages of database trigger ?
Database trigger is stored PL/SQL program unit associated with a specific database table. Usages
are Audit
data modificateions, Log events transparently, Enforce complex business rules Derive column
values
automatically, Implement complex security authorizations. Maintain replicate tables.
17. How many types of database triggers can be specified on a table ? What are they ?
Insert Update Delete
Before Row o.k. o.k. o.k.
After Row o.k. o.k. o.k.
Before Statement o.k. o.k. o.k.
After Statement o.k. o.k. o.k.
If FOR EACH ROW clause is specified, then the trigger for each Row affected by the statement.
If WHEN clause is specified, the trigger fires according to the retruned boolean value.
18. Is it possible to use Transaction control Statements such a ROLLBACK or COMMIT in Database
Trigger ? Why ?
It is not possible. As triggers are defined for each table, if you use COMMIT of ROLLBACK in a
trigger, it affects logical transaction processing.
19. What are two virtual tables available during database trigger execution ?
The table columns are referred as OLD.column_name and NEW.column_name.
For triggers related to INSERT only NEW.column_name values only available.
For triggers related to UPDATE only OLD.column_name NEW.column_name values only available.
For triggers related to DELETE only OLD.column_name values only available.
20. What happens if a procedure that updates a column of table X is called in a database trigger of
the same table ?
Mutation of table occurs.
21. Write the order of precedence for validation of a column in a table ?
I. done using Database triggers.
ii. done using Integarity Constraints.
22. What is an Exception ? What are types of Exception ?
Exception is the error handling part of PL/SQL block. The types are Predefined and user_defined.
Some of
Predefined execptions are.
CURSOR_ALREADY_OPEN
DUP_VAL_ON_INDEX
NO_DATA_FOUND
TOO_MANY_ROWS
INVALID_CURSOR
INVALID_NUMBER
LOGON_DENIED
NOT_LOGGED_ON
PROGRAM-ERROR
STORAGE_ERROR
TIMEOUT_ON_RESOURCE
VALUE_ERROR
ZERO_DIVIDE
OTHERS.
23. What is Pragma EXECPTION_INIT ? Explain the usage ?
The PRAGMA EXECPTION_INIT tells the complier to associate an exception with an oracle error. To
get an error message of a specific oracle error.
e.g. PRAGMA EXCEPTION_INIT (exception name, oracle error number)
24. What is Raise_application_error ?
Raise_application_error is a procedure of package DBMS_STANDARD which allows to issue an
user_defined error messages from stored sub-program or database trigger.
25. What are the return values of functions SQLCODE and SQLERRM ?
SQLCODE returns the latest code of the error that has occured.
SQLERRM returns the relevant error message of the SQLCODE.
26. Where the Pre_defined_exceptions are stored ?
In the standard package.
Procedures, Functions & Packages ;
27. What is a stored procedure ?
A stored procedure is a sequence of statements that perform specific function.
28. What is difference between a PROCEDURE & FUNCTION ?
A FUNCTION is alway returns a value using the return statement.
A PROCEDURE may return one or more values through parameters or may not return at all.
29. What are advantages fo Stored Procedures /
Extensibility,Modularity, Reusability, Maintainability and one time compilation.
30. What are the modes of parameters that can be passed to a procedure ?
IN,OUT,IN-OUT parameters.
31. What are the two parts of a procedure ?
Procedure Specification and Procedure Body.
32. Give the structure of the procedure ?
PROCEDURE name (parameter list.....)
is
local variable declarations
BEGIN
Executable statements.
Exception.
exception handlers
end;
33. Give the structure of the function ?
FUNCTION name (argument list .....) Return datatype is
40. Name the tables where characteristics of Package, procedure and functions are stored ?
User_objects, User_Source and User_error.
1.
SQL> SELECT sum(bytes)/1024/1024 FROM user_segments;
SUM(BYTES)/1024/1024
2552.75
-- OR -2.
SQL> SELECT tablespace_name, Sum(bytes)/1024/1024 AS total_size_mb
FROM dba_segments
WHERE owner = Upper(&User_Name)
GROUP BY owner, rollup(tablespace_name)
-- OR -3. To be more precise on particular table which excluding index,lob segments etc
SQL> SELECT sum(bytes)/1024/1024/1024 as size_gig, segment_type
FROM dba_segments
WHERE owner='XXX'
GROUP BY segment_type;
Implementing Dataguard on 11g RAC
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = RAC_STDBY01-vip)(PORT = 1521)
(IP = FIRST))
)
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = RAC_STDBY01)(PORT = 1521)
(IP = FIRST))
)
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC))
)
)
)
SID_LIST_LISTENER_RAC_STDBY01 =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME=RAC_STDBY_dgmgrl.local)
(SID_NAME = RAC_STDBY1)
(ORACLE_HOME = $ORACLE_HOME)
)
)
using the service name RAC_STDBY1_DGMGRL ** This will be used for the database
duplication.
RAC_STDBY1.local Points to the RAC_STDBY instance on RAC_STDBY01 using the
service name RAC_STDBY.local
RAC_STDBY2.local Points to the RAC_STDBY instance on RAC_STDBY02 using the
service name RAC_STDBY.local
RAC_STDBY.local Points to the RAC_STDBY database i.e. Contains all the database
instances
listener_DB_UNIQUE_NAME.local This will be a tns alias entry consisting of two
address lines. The first address line will be the address of the listener on Node1 and
the second will be the address of the listener on Node 2. Placing both of the above
listeners in the address list will ensure that the database automatically registers
with both nodes. There must be two sets of entries. One for the standby nodes call
listener_RAC_STDBY and one for the primary nodes called listener_RAC_PRIM
RAC_PRIM1_DGMGRL.local =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = RAC_PRIM01-vip)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = RAC_PRIM_DGMGRL.local)
)
)
RAC_PRIM1.local =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = RAC_PRIM01-vip)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = RAC_PRIM.local)
(INSTANCE_NAME = RAC_PRIM1)
)
)
RAC_PRIM2.local =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = RAC_PRIM02-vip)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = RAC_PRIM.local)
(INSTANCE_NAME = RAC_PRIM2)
)
)
RAC_PRIM.local =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = RAC_PRIM01-vip)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = RAC_PRIM02-vip)(PORT = 1521))
(LOAD_BALANCE = yes)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = RAC_PRIM.local)
)
)
RAC_STDBY1_DGMGRL.local =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = RAC_STDBY01-vip)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = RAC_STDBY_DGMGRL.local)
)
)
RAC_STDBY2.local=
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = RAC_STDBY02-vip)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = RAC_STDBY.local)
(INSTANCE_NAME=RAC_STDBY2)
)
)
RAC_STDBY1.local=
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = RAC_STDBY01-vip)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = RAC_STDBY.local)
(INSTANCE_NAME=RAC_STDBY1)
)
)
RAC_STDBY.local=
(DESCRIPTION =
(ADDRESS_LIST=
(ADDRESS = (PROTOCOL = TCP)(HOST = RAC_STDBY01-vip)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = RAC_STDBY02-vip)(PORT = 1521)))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = RAC_STDBY.local)
)
)
LISTENERS_RAC_PRIM.local=
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = RAC_PRIM01-vip)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = RAC_PRIM02-vip)(PORT = 1521))
)
The standby database is created from the primary database. In order to achieve
this, up to Oracle10g a backup of the primary database needs to be made and
transferred to the standby and restored. Oracle RMAN 11g simplifies this process by
providing a new method which allows an on the fly-duplicate to take place. This
will be the method used here (the pre-11g method is described in the Appendicies).
From the primary database invoke RMAN using the following command:
export ORACLE_SID=RAC_PRIM1
rman target / auxiliary sys/mypasswd@RAC_STDBY1_dgmgrl
NOTE: If RMAN returns the error rman: cant open target then ensure that
ORACLE_HOME/bin appears first in the PATH because there exists a Linux utility
also named RMAN.
Next, issue the following duplicate command:
duplicate target database for standby from active database
spfile
set db_unique_name=RAC_STDBY
set control_files=+DATA/RAC_STDBY/controlfile/control01.dbf
set instance_number=1
set audit_file_dest=/u01/app/oracle/admin/RAC_STDBY/adump
set remote_listener=LISTENERS_RAC_STDBY
nofilenamecheck;
Before starting this process, note down the value of the control_files parameter from
the currently running standby database
Create SPFILE
Having created the textual initialisation file it now needs to be converted to a spfile
and stored within ASM by issuing:
export ORACLE_SID=RAC_STDBY1
sqlplus / as sysdba
create spfile=+DATA/RAC_STDBY/spfileRAC_STDBY.ora from pfile=
/tmp/initRAC_STDBY.ora
If you wish 3 to have control files simply update the control_files parameter to
include the original controlfile as well as the ones just created.
mount
srvctl add instance d RAC_STDBY i RAC_STDBY1 n RAC_STDBY01
srvctl add instance d RAC_STDBY i RAC_STDBY2 n RAC_STDBY02
Test
Test that the above has worked by stopping any running standby instances and then
starting the database (all instances) using the command:
srvctl start database d RAC_STDBY
Once started check that the associated instances are running by using the
command:
srvctl status database d RAC_STDBY
Temporary Files
Temporary files associated with a temporary tablespace are automatically created
with a standby database.
1. sqlplus / a sysdba
2. startup mount
3. alter database add standby logfile SIZE 100M;
NOTE: Standby Redo Logs are also created in logfile groups. But be aware of the fact
that group numbers then must be greater than the group numbers which are
associated with the ORLs in the primary database. Wrt group numbering Oracle
makes no difference between ORLs and SRLs.
NOTE: Standby Redo Logs need to be created on both databases.
The standby database is now created. The next stage in the process concerns
enabling transaction synchronisation. There are two ways of doing this:
1. Using SQL Plus
2. Using the Data Guard Broker
db_unique_name=PRIMARY_RAC_PRIM VALID_FOR=(ALL_LOGFILES,PRIMARY_ROLE)
log_archive_dest_2 (Max. Performance Mode) service=RAC_PRIM ARCH
db_unique_name=PRIMARY_RAC_PRIM VALID_FOR=(ALL_LOGFILES,PRIMARY_ROLE)
Standby Site
The standby database needs to be placed into Managed Recovery mode. This is
achieved by issuing the statement:
Alter database recover managed standby database disconnect;
Oracle 10gR2 introduced Real Time redo apply (SRLs required). Enabling real time
apply is achieved by issuing the statement:
alter database recover managed standby database using current logfile disconnect;
Primary Site:
Set:
log_archive_dest_state_2=enable
in the init.ora file or issue via SQLPlus :
alter system set log_archive_dest_state_2=enable
How to change the characterset of Oracle 10g DB
Decide the character set you want to change and check whether new character is
superset of old character set
1.SQL> shutdown immediate
2.SQL> startup open restrict
3.SQL> alter database character set internal_use UTF8;
If you wish to monitor the progress of RMAN backup validate, you may issue this
query:
3. Once the validate process is complete, you either check the alert log or a
view depending on the version of Oracle being used.
Oracle Database 11g Top New Features : Summary
Oracle Database 11g Top New Features : Summary
to easily
identify which patches are necessary for the features you are using. EM will allow
you to
subscribe to a feature based patching service, so EM automatically scans for
available
patches for the features you are using
# RMAN UNDO bypass :
Rman backup can bypass undo. Undo tablespaces are getting huge, but contain lots
of
useless information. Now rman can bypass those types of tablespace. Great for
exporting a
tablespace from backup.
# Virtual columns/indexes :
User can create Virtual index on table. This Virtual index is not visible to optimizer,
so it will
not affect performance, Developer can user HINT and see is Index is useful or
not.Invisible
Indexesprevent premature use of newly created indexes
# New default audit settings :
Oracle database where general database auditing was "off" by default, logging is
intended
to be enabled by default with the Oracle Database 11g beta secure configuration.
Notable
performance improvements are planned to be introduced to reduce the
performance
degradation typically associated with auditing.
# Case sensitive password :
Passwords are expected to also become case sensitive This and other changes
should result
in better protection against password guessing scenarios. For
example, in addition to limiting the number of failed login attempts to 10 (default
configuration in 10gR2), Oracle 11g betas planned default settings should expire
passwords every 180 days, and limit to seven the number of times a user can login
with an
expired password before disabling access.
# Faster DML triggers : Create a disabled trigger; specify trigger firing order
# Fine grained access control for Utl_TCP:
in 10g all port are available, now it is controlled.
# Data Guard supports "Flashback Standby"
# New Trigger features
# Partitioning by logical object and automated partition creation.
# LOB's - New high-performance LOB features.
# New Oracle11g Advisors
# Enhanced Read only tables
# Table trigger firing order
# Enhanced Index rebuild online : - Online index build with NO pause to DML.
# No recompilation of dependent objects:- When
A) Columns added to tables
B) Procedures added to packages
# Improved optimizer statistics collection speed
# Online index build with NO pause to DML
# Read only table :alter table t read only
alter table t read write
Oracle 11g Database SQL/PL-SQL New Features
---------------------------------------------> Fine Grained Dependency Tracking:
In 11g we track dependencies at the level of element within unit. so that these
changes have
no consequence
Transparent performance improvement
Unnecessary recompilation certainly consumes CPU
create table t(a number)
create view v as select a from t
alter table t add(Unheard_Of number)
select status from User_Objectswhere Object_Name = 'V'
- ----VALID
No recompilation of dependent objects when Columns added to tables OR
Procedures
added to packages
> Named and Mixed Notation from SQL:
select fun(P4=>10) from DUAL
In 10g not possible to call function in select statment by passing 4th parameter,
but in 11g it is possible
> PL/SQL "continue" keyword - It is same as we read in c/c++ loop
> Support for super: It is same "super" in Java.
> Powerfull Regular Expression:
Now we can access data between TAGS like data between tags .........
The new built-in REGEXP_COUNT returns the number of times the pattern is
matched in the
input string.
> New table Data Type "simple_integer"
> SQL Performance Analyzer(SPA) :
It is same as Database replay except it not capture all transaction.The SQL
Performance
Analyzer (SPA) leverages existing Oracle Database 10g SQL tuning components. The
SPA
provides the ability to capture a specific SQL workload in a SQL Tuning Set, take a
performance baseline before a major database or system change, make the desired
change
to the system, and then replay the SQL workload against the modified database or
configuration. The before and after performance of the SQL workload can then be
compared
with just a few clicks of the mouse. The DBA only needs to isolate any SQL
statements that
are now performing poorly and tune them via the SQL Tuning Advisor
> Caching The Results with /*+ result_cache */ :
select /*+ result_cache */ * from my_table, New for Oracle 11g, the result_cache
hint caches
the result set of a select statement. This is similar to alter table table_name
cache,but as you
can adding predicates makes /*+ result_cache */ considerably more powerful by
caching a
subset of larger tables and common queries.
select /*+ result_cache */ col1, col2, col3 from my_table where colA = :B1
> The compound trigger :
A compound trigger lets you implement actions for each of the table DML timing
points in a
single trigger
> PL/SQL unit source can exceeds 32k characters
> Easier to execute table DDL operations online:
Option to wait for active DML operations instead of aborting
> Fast add column with default value:
Does not need to updateall rows to default value.
Oracle 11g Database Backup & Recovery New Features
-----------------------------------------------* Enhanced configuration of archive deletion policies Archive can be deleted , if it is
not
need DG , Streams Flashback etc When you CONFIGURE an archived log deletion
policy
applies to all archiving destinations, including the flash recovery area. BACKUP ...
DELETE
INPUT and DELETE... ARCHIVELOG use this configuration, as does the flash recovery
area.
When we back up the recovery area, RMAN can fail over to other archived redo log
destinations if the flash recovery area is inaccessible.
* Configuring backup compression:
In 11g can use CONFIGURE command to choose between the BZIP2 and ZLIB
compression
algorithms for RMAN backups.
* Active Database Duplication:
Now DUPLICATE command is network aware i.e.we can create a duplicate or
standby
database over the network without taking backup or using old backup.
* Parallel backup and restore for very large files:
RMAN Backups of large data files now use multiple parallel server processes to
efficiently
distribute theworkload for each file. This features improves the performance of
backups.
* Improved block media recovery performance:
RECOVER command can recover individual data blocks.
RMAN take older, uncorrupted blocks from flashback and the RMAN can use these
blocks,
thereby speeding up block media recovery.
* Fast incremental backups on physical standby database:
11g has included new feature of enable block change tracking on a physical standby
database (ALTER DATABASE ENABLE/DISABLE BLOCK CHANGE TRACKING SQL
statement).
This new 11g feature enables faster incremental backups on a physical standby
database
than in previous releases.because RMAN identifywe the changed blocks sincethe
last
incremental backup.
11g ASM New Features
----------------------The new features in Automatic Storage Management (ASM) extend the storage
management automation, improve scalability, and further simplify management for
Oracle Database files.
ASM Fast Mirror Resync
A new SQL statement, ALTER DISKGROUP ... DISK ONLINE, can be executed
after a failed disk has been repaired. The command first brings the disk online for
writes so that no new writes are missed. Subsequently, it initiates a copy of all
extents
marked as stale on a disk from their redundant copies.
This feature significantly reduces the time it takes to repair a failed diskgroup,
potentially from hours to minutes. The repair time is proportional to the number of
extents that have been written to or modified since the failure.
ASM Manageability Enhancements
The new storage administration features for ASM manageability include the
following:
New attributes for disk group compatibility
To enable some of the new ASM features, you can use two new disk group
compatibility attributes, compatible.rdbms and compatible.asm. These
attributes specify the minimum software version that is required to use disk
groups for the database and for ASM, respectively. This feature enables
heterogeneous environments with disk groups from both Oracle Database 10g and
Oracle Database 11g. By default, both attributes are set to 10.1. You must advance
these attributes to take advantage of the new features.
New ASM command-line utility (ASMCMD) commands and options
ASMCMD allows ASM disk identification, disk bad block repair, and backup and
restore operations in your ASM environment for faster recovery.
ASM fast rebalance
Rebalance operations that occur while a disk group is in RESTRICTED mode
eliminate the lock and unlock extent map messaging between ASM instances in
to 64 MB.
Convert Single-Instance ASM to Clustered ASM
This feature provides support within Enterprise Manager to convert a non-clustered
ASM database to a clustered ASM database by implicitly configuring ASM on all
nodes. It also extends the single-instance to Oracle RAC conversion utility to support
standby databases.
Simplifying the conversion makes it easier for customers to migrate their databases
and achieve the benefits of scalability and high availability provided by Oracle RAC.
New SYSASM Privilege for ASM Administration
This feature introduces the new SYSASM privilege to allow for separation of
database
management and storage management responsibilities.
The SYSASM privilege allows an administrator to manage the disk groups that can
be
shared by multiple databases. The SYSASM privilege provides a clear separation of
duties from the SYSDBA privilege.
Dropping a Database in 10G
Dropping a Database in 10G Consists of the following steps.
echo $ORACLE_SID
sqlplus "/as sysdba"
SQL> startup nomount;
ORACLE instance started.
Total System Global Area 1077936128 bytes
Fixed Size 2034344 bytes
Variable Size 427824472 bytes
Database Buffers 633339904 bytes
Redo Buffers 14737408 bytes
SQL> alter database mount exclusive;
Database altered.
SQL> alter system enable restricted session;
System altered.
=> Complete Open Database Recovery (when the database is initially closed).Non
system tablespace is missing
If a non system tablespace is missing or corrupted and the database
crashed,recovery can be performed after the database is open.
Pre requisites: A closed or open database backup and archived logs.
1. startup; (you will get ora-1157 ora-1110 and the name of the missing datafile, the
database will remain mounted)
2. Use OS commands to restore the missing or corrupted datafile to its original
location, ie:
cp -p /user/backup/uman/user01.dbf /user/oradata/u01/dbtst/user01.dbf
3. alter database datafile3 offline; (tablespace cannot be used because the
database is not open)
4. alter database open;
5. recover datafile 3;
6. alter tablespace online;
=> Recovery of a Missing Datafile that has no backups (database is open).
If a non system datafile that was not backed up since the last backup is
missing,recovery can be performed if all archived logs since the creation of the
missing datafile exist.
Pre requisites: All relevant archived logs.
1. alter tablespace offline immediate;
2. alter database create datafile /user/oradata/u01/dbtst/newdata01.dbf;
3. recover tablespace ;
4. alter tablespace online;
If the create datafile command needs to be executed to place the datafile on a
location different than the original use:
alter database create datafile /user/oradata/u01/dbtst/newdata01.dbf as
/user/oradata/u02/dbtst/newdata01.dbf
Rman can be used with the repository installed on the archivelog, or with a recovery
catalog that may be installed in the same or other database.
Configuration and operation recommendations:
Set the parameter controlfile autobackup to ON to have with each backup a
controlfile backup also:
configure controlfile autobackup on;
set the parameter retention policy to the recovery window you want to have,
ie redundancy 2 will keep the last two backups available, after executing delete
obsolete commands:
configure retention policy to redundancy 2;
Execute your full backups with the option plus archivelogs to include your
archivelogs with every backup:
backup database plus archivelog;
Perform daily maintenance routines to maintain on your backup directory the
number of backups you need only:
crosscheck backup;
crosscheck archivelog all;
delete noprompt obsolete backup;
To work with Rman and a database based catalog follow these steps:
1. sqlplus /
2. create tablespace repcat;
3. create user rcuser identified by rcuser default tablespace repcat temporary
tablespace temp;
4. grant connect, resource, recovery_catalog_owner to rcuser
5. exit
6. rman catalog rcuser/rcuser # connect to rman catalog as the rcuser
7. create catalog # create the catalog
8. connect target / #
1.
2.
3.
4.
5.
rman target /
sql alter tablespace offline immediate;
restore datafile 3;
recover datafile 3;
sql alter tablespace online;
1.) Patchset :
2.) Patchset Updates :
1.) Patchset : A group of patches form a patch set. Patchsets are applied by invoking OUI
(Oracle Universal Installer) . Patchsets are generally applied for Upgradation purpose . This results
in a version change for our Oracle software, for example, from Oracle Database 11.2.0.1.0 to
Oracle Database 11.2.0.3.0. We will cover this issue later .
2.) Patchset Updates : Patch Set Updates are proactive cumulative patches containing
recommended bug fixes that are released on a regular and predictable schedule . Oracle has
catergaries as :
i.) Critical Patch Update (CPU) now refers to the overall release of security fixes each quarter
rather than the cumulative database security patch for the quarter. Think of the CPU as the
overarching quarterly release and not as a single patch .
ii.) Patch Set Updates (PSU) are the same cumulative patches that include both the security
fixes and priority fixes. The key with PSUs is they are minor version upgrades (e.g., 11.2.0.1.1 to
11.2.0.1.2). Once a PSU is applied, only PSUs can be applied in future quarters until the
database is upgraded to a new base version.
iii.) Security Patch Update (SPU) terminology is introduced in the October 2012 Critical Patch
Update as the term for the quarterly security patch. SPU patches are the same as previous CPU
patches, just a new name . For the database, SPUs can not be applied once PSUs have been
applied until the database is upgraded to a new base version.
iv.) Bundle Patches are the quarterly patches for Windows and Exadata which include both the
quarterly security patches as well as recommended fixes.
PSUs(PatchSet Updates) or CPUs(Critical Patch Updates) ,SPU are applied via opatch utility.
While applying Patchset or patchset upgrades , basically there are two entities in the Oracle
Database environment
i. ) Oracle Database Software
ii.) Oracle Database
Most of the database patching activities involve, in the following sequence
'./runInstaller' or
'opatch apply'
known as
This approach minimizes the requirement of database shutdown across each patching activity
and simplifies the patching mechanism as two tasks:
Database update.
Here , we will cover the Opatch Utility in details along with example.
OPatch is the recommended (Oracle-supplied) tool that customers are supposed to use in
order to apply or rollback patches. OPatch is PLATFORM specific . Release is based on Oracle
Universal Installer version . OPatch resides in $ORACLE_HOME/OPatch . OPatch supports the
following :
Detecting conflict when applying an interim patch after previous interim patches have
been applied. It also suggests the best options to resolve a conflict .
Reporting on installed products and interim patch.
The patch metadata exist in the inventory.xml and action.xml files exists
under<stage_area>/<patch_id>/etc/config/
Inventory .xml file have the following information :
Bug number
Unique Patch ID
OS platforms ID
Login to metalink.
On the patch search section enter patch number and select the platform of your database.
Click search.
/u01/app/oracle/oradata
/u01/app/oraInventary
Notes :
i.) If we are using a Data Guard Physical Standby database, we must install this patch on both
the primary database and the physical standby database .
ii.) While applying patching take care of mount point status .There should be sufficient Space .
Applying CPUJan2012 Patch on 11.2.0.2/Linux(64 bit)
STEPS:1.
Database Version
2.
OS version
3.
Download CPUJan2012 patch for 11.2.0.2.0
4.
Opatch Version
5.
Sessions Status
6.
Invalid objects
7.
Status of Oracle Services
8.
Backup
9.
Apply Opatch
10.
Post Installation
11.
Check the status from registry$history
12.
Recompiling Views in Database
1) Database Version
SQL> select * from v$version;
BANNER
-------------------------------------------------------------------------------Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
11.2.0.2.0
Production
4) Opatch Version
To apply CPUJan2012, OPatch utility version 11.2.0.1.0 or later to apply this patch. Oracle recommends that you use
the latest released OPatch 11.2, which is available for download from My Oracle Support patch 6880880 by
selecting the 11.2.0.0.0 release
oracle-ckpt.com> export PATH=/u00/app/oracle/product/11.2.0/OPatch:$PATH
oracle-ckpt.com> opatch lsinventory
Invoking OPatch 11.2.0.1.1
Oracle Interim Patch Installer version 11.2.0.1.1
Copyright (c) 2009, Oracle Corporation.
Oracle Home
: /u00/app/oracle/product/11.2.0
: /etc/oraInst.loc
OPatch version
: 11.2.0.1.1
OUI version
: 11.2.0.2.0
OUI location
: /u00/app/oracle/product/11.2.0/oui
Log file location : /u00/app/oracle/product/11.2.0/cfgtoollogs/opatch/opatch2012-0303_06-32-39AM.log
Patch history file:
/u00/app/oracle/product/11.2.0/cfgtoollogs/opatch/opatch_history.txt
11.2.0.2.0
5) Sessions Status
Check How Many sesion are ACTIVE, If any found Ask Application team to bring down all Applications/Processes.
SQL> select username,count(*) from v$session where username is not nulll group by
username;
USERNAME
COUNT(*)
------------------------------ ---------26
SOTCADM
SYS
SQL>
6) Invalid objects
SQL> select count(*),object_type from dba_objects where status <> 'VALID' and
OWNER !='PUBLIC' and OBJECT_TYPE!='SYNONYM' group by object_type;
COUNT(*) OBJECT_TYPE
---------- ------------------38 TRIGGER
2 VIEW
SQL>
7) Status of Oracle Services
oracle-ckpt.com> ps -ef|grep pmon
oracle
8016 30235
0 02:17 pts/0
8019 30235
oracle-ckpt.com>
0 02:17 pts/0
8 ) Backup
Take Cold Backup of Database & Backup of (ORACLE_HOME & Inventory)
oracle-ckpt.com> tar -zcpvf 11.2.0_Home_Inventory_Backup_$(date +%Y%m%d).tar.gz
/u00/app/oracle/product/11.2.0 /u00/app/oraInventory/
/u00/app/oracle/product/11.2.0/
/u00/app/oracle/product/11.2.0/jdev/
/u00/app/oracle/product/11.2.0/jdev/lib/
/u00/app/oracle/product/11.2.0/jdev/lib/jdev-rt.jar
/u00/app/oracle/product/11.2.0/jdev/lib/javacore.jar
/u00/app/oracle/product/11.2.0/jdev/doc/
/u00/app/oracle/product/11.2.0/jdev/doc/extension/
/u00/app/oracle/product/11.2.0/jdev/doc/extension/extension.xsd
/u00/app/oracle/product/11.2.0/olap/
---
------
/u00/app/oraInventory/orainstRoot.sh
/u00/app/oraInventory/ContentsXML/
/u00/app/oraInventory/ContentsXML/comps.xml
/u00/app/oraInventory/ContentsXML/libs.xml
/u00/app/oraInventory/ContentsXML/inventory.xml
/u00/app/oraInventory/install.platform
/u00/app/oraInventory/oui/
/u00/app/oraInventory/oui/srcs.lst
oracle-ckpt.com>
9) Apply Opatch
oracle-ckpt.com> export PATH=$ORACLE_HOME/OPatch:$PATH:
oracle-ckpt.com> opatch napply -skip_subset -skip_duplicate
Invoking OPatch 11.2.0.1.1
UTIL session
Oracle Home
: /u00/app/oracle/product/11.2.0
: /etc/oraInst.loc
OPatch version
: 11.2.0.1.1
OUI version
: 11.2.0.2.0
OUI location
: /u00/app/oracle/product/11.2.0/oui
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> @?/rdbms/admin/catbundle.sql cpu apply
PL/SQL procedure successfully completed.
PL/SQL procedure successfully completed.
Generating apply and rollback scripts...
Check the following file for errors:
/
u00/app/oracle/cfgtoollogs/catbundle/catbundle_CPU_PROD_GENERATE_2012Feb26_02_27_09.lo
g
Apply script: /u00/app/oracle/product/11.2.0/rdbms/admin/catbundle_CPU_PROD_APPLY.sql
Rollback script:
/u00/app/oracle/product/11.2.0/rdbms/admin/catbundle_CPU_PROD_ROLLBACK.sql
PL/SQL procedure successfully completed.
Executing script file...
SQL> COLUMN spool_file NEW_VALUE spool_file NOPRINT
SQL> SELECT '/u00/app/oracle/cfgtoollogs/catbundle/' || 'catbundle_CPU_' || name ||
'_APPLY_' || TO_CHAR(SYSDATE, 'YYYYMonDD_hh24_mi_ss',
'NLS_DATE_LANGUAGE=''AMERICAN''') || '.log' AS spool_file FROM v$database;
SQL> ALTER SESSION SET current_schema = SYS;
Session altered.
SQL> PROMPT Updating registry...
Updating registry...
SQL> INSERT INTO registry$history
2
(action_time, action,
3
namespace, version, id,
4
bundle_series, comments)
5 VALUES
6
(SYSTIMESTAMP, 'APPLY',
7
SYS_CONTEXT('REGISTRY$CTX','NAMESPACE'),
8
'11.2.0.2',
9
4,
10
'CPU',
11
'CPUJan2012');
1 row created.
SQL> COMMIT;
Commit complete.
SQL> SPOOL off
SQL> SET echo off
Check the following log file for errors:
/u00/app/oracle/cfgtoollogs/catbundle/catbundle_CPU_PROD_APPLY_2012Feb26_02_27_12.log
SQL>
11) Check the status from registry$history
COUNT(*) OBJECT_TYPE
---------- ------------------38 TRIGGER
2 VIEW
SQL>
After Patching & Recompile
SQL> select count(*),object_type from dba_objects where status <> 'VALID' and OWNER !
='PUBLIC' and OBJECT_TYPE!='SYNONYM' group by object_type;
COUNT(*) OBJECT_TYPE
---------- ------------------2 VIEW
SQL>
13) Opatch Status
oracle-ckpt.com> opatch lsinventory|grep 13343244
Patch
13343244
/proc/meminfo
Avail
25G
Used
19G
0
3.4G
Use%
44%
Avail
25G
1.5G
0
Mounted on
/
Use%
44%
0%
100%
Mounted on
/
/dev/shm
/media/RHEL_5.3 x86_64 DVD
shared buffers
cached
0
109776
384096
server1.example.com
2.6.18-128.el5 #1
GNU/Linux
SMP
Wed
2008
make-3.81
binutils-2.17.50
gcc-4.1.2
gcc-c++-4.1.2
compat-libcap1
compat-libstdc++-33
glibc-2.5-58
glibc-devel-2.5
libgcc-4.1.2
libstdc++-4.1.2
libstdc++-devel-4
libaio-0.3.106
libaio-devel-0.3
ksh
sysstat
unixODBC
unixODBC-devel
are
required
for
the
Oracle
Installation , so
make
sure
all
the
(x86_64)
(x86_64)
(x86_64)
(x86_64)
(x86_64)
(x86_64)
(x86_64)
(x86_64)
(x86_64)
(x86_64)
(x86_64)
Execute the below command as root to make sure that we have all this rpms installed. If
not installed, then download them from appropriate linux site or we will find the package
from the Red Hat Enterprise Linux 5 DVD . For example ,
# rpm -qa | grep glib*
The above command will display all the installed packages, name starting with glib, similarly
we can check for all others packages . If any of the above packages are not installed, run
the following command:
# rpm -ivh </path/to/><version>.i386.rpm
fs.aio-max-nr = 1048576
net.ipv4.ip_local_port_range = 9000 65500
After adding these lines to /etc/sysctl.conf , run the below command as root to make them
enabled.
# sysctl -p
oracle
oracle
oracle
oracle
soft
hard
soft
hard
the
the
nproc 2047
nproc 16384
nofile 1024
nofile 65536
Where "nproc" is the maximum number of processes available to the user and "nofiles" is
the number of open file descriptors.
We do not have to create these specific group names, but during installation we are prompted
to provide operating system groups whose members are granted access to these system
privileges. we can assign the same group to provide authentication for these privileges, but
Oracle recommends that we should provide a unique group to designate each privileges.
i .) The OSDBA group (typically, dba) : This group identifies operating system user accounts that
have database administrative privileges (the SYSDBA privilege).
#groupadd -g 501 dba
ii .) The Oracle Inventory Group (oinstall) : This group owns the Oracle inventory that is a
catalog of all Oracle software installed on the system. A single Oracle Inventory group is required for
all installations of Oracle software on the system.
# groupadd -g 502 oinstall
iii .) The OSOPER group for Oracle Database (typically, oper) : This is an optional group. We
create this group if we want a separate group of operating system users to have a limited
set of database administrative privileges for starting up and shutting down the database (the
SYSOPER privilege).
# groupadd -g 503 oper
iv .) The OSBACKUPDBA group for Oracle Database (typically, backupdba) : Create this
group if we want a separate group of operating system users to have a limited set of database
backup and recovery related administrative privileges (the SYSBACKUP privilege).
# groupadd -g 504 backupdba
v .) The OSDGDBA group for Oracle Data Guard (typically, dgdba) : Create this group if we
want a separate group of operating sytsem users to have a limited set of
privileges to
administer and monitor Oracle Data Guard (the SYSDG privilege).
# groupadd -g 505 dgdba
vi .) The OSKMDBA group for encyption key management (typically, kmdba) : Create this
group if we want a separate group of operating sytem users to have a limited set of
privileges for encryption key management such as Oracle Wallet Manager management (the
SYSKM privilege).
# groupadd -g 506 kmdba
vii .) The OSDBA group for Oracle ASM (typically, asmdba) : The OSDBA group for Oracle
ASM can be the same group u sed as the OSDBA group for the database, or we can create a
separate OSDBA group for Oracle ASM to provide administrative access to Oracle ASM instances .
# groupadd -g 507 asmdba
viii .) The OSASM group for Oracle ASM Administration (typically, asmadmin) : Create this
group as a separate group if we want to have separate administration privileges groups for
Oracle ASM and Oracle Database administrators. Members of this group are granted the
SYSASM system privileges to administer Oracle ASM .
# groupadd -g 508 asmoper
ix .) The OSOPER group for Oracle ASM (typically, asmoper) : This is an optional group.
Create this group if we want a separate group of operating system users to have a limited set
of Oracle instance administrative privileges (the SYSOPER for ASM privilege), including starting up
and stopping the Oracle ASM instance . By default , members of the OSASM group also have all
privileges granted by the SYSOPER for ASM privilege.
# groupadd -g 509 asmadmin
x . ) Create Oracle user :
# useradd -u 54321 -g oinstall -G dba,asmdba,backupdba,dgdba,kmdba oracle
#passwd oracle
<<ORACLE PASSWORD >>
The -u option specifies the user ID. Using this command flag is optional because the system
can provide with an automatically generated user ID number. However, Oracle recommends
that we should specify a number. We must note the user ID number because we need it during
preinstallation.
Step 11 : Finally run the runInstaller for Installation of Oracle 12c release 1
Once , runInstaller get initaited , OUI get invoked and rest are interative graphical console .
Select "Create and configure a database" option and click on next button
Summary page displays all the locations and database information . Click next