Saturday, July 31, 2010

RMAN Backup and Recovery

RMAN Backup:
Listener shld be start
#xhost +
#mkdir /u01/prd
#mkdir /u01/rmanprd
#su – oracle
$export ORACLE_SID=prd
$sqlplus / as sysdba
sys@prd>startup
sys@prd>create tablespace rman_ts datafile ‘/u01/prd/rmants1.dbf’ size 300m;
sys@prd>create user rman identified by abc default tablespace rman_ts;
sys@prd>grant connect,resource,recovery_catalog_owner to rman;
sys@prd>host
$rman target system/manager rcvcat rman/abc@prdservice
Rman>create catalog;
Rman>register database;

Full Database Backup Script
Run {
Allocate channel c1 type disk;
Backup full database filesperset 1 format ‘/u01/rmanprd/rman%s.%p’;
Release channel c1;
}

Recovery Loss of User Data file Script
Run {
Allocate channel c1 type disk;
Sql ‘alter database datafile 4 offline’;
Restore datafile 4;
Recover datafile 4;
Sql ‘alter database datafile 4 online’;
Release channel c1;
}

Recovery Loss of Control File Script
Run {
Allocate channel c1 type disk;
Restore controlfile;
Restore database;
Sql ‘alter database mount’;
Recover database;
Sql ‘alter database open resetlogs’;
Release channel c1;
}

Recovery Loss of Redo Log File Script
Run {
Allocate channel c1 type disk;
Restore database;
Recover database;
Sql ‘alter database open resetlogs’;
Release channel c1;
}

Listener and TNS Configuration

Listener Configuration(server Side)
#su – oracle
$netca
Listener Configuration –Next
Add –Next
Listener name= LISTENER
Selected protocols =TCP – Next
Use standard port = 1521
Would u like to configure anoter instance =No –Next - Finish
$cd $ORACLE_HOME/network.admin
$vi listener.ora
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC=
(SID_NAME=prd
(ORACLE_HOME=‘/u01/app/oracle/product/11.2.0/db_1/)
)
)
)
Exit code 0 (check for this)
$lsnrctl stop
$lsnrctl start
TNS Configuration: (client side)
$netca
Local Net Service Name Configuration – Next
Add – Next
Service Name =prd (SID Name)
TCP –Next
Host Name =ecs01 or 192.168.1.1
Service Name=prdservice
No Donot test –next –Next – Finish
$tnsping prdservice

Oracle Database Installation On RHEL 5.0

Oracle Database Installation:
#xhost +
#su - oracle
$dbca
Create database – Next
General Purpose – Next
Global Database Name=prd
SID=prd
Uncheck configure Enterprise Manager – Next
Use same administrative password for all accouts
system – sys ---manager
select use database file from template – Next
check specify flash recovery area
check enable archive mode – Next
check sample schemas (optional)
and remaining be the default values – Next – Finish

$pwd
/u01
$vi login.sql
Set sqlp “_user’@’_connect_identifier>”
$sqlplus / as sysdba
If any occurs like error while loading shared libraries then enter the below line.
$chcon –t textrel_shlib_t ‘/u01/app/oracle/product/11.2.0/db_1/lib/liblntsh.so.11.1’
$sqlplus / as sysdba
ssy@prd>startup

Oracle 11gR2 Installation on RHEL 5.0

Oracle 11gR2 Installationon RHEL 5.0

Physical RAM:
# grep MemTotal /proc/meminfo
1805312

Swap Memory:
# grep SwapTotal /proc/meminfo
4096532 kb

#mkdir /u01



Creating /u01 File System
Fdisk /dev/sda
Command:n
First cylinder:
Last cylinder:+27g
Command:w
#partprobe /dev/sda13
#Mkfs.ext3 /dev/sda13

Mounting File System

#Mount /dev/sda13 /u01
#Vi /etc/fstab
/dev/sda13 /u01 ext3 defaults 1 2

#df –h /u01

Filesystem Size Used Avail Use% Mounted on
/dev/sda2 27G 166M 26G 2% /u01


#Vi /etc/hosts
192.168.1.1 ecs01.ecsme.com ecs01 ecs01
#Vi /etc /sysconfig/network
Hostname=ecs01.ecsme.com
Neat-tui
Static ip 192.168.1.1
Netmask:255.255.255.0
#service network restart

# uname -r
2.6.18-194.el5xen


Adding Linux Kernel Parameters to support Oracle

#vi /etc/sysctl.conf
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 536870912
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048586
net.ipv4.tcp_wmem = 262144 262144 262144
net.ipv4.tcp_rmem = 4194304 4194304 4194304

Note: we may find the parameters mentioned above already present in the /etc/sysctl.conf file. If they have a value lower then mentioned above then make sure you change it, but if they have a larger value then it is safe to leave it as it is.

Make the kernel parameters changes effective immediately:

# /sbin/sysctl -p

Creating groups and oracle user
#/usr/sbin/groupadd oinstall
#/usr/sbin/groupadd dba
#/usr/sbin/groupadd oper

#/usr/sbin/useradd -g oinstall -G dba,oper –d /u01 oracle

#/usr/bin/passwd oracle
Passwd:oracle

#mkdir -p /u01/app/oracle/product/11.2.0/db_1
#chown -R oracle:oinstall /u01
#chmod -R 775 /u01

#mkdir -p /u01/app/oraInventory
#chown -R oracle:oinstall /u01/oraInventory
#chmod -R 775 /u01

Shell limits for the user Oracle
#vi /etc/security/limits.conf
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536

Where "nproc" is the maximum number of processes available to the user and "nofiles" is the number of open file descriptors.

#vi /etc/pam.d/login
session required pam_limits.so
#vi /etc/selinux/config
SELINUX=disabled


Install necessary packages for Oracle.
Put the Linux Media into DVD and go to the "Server" directory.
For RHEL 5 (32-bit):

binutils-2.17.50.0.6
compat-libstdc++-33-3.2.3
compat-libstdc++-33-3.2.3
elfutils-libelf-0.125
elfutils-libelf-devel-0.125
gcc-4.1.2
gcc-c++-4.1.2
glibc-2.5-24
glibc-common-2.5
glibc-devel-2.5
glibc-devel-2.5
libaio-0.3.106
libaio-0.3.106
libaio-devel-0.3.106
libaio-devel-0.3.106
libgcc-4.1.2
libgcc-4.1.2
libstdc++-4.1.2
libstdc++-4.1.2
libstdc++-devel 4.1.2
make-3.81
sysstat-7.0.2
unixODBC-2.2.11
unixODBC-2.2.11
unixODBC-devel-2.2.11
unixODBC-devel-2.2.11


#reboot

#xhost +

#su – oracle

$xclock (clock shld come)

$pwd
/u01

$echo $SHELL
/bin/bash

$vi .bash_profile
# .bash_profile
ORACLE_HOSTNAME=ecs01.ecsme.com
export ORACLE_HOSTNAME
ORACLE_BASE=/u01/app/oracle
export ORACLE_BASE
ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
export ORACLE_HOME
ORACLE_SID=prd
export ORACLE_SID
ORACLE_TERM=xterm
export ORACLE_TERM
PATH=$ORACLE_HOME/bin:/usr/sbin:$PATH
export PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export LD_LIBRARY_PATH
umask 022

$cd /u01
$ls
linux_11gR2_database_1of2.zip linux_11gR2_database_2of2.zip

$unzip linux_11gR2_database_1of2.zip
$unzip linux_11gR2_database_2of2.zip

$cd database/
$./runInstaller

Configuration Security updates – Next
Install database software only – Next
Single Instance Database Installation – Next
Product Language – English - Next
Enterprise Edition – Next
Installation Location
Oracle base=/u01/app/oracle
Oracle Home=/u01/app/oracle/product/11.2.0/db_1
Create Inventory
Inventory Directory=/u01/app/oraInventory
oraInventory group name = oinstall
Operating System Groups
Oracle dba =dba
OS oper = oper
Checking for Prerequistes – Next
Finish
Installation Begins


Execute the configuration scripts as root after installation.
#/u01/app/oraInventory/orainstRoot.sh
#/u01/app/oracle/product/11.2.0/db_1/root.sh


In the above if u get any errors check for the below
1.File system mounting
2.File Permissions
3.Make sure that Oracle Software is not corrupted and shld be supported by the machine.