Showing posts with label database administration. Show all posts
Showing posts with label database administration. Show all posts

Tuesday, December 23, 2014

Oracle Database 12c Release 1 RAC On CentOS 6.4 Using VMWare Workstation


Resources:
https://gruffdba.wordpress.com/2013/07/10/oracle-12cr1-12-1-0-1-2-node-rac-on-centos-6-4-on-vmware-workstation-9-introduction/
http://oracle-base.com/articles/12c/oracle-db-12cr1-rac-installation-on-oracle-linux-6-using-virtualbox.php 
http://www.unixmen.com/dns-server-installation-step-by-step-using-centos-6-3/


             rac1                  rac2
        ----------------      --------------------
HDD        40GB                   40GB
eth0       1.0.2.5                1.0.2.6  vment2 Host-Only 
eth1       1.0.3.5                1.0.3.6  vmnet3 Host-Only
eth2       1.0.8.5                1.0.8.6  vmnet8 Nat


- install OS CentOS 6.4 64-bit

http://oracle-base.com/articles/linux/oracle-linux-6-installation.php
Desktop Environments > GNOME Desktop Environment
Applications > Editors
Applications > Graphical Internet
Development > Development Libraries
Development > Development Tools
Servers > Server Configuration Tools
Base System > Administration Tools
Base System > Base
Base System > System Tools
Base System > X Window System

- install VirtualBox additions
 

chmod +x ./VBoxLinuxAdditions.run
./VBoxLinuxAdditions.run


- install Packages using local yum repo
 

cd /etc/yum.repo.d/
mkdir oldrepo
mv ./* oldrepo
vim dvd.repo
[dvd]
name=dvd
baseurl=file:///media/CentOS_6.4_Final
gpgcheck=0
enabled=1
yum clean all
yum makecache
yum repolist


- install required packages for oracle RAC installation
 

yum install binutils -y
yum install compat-libcap1 -y
yum install compat-libstdc++-33 -y
yum install compat-libstdc++-33.i686 -y
yum install gcc -y
yum install gcc-c++ -y
yum install glibc -y
yum install glibc.i686 -y
yum install glibc-devel -y
yum install glibc-devel.i686 -y
yum install ksh -y
yum install libgcc -y
yum install libgcc.i686 -y
yum install libstdc++ -y
yum install libstdc++.i686 -y
yum install libstdc++-devel -y
yum install libstdc++-devel.i686 -y
yum install libaio -y
yum install libaio.i686 -y
yum install libaio-devel -y
yum install libaio-devel.i686 -y
yum install libXext -y
yum install libXext.i686 -y
yum install libXtst -y
yum install libXtst.i686 -y
yum install libX11 -y
yum install libX11.i686 -y
yum install libXau -y
yum install libXau.i686 -y
yum install libxcb -y
yum install libxcb.i686 -y
yum install libXi -y
yum install libXi.i686 -y
yum install make -y
yum install sysstat -y
yum install unixODBC -y
yum install unixODBC-devel -y
cd /
eject


- Amend the hostname in the "/etc/sysconfig/network" file.
 

vim /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=rac1.example.com


- Enter following data to “/ect/hosts”, comment rac-scan must be resolv by DNS server
 

vim /etc/hosts
127.0.0.1       localhost.localdomain   localhost

# Public
1.0.2.5   rac1.example.com   rac1
1.0.2.6   rac2.example.com   rac2

# Private
1.0.3.5   rac1-priv.example.com      rac1-priv
1.0.3.6   rac2-priv.example.com      rac2-priv

# Virtual
1.0.2.11   rac1-vip.example.com       rac1-vip
1.0.2.12   rac2-vip.example.com       rac2-vip

# SCAN
#1.0.2.15   rac-scan.example.com       rac-scan
#1.0.2.16   rac-scan.example.com       rac-scan
#1.0.2.17   rac-scan.example.com       rac-scan


- Edit "/etc/resolv.conf" file in clients in rac1, rac2
 

vim /etc/resolv.conf
nameserver 1.0.2.5
nameserver 1.0.2.6
nameserver 8.8.8.8
search example.com


- edit Network Additions for DNS Server in rac1, rac2ifcfg-eth2
 

vim /etc/sysconfig/network-scripts/ifcfg-eth0 >> PEERDNS=no
vim /etc/sysconfig/network-scripts/ifcfg-eth1 >> PEERDNS=no
vim /etc/sysconfig/network-scripts/ifcfg-eth2 >> PEERDNS=no


- Linux Kernel Parameters for Oracle 11gR2 on RHEL 5, Edit the /etc/sysctl.conf and add following lines:
 

vim /etc/sysctl.conf
# added for Oracle 12cR1
kernel.shmall = 2097152
kernel.shmmax = 3221225472
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.file-max = 6815744
fs.aio-max-nr = 1048576
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 = 1048576

- Now execute “sysctl -p” command to apply the new settings:
 

/sbin/sysctl -p


- Edit the /etc/security/limits.conf file and add following lines:
 

vim /etc/security/limits.conf
# added for Oracle 12cR1
oracle              soft   nproc   2047
oracle              hard   nproc   16384
oracle              soft   nofile  1024
oracle              hard   nofile  65536
oracle              soft   stack   10240
oracle              hard   stack   10240


- Edit the /etc/pam.d/login file and add following line:
 

vim /etc/pam.d/login
# added for Oracle 12cR1
session    required     pam_limits.so


- To make the change permanent, modify the /etc/sysconfig/selinux change value of SELINUX variable to disabled:
 

vim  /etc/sysconfig/selinux
SELINUX=disabled


- To permanently disable the firewall we will disable the service:
 

service iptables stop
chkconfig iptables off


- create the user oracle account and the OS groups:
 

groupadd dba
groupadd oper
groupadd oinstall
groupadd asmdba
groupadd asmadmin
useradd -g oinstall -G dba,oper,asmdba,asmadmin oracle
passwd oracle


- Create the directories in which the Oracle software will be installed.
 

mkdir -p /u01/app/12102/grid
mkdir -p /u01/app/oracle/product/12102/db_1
chown -R oracle:oinstall /u01
chmod -R 775 /u01/


- Login as the "oracle" user and add the following lines at the end of the "/home/oracle/.bash_profile" file.
 

vim /home/oracle/.bash_profile
# Oracle Settings
export TMP=/tmp
export TMPDIR=$TMP

export ORACLE_HOSTNAME=rac1.example.com
export ORACLE_UNQNAME=cdbrac.example.com
export ORACLE_BASE=/u01/app/oracle
export GRID_HOME=/u01/app/12102/grid
export DB_HOME=$ORACLE_BASE/product/12102/db_1
export ORACLE_HOME=$DB_HOME
export ORACLE_SID=cdbrac1
export ORACLE_TERM=xterm
export BASE_PATH=/usr/sbin:$PATH
export PATH=$ORACLE_HOME/bin:$BASE_PATH

export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib

alias grid_env='. /home/oracle/grid_env'
alias db_env='. /home/oracle/db_env'


- Create a file called "/home/oracle/grid_env" with the following contents.
 

vim /home/oracle/grid_env
export ORACLE_SID=+ASM1
export ORACLE_HOME=$GRID_HOME
export PATH=$ORACLE_HOME/bin:$BASE_PATH

export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib


- Create a file called "/home/oracle/db_env" with the following contents.
 

vim /home/oracle/db_env
export ORACLE_SID=cdbrac1
export ORACLE_HOME=$DB_HOME
export PATH=$ORACLE_HOME/bin:$BASE_PATH

export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib



##################### clone Virtual Machine rac1 to rac2 #######################

- in rac1 after poweroff click Edit Virtual Machine Settings > Add > Hard Disk > SCSI >
- Create New Virtual Disk > Space 20 GB, Check Allocate All disk Space now ,
- Store Virtual Disks As Single file > Finish
- from settings > Advanced > select SCSI 1:0 Indepedent , Persisent > Close
- Add same disk to rac2
- edit .vmx file for rac1, rac2
 

- $ vim /data/vmware/rac121-node1/rac121-node1.vmx (in phyiscal machine)

disk.EnableUUID = "TRUE"
disk.locking = "FALSE"
diskLib.dataCacheMaxSize = "0"
diskLib.dataCacheMaxReadAheadSize = "0"
diskLib.dataCacheMinReadAheadSize = "0"
diskLib.dataCachePageSize = "4096"
diskLib.maxUnsyncedWrites = "0"
scsi1.sharedBus = "virtual"


after this line in .vmx file
 

replay.supported = "FALSE"


- $ vim /data/vmware/rac121-node2/rac121-node2.vmx (in phyiscal machine) add theses lines
 

disk.EnableUUID = "TRUE"
disk.locking = "FALSE"
diskLib.dataCacheMaxSize = "0"
diskLib.dataCacheMaxReadAheadSize = "0"
diskLib.dataCacheMinReadAheadSize = "0"
diskLib.dataCachePageSize = "4096"
diskLib.maxUnsyncedWrites = "0"
scsi1.sharedBus = "virtual"


after this line in .vmx file
 

replay.supported = "FALSE"


################ edit changes after clone rac1 to rac2 (in rac2) #################
- Amend the hostname in the "/etc/sysconfig/network" file.
 

vim /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=rac2.example.com


- Edit the "/etc/sysconfig/network-scripts/ifcfg-eth0, eth1 to change ip address for rac2
 

eth0    1.0.2.6       255.255.255.0           internal Network
eth1    1.0.3.6       255.255.255.0           internal Network
eth2    1.0.8.6       255.255.255.0    1.0.8.2    nat


- Edit the "/home/oracle/.bash_profile" file on the "rac2" node to correct the ORACLE_SID and ORACLE_HOSTNAME values.
 

ORACLE_SID=cdbrac2; export ORACLE_SID
ORACLE_HOSTNAME=rac2.example.com; export ORACLE_HOSTNAME


- Also, amend the ORACLE_SID setting in the "/home/oracle/db_env" and "/home/oracle/grid_env" files.
- Create a file called "/home/oracle/grid_env" with the following contents.
 

vim /home/oracle/grid_env
ORACLE_SID=+ASM2; export ORACLE_SID


- edit a file called "/home/oracle/db_env" with the following contents.
 

vim /home/oracle/db_env
ORACLE_SID=cdbrac2; export ORACLE_SID


############### Configure Shared Disks and UDEV rules ###############
-Use the "fdisk" command to partition the disks sdb to sde in rac1.
 

fdisk /dev/sdb > n > p > 1 > w


- Add the following to the "/etc/scsi_id.config" file to configure SCSI devices as trusted. Create the file if it doesn't already exist.
 

/sbin/scsi_id -g -u -d /dev/sdb
36000c29552c32294599f95242522e11a


- Using these values above, edit the "/etc/udev/rules.d/99-oracleasm.rules" in rac1
 

vim /etc/udev/rules.d/99-oracleasm.rules
KERNEL=="sd?1", BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u -d /dev/$parent", RESULT=="36000c29552c32294599f95242522e11a", NAME="asm-disk1", OWNER="oracle", GROUP="asmadmin", MODE="0660"



- start UDEV and list shared disks in rac1
 

/sbin/start_udev
ls -al /dev/asm*


- just refersh disk table and add rules in rac2
 

fdisk /dev/sdb > u > p > w


- Edit "/etc/udev/rules.d/99-oracleasm.rules" file
 

vim /etc/udev/rules.d/99-oracleasm.rules
KERNEL=="sd?1", BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u -d /dev/$parent", RESULT=="36000c29552c32294599f95242522e11a", NAME="asm-disk1", OWNER="oracle", GROUP="asmadmin", MODE="0660"



- start UDEV and list shared disks in rac2
 

/sbin/start_udev
ls -al /dev/asm*



############ install NTP server #################
 

1.0.2.5       rac1.example.com    NTP Server
1.0.2.6       rac6.example.com    NTP Server


- NTP Server configure in rac1, rac2 same steps
 

chkconfig ntpd on


- Edit "/etc/ntp.conf" file
 

vim /etc/ntp.conf
restrict 1.0.2.0 mask 255.255.255.0 nomodify notrap
server  1.0.2.5
server  1.0.2.6
fudge   1.0.2.6 stratum 10
driftfile /var/lib/ntp/drift
keys /etc/ntp/keys
 

- Edit /etc/sysconfig/ntpd file:
 

vim /etc/sysconfig/ntpd
OPTIONS="-x -u ntp:ntp -p /var/run/ntpd.pid -g"
SYNC_HWCLOCK=no

chown ntp:ntp /etc/ntp

/etc/init.d/ntpd restart

ntpq -p

    remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
rac1.example.co .INIT.          16 u    - 1024    0    0.000    0.000   0.000
rac2.example.co .INIT.          16 u  592 1024    0    0.000    0.000   0.000


############# DNS Master & Slave Server configuration #################
 

1.0.2.5       rac1.example.com    DNS Master
1.0.2.6       rac2.example.com    DNS Slave


############ DNS Master configuration (rac1) ################
 

yum install -y bind bind-libs bind-utils


- Edit main DNS file "named.conf"
 

vim /etc/named.conf
options {
       listen-on port 53 { 1.0.2.5; };
       directory       "/var/named";
       dump-file       "/var/named/data/cache_dump.db";
       statistics-file "/var/named/data/named_stats.txt";
       memstatistics-file "/var/named/data/named_mem_stats.txt";
       allow-query     { 1.0.2.0/24; };
       allow-transfer { 1.0.2.6;};
       recursion yes;

       dnssec-enable yes;
       dnssec-validation yes;
       dnssec-lookaside auto;

       bindkeys-file "/etc/named.iscdlv.key";
       managed-keys-directory "/var/named/dynamic";
};

logging {
       channel default_debug {
               file "data/named.run";
               severity dynamic;
       };
};

zone "." IN {
       type hint;
       file "named.ca";
};

zone "example.com." IN {
       type master;
       file "example.fwd";
       allow-update { none; };
};

zone "2.0.1.in-addr.arpa." IN {
       type master;
       file "example.rev";
       allow-update { none; };
};

include "/etc/named.root.key";


- Create "example.fwd" and "example.rev" files:
 

cd /var/named/
cp -v localdomain.zone example.fwd
cp -v named.local example.rev


- Edit "/var/named/example.fwd" to set forward zone
 

vim /var/named/example.fwd

$TTL 86400
@   IN  SOA     rac1.example.com. root.rac1.example.com. (
       2011071001  ;Serial
       3600        ;Refresh
       1800        ;Retry
       604800      ;Expire
       86400       ;Minimum TTL
)
@          IN NS   rac1.example.com.
@          IN NS   rac2.example.com.
@               IN A    1.0.2.5
@              IN A    1.0.2.6
@           IN A    1.0.2.11
@           IN A    1.0.2.12
@           IN A    1.0.2.15
@          IN A    1.0.2.16
@           IN A    1.0.2.17
rac1            IN A    1.0.2.5
rac2            IN A    1.0.2.6
rac1-vip        IN A    1.0.2.11
rac2-vip        IN A    1.0.2.12
rac-scan        IN A    1.0.2.15
rac-scan        IN A    1.0.2.16
rac-scan        IN A    1.0.2.17


- Edit "/var/named/example.rev" to set reverse zone
 

vim /var/named/example.rev
$TTL    86400
@       IN      SOA     rac1.example.com. root.rac1.example.com.  (
                                     1997022700 ; Serial
                                     28800      ; Refresh
                                     14400      ; Retry
                                     3600000    ; Expire
                                     86400 )    ; Minimum
@          IN NS   rac1.example.com.
@          IN NS   rac2.example.com.
@          IN PTR    example.com.
rac1            IN A    1.0.2.5
rac2            IN A    1.0.2.6
rac1-vip        IN A    1.0.2.11
rac2-vip        IN A    1.0.2.12
rac-scan        IN A    1.0.2.15
rac-scan        IN A    1.0.2.16
rac-scan        IN A    1.0.2.17
5          IN PTR  rac1.example.com.
6          IN PTR  rac2.example.com.
11         IN PTR  rac1-vip.example.com.
12         IN PTR  rac2-vip.example.com.
15            IN PTR  rac-scan.example.com.
16         IN PTR  rac-scan.example.com.
17         IN PTR  rac-scan.example.com.


- change chroot premission to "named" group
 

chgrp named /etc/named.conf
chgrp named /var/named/example.fwd
chgrp named /var/named/example.rev


- Test DNS configuration and zone files for any syntax errors
 

named-checkconf  /etc/named.conf
named-checkzone example.com /var/named/example.fwd
named-checkzone example.com /var/named/example.rev


############### Configure Slave DNS Server ##############
 

yum install -y bind bind-libs bind-utils


- Edit main DNS file "named.conf"
 

vim /var/named.conf
options {
       listen-on port 53 { 1.0.2.6; };
       directory       "/var/named";
       dump-file       "/var/named/data/cache_dump.db";
       statistics-file "/var/named/data/named_stats.txt";
       memstatistics-file "/var/named/data/named_mem_stats.txt";
       allow-query     { 1.0.2.0/24; };
       recursion yes;

       dnssec-enable yes;
       dnssec-validation yes;
       dnssec-lookaside auto;

       bindkeys-file "/etc/named.iscdlv.key";
       managed-keys-directory "/var/named/dynamic";
};

logging {
       channel default_debug {
               file "data/named.run";
               severity dynamic;
       };
};

zone "." IN {
       type hint;
       file "named.ca";
};

zone "example.com." IN {
       type slave;
       file "slaves/example.fwd";
       allow-update { none; };
       masters { 1.0.2.5; };
};
zone "2.0.1.in-addr.arpa." IN {
       type slave;
       file "slaves/example.rev";
       allow-update { none; };
       masters { 1.0.2.5; };
};

include "/etc/named.root.key";


- restart DNS server in rac1, rac2
 

/etc/init.d/named restart


- Verfiy DNS Server working in rac1, rac2
 

dig rac1.example.com
dig rac2.example.com
dig -x 1.0.2.5
dig -x 1.0.2.6
nslookup rac1
nslookup rac2
nslookup rac1-vip
nslookup rac2-vip
nslookup rac-scan


############### install grid software ##################
- Extract grid software to rac1 and extract it to gird as user oracle
 

[oracle@rac1 ~]$ cd /media/CDROM/
[oracle@rac1 ~]$ unzip -d /tmp/ ./linuxamd64_12102_grid_1of2.zip
[oracle@rac1 ~]$ unzip -d /tmp/ ./linuxamd64_12102_grid_2of2.zip
[oracle@rac1 ~]$ unzip -d /tmp/ ./linuxamd64_12102_database_1of2.zip
[oracle@rac1 ~]$ unzip -d /tmp/ ./linuxamd64_12102_database_2of2.zip


- set up password sharing:
 

cd /tmp/grid/sshsetup/
./sshUserSetup.sh -user oracle -hosts "rac1 rac2" -noPromptPassphrase -confirm -advanced

- runcluvfy.sh script is used to ensure your cluster is ready for the grid install
cd grid
./runcluvfy.sh stage -pre crsinst -n rac1,rac2
./runInstaller


################## install database software ##################
 

cd /tmp/database/
./runInstaller


################# Verify RAC installation ###################
 

srvctl config database -d cdbrac
srvctl status database -d cdbrac
srvctl status listener
srvctl status asm
sqlplus as sysdba
SELECT inst_name FROM v$active_instances;


################# shutdown RAC database ######################
 

srvctl stop database -d cdbrac
srvctl stop instance -d cdbrac -i cdbrac1,cdbrac2
srvctl stop asm -n rac1 -o immediate


Saturday, December 20, 2014

Oracle Database 11g Release 2 RAC On Oracle Linux 5.5 Using VirtualBox

Resources:



Software
Enterprise Linux 5.4 64-bit: https://edelivery.oracle.com/linux/


- Install Enterprise Linux 5.5 x64 Bit:


rac1.example.com
rac2.example.com
internal Network (eth0)
1.0.5.5
1.0.5.6
internal Network (eth1)
1.0.6.5
1.0.6.6
Nat (eth2)
10.0.4.5
10.0.4.6
HDD
50GB
50GB
RAM
4GB
4GB

Desktop Environments > GNOME Desktop Environment
Applications > Editors
Applications > Graphical Internet
Development > Development Libraries
Development > Development Tools
Servers > Server Configuration Tools
Base System > Administration Tools
Base System > Base
Base System > System Tools
Base System > X Window System

- install Packages
 


# From Oracle Linux 5 DVD
cd /media/cdrom/Server
rpm -Uvh binutils-2.*
rpm -Uvh compat-libstdc++-33*
rpm -Uvh elfutils-libelf-0.*
rpm -Uvh elfutils-libelf-devel-*
rpm -Uvh gcc-4.*
rpm -Uvh gcc-c++-4.*
rpm -Uvh glibc-2.*
rpm -Uvh glibc-common-2.*
rpm -Uvh glibc-devel-2.*
rpm -Uvh glibc-headers-2.*
rpm -Uvh ksh-2*
rpm -Uvh libaio-0.*
rpm -Uvh libaio-devel-0.*
rpm -Uvh libgcc-4.*
rpm -Uvh libstdc++-4.*
rpm -Uvh libstdc++-devel-4.*
rpm -Uvh make-3.*
rpm -Uvh sysstat-7.*
rpm -Uvh unixODBC-2.*
rpm -Uvh unixODBC-devel-2.*
rpm -Uvh pdksh-5*
cd /
eject



- Linux Kernel Parameters for Oracle 11gR2 on RHEL 5, Edit the /etc/sysctl.conf and add following lines:
 

vim /etc/sysctl.conf
# kernel parameters for 11g installation
kernel.shmmni = 4096 
kernel.shmmax = 4398046511104
kernel.shmall = 1073741824
kernel.sem = 250 32000 100 128
fs.aio-max-nr = 1048576
fs.file-max = 6815744
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


- Now execute “sysctl -p” command to apply the new settings:
 

/sbin/sysctl -p


- Edit the /etc/security/limits.conf file and add following lines:
 

vim /etc/security/limits.conf
# shell limits for users oracle 11gR2
oracle   soft   nproc    131072
oracle   hard   nproc    131072
oracle   soft   nofile   131072
oracle   hard   nofile   131072
oracle   soft   core     unlimited
oracle   hard   core     unlimited
oracle   soft   memlock  50000000
oracle   hard   memlock  50000000


- Edit the /etc/pam.d/login file and add following line:
 

vim /etc/pam.d/login
session    required     pam_limits.so


- To make the change permanent, modify the /etc/sysconfig/selinux change value of SELINUX variable to disabled:
 

vim  /etc/sysconfig/selinux
SELINUX=disabled


- To permanently disable the firewall we will disable the service:
 

service iptables stop
chkconfig iptables off


- create the user oracle account and the OS groups:
 

groupadd dba
groupadd oper
groupadd oinstall
groupadd asmdba
groupadd asmadmin
useradd -g oinstall -G dba,oper,asmdba,asmadmin oracle
passwd oracle


- Create the directories in which the Oracle software will be installed.
 

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


- Login as the "oracle" user and add the following lines at the end of the "/home/oracle/.bash_profile" file.
 

vim /home/oracle/.bash_profile
# Oracle Settings
TMP=/tmp; export TMP
TMPDIR=$TMP; export TMPDIR


ORACLE_HOSTNAME=rac1.example.com; export ORACLE_HOSTNAME
ORACLE_UNQNAME=racdb.example.com; export ORACLE_UNQNAME
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
GRID_HOME=/u01/app/11.2.0/grid; export GRID_HOME
DB_HOME=$ORACLE_BASE/product/11.2.0/db_1; export DB_HOME
ORACLE_HOME=$DB_HOME; export ORACLE_HOME
ORACLE_SID=racdb1; export ORACLE_SID
ORACLE_TERM=xterm; export ORACLE_TERM
BASE_PATH=/usr/sbin:$PATH; export BASE_PATH
PATH=$ORACLE_HOME/bin:$BASE_PATH; export PATH


LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH


if [ $USER = "oracle" ]; then
  if [ $SHELL = "/bin/ksh" ]; then
    ulimit -p 16384
    ulimit -n 65536
  else
    ulimit -u 16384 -n 65536
  fi
fi


alias grid_env='. /home/oracle/grid_env'
alias db_env='. /home/oracle/db_env'


- Create a file called "/home/oracle/grid_env" with the following contents.
 

vim /home/oracle/grid_env
ORACLE_SID=+ASM1; export ORACLE_SID
ORACLE_HOME=$GRID_HOME; export ORACLE_HOME
PATH=$ORACLE_HOME/bin:$BASE_PATH; export PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH


- Create a file called "/home/oracle/db_env" with the following contents.
 

ORACLE_SID=racdb1; export ORACLE_SID
ORACLE_HOME=$DB_HOME; export ORACLE_HOME
PATH=$ORACLE_HOME/bin:$BASE_PATH; export PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH


- Amend the hostname in the "/etc/sysconfig/network" file.
 

vim /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=rac1.example.com


- Enter following data to “/ect/hosts”, rac-scan section is commented to avoid error "oracle cluster verification utility failed" must be resolved be DNS Server
 

vim /etc/hosts
127.0.0.1       localhost.localdomain   localhost


# Public
1.0.5.5   rac1.example.com   rac1
1.0.5.6   rac2.example.com   rac2


# Private
1.0.6.5   rac1-priv.example.com      rac1-priv
1.0.6.6   rac2-priv.example.com      rac2-priv


# Virtual
1.0.5.11   rac1-vip.example.com       rac1-vip
1.0.5.12   rac2-vip.example.com       rac2-vip


# SCAN
#1.0.5.15   rac-scan.example.com       rac-scan
#1.0.5.16   rac-scan.example.com       rac-scan
#1.0.5.17   rac-scan.example.com       rac-scan


- install oracle asm packages for os kernel
 

uname -rm # to know os kernel &  arch
rpm -Uvh oracleasm-support-2.1.7-1.el5.x86_64.rpm oracleasm-2.6.18-194.el5-2.0.5-1.el5.x86_64.rpm oracleasmlib-2.0.4-1.el5.x86_64.rpm
/etc/init.d/oracleasm disable 
/etc/init.d/oracleasm enable
/etc/init.d/oracleasm configure -i
Default user to own the driver interface []: oracle
Default group to own the driver interface []: dba
Start Oracle ASM library driver on boot (y/n) [n]: y
Scan for Oracle ASM disks on boot (y/n) [y]: 


- Install Guest Additions: Log into the VM as the root user and add the "divider=10" option to the kernel boot options in "/etc/grub.conf" file to reduce the idle CPU load.
 


vim /etc/grub.conf
kernel /vmlinuz-2.6.18-308.24.1.0.1.el5 ro root=/dev/VolGroup00/LogVol00 rhgb quiet numa=off divider=10




######### clone Virtual Machine rac1 to rac2 #######################
######## in rac1
-Use the "fdisk" command to partition the disks sdb to sde.
 

# fdisk /dev/sdb > n > p > 1 > w
# fdisk /dev/sdc > n > p > 1 > w
# fdisk /dev/sdd > n > p > 1 > w
# fdisk /dev/sde > n > p > 1 > w


- in rac1 create ASM disks, Mark the five shared disks as follows.
 

# /usr/sbin/oracleasm createdisk DISK1 /dev/sdb1
# /usr/sbin/oracleasm createdisk DISK2 /dev/sdc1
# /usr/sbin/oracleasm createdisk DISK3 /dev/sdd1
# /usr/sbin/oracleasm createdisk DISK4 /dev/sde1


###### in rac1, rac2 scan for refersh ASM disks
 

/usr/sbin/oracleasm scandisks
/usr/sbin/oracleasm listdisks


- Amend the hostname in the "/etc/sysconfig/network" file.
 

vim /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=rac2.example.com


- Edit the "/etc/sysconfig/network-scripts/ifcfg-eth0, eth1 to change ip address for rac2
 

eth0 1.0.5.6  255.255.255.0   internal Network
eth1 1.0.6.6  255.255.255.0   internal Network
eth2 10.0.4.6 255.255.255.0   10.0.4.2 nat


- Edit the "/home/oracle/.bash_profile" file on the "rac2" node to correct the ORACLE_SID and ORACLE_HOSTNAME values.
 



ORACLE_SID=racdb2; export ORACLE_SID
ORACLE_HOSTNAME=rac2.example.com; export ORACLE_HOSTNAME


- Also, amend the ORACLE_SID setting in the "/home/oracle/db_env" and "/home/oracle/grid_env" files. - Create a file called "/home/oracle/grid_env" with the following contents.
 

vim /home/oracle/grid_env
ORACLE_SID=+ASM2; export ORACLE_SID


- edit a file called "/home/oracle/db_env" with the following contents.
vim /home/oracle/db_env
ORACLE_SID=racdb2; export ORACLE_SID



############ install NTP server #################

 

1.0.5.6  rac2.example.com NTP Server
1.0.5.5  rac1.example.com NTP Server



- NTP Server configure rac1,rac2 to load in boot startup
 
      
chkconfig ntpd on


- edit NTP server configuration file "/etc/ntp.conf"
 

vim /etc/ntp.conf
restrict 1.0.5.0 mask 255.255.255.0 nomodify notrap
server  1.0.5.5
server  1.0.5.6
fudge   1.0.5.6 stratum 10
driftfile /var/lib/ntp/drift
keys /etc/ntp/keys
   

- edit "/etc/sysconfig/ntpd" by add '-x' and '-g'
 

 vim /etc/sysconfig/ntpd
OPTIONS="-x -u ntp:ntp -p /var/run/ntpd.pid -g"
SYNC_HWCLOCK=no


- start NTP server in rac1, rac2 and verify it's working
 

/etc/init.d/ntpd start
ntpdate -u 1.0.5.6  
ntpq -p



############# DNS Master & Slave Server configuration #################

 

1.0.5.5  rac1.example.com DNS Master
1.0.5.6  rac2.example.com DNS Slave



########### DNS Master configuration (rac1) ################
 

yum install -y bind bind-libs bind-utils system-config-bind
system-config-bind # to generate configuration files just run one time


- Edit main DNS file "named.conf"
 

vim /etc/named.conf 
options {
        directory "/var/named";
        dump-file "/var/named/data/cache_dump.db";
        statistics-file "/var/named/data/named_stats.txt";
};


zone "." IN {
        type hint;
        file "named.root";
};


zone "example.com." IN {
        type master;
        file "example.fwd";
        allow-update { none; };
        allow-transfer { 1.0.5.6; };
};


zone "5.0.1.in-addr.arpa." IN {
        type master;
        file "example.rev";
        allow-update { none; };
        allow-transfer { 1.0.5.6; };
};

include "/etc/rndc.key";


- Create "example.fwd" for forward zone
 

cd /var/named/
cp -v localdomain.zone example.fwd
cp -v named.local example.rev


vim /var/named/example.fwd
$TTL    86400
@               IN SOA  rac1.example.com. root.rac1.example.com. (
                                        42              ; serial (d. adams)
                                        3H              ; refresh
                                        15M             ; retry
                                        1W              ; expiry
                                        1D )            ; minimum
         IN NS   rac1.example.com.
         IN NS   rac2.example.com.
rac1            IN A    1.0.5.5
rac2            IN A    1.0.5.6   
rac1-vip        IN A    1.0.5.11      
rac2-vip        IN A    1.0.5.12       
rac-scan        IN A    1.0.5.15       
rac-scan        IN A    1.0.5.16      
rac-scan        IN A    1.0.5.17



- create file "example.rev" for reverse zone:
 

vim /var/named/example.rev
$TTL    86400
@       IN      SOA     rac1.example.com. root.rac1.example.com.  (
                                      1997022700 ; Serial
                                      28800      ; Refresh
                                      14400      ; Retry
                                      3600000    ; Expire
                                      86400 )    ; Minimum
        IN NS   rac1.example.com.
        IN NS   rac2.example.com.
5       IN PTR  rac1.example.com.
6      IN PTR  rac2.example.com.
11     IN PTR  rac1-vip.example.com.
12     IN PTR  rac2-vip.example.com.
15     IN PTR  rac-scan.example.com.
16     IN PTR  rac-scan.example.com.
17     IN PTR  rac-scan.example.com.


- change chroot premission to "named" group
 

chgrp named /etc/named.conf
chgrp named /var/named/example.fwd
chgrp named /var/named/example.rev


- Test DNS configuration and zone files for any syntax errors
 

named-checkconf  /etc/named.conf 
named-checkzone example.com /var/named/example.fwd
named-checkzone example.com /var/named/example.rev



########### Configure Slave DNS Server ##############
 


yum install -y bind bind-libs bind-utils system-config-bind
system-config-bind # to generate configuration files just run one time


- Edit main DNS file "named.conf"
 


vim /var/named.conf 
options {
        directory "/var/named";
        dump-file "/var/named/data/cache_dump.db";
        statistics-file "/var/named/data/named_stats.txt";
};
zone "." IN {
        type hint;
        file "named.root";
};


zone "example.com." IN {
        type slave;
        file "slaves/example.fwd";
        allow-update { none; };
        masters { 1.0.5.5; };
};
zone "5.0.1.in-addr.arpa." IN {
        type slave;
        file "slaves/example.rev";
        allow-update { none; };
        masters { 1.0.5.5; };
};
include "/etc/rndc.key";



- Edit "/etc/resolv.conf" file in clients in rac1, rac2
 

vim /etc/resolv.conf
nameserver 1.0.5.5
nameserver 1.0.5.6
nameserver 8.8.8.8
search example.com



- Network Additions for DNS Server in rac1, rac2
 

vim /etc/sysconfig/network-scripts/ifcfg-eth0 >> PEERDNS=no
vim /etc/sysconfig/network-scripts/ifcfg-eth1 >> PEERDNS=no
vim /etc/sysconfig/network-scripts/ifcfg-eth2 >> PEERDNS=no


- restart DNS server in rac1, rac2
 

/etc/init.d/named restart


- Verfiy DNS Server working in rac1, rac2
 

dig rac1.example.com
dig rac2.example.com
dig -x 1.0.5.5
dig -x 1.0.5.6
nslookup rac1
nslookup rac2
nslookup rac1-vip
nslookup rac2-vip
nslookup rac-scan



############### install grid software ##################
- Extract grid software to rac1 and extract it to gird as user oracle
 

unzip -d /tmp /media/db_112010_lnx64/linux.x64_11gR2.zip
unzip -d /tmp /media/db_112010_lnx64/linux.x64_11gR2_database_1of2
unzip -d /tmp /media/db_112010_lnx64/linux.x64_11gR2_database_2of2


- generate ssh keys between rac1,rac2 using grid software utility (sshUserSetup.sh)
 

cd /tmp/grid/sshsetup/
./sshUserSetup.sh -user oracle -hosts "rac1 rac2" -noPromptPassphrase -confirm -advanced

 - test rac1,rac2 using grid software utility (runcluvfy.sh)
cd /tmp/grid/
./runcluvfy.sh stage -pre crsinst -n rac1,rac2
./runInstaller




########## Verify RAC installation ###########

 


srvctl config database -d racdb
srvctl status database -d racdb
srvctl status listener
srvctl status asm


Status of your database can be visible in OEM 
https://rac1.example.com:1158/em/



########## shutdown RAC databases #############

 


emctl stop dbconsole
srvctl stop database -d racdb
srvctl stop instance -d racdb -i racdb1,racdb2
srvctl stop asm -n rac1 -o immediate


Friday, October 10, 2014

Oracle 11g Admin R2 - Chapter 09 Managing Diagnostic Data


- Problem is a critical error in a database instance, Oracle Automatic Storage Management (Oracle ASM) instance, or other Oracle product or component. Critical errors manifest as internal errors, such as ORA-00600, or other severe errors, such as ORA-07445


- Incident is a single occurrence of a problem. When a problem (critical error) occurs multiple times, an incident is created for each occurrence. Incidents are timestamped and tracked in the Automatic Diagnostic Repository (ADR)


- Flood-controlled incident is an incident that generates an alert log entry, is recorded in the ADR, but does not generate incident dumps. Flood-controlled incidents provide a way of informing you that a critical error is ongoing, without overloading the system with diagnostic data, database writes a message to the alert log indicating that no further incidents will be recorded:
  1. After five incidents occur for the same problem key in one hour
  2. After 25 incidents occur for the same problem key in one day
  3. After 50 incidents for the same problem key occur in one hour
  4. After 250 incidents for the same problem key occur in one day
- Automatic Diagnostic Repository (ADR) file-based repository for database diagnostic data such as traces, dumps, the alert log, health monitor reports, and more. ADR home is given by the following path, which starts at the ADR base directory:

        diag/product_type/product_id/instance_id
        ADR_base/diag/rdbms/orcl/orcl/
        ADR_base/diag/asm/+asm/+asm/


, ADR in RAC:
- each node can have ADR base on its own local storage, or ADR base can be set to a location on shared storage
- you can use ADRCI utility to view aggregated diagnostic data from all instances on a single report.


- Alert log is an XML file that is a chronological log of database messages and errors such as starting up or shutting down the database, recovering the database, creating or dropping a tablespace, and others.


- Trace Files updated periodically over the life of the process and can contain information on the process environment, status, activities, and errors with file extension is .trc and sometimes trace map (.trm) files.


- Dump Files is a specific type of trace file. A dump is typically a one-time output of diagnostic data in response to an event (such as an incident)


- Core File contains a memory dump, in an all-binary, port-specific format. Core file names include the string "core" and the operating system process ID. Core files are useful to Oracle Support engineers only.

- Viewing ADR Locations with the V$DIAG_INFO View
  

SQL> col name format a35
SQL> col value format a65
SQL> select * from v$diag_info;
   INST_ID|NAME                               |VALUE
----------|-----------------------------------|-----------------------------------------------------------------
         1|Diag Enabled                       |TRUE
         1|ADR Base                           |/u01/app/oracle
         1|ADR Home                           |/u01/app/oracle/diag/rdbms/orcl/orcl
         1|Diag Trace                         |/u01/app/oracle/diag/rdbms/orcl/orcl/trace
         1|Diag Alert                         |/u01/app/oracle/diag/rdbms/orcl/orcl/alert
         1|Diag Incident                      |/u01/app/oracle/diag/rdbms/orcl/orcl/incident
         1|Diag Cdump                         |/u01/app/oracle/diag/rdbms/orcl/orcl/cdump
         1|Health Monitor                     |/u01/app/oracle/diag/rdbms/orcl/orcl/hm
         1|Default Trace File                 |/u01/app/oracle/diag/rdbms/orcl/orcl/trace/orcl_ora_14866.trc
         1|Active Problem Count               |0
         1|Active Incident Count              |0

11 rows selected.

- Viewing Critical Errors with the V$DIAG_CRITICAL_ERROR View
  
SQL> select * from v$diag_critical_error;
FACILITY  |ERROR
----------|-----------------------------------------------------------------
ORA       |7445
ORA       |4030
ORA       |4031
ORA       |29740
ORA       |255
ORA       |355
ORA       |356
ORA       |239
ORA       |240
ORA       |494
ORA       |3137
ORA       |227
ORA       |353
ORA       |1578
ORA       |32701
ORA       |32703
ORA       |29770
ORA       |29771
ORA       |445
ORA       |25319
ORA       |56729
OCI       |3106
OCI       |3113
OCI       |3135

24 rows selected.


- Investigating, Reporting, and Resolving a Problem

  • Task 1: View Critical Error Alerts in Enterprise Manager
  • Task 2: View Problem Details
  • Task 3: (Optional) Gather Additional Diagnostic Information
  • Task 4: (Optional) Create a Service Request
  • Task 5: Package and Upload Diagnostic Data to Oracle Support
  • Task 6: Track the Service Request and Implement Any Repairs
  • Task 7: Close Incidents
-
- Viewing the Alert Log a. Enterprise Manager > Home Page > Alert Log Contents b. SQL Plus
    SQL> select * from v$diag_info;

- To find the trace file for your current session:
    SQL> select value from v$diag_info where name = 'Default Trace File';
    VALUE
    -----------------------------------------------------------------
    /u01/app/oracle/diag/rdbms/orcl/orcl/trace/orcl_ora_3605.trc

- To find all trace files for the current instance:
    SQL> select value from v$diag_info where name = 'Diag Trace';
    VALUE
    -----------------------------------------------------------------
    /u01/app/oracle/diag/rdbms/orcl/orcl/trace
    

- To determine the trace file for each Oracle Database process:
SQL> col program format a40
SQL> col tracefile format a65
SQL> select pid, program, tracefile from v$process;
       PID|PROGRAM                                 |TRACEFILE
----------|----------------------------------------|-----------------------------------------------------------------
         1|PSEUDO                                  |/u01/app/oracle/diag/rdbms/orcl/orcl/trace/orcl_ora_0.trc
         2|oracle@demo1.localdomain (PMON)         |/u01/app/oracle/diag/rdbms/orcl/orcl/trace/orcl_pmon_32236.trc
         3|oracle@demo1.localdomain (PSP0)         |/u01/app/oracle/diag/rdbms/orcl/orcl/trace/orcl_psp0_32238.trc
         4|oracle@demo1.localdomain (VKTM)         |/u01/app/oracle/diag/rdbms/orcl/orcl/trace/orcl_vktm_32240.trc
         5|oracle@demo1.localdomain (GEN0)         |/u01/app/oracle/diag/rdbms/orcl/orcl/trace/orcl_gen0_32244.trc
         6|oracle@demo1.localdomain (DIAG)         |/u01/app/oracle/diag/rdbms/orcl/orcl/trace/orcl_diag_32246.trc
         7|oracle@demo1.localdomain (DBRM)         |/u01/app/oracle/diag/rdbms/orcl/orcl/trace/orcl_dbrm_32248.trc
         8|oracle@demo1.localdomain (DIA0)         |/u01/app/oracle/diag/rdbms/orcl/orcl/trace/orcl_dia0_32250.trc
         9|oracle@demo1.localdomain (MMAN)         |/u01/app/oracle/diag/rdbms/orcl/orcl/trace/orcl_mman_32252.trc
        10|oracle@demo1.localdomain (DBW0)         |/u01/app/oracle/diag/rdbms/orcl/orcl/trace/orcl_dbw0_32254.trc


- ADRCI SHOW TRACEFILE command
$ adrci
adrci> show tracefile
     diag/tnslsnr/demo1/listener/trace/listener.log
     diag/rdbms/orcl/orcl/trace/orcl_vktm_25376.trc
     diag/rdbms/orcl/orcl/trace/orcl_cjq0_25525.trc
     diag/rdbms/orcl/orcl/trace/orcl_arc0_19281.trc




Tuesday, October 7, 2014

Oracle 11g Admin - 5 Managing Processes

- server process can be either of the following:
  • A dedicated server process, which services only one user process
  • A shared server process, which can service multiple user processes

- Dispatcher can support multiple client connections concurrently. Each client connection is bound to a virtual circuit.
- Virtual circuit is a piece of shared memory used by the dispatcher for client database connection requests and replies.  

http://docs.oracle.com/cd/B28359_01/network.111/b28316/img/netag118.gif


- Dedicated Servers, Shared Servers, and Database Resident Connection Pooling
Dedicated Server Shared Server Database Resident Connection Pooling
When a client request is received, a new server process and a session are created for the client. When the first request is received from a client, the Dispatcher process places this request on a common queue. The request is picked up by an available shared server process. The Dispatcher process then manages the communication between the client and the shared server process. When the first request is received from a client, the Connection Broker picks an available pooled server and hands off the client connection to the pooled server.
If no pooled servers are available, the Connection Broker creates one. If the pool has reached its maximum size, the client request is placed on the wait queue until a pooled server is available.
Releasing database resources involves terminating the session and server process. Releasing database resources involves terminating the session. Releasing database resources involves releasing the pooled server to the pool.
Memory requirement is proportional to the number of server processes and sessions. There is one server and one session for each client. Memory requirement is proportional to the sum of the shared servers and sessions. There is one session for each client. Memory requirement is proportional to the number of pooled servers and their sessions. There is one session for each pooled server.
Session memory is allocated from the PGA. Session memory is allocated from the SGA. Session memory is allocated from the PGA.

### Initialization Parameters for Shared Server

[oracle@localhost ~]$ sqlplus / as sysdba

SQL> alter system set shared_servers=55;

System altered.

SQL> show parameter max_shared_servers;

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
max_shared_servers                   integer     5
SQL> show parameter shared_server_sessions;

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
shared_server_sessions               integer
SQL> show parameter dispatchers;

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
dispatchers                          string      (PROTOCOL=TCP)
max_dispatchers                      integer
SQL> show parameter max_dispatchers

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
max_dispatchers                      integer
SQL> show parameter circuits;

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
circuits                             integer

 

 - DISPATCHERS Initialization Parameter Attributes

Attribute Description
ADDRESS Specify the network protocol address of the endpoint on which the dispatchers listen.
DESCRIPTION Specify the network description of the endpoint on which the dispatchers listen, including the network protocol address. The syntax is as follows:
(DESCRIPTION=(ADDRESS=...))
PROTOCOL Specify the network protocol for which the dispatcher generates a listening endpoint. For example:
(PROTOCOL=tcp) 
See the Oracle Database Net Services Reference for further information about protocol address syntax.


- how many dispatchers this configuration should have. It is optional and defaults to 1.
Attribute Description
DISPATCHERS Specify the initial number of dispatchers to start.


- Network attributes of each dispatcher of this configuration. They are all optional.
Attribute Description
CONNECTIONS Specify the maximum number of network connections to allow for each dispatcher.
SESSIONS Specify the maximum number of network sessions to allow for each dispatcher.
TICKS Specify the duration of a TICK in seconds. A TICK is a unit of time in terms of which the connection pool timeout can be specified. Used for connection pooling.
LISTENER Specify an alias name for the listeners with which the PMON process registers dispatcher information. Set the alias to a name that is resolved through a naming method.
MULTIPLEX Used to enable the Oracle Connection Manager session multiplexing feature.
POOL Used to enable connection pooling.
SERVICE Specify the service names the dispatchers register with the listeners.

SQL> select * from v$queue;

PADDR    TYPE           QUEUED       WAIT     TOTALQ
-------- ---------- ---------- ---------- ----------
00       COMMON              0          0          0
3B3D5040 DISPATCHER          0          0          0

SQL> set lines 2000
SQL> col network format a65;
SQL> select name,network,status from v$dispatcher;

NAME NETWORK                                                           STATUS
---- ----------------------------------------------------------------- ----------------
D000 (ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=43399))  WAIT

SQL> alter system shutdown immediate 'D000';

System altered.

SQL> -- disable shared server --
SQL> ALTER SYSTEM SET DISPATCHERS = '';

System altered.

SQL> ALTER SYSTEM SET SHARED_SERVERS = 50;

System altered.

 

- Shared Server Data Dictionary Views

View Description
V$DISPATCHER Provides information on the dispatcher processes, including name, network address, status, various usage statistics, and index number.
V$DISPATCHER_CONFIG Provides configuration information about the dispatchers.
V$DISPATCHER_RATE Provides rate statistics for the dispatcher processes.
V$QUEUE Contains information on the shared server message queues.
V$SHARED_SERVER Contains information on the shared servers.
V$CIRCUIT Contains information about virtual circuits, which are user connections to the database through dispatchers and servers.
V$SHARED_SERVER_MONITOR Contains information for tuning shared server.
V$SGA Contains size information about various system global area (SGA) groups. May be useful when tuning shared server.
V$SGASTAT Contains detailed statistical information about the SGA, useful for tuning.
V$SHARED_POOL_RESERVED Lists statistics to help tune the reserved pool and space within the shared pool.


SQL> select * from v$sga;

NAME                      VALUE
-------------------- ----------
Fixed Size              1344840
Variable Size         348129976
Database Buffers      100663296
Redo Buffers            6008832

SQL> select * from v$sgastat;
SQL> desc v$dispatcher_config;
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 CONF_INDX                                          NUMBER
 NETWORK                                            VARCHAR2(1024)
 DISPATCHERS                                        NUMBER
 CONNECTIONS                                        NUMBER
 SESSIONS                                           NUMBER
 POOL                                               VARCHAR2(4)
 TICKS                                              NUMBER
 INBD_TIMOUT                                        NUMBER
 OUTBD_TIMOUT                                       NUMBER
 MULTIPLEX                                          VARCHAR2(4)
 LISTENER                                           VARCHAR2(1200)
 SERVICE                                            VARCHAR2(512)

SQL> select network,dispatchers,connections,pool from v$dispatcher_config;

NETWORK                                       DISPATCHERS CONNECTIONS POOL
--------------------------------------------- ----------- ----------- ----
(ADDRESS=(PARTIAL=YES)(PROTOCOL=TCP))                   1        1022 OFF

- Enabling Database Resident Connection Pooling using PL/SQL Packages

Parameter Name Description
MINSIZE The minimum number of pooled servers in the pool. The default value is 4.
MAXSIZE The maximum number of pooled servers in the pool. The default value is 40.
The connection pool reserves 5% of the pooled servers for authentication, and at least one pooled server is always reserved for authentication. When setting this parameter, ensure that there are enough pooled servers for both authentication and connections.
INCRSIZE The number of pooled servers by which the pool is incremented if servers are unavailable when a client application request is received. The default value is 2.
SESSION_CACHED_CURSORS The number of session cursors to cache in each pooled server session. The default value is 20.
INACTIVITY_TIMEOUT The maximum time, in seconds, the pooled server can stay idle in the pool. After this time, the server is terminated. The default value is 300.
This parameter does not apply if the pool is at MINSIZE.
MAX_THINK_TIME The maximum time of inactivity, in seconds, for a client after it obtains a pooled server from the pool. After obtaining a pooled server from the pool, if the client application does not issue a database call for the time specified by MAX_THINK_TIME, the pooled server is freed and the client connection is terminated. The default value is 120.
MAX_USE_SESSION The number of times a pooled server can be taken and released to the pool. The default value is 500000.
MAX_LIFETIME_SESSION The time, in seconds, to live for a pooled server in the pool. The default value is 86400.
NUM_CBROK The number of Connection Brokers that are created to handle client requests. The default value is 1.
Creating multiple Connection Broker processes helps distribute the load of client connection requests if there are a large number of client applications.
MAXCONN_CBROK The maximum number of connections that each Connection Broker can handle.
The default value is 40000. But if the maximum connections allowed by the platform on which the database is installed is lesser than the default value, this value overrides the value set using MAXCONN_CBROK.
Set the per-process file descriptor limit of the operating system sufficiently high so that it supports the number of connections specified by MAXCONN_CBROK.


SQL> EXECUTE DBMS_CONNECTION_POOL.START_POOL();

PL/SQL procedure successfully completed.

SQL> EXECUTE DBMS_CONNECTION_POOL.ALTER_PARAM ('','MINSIZE','10');

PL/SQL procedure successfully completed.

SQL> EXECUTE DBMS_CONNECTION_POOL.ALTER_PARAM ('','MAXCONN_CBROK','50000');

PL/SQL procedure successfully completed.

SQL> EXECUTE DBMS_CONNECTION_POOL.RESTORE_DEFAULTS();

PL/SQL procedure successfully completed.

- Data Dictionary Views for Database Resident Connection Pooling

View Description
DBA_CPOOL_INFO Contains information about the connection pool such as the pool status, the maximum and minimum number of connections, and timeout for idle sessions.
V$CPOOL_CONN_INFO Contains information about each connection to the connection broker.
V$CPOOL_STATS Contains pool statistics such as the number of session requests, number of times a session that matches the request was found in the pool, and total wait time for a session request.
V$CPOOL_CC_STATS Contains connection class level statistics for the pool.


SQL> desc dba_cpool_info
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 CONNECTION_POOL                                    VARCHAR2(128)
 STATUS                                             VARCHAR2(16)
 MINSIZE                                            NUMBER
 MAXSIZE                                            NUMBER
 INCRSIZE                                           NUMBER
 SESSION_CACHED_CURSORS                             NUMBER
 INACTIVITY_TIMEOUT                                 NUMBER
 MAX_THINK_TIME                                     NUMBER
 MAX_USE_SESSION                                    NUMBER
 MAX_LIFETIME_SESSION                               NUMBER
 NUM_CBROK                                          NUMBER
 MAXCONN_CBROK                                      NUMBER

SQL> select status,minsize,maxsize from dba_cpool_info;

STATUS              MINSIZE    MAXSIZE
---------------- ---------- ----------
ACTIVE                   10         40

- Oracle Database Background Processes

Process Name Description
Database writer (DBWn) The database writer writes modified blocks from the database buffer cache to the data files. Oracle Database allows a maximum of 36 database writer processes (DBW0-DBW9 and DBWa-DBWj). The DB_WRITER_PROCESSES initialization parameter specifies the number of DBWn processes. The database selects an appropriate default setting for this initialization parameter or adjusts a user-specified setting based on the number of CPUs and the number of processor groups.
For more information about setting the DB_WRITER_PROCESSES initialization parameter, see the Oracle Database Performance Tuning Guide.
Log writer (LGWR) The log writer process writes redo log entries to disk. Redo log entries are generated in the redo log buffer of the system global area (SGA). LGWR writes the redo log entries sequentially into a redo log file. If the database has a multiplexed redo log, then LGWR writes the redo log entries to a group of redo log files. See Chapter 12, "Managing the Redo Log" for information about the log writer process.
Checkpoint (CKPT) At specific times, all modified database buffers in the system global area are written to the data files by DBWn. This event is called a checkpoint. The checkpoint process is responsible for signalling DBWn at checkpoints and updating all the data files and control files of the database to indicate the most recent checkpoint.
System monitor (SMON) The system monitor performs recovery when a failed instance starts up again. In an Oracle Real Application Clusters database, the SMON process of one instance can perform instance recovery for other instances that have failed. SMON also cleans up temporary segments that are no longer in use and recovers terminated transactions skipped during system failure and instance recovery because of file-read or offline errors. These transactions are eventually recovered by SMON when the tablespace or file is brought back online.
Process monitor (PMON) The process monitor performs process recovery when a user process fails. PMON is responsible for cleaning up the cache and freeing resources that the process was using. PMON also checks on the dispatcher processes (described later in this table) and server processes and restarts them if they have failed.
Archiver (ARCn) One or more archiver processes copy the redo log files to archival storage when they are full or a log switch occurs. Archiver processes are the subject of Chapter 13, "Managing Archived Redo Logs".
Recoverer (RECO) The recoverer process is used to resolve distributed transactions that are pending because of a network or system failure in a distributed database. At timed intervals, the local RECO attempts to connect to remote databases and automatically complete the commit or rollback of the local portion of any pending distributed transactions. For information about this process and how to start it, see Chapter 35, "Managing Distributed Transactions".
Dispatcher (Dnnn) Dispatchers are optional background processes, present only when the shared server configuration is used. Shared server was discussed previously in "Configuring Oracle Database for Shared Server".


- Managing Processes for Parallel SQL Execution

- Degree of parallelism is the number of parallel execution servers that can be associated with a single operation

SQL> alter session enable parallel dml;

Session altered.

SQL> alter session disable parallel ddl;

Session altered.

SQL> alter session enable parallel ddl;

Session altered.

SQL> alter session force parallel ddl parallel 10;

Session altered.

SQL> show parameter parallel_max_servers;

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
parallel_max_servers                 integer     40
 


- Terminating Sessions

SQL> -- as user HR login from SQL Deveolper --
SQL> select username,sid, serial#,status
  2  from v$session
  3  where username='HR';

USERNAME                              SID    SERIAL# STATUS
------------------------------ ---------- ---------- --------
HR                                     53         35 INACTIVE

SQL> alter system kill session '53,35';

System altered.

SQL> -- as user HR login again from terminal with new session --

SQL> select username,sid, serial#,status,server
  2  from v$session
  3  where username='HR';

USERNAME                              SID    SERIAL# STATUS   SERVER
------------------------------ ---------- ---------- -------- ---------
HR                                     52         31 INACTIVE DEDICATED
HR                                     53         35 KILLED   PSEUDO


- Process and Session Data Dictionary Views

View Description
V$PROCESS Contains information about the currently active processes
V$SESSION Lists session information for each current session
V$SESS_IO Contains I/O statistics for each user session
V$SESSION_LONGOPS Displays the status of various operations that run for longer than 6 seconds (in absolute time). These operations currently include many backup and recovery functions, statistics gathering, and query execution. More operations are added for every Oracle Database release.
V$SESSION_WAIT Displays the current or last wait for each session
V$SESSION_WAIT_HISTORY Lists the last ten wait events for each active session
V$WAIT_CHAINS Displays information about blocked sessions
V$SESSTAT Contains session statistics
V$RESOURCE_LIMIT Provides information about current and maximum global resource utilization for some system resources
V$SQLAREA Contains statistics about shared SQL areas. Contains one row for each SQL string. Provides statistics about SQL statements that are in memory, parsed, and ready for execution


SQL> desc v$process;
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 ADDR                                               RAW(4)
 PID                                                NUMBER
 SPID                                               VARCHAR2(24)
 PNAME                                              VARCHAR2(5)
 USERNAME                                           VARCHAR2(15)
 SERIAL#                                            NUMBER
 TERMINAL                                           VARCHAR2(30)
 PROGRAM                                            VARCHAR2(48)
 TRACEID                                            VARCHAR2(255)
 TRACEFILE                                          VARCHAR2(513)
 BACKGROUND                                         VARCHAR2(1)
 LATCHWAIT                                          VARCHAR2(8)
 LATCHSPIN                                          VARCHAR2(8)
 PGA_USED_MEM                                       NUMBER
 PGA_ALLOC_MEM                                      NUMBER
 PGA_FREEABLE_MEM                                   NUMBER
 PGA_MAX_MEM                                        NUMBER

SQL> select pid,pname,username from v$process;

       PID PNAME USERNAME
---------- ----- ---------------
         1
         2 PMON  oracle
         3 PSP0  oracle
         4 VKTM  oracle
         5 GEN0  oracle
         6 DIAG  oracle
         ............


happy oracle,