2012年11月17日 星期六

Oracle 11g – R2 RAC 11.2.0.1 installation on Centos5


http://mudasblog.wordpress.com/2010/10/29/oracle-rac-11-2-0-1-installation-on-centos5-64bit-with-multipath-san/

Oracle 11g – R2 RAC 11.2.0.1 installation on Centos5 (64bit) with multipath (SAN)

This is a quick and dirty install guide for doing a RAC 11.2.0.1 installation at Centos5. Some points should be done at both servers, but i don’t have it explained in detail – sorry – as i said ‘quick and dirty’ :)
**** used ip’s for this configuration ****
10.41.11.11 – node1 public
10.41.11.12 – node2 public
10.41.22.11 – node1 interconnect
10.41.22.12 – node2 interconnect
10.41.11.111 – node1 virtual ip
10.41.11.112 – node2 virtual ip
10.41.11.180 – scan1
10.41.11.190 – scan1
**** do some sanity ****
[root@rac11 ~]# yum update
[root@rac11 ~]# chkconfig bluetooth off
[root@rac11 ~]# chkconfig cpuspeed off
[root@rac11 ~]# chkconfig cups off
[root@rac11 ~]# chkconfig kudzu off
[root@rac11 ~]# chkconfig pcscd off
[root@rac11 ~]# chkconfig smartd off
[root@rac11 ~]# chkconfig yum-updatesd off
[root@rac11 ~]# yum install sysstat
[root@rac11 ~]# yum install ntp
**** edit the /etc/ntp/step-tickers file and insert your timeserver, only one entry, not more ****
[root@rac11 ~]# chkconfig ntpd on
**** edit the /etc/sysconfig/ntpd file and add the ‘-x’ parameter ****
# Drop root to id ‘ntp:ntp’ by default.
OPTIONS=”-x -u ntp:ntp -p /var/run/ntpd.pid”
# Set to ‘yes’ to sync hw clock after successful ntpdate
SYNC_HWCLOCK=no
# Additional options for ntpdate
NTPDATE_OPTIONS=”"
**** disable the firewall and the disable selinux rules ****
[root@rac11 ~]# system-config-securitylevel-tui
**** multipath configuration for node1 / node2 is ident excluding the svc-root partition id ****
[root@rac11 ~]# cat /etc/multipath.conf
#####################################
# Multipath.conf file for IBM Storage
#
# Version 2.01
#
# Red Hat Enterprise Linux Server 5.0 DM-MPIO Configuration file
#
# IMPORTANT: If you change multipath.conf settings after the DM MPIO devices
# have already been configured, be sure to rerun “multipath”.
#######################################
#
#
# defaults:
#
# polling_interval : The interval between two path checks in seconds.
#
# failback : The failback policy should be set to “immediate”
# to have automatic failback, i.e. if a higher
# priority path that previously failed is restored,
# I/O automatically and immediately fails back to
# the preferred path.
#
# no_path_retry : Use this setting in order to deal with transient total
# path failure scenarios. Indicates that the if all
# paths are failed for 10 checks (iterations of the checkerloop) then
# will set the device to .fail_if_no_path. so that I/O will not stay
# queued forever and I/O errors are returned back to the
# application. This value should be adjusted based on the value of the
# polling_interval. Basically, with a larger polling_interval, this
# means that the amount of time of allowed total path failure will be
# longer, since the tolerance time is (no_path_retry * polling_interval)
# seconds. SHOULD NOT BE USED WITH .features..
#
# rr_min_io : The number of IOs to route to a path before switching
# to the next path in the same path group
#
# path_checker : The default ‘readsector0′ path checker uses SCSI READ (opcode 0×28)
# which doesn’t work in clustered environments. TUR (Test Unit Ready) does work in
# clustered environments with storage that subscribes to the SCSI-3
# spec.
#
# user_friendly_names: With this value set to .yes., DM MPIO devices will be named as .mpath0.,
# .mpath1., .mpath2., etc. … The /var/lib/mulitpath/bindings file is
# automatically generated, mapping the .mpathX. name to the wwid of the LUN.
# If set to “no”, use the WWID as the alias. In either case this be will be overriden
# by any specific aliases in this file.
#
#
defaults {
polling_interval 5
failback immediate
no_path_retry 12
rr_min_io 100
path_checker tur
user_friendly_names yes
}
#
# An example of blacklisting a local SCSI disk.
# Here a local disk with wwid SIBM-ESXSMAN3184MC_FUFR9P29044K2 is
# blacklisted and will not appear when “multipath -l(l)” is invoked.
#
#
#blacklist {
# wwid SIBM-ESXSMAN3184MC_FUFR9P29044K2
#}
blacklist {
devnode “^(ram|raw|loop|fd|md|sr|scd|st)[0-9]*”
devnode “^hd[a-z][[0-9]*]”
devnode “^cciss!c[0-9]d[0-9]*[p[0-9]*]”
devnode “^sd[a-z][[0-9]*]”
}
#
# An example of using an alias.
# NOTE: this will override the “user_friendly_name” for this LUN.
#
# Here a LUN from IBM storage with wwid 3600507630efffe32000000000000120a
# is given an alias of “IBM-1750″ and will appear as “IBM-1750
#(3600507630efffe32000000000000120a)”, when “multipath -l(l)” is invoked.
#
#
#multipaths {
# multipath {
# wwid 3600507630efffe32000000000000120a
# alias IBM-1750
# }
#}
multipaths {
multipath {
wwid 360050768019b8231100000000000004c
alias svc-root
}
multipath {
wwid 360050768019b8231100000000000004d
alias svc-data1
}
multipath {
wwid 360050768019b8231100000000000004e
alias svc-flash1
}
multipath {
wwid 360050768019b8231100000000000004f
alias svc-scratch1
}
}
#
# devices : List of per storage controler settings, overrides default
# settings (device_maps block), overriden by per multipath
# settings (multipaths block)
#
# vendor : Vendor Name
#
# product : Product Name
#
# path_grouping_policy : Path grouping policy to apply to multipath hosted
# by this storage controller
#
# prio_callout : The program and args to callout to obtain a path
# weight. Weights are summed for each path group to
# determine the next PG to use case of failure.
# NOTE: If no callout then all paths have equals weight.
#
#
devices {
# DS8000
device {
vendor “IBM”
product “2107900″
path_grouping_policy group_by_serial
}
# SVC
device {
vendor “IBM”
product “2145″
path_grouping_policy group_by_prio
prio_callout “/sbin/mpath_prio_alua /dev/%n”
}
}
#devices {
##DS4700
# device {
# vendor “IBM”
# product “1814″
# hardware_handler “1 rdac”
# path_checker rdac
# failback immediate
# path_grouping_policy group_by_prio
# prio_callout “/sbin/mpath_prio_tpc /dev/%n”
# }
#}
**** important for multipath and oracleasm ****
**** insert in /etc/sysconfig/oracleasm ****
# ORACLEASM_UID: Default UID owning the /dev/oracleasm mount point.
ORACLEASM_UID=grid
# ORACLEASM_GID: Default GID owning the /dev/oracleasm mount point.
ORACLEASM_GID=asmadmin
# ORACLEASM_CLEARBOOT: ‘true’ means clean old disk perms on boot
ORACLEASM_CLEARBOOT=true
# ORACLEASM_SCANORDER: Matching patterns to order disk scanning
# ORACLEASM_SCANORDER=dm
# ORACLEASM_SCANEXCLUDE: Matching patterns to exclude disks from scan
# ORACLEASM_SCANEXCLUDE=sd
**** reboot all servers ****
**** eth configuration for racnode1 / racnode 2 is similar ****
[root@rac11 network-scripts]# cat ifcfg-eth*
#eth0
# Broadcom Corporation NetXtreme II BCM5709S Gigabit Ethernet
DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
MASTER=bond0
SLAVE=yes
USERCTL=yes
#HWADDR=00:21:5E:4C:D4:0E
TYPE=Ethernet
#eth1
# Broadcom Corporation NetXtreme II BCM5709S Gigabit Ethernet
DEVICE=eth1
BOOTPROTO=none
ONBOOT=yes
MASTER=bond0
SLAVE=yes
USERCTL=yes
#HWADDR=00:21:5E:4C:D4:0F
TYPE=Ethernet
#eth2
# Broadcom Corporation NetXtreme II BCM5709S Gigabit Ethernet
DEVICE=eth2
BOOTPROTO=none
ONBOOT=yes
MASTER=bond1
SLAVE=yes
USERCTL=yes
#HWADDR=e4:1f:13:3a:8c:08
TYPE=Ethernet
#eth3
# Broadcom Corporation NetXtreme II BCM5709S Gigabit Ethernet
DEVICE=eth3
BOOTPROTO=none
ONBOOT=yes
MASTER=bond1
SLAVE=yes
USERCTL=yes
#HWADDR=e4:1f:13:3a:8c:0a
TYPE=Ethernet
[root@rac11 network-scripts]#
**** bonding configuration / check that all bond devices must have the same default gateway ****
[root@rac11 network-scripts]# cat ifcfg-bond*
# bond0
DEVICE=bond0
BOOTPROTO=none
ONBOOT=yes
NETWORK=10.41.11.0
NETMASK=255.255.255.0
IPADDR=10.41.11.11
USERCTL=no
GATEWAY=10.41.11.254
TYPE=Ethernet
IPV6INIT=no
PEERDNS=yes
#bond1
DEVICE=bond1
BOOTPROTO=none
ONBOOT=yes
NETWORK=10.41.22.0
NETMASK=255.255.255.0
IPADDR=10.41.22.11
USERCTL=no
GATEWAY=10.41.11.254
TYPE=Ethernet
IPV6INIT=no
PEERDNS=yes
**** modeprobe.conf / as this are ibm blades a active/active configuration of bonding is not possible ****
**** in our case we are using a active/passive configuration for our bonds = mode1 – otherwise mode4 ****
[root@rac11 etc]# cat modprobe.conf
alias eth0 bnx2
alias eth1 bnx2
alias scsi_hostadapter qla2xxx
alias scsi_hostadapter1 usb-storage
alias eth2 bnx2
alias eth3 bnx2
alias usb0 cdc_ether
##
alias bond0 bonding
alias bond1 bonding
## you need the max_bonds setting if you have more than one bond interface ##
## bond mode=1 (active-backup)
options bonding max_bonds=2
options bond0 mode=1 miimon=100
options bond1 mode=1 miimon=100
**** some fixes before installing the database ****
**** if you want use more than 1.3 (?) gig ram for your database ****
hint about 11gR2 and tmpfs
ORA-00845 – MEMORY_TARGET not supported on this system
This error is common, and it occurs most frequently when the Linux /dev/shm mount point isn’t large enough. Specifically, your SGA and PGA are sized such that there isn’t enough space in /dev/shm for the instance to start.
So, to fix it:
mount -t tmpfs shmfs -o size=1300m /dev/shm
where 1300m is whatever size that will at least cover your MEMORY_TARGET parameter.
Once you’ve got a value for /dev/shm set that works, you can add it to /etc/fstab, such that it’ll be a permanent change.
Edit /etc/fstab, and add the following line, adjusting the size to fit your environment:
shmfs /dev/shm tmpfs size=1300m 0 0
eg: in our case we have ram enough and so we allocate 35gig for our database
eg: mount -t tmpfs shmfs -o size=35000m /dev/shm
eg: change also in fstab: tmpfs /dev/shm tmpfs size=35000m 0 0
**** if you use centos instead of rhel in your environment ****
IMPORTANT: If you begin to install the ‘grid’ software and you execute the setup the system will ask you the excute some task as ‘root’ user.
At this time stop your regular setup work and use this fix to avoid further installation problems, so before you starting any root scripts suggested from oracle fix this issue before otherwise you get:
ADVM/ACFS is not supported on centos-release-5-5.el5.centos
FIX: edit in /grid/lib/osds_acfslib.pm
search for ‘release’ and insert the centos section release (checkit twice for proper brackets and pipes):
if (($release =~ /enterprise-release-5/) ||
($release =~ /redhat-release-5/) ||
($release =~ /centos-release-5/))
If you forget this or make some failures for this string … there is a also a workaround for this at ‘http://brianbontrager.blogspot.com/ – Learning ASM: Breakin’ the Rules (or, Running ACFS on CentOS)’
**** need some status output script for better life at login as admin or root ****
#
# created by muda
#
clear
echo -e “\nWelcome user $USER – you are logged on $HOSTNAME”
echo -e “\nServer Information: ” ; uname -a
echo “”
#
# Ifconfig stuff
#
echo -e “IP Information:”
for NIC_ID in $(ls /etc/sysconfig/network-scripts/ifcfg-bond* | cut -d”-” -f3 ); do
for SERVER_IP in $(cat /etc/sysconfig/network-scripts/ifcfg-${NIC_ID}|grep -iw ipaddr| cut -d”=” -f2 ); do
echo “” >/dev/null
echo -e “The IP of ${NIC_ID} is: ${SERVER_IP}”
done
done
for NIC_ID in $(ls /etc/sysconfig/network-scripts/ifcfg-eth* | cut -d”-” -f3 ); do
for SERVER_IP in $(cat /etc/sysconfig/network-scripts/ifcfg-${NIC_ID}|grep -iw ipaddr| cut -d”=” -f2 ); do
echo “” >/dev/null
echo -e “The IP of ${NIC_ID} is: ${SERVER_IP}”
done
done
for SERVER_GW in $(cat /etc/sysconfig/network |grep -iw gateway | cut -d”=” -f2 ); do
##for SERVER_GW in $(cat /etc/sysconfig/network-scripts/ifcfg-${NIC_ID} |grep -iw gateway | cut -d”=” -f2 ); do
echo “” >/dev/null
echo -e “The Standard Gateway IP is: ${SERVER_GW}”
done
##
echo “” >/dev/null
echo -e “Routing: $(/sbin/ip -o route |grep -iw default)”
echo -e “\nUsers logged on: ” ; w -h
echo -e “\nLast (4) logged in users: ” ; last -4 -a
echo -e “\nCurrent date: ” ; date
echo -e “\nMachine stats: ” ; uptime
echo -e “\nMemory stats: ” ; free
echo “”
#
# Filesystem Usage
#
echo -e “\nFilesystem \t Usage(%) \t Status\n”
for FILESYSTEM in $(df -P |grep ‘^/’ | grep -v ‘none’ | grep -v ‘proc’ | awk ‘{print $1;}’ ); do
for USAGE in $(df -P | grep “${FILESYSTEM}” | awk ‘{print $5}’ ); do
USAGE_NEW=${USAGE%%%}
done
printf “%-40s %-10s %-10s” ${FILESYSTEM} ${USAGE_NEW}
if [ $USAGE_NEW -gt 90 ] ; then
echo “=== CRITICAL ===”
elif [ $USAGE_NEW -gt 75 ] ; then
echo “=== WARNING ===”
else
echo “ok”
fi
done
##
**** add this in /etc/bashrc to run /etc/muda.status at logon ****
After: # are we an interactive shell?
if [ "$PS1" ]; then
Insert: ## some stuff by muda ##
[ "$UID" = "0" -o "$USER" = "admin" ] && . /etc/muda.status
**** check /etc/hosts that you don’t have any other names for 127.0.0.1 / ::1 than localhost ****
127.0.0.1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
**** add this in your sshd config authentication section to allow root connects with ssh keys ****
# Authentication:
## changes by muda – start ##
LoginGraceTime 30
PermitRootLogin without-password
StrictModes yes
MaxAuthTries 3
PermitEmptyPasswords no
## changes by muda – stop ##
**** add to your /etc/hosts the ip’s for your nodes ****
# Public Network – (bond0)
10.41.11.11 rac11.db.foo.com rac11
10.41.11.12 rac12.db.foo.com rac12
# Private Interconnect – (bond1)
10.41.22.11 rac11-priv.db-ic.foo.com rac11-priv
10.41.22.12 rac12-priv.db-ic.foo.com rac12-priv
# Public Virtual IP (VIP) addresses – (bond1:1)
10.41.11.111 rac11-vip.db.foo.com rac11-vip
10.41.11.112 rac12-vip.db.foo.com rac12-vip
# Single Client Access Name (SCAN) – hash out the ip values, because you get errors when not at grid installation
# 10.41.11.180 rac1-cluster-scan.db.foo.com rac1-cluster-scan
# 10.41.11.190 rac1-cluster-scan.db.foo.com rac1-cluster-scan


**** recommended packages for oracle installation (version can be higher) ****
binutils-2.17.50.0.6
compat-libstdc++-33-3.2.3
compat-libstdc++-33-3.2.3 (32 bit)
elfutils-libelf-0.125
elfutils-libelf-devel-0.125
elfutils-libelf-devel-static-0.125
gcc-4.1.2
gcc-c++-4.1.2
glibc-2.5-24
glibc-2.5-24 (32 bit)
glibc-common-2.5
glibc-devel-2.5
glibc-devel-2.5 (32 bit)
glibc-headers-2.5
ksh-20060214
libaio-0.3.106
libaio-0.3.106 (32 bit)
libaio-devel-0.3.106
libaio-devel-0.3.106 (32 bit)
libgcc-4.1.2
libgcc-4.1.2 (32 bit)
libstdc++-4.1.2
libstdc++-4.1.2 (32 bit)
libstdc++-devel 4.1.2
make-3.81
sysstat-7.0.2
unixODBC-2.2.11
unixODBC-2.2.11 (32 bit)
unixODBC-devel-2.2.11
unixODBC-devel-2.2.11 (32 bit)
**** installed packages for this installation ****
yum install binutils compat-libstdc++-33 elfutils-libelf-devel.x86_64 gcc.x86_64 gcc-c++.x86_64 glibc-devel libaio-devel sysstat unixODBC unixODBC-devel
yum install xauth gnome-screensaver control-center libXtst libXtst-devel libXp-devel pdksh ntp sysstat xclock
**** install user and groups for oracle ****
# add groups
groupadd -g 3100 oinstall
groupadd -g 3200 asmadmin
groupadd -g 3201 asmdba
groupadd -g 3202 asmoper
groupadd -g 3300 dba
groupadd -g 3301 oper
# add user
useradd -m -u 3100 -g oinstall -G asmadmin,asmdba,asmoper,dba -d /home/grid -s /bin/bash -c “Grid Infrastructure Owner” grid
useradd -m -u 3101 -g oinstall -G dba,oper,asmdba -d /home/oracle -s /bin/bash -c “Oracle Software Owner” oracle
#check user grid and oracle
id grid
uid=3100(grid) gid=3100(oinstall) groups=3100(oinstall),3200(asmadmin),3201(asmdba),3202(asmoper),3300(dba) context=user_u:system_r:unconfined_t
id oracle
uid=3100(grid) gid=3100(oinstall) groups=3100(oinstall),3200(asmadmin),3201(asmdba),3202(asmoper) context=user_u:system_r:unconfined_t
passwd grid
passwd oracle

**** set some enviroment for oracle and grid ****
# /home/grid/.bash_profile
# —————————————————
# .bash_profile
# —————————————————
# OS User: grid
# Application: Oracle Grid Infrastructure
# Version: Oracle 11g release 2
# —————————————————
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
alias ls=”ls -FA”
# —————————————————
# ORACLE_SID
# —————————————————
# Specifies the Oracle system identifier (SID)
# for the Automatic Storage Management (ASM)instance
# running on this node.
# Each RAC node must have a unique ORACLE_SID.
# (i.e. +ASM1, +ASM2,…)
# —————————————————
ORACLE_SID=+ASM1; export ORACLE_SID
# —————————————————
# JAVA_HOME
# —————————————————
# Specifies the directory of the Java SDK and Runtime
# Environment.
# —————————————————
#JAVA_HOME=/usr/local/java; export JAVA_HOME
# —————————————————
# ORACLE_BASE
# —————————————————
# Specifies the base of the Oracle directory structure
# for Optimal Flexible Architecture (OFA) compliant
# installations. The Oracle base directory for the
# grid installation owner is the location where
# diagnostic and administrative logs, and other logs
# associated with Oracle ASM and Oracle Clusterware
# are stored.
# —————————————————
ORACLE_BASE=/opt/apps/gridbase; export ORACLE_BASE
# —————————————————
# ORACLE_HOME
# —————————————————
# Specifies the directory containing the Oracle
# Grid Infrastructure software. For grid
# infrastructure for a cluster installations, the Grid
# home must _not_ be placed under one of the Oracle base
# directories, or under Oracle home directories of
# Oracle Database installation owners, or in the home
# directory of an installation owner. During
# installation, ownership of the path to the Grid
# home is changed to root. This change causes
# permission errors for other installations.
# —————————————————
ORACLE_HOME=/opt/apps/grid/; export ORACLE_HOME
# —————————————————
# ORACLE_PATH
# —————————————————
# Specifies the search path for files used by Oracle
# applications such as SQL*Plus. If the full path to
# the file is not specified, or if the file is not
# in the current directory, the Oracle application
# uses ORACLE_PATH to locate the file.
# This variable is used by SQL*Plus, Forms and Menu.
# —————————————————
#ORACLE_PATH=/u01/app/oracle/common/oracle/sql; export ORACLE_PATH
# —————————————————
# SQLPATH
# —————————————————
# Specifies the directory or list of directories that
# SQL*Plus searches for a login.sql file.
# —————————————————
# SQLPATH=/u01/app/common/oracle/sql; export SQLPATH
# —————————————————
# ORACLE_TERM
# —————————————————
# Defines a terminal definition. If not set, it
# defaults to the value of your TERM environment
# variable. Used by all character mode products.
# —————————————————
#ORACLE_TERM=xterm; export ORACLE_TERM
# —————————————————
# NLS_DATE_FORMAT
# —————————————————
# Specifies the default date format to use with the
# TO_CHAR and TO_DATE functions. The default value of
# this parameter is determined by NLS_TERRITORY. The
# value of this parameter can be any valid date
# format mask, and the value must be surrounded by
# double quotation marks. For example:
#
# NLS_DATE_FORMAT = “MM/DD/YYYY”
#
# —————————————————
#NLS_DATE_FORMAT=”DD-MON-YYYY HH24:MI:SS”; export NLS_DATE_FORMAT
# —————————————————
# TNS_ADMIN
# —————————————————
# Specifies the directory containing the Oracle Net
# Services configuration files like listener.ora,
# tnsnames.ora, and sqlnet.ora.
# —————————————————
#TNS_ADMIN=$ORACLE_HOME/network/admin; export TNS_ADMIN
# —————————————————
# ORA_NLS11
# —————————————————
# Specifies the directory where the language,
# territory, character set, and linguistic definition
# files are stored.
# —————————————————
#ORA_NLS11=$ORACLE_HOME/nls/data; export ORA_NLS11
# —————————————————
# PATH
# —————————————————
# Used by the shell to locate executable programs;
# must include the $ORACLE_HOME/bin directory.
# —————————————————
#PATH=.:${JAVA_HOME}/bin:${PATH}:$HOME/bin:$ORACLE_HOME/bin
#PATH=${PATH}:/usr/bin:/bin:/usr/bin/X11:/usr/local/bin
#PATH=${PATH}:/u01/app/common/oracle/bin
PATH=${PATH}:$HOME/bin:$ORACLE_HOME/bin
export PATH
# —————————————————
# LD_LIBRARY_PATH
# —————————————————
# Specifies the list of directories that the shared
# library loader searches to locate shared object
# libraries at runtime.
# —————————————————
#LD_LIBRARY_PATH=$ORACLE_HOME/lib
#LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$ORACLE_HOME/oracm/lib
#LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/lib:/usr/lib:/usr/local/lib
#export LD_LIBRARY_PATH
# —————————————————
# CLASSPATH
# —————————————————
# Specifies the directory or list of directories that
# contain compiled Java classes.
# —————————————————
#CLASSPATH=$ORACLE_HOME/JRE
#CLASSPATH=${CLASSPATH}:$ORACLE_HOME/jlib
#CLASSPATH=${CLASSPATH}:$ORACLE_HOME/rdbms/jlib
#CLASSPATH=${CLASSPATH}:$ORACLE_HOME/network/jlib
#export CLASSPATH
# —————————————————
# THREADS_FLAG
# —————————————————
# All the tools in the JDK use green threads as a
# default. To specify that native threads should be
# used, set the THREADS_FLAG environment variable to
# “native”. You can revert to the use of green
# threads by setting THREADS_FLAG to the value
# “green”.
# —————————————————
#THREADS_FLAG=native; export THREADS_FLAG
# —————————————————
# TEMP, TMP, and TMPDIR
# —————————————————
# Specify the default directories for temporary
# files; if set, tools that create temporary files
# create them in one of these directories.
# —————————————————
#export TEMP=/tmp
#export TMPDIR=/tmp
# —————————————————
# UMASK
# —————————————————
# Set the default file mode creation mask
# (umask) to 022 to ensure that the user performing
# the Oracle software installation creates files
# with 644 permissions.
# —————————————————
umask 022
# ——-
# by MUDA
# ——-
alias rsqlplus=’rlwrap sqlplus’
alias rrman=’rlwrap rman’
# /home/oracle/.bash_profile
# —————————————————
# .bash_profile
# —————————————————
# OS User: oracle
# Application: Oracle Database Software Owner
# Version: Oracle 11g release 2
# —————————————————
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
alias ls=”ls -FA”
# —————————————————
# ORACLE_SID
# —————————————————
# Specifies the Oracle system identifier (SID) for
# the Oracle instance running on this node.
# Each RAC node must have a unique ORACLE_SID.
# (i.e. racdb1, racdb2,…)
# —————————————————
ORACLE_SID=rac11; export ORACLE_SID
# —————————————————
# ORACLE_UNQNAME
# —————————————————
# In previous releases of Oracle Database, you were
# required to set environment variables for
# ORACLE_HOME and ORACLE_SID to start, stop, and
# check the status of Enterprise Manager. With
# Oracle Database 11g release 2 (11.2) and later, you
# need to set the environment variables ORACLE_HOME
# and ORACLE_UNQNAME to use Enterprise Manager.
# Set ORACLE_UNQNAME equal to the database unique
# name.
# —————————————————
ORACLE_UNQNAME=rac1; export ORACLE_UNQNAME
# —————————————————
# JAVA_HOME
# —————————————————
# Specifies the directory of the Java SDK and Runtime
# Environment.
# —————————————————
#JAVA_HOME=/usr/local/java; export JAVA_HOME
# —————————————————
# ORACLE_BASE
# —————————————————
# Specifies the base of the Oracle directory structure
# for Optimal Flexible Architecture (OFA) compliant
# database software installations.
# —————————————————
ORACLE_BASE=/opt/apps/database; export ORACLE_BASE
# —————————————————
# ORACLE_HOME
# —————————————————
# Specifies the directory containing the Oracle
# Database software.
# —————————————————
ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db1; export ORACLE_HOME
# —————————————————
# ORACLE_PATH
# —————————————————
# Specifies the search path for files used by Oracle
# applications such as SQL*Plus. If the full path to
# the file is not specified, or if the file is not
# in the current directory, the Oracle application
# uses ORACLE_PATH to locate the file.
# This variable is used by SQL*Plus, Forms and Menu.
# —————————————————
#ORACLE_PATH=/u01/app/common/oracle/sql; export ORACLE_PATH
# —————————————————
# SQLPATH
# —————————————————
# Specifies the directory or list of directories that
# SQL*Plus searches for a login.sql file.
# —————————————————
# SQLPATH=/u01/app/common/oracle/sql; export SQLPATH
# —————————————————
# ORACLE_TERM
# —————————————————
# Defines a terminal definition. If not set, it
# defaults to the value of your TERM environment
# variable. Used by all character mode products.
# —————————————————
#ORACLE_TERM=xterm; export ORACLE_TERM
# —————————————————
# NLS_DATE_FORMAT
# —————————————————
# Specifies the default date format to use with the
# TO_CHAR and TO_DATE functions. The default value of
# this parameter is determined by NLS_TERRITORY. The
# value of this parameter can be any valid date
# format mask, and the value must be surrounded by
# double quotation marks. For example:
#
# NLS_DATE_FORMAT = “MM/DD/YYYY”
#
# —————————————————
#NLS_DATE_FORMAT=”DD-MON-YYYY HH24:MI:SS”; export NLS_DATE_FORMAT
# —————————————————
# TNS_ADMIN
# —————————————————
# Specifies the directory containing the Oracle Net
# Services configuration files like listener.ora,
# tnsnames.ora, and sqlnet.ora.
# —————————————————
#TNS_ADMIN=$ORACLE_HOME/network/admin; export TNS_ADMIN
# —————————————————
# ORA_NLS11
# —————————————————
# Specifies the directory where the language,
# territory, character set, and linguistic definition
# files are stored.
# —————————————————
#ORA_NLS11=$ORACLE_HOME/nls/data; export ORA_NLS11
# —————————————————
# PATH
# —————————————————
# Used by the shell to locate executable programs;
# must include the $ORACLE_HOME/bin directory.
# —————————————————
#PATH=.:${JAVA_HOME}/bin:${PATH}:$HOME/bin:$ORACLE_HOME/bin
#PATH=${PATH}:/usr/bin:/bin:/usr/bin/X11:/usr/local/bin
#PATH=${PATH}:/u01/app/common/oracle/bin
PATH=${PATH}:$HOME/bin:$ORACLE_HOME/bin
export PATH
# —————————————————
# LD_LIBRARY_PATH
# —————————————————
# Specifies the list of directories that the shared
# library loader searches to locate shared object
# libraries at runtime.
# —————————————————
#LD_LIBRARY_PATH=$ORACLE_HOME/lib
#LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$ORACLE_HOME/oracm/lib
#LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/lib:/usr/lib:/usr/local/lib
#export LD_LIBRARY_PATH
# —————————————————
# CLASSPATH
# —————————————————
# Specifies the directory or list of directories that
# contain compiled Java classes.
# —————————————————
#CLASSPATH=$ORACLE_HOME/JRE
#CLASSPATH=${CLASSPATH}:$ORACLE_HOME/jlib
#CLASSPATH=${CLASSPATH}:$ORACLE_HOME/rdbms/jlib
#CLASSPATH=${CLASSPATH}:$ORACLE_HOME/network/jlib
#export CLASSPATH
# —————————————————
# THREADS_FLAG
# —————————————————
# All the tools in the JDK use green threads as a
# default. To specify that native threads should be
# used, set the THREADS_FLAG environment variable to
# “native”. You can revert to the use of green
# threads by setting THREADS_FLAG to the value
# “green”.
# —————————————————
#THREADS_FLAG=native; export THREADS_FLAG
# —————————————————
# TEMP, TMP, and TMPDIR
# —————————————————
# Specify the default directories for temporary
# files; if set, tools that create temporary files
# create them in one of these directories.
# —————————————————
#export TEMP=/tmp
#export TMPDIR=/tmp
# —————————————————
# UMASK
# —————————————————
# Set the default file mode creation mask
# (umask) to 022 to ensure that the user performing
# the Oracle software installation creates files
# with 644 permissions.
# —————————————————
umask 022
# ——-
# by MUDA
# ——-
alias rsqlplus=’rlwrap sqlplus’
alias rrman=’rlwrap rman’
**** create the directory for the oracle installation ****
mkdir -p /opt/apps/
chmod -R 775 /opt/apps/
chown -R oracle:oinstall /opt/apps/
**** set new values for oracle and grid in the /etc/security/limits.conf ****
grid soft nproc 2047
grid hard nproc 16384
grid soft nofile 2047
grid hard nofile 65536
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 2047
oracle hard nofile 65536
**** put the limits settings in your /etc/pam.d/ ****
insert into /etc/pam.d/login
session required pam_limits.so
insert into /etc/pam.d/su
session required pam_limits.so
**** activate new ulimits for oracle and grid ****
*insert into /etc/profile
if [ \$USER = "oracle" ] || [ \$USER = "grid" ]; then
if [ \$SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
umask 022
fi
*insert into /etc/csh.login
if ( \$USER == “oracle” || \$USER == “grid” ) then
limit maxproc 16384
limit descriptors 65536
endif
**** add values in /etc/sysctl.conf ****
### ORACLE SECTION ###
# Controls the maximum number of shared memory segments system wide
kernel.shmmni = 4096
# Sets the following semaphore values:
# SEMMSL_value SEMMNS_value SEMOPM_value SEMMNI_value
kernel.sem = 250 32000 100 128
# Sets the maximum number of file-handles that the Linux kernel will allocate
fs.file-max = 6815744
# Defines the local port range that is used by TCP and UDP
# traffic to choose the local port
net.ipv4.ip_local_port_range = 9000 65500
# Default setting in bytes of the socket “receive” buffer which
# may be set by using the SO_RCVBUF socket option
net.core.rmem_default=262144
# Maximum setting in bytes of the socket “receive” buffer which
# may be set by using the SO_RCVBUF socket option
net.core.rmem_max=4194304
# Default setting in bytes of the socket “send” buffer which
# may be set by using the SO_SNDBUF socket option
net.core.wmem_default=262144
# Maximum setting in bytes of the socket “send” buffer which
# may be set by using the SO_SNDBUF socket option
net.core.wmem_max=1048576
# Maximum number of allowable concurrent asynchronous I/O requests requests
fs.aio-max-nr=1048576
**** activate the values in /etc/sysctl.conf ****
sysctl -p
**** create for oracle and grid ssh keys (no passphrase) ****
[root@rac11 ~]# su – grid
mkdir .ssh
chmod 700 .ssh/
ssh-keygen -t dsa
touch .ssh/authorized_keys
chmod 600 .ssh/authorized_keys
[root@rac11 ~]# su – oracle
mkdir .ssh
chmod 700 .ssh
ssh-keygen -t dsa
touch .ssh/authorized_keys
chmod 600 .ssh/authorized_keys
**** test the logins on _both_ servers (as grid and oracle user) ****
ssh rac11 cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
ssh rac12 cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
ssh rac11.db.foo.com cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
ssh rac12.db.foo.com cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
**** download asm files from oracle ****
download asm files from oracle (http://www.oracle.com/technology/software/tech/linux/asmlib/rhel5.html)
and install it on both servers
**** install it on your nodes ****
rpm -ivh oracleasm-2.6.18-194.11.3.el5-2.0.5-1.el5.x86_64.rpm oracleasmlib-2.0.4-1.el5.x86_64.rpm oracleasm-support-2.1.3-1.el5.x86_64.rpm
**** configure asm on your nodes ****
execute: oracleasm configure
ORACLEASM_ENABLED=false
ORACLEASM_UID=
ORACLEASM_GID=
ORACLEASM_SCANBOOT=true
ORACLEASM_SCANORDER=”"
ORACLEASM_SCANEXCLUDE=”"
execute: oracleasm configure -i
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 []: grid
Default group to own the driver interface []: asmadmin
Start Oracle ASM library driver on boot (y/n) [n]: y
Scan for Oracle ASM disks on boot (y/n) [y]: y
Writing Oracle ASM library driver configuration: done
execute: oracleasm init
Creating /dev/oracleasm mount point: /dev/oracleasm
Loading module “oracleasm”: oracleasm
Mounting ASMlib driver filesystem: /dev/oracleasm
**** asm and multipath need special settings in /etc/sysconfig/oracleasm ****
# for device mapper drives, scan dm at first #
ORACLEASM_SCANORDER=dm
# ignore sd drives, because we have multipath, to avoid missconfigurations #
ORACLEASM_SCANEXCLUDE=sd

**** unzip all oracle packages ****
in our case to ‘/opt/apps/oracle/stage’
**** start with the grid installation ***
check if all settings are proper set (as user grid):
sh runcluvfy.sh stage -pre crsinst -n rac11,rac12 -verbose
**** make sure that testrac1-cluster-scan is resolved by dns ****
Not by host entry, avoid this, otherwise the installation of the listener fails.
A workaround is possible, but not recommended
**** pre design asm storage system ****
Our configuration is:
10gig for CRS (3times – internal redundcy)
490gig for DATA (external reduncy)
490gig for FLASH (external reduncy)
**** fdisk our system (only at the first node) ****
[root@rac11 tmp]# fdisk /dev/mapper/svc-data1
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 won’t be recoverable.
The number of cylinders for this disk is set to 65270.
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 0×0000 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-65270, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-65270, default 65270): +10000M
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (1218-65270, default 1218):
Using default value 1218
Last cylinder or +size or +sizeM or +sizeK (1218-65270, default 65270):
Using default value 65270
Command (m for help): p
Disk /dev/mapper/svc-data1: 536.8 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/mapper/svc-data1p1 1 1217 9775521 83 Linux
/dev/mapper/svc-data1p2 1218 65270 514505722+ 83 Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 22: Invalid argument.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
[root@rac11 tmp]# fdisk /dev/mapper/svc-flash1
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 won’t be recoverable.
The number of cylinders for this disk is set to 65270.
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 0×0000 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-65270, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-65270, default 65270): +10000M
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (1218-65270, default 1218):
Using default value 1218
Last cylinder or +size or +sizeM or +sizeK (1218-65270, default 65270):
Using default value 65270
Command (m for help): p
Disk /dev/mapper/svc-flash1: 536.8 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/mapper/svc-flash1p1 1 1217 9775521 83 Linux
/dev/mapper/svc-flash1p2 1218 65270 514505722+ 83 Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 22: Invalid argument.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
[root@rac11 tmp]# fdisk /dev/mapper/svc-scratch1
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 won’t be recoverable.
The number of cylinders for this disk is set to 33418.
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 0×0000 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-33418, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-33418, default 33418): +10000M
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (1218-33418, default 1218):
Using default value 1218
Last cylinder or +size or +sizeM or +sizeK (1218-33418, default 33418):
Using default value 33418
Command (m for help): p
Disk /dev/mapper/svc-scratch1: 274.8 GB, 274877906944 bytes
255 heads, 63 sectors/track, 33418 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/mapper/svc-scratch1p1 1 1217 9775521 83 Linux
/dev/mapper/svc-scratch1p2 1218 33418 258654532+ 83 Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 22: Invalid argument.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
**** reboot all nodes ****
**** create the partions in asm ****
[root@rac11 ~]# oracleasm createdisk DATA1 /dev/mapper/svc-data1p2
Writing disk header: done
Instantiating disk: done
[root@rac11 ~]# oracleasm createdisk FLASH1 /dev/mapper/svc-flash1p2
Writing disk header: done
Instantiating disk: done
[root@rac11 ~]# oracleasm createdisk CRS1 /dev/mapper/svc-data1p1
Writing disk header: done
Instantiating disk: done
[root@rac11 ~]# oracleasm createdisk CRS2 /dev/mapper/svc-flash1p1
Writing disk header: done
Instantiating disk: done
[root@rac11 ~]# oracleasm createdisk CRS3 /dev/mapper/svc-scratch1p1
Writing disk header: done
Instantiating disk: done
**** scan on both nodes for the disks ****
[root@rac11 ~]# oracleasm scandisks
Reloading disk partitions: done
Cleaning any stale ASM disks…
Scanning system for ASM disks…
Instantiating disk “CRS1″
Instantiating disk “DATA1″
Instantiating disk “CRS2″
Instantiating disk “FLASH1″
Instantiating disk “CRS3″
[root@rac11 ~]# oracleasm listdisks
CRS1
CRS2
CRS3
DATA1
FLASH1
**** install the grid software ****
There is the option to install the software only.
After that you have the possibility to run ‘netca’ and ‘asmca’
We make a ‘full’ installation for our nodes instead.
**** be aware that we need for this installation a fix when using centos instead of rhel ****
execute as user grid: (pwd /opt/apps/stage/grid) ./runInstaller
Step1: Install and Configure Grid Infrastructure for a Cluster
Step2: Advanced Installation
Step3: Let ‘English’ as Language
Step4: Change the Clustername to: rac1-cluster
Change the SCAN name to: rac1-cluster-scan.db.foo.com
Unselect ‘Configure GSN’
(It is very important at this step that the dns server is resolving the SCAN name)
Step5: Add the 2nd clusternode:
Hostname: rac12.db.foo.com
Virtual IP Name: rac12-vip.db.foo.com
Step6: Network Interface Usage (check if correct – public and private subnet was found)
Step7: Storage Option for OCR and voting (we use ASM for that usecase)
HINT: If your system dont display the disks – change the discovery path to /dev/oracleasm/disks
Step8: Disk Group Options:
Diskgroup Name: CRS / Normal Redundancy / candidate disk: CRS1 CRS2 CRS3
Step9: Use different passwords for ‘SYS’ and ‘ASMSNMP’
Step10: Don’t use IPMI
Step11: Check suggested groups: asmdba / asmoper / asmadmin
Step12: Oracle Base: /opt/apps/gridbase
Software Location: /opt/apps/grid/
Step13: Inventory Location: /opt/apps/oraInventory
Inventory Group Name: oinstall
Step14-1: Prerequisite Checks: In our case we have not enough swap space (only 10g instead 16g) – i ignore it.
Step14-2: Install Package cvuqdisk-1.0.9-1.rpm on all nodes (is located in grid/rpm/ install directory) – 11.2.0.2
Step14-3: If problems with ASM (and udev) check this (Bug 10044507):
- https://gjilevski.wordpress.com/2010/10/03/fresh-oracle-11-2-0-2-grid-infrastructure-installation-prvf-5150-prvf-5184/
- http://www.oracledatabase12g.com/archives/readme-information-for-oracle-database-11g-release-2-11-2-0-2.html
Step15: Summary (Save Response File) – Finish
Step16: Setup (go for a coffee)
ATTENTION START for CENTOS: At the step ‘Execute Configuration Scripts’ we do some kind of break to fix the ‘centos’ issue.
1. open a shell as root
2. in our case cd /opt/apps/grid/lib
3. open osds_acfslib.pm
4. search for
# OK, now check to see if we support this release
$supported = 0;
if (($release =~ /enterprise-release-5/) ||
($release =~ /redhat-release-5/))
{
5. change to
# OK, now check to see if we support this release
$supported = 0;
if (($release =~ /enterprise-release-5/) ||
($release =~ /redhat-release-5/) ||
($release =~ /centos-release-5/))
{
6. do this on both nodes (as root)
ATTENTION END for CENTOS:
Execute the root shell scripts suggested from grid setup
**** Create the diskgroups for DATA and FLASH ****
asmca
Select: Diskgroups – Create
Create Diskgoup DATA – external Redundancy – Path /dev/oracleasm/disks/DATA1
Create Diskgoup FLASH – external Redundancy – Path /dev/oracleasm/disks/FLASH1
Finish
**** database 11gR2 installation ****
change ownership for /opt/apps to user oracle, because grid setup changed it to root:
chown oracle /opt/apps
chmod 775 /opt/apps
**** fix the redhat-release entry ****
replace the entry CentOS release 5.5 (Final) with Red Hat Enterprise Linux Server release 5.5 (Final)
**** install db software only ****
IMPORTANT: run as user oracle!
./runInstaller
Step2: Install Database software only
Step3: RAC Installation – both nodes should be selected
Step4: Language – English only
Step5: Database Edition – Enterprise
Step6: Select Oracle Base – /opt/apps/database and Oracle Home – /opt/apps/database/product/11.2.0/db1
Step7: Operating System Groups – as suggested
Step8: PreReq Checks – fix if there are any problems
Step9: Summary
Step10: Install Product
Step11: Run root.sh scripts – then finish
**** create database ****
IMPORTANT: run as user oracle!
dbca
Step0: Select RAC
Step1: Create Database
Step2: Custom Database
Step3: Configuration Type: Admin Managed
Global Database Name: rac1.foo.net
SID: rac1
Select all nodes: rac11 and rac12
Step4: Enterprise Manager – until we have installed the gridcontrol server!
Database Control local managed
Enable automatic maintenance tasks
Step5: Use one password for all accounts
Step6: Storage Type ASM
Use Oracle Managed Files – Browse – Available Diskgroups – select DATA
Specify ASM password:
Specify Flash Recovery Area – Browse – select FLASH
Size it the a proper value – in our case 502346 M Bytes
Dont select – enable archiving – we do this later!
Step7: Database Components – unselect DWH Builder
Step8: Initialization Parameters
Typical – start with 50gig
Use automatic memory management
Sizing – 8k block size
Processes – 2000
Character Set – Use Unicode – AL32UTF8
Connection Mode – Dedicated Server Mode
Open Cursors – 2000
Step9: Database Storage
Change Redo Log Groups – Change size of every one to 102400 K Bytes
Later we would add 2 addtional groups to the redo log groups!
Step10: Creation Options – create database, save template, create scripts – FINISH
**** OPEN POINTZ ****
redo log group – add 2 additional members
gridcontrol 11g – install and configure
**** archivelogs – enable it after backup is working ****
Step1: srvctl stop database -d rac1
Step2: crs_stat -t
Step3: srvctl start instance -d rac1 -i rac11 -o mount
Step4: crs_stat -t
Step5: sqlplus /nolog
Step6: connect /as sysdba
Step7: alter database archivelog
Step8: srvctl stop database -d rac1
Step9: srvctl start database -d rac1
Step10: sqlplus /as sysdba
Step11: archive log list
Step12: alter system switch logfile
**** flashback – enable it after backup is working ****
Step1: srvctl stop database -d rac1
Step2: crs_stat -t
Step3: srvctl start instance -d rac1 -i rac11 -o mount
Step4: crs_stat -t
Step5: sqlplus /nolog
Step6: connect /as sysdba
Step7: alter database flashback on
Step8: srvctl stop database -d rac1
Step9: srvctl start database -d rac1
**** configure rman – catalog exists and is located on gridcontrol ****
rman target / catalog rman@emrep
Step1: register database;
Step2: report schema;
Step3: show all;
DEFAULT SETTINGS:
RMAN configuration parameters for database with db_unique_name RAC1 are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO ‘%F’; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM ‘AES128′; # default
CONFIGURE COMPRESSION ALGORITHM ‘BASIC’ AS OF RELEASE ‘DEFAULT’ OPTIMIZE FOR LOAD TRUE ; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO ‘/opt/apps/database/product/11.2.0/db1/dbs/snapcf_rac11.f’; # default
NEW SETTINGS:
RMAN configuration parameters for database with db_unique_name RAC1 are:
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 14 DAYS;
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO ‘SBT_TAPE’;
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO ‘%F’; # default
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE SBT_TAPE TO ‘%F’; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 2 BACKUP TYPE TO BACKUPSET;
CONFIGURE DEVICE TYPE ‘SBT_TAPE’ PARALLELISM 2 BACKUP TYPE TO BACKUPSET;
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE SBT_TAPE TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE ‘SBT_TAPE’ TO 1;
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE CHANNEL DEVICE TYPE ‘SBT_TAPE’ PARMS ‘ENV=(TDPO_OPTFILE=/opt/tivoli/tsm/client/oracle/bin64/tdpo.opt)’;
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM ‘AES128′; # default
CONFIGURE COMPRESSION ALGORITHM ‘BASIC’ AS OF RELEASE ‘DEFAULT’ OPTIMIZE FOR LOAD TRUE ; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO ‘/opt/apps/database/product/11.2.0/db1/dbs/snapcf_rac11.f’; # default
**** some checks ****
# Check CRS Status #
[grid@rac11 ~]$ crs_stat -t -v
Name Type R/RA F/FT Target State Host
———————————————————————-
ora.CRS.dg ora….up.type 0/5 0/ ONLINE ONLINE rac11
ora.DATA.dg ora….up.type 0/5 0/ ONLINE ONLINE rac11
ora.FLASH.dg ora….up.type 0/5 0/ ONLINE ONLINE rac11
ora….ER.lsnr ora….er.type 0/5 0/ ONLINE ONLINE rac11
ora….N1.lsnr ora….er.type 0/5 0/0 ONLINE ONLINE rac12
ora….N2.lsnr ora….er.type 0/5 0/0 ONLINE ONLINE rac11
ora.asm ora.asm.type 0/5 0/ ONLINE ONLINE rac11
ora.eons ora.eons.type 0/3 0/ ONLINE ONLINE rac11
ora.gsd ora.gsd.type 0/5 0/ OFFLINE OFFLINE
ora….network ora….rk.type 0/5 0/ ONLINE ONLINE rac11
ora.oc4j ora.oc4j.type 0/5 0/0 OFFLINE OFFLINE
ora.ons ora.ons.type 0/3 0/ ONLINE ONLINE rac11
ora.rac1.db ora….se.type 0/2 0/1 ONLINE ONLINE rac11
ora….SM1.asm application 0/5 0/0 ONLINE ONLINE rac11
ora….11.lsnr application 0/5 0/0 ONLINE ONLINE rac11
ora.rac11.gsd application 0/5 0/0 OFFLINE OFFLINE
ora.rac11.ons application 0/3 0/0 ONLINE ONLINE rac11
ora.rac11.vip ora….t1.type 0/0 0/0 ONLINE ONLINE rac11
ora….SM2.asm application 0/5 0/0 ONLINE ONLINE rac12
ora….12.lsnr application 0/5 0/0 ONLINE ONLINE rac12
ora.rac12.gsd application 0/5 0/0 OFFLINE OFFLINE
ora.rac12.ons application 0/3 0/0 ONLINE ONLINE rac12
ora.rac12.vip ora….t1.type 0/0 0/0 ONLINE ONLINE rac12
ora….ry.acfs ora….fs.type 0/5 0/ ONLINE ONLINE rac11
ora.scan1.vip ora….ip.type 0/0 0/0 ONLINE ONLINE rac12
ora.scan2.vip ora….ip.type 0/0 0/0 ONLINE ONLINE rac11
# Check Clusterware Resources #
[grid@rac11 ~]$ crsctl check crs
CRS-4638: Oracle High Availability Services is online
CRS-4537: Cluster Ready Services is online
CRS-4529: Cluster Synchronization Services is online
CRS-4533: Event Manager is online
# Check Cluster Nodes #
[grid@rac11 ~]$ olsnodes -n
rac11 1
rac12 2
# Check Oracle TNS Listener Process on Both Nodes #
[grid@rac11 ~]$ ps -ef | grep lsnr | grep -v ‘grep’ | grep -v ‘ocfs’ | awk ‘{print $9}’
LISTENER
LISTENER_SCAN2
[grid@rac12 ~]$ ps -ef | grep lsnr | grep -v ‘grep’ | grep -v ‘ocfs’ | awk ‘{print $9}’
LISTENER_SCAN1
LISTENER
# Confirming Oracle ASM Function for Oracle Clusterware Files #
[grid@rac11 ~]$ srvctl status asm -a
ASM is running on rac11,rac12
ASM is enabled.
# Check Oracle Cluster Registry (OCR) #
[root@rac11 ~]# ocrcheck
Status of Oracle Cluster Registry is as follows :
Version : 3
Total space (kbytes) : 262120
Used space (kbytes) : 2760
Available space (kbytes) : 259360
ID : 1690752905
Device/File Name : +CRS
Device/File integrity check succeeded
Device/File not configured
Device/File not configured
Device/File not configured
Device/File not configured
Cluster registry integrity check succeeded
Logical corruption check succeeded
# Check Voting Disk #
[root@rac11 ~]# crsctl query css votedisk
## STATE File Universal Id File Name Disk group
– —– —————– ——— ———
1. ONLINE 8abc526b7ea84fabbfd274680864f46c (/dev/oracleasm/disks/CRS1) [CRS]
2. ONLINE 780da55f9fc84f59bfba13318847c2c7 (/dev/oracleasm/disks/CRS2) [CRS]
3. ONLINE 5a8daba8e2d04f7dbf1f6684c7c18129 (/dev/oracleasm/disks/CRS3) [CRS]
# Housekeeping logfiles
[root@rac11 ~]# cat /etc/logrotate.d/ora_listener
/opt/apps/gridbase/diag/tnslsnr/rac11/listener/trace/listener.log {
weekly
compress
rotate 4
notifempty
missingok
copytruncate
}
/opt/apps/gridbase/diag/tnslsnr/rac11/listener_scan1/trace/listener_scan1.log {
weekly
compress
rotate 4
notifempty
missingok
copytruncate
}
/opt/apps/gridbase/diag/tnslsnr/rac11/listener_scan2/trace/listener_scan2.log {
weekly
compress
rotate 4
notifempty
missingok
copytruncate
}
Maybe helpful for UDEV and ASM with proper rights
/etc/rc.local
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don’t
# want to do the full Sys V style init stuff.
touch /var/lock/subsys/local
#
# muda – needed for oracle – 11.2.0.2 installation, seems not needed with 11.2.0.1
#
# CRS disks 11gR2
#################
chown grid:asmadmin /dev/mapper/svc-data1p1
chmod 0660 /dev/mapper/svc-data1p1
chown grid:asmadmin /dev/mapper/svc-flash1p1
chmod 0660 /dev/mapper/svc-flash1p1
chown grid:asmadmin /dev/mapper/svc-scratch1p1
chmod 0660 /dev/mapper/svc-scratch1p1
#
# DATA and FLASH disks 11gR2
############################
chown oracle:oinstall /dev/mapper/svc-data1p2
chmod 0660 /dev/mapper/svc-data1p2
chown oracle:oinstall /dev/mapper/svc-flash1p2
chmod 0660 /dev/mapper/svc-flash1p2

2012年8月4日 星期六

Oracle:查詢誰Lock住Process, sid number ?做了什麼事?


ORACLE Tips: 查詢誰Lock住Process, sid number ?

Oracle:10G

select b.object_name obj_name,
       d.ctime time,
       to_char(d.lmode) l,
       to_char(d.request) r,
       a.os_user_name os_user,
       c.machine machine,
       c.program program,
       c.serial# s_serial,
       a.oracle_username ora_user,
       a.object_id obj_id,
       a.process pid,
       a.session_id s_id,
       p.spid
from v$locked_object a, all_objects b, v$session c, v$lock d,V$process p
where a.object_id=b.object_id
and c.Paddr = p.Addr
and a.session_id=c.sid
and a.session_id=d.sid
and d.type='TX'
order by d.ctime desc, p.spid;

---------------------------------------------------------------------------------------------------------

#查詢Session History(首先要知道Session_id,通常em發送訊息過來,就會指名session_id,
這樣會比較好找出是那一個Session做什麼事):

select sample_time,session_id,sql_id,session_state,blocking_session_status,
event,wait_class,time_waited,program,module from v$active_session_history
where blocking_session_status!='NOT IN WAIT';

#記住sql_id,再到v$sqltext查詢是執行那一個sql(piece是執行順序):

select * from v$sqltext where sql_id='f2fnfj93dwwvh' order by piece;

上面的動作都是Oracle 10G的ASH的功能:

ASH (Active Session History) 體系結構


在Oracle10g之前,當前會話記錄保存在v$session中;處於等待狀態的會話會被復制一份放在
v$session_wait中。當該連接斷開後,其原來的連接信息在v$session和v$session_wait中就
會被刪除。沒有視圖能提供有關session在歷史上的每個時間點上都在做什麼,以及在等待
什麼資源。原來的v$session及v$session_wait只是顯示當前session正在執行什麼SQL及等待
什麼資源。


從Oracle10g開始,Oracle提供了Active Session History (ASH)來解決這個問題。 每隔1秒鐘
ASH都會將當前活動的session的信息記錄在SGA的一個緩衝區(循環使用)中。在ASH中,這個過
程稱為采樣(Sampling)。ASH缺省每一秒收集一下v$session中活動會話的情況,記錄會話等待
的事件,不活動的會話不會被采樣, 間隔時間由 _ash_sampling_interval 參數確定 .


在10g中新出現了一個視圖:v$session_wait_history。這個視圖保存了每個活動session在
v$session_wait中最近10次的等待事件.  但這對於一段時期內的數據性能狀況的監測是遠遠不夠
的,為了解決這個問題,在10g中還新添加了一個視圖:v$active_session_history。這就是ASH
(active session history)。


ASH采用的策略 ---

典型的情況下,為了診斷當前數據庫的狀態,需要最近的五到十分鐘的詳細信息。然而,由於記錄
session的活動信息是很費時間和空間的,ASH采用的策略是:  保存處於等待狀態的活動session的
信息,每秒從v$session_wait及v$session中采樣一次,並將采樣信息保存在內存中(註意:ASH的
采樣數據是保存在內存中)。

 ASH的工作原理 ---

對於Active Session的采樣(每秒收集相關視圖中的信息)數據存放在SGA中,SGA中分配給ASH的大小
可以從v$sgastat中查詢(Shared Pool下ASH buffers),該空間可以循環使用,如果需要,以前的信
息可以被新的信息覆蓋。要把所有session的所有活動記錄下來是非常消耗資源的。因此ASH只能從
V$SESSION 等少數相關視圖中獲取那些活動的session的信息。ASH每隔1秒收集session信息時,不是
通過SQL語句完成的,而是采用直接訪問內存的方式,相對更高效。


因為每秒需要采樣數據,所以ASH緩存裏數據量非常大,將他們全部刷新到磁盤上的話,會非常消
耗磁盤空間,因此在將ASH緩存中的數據刷新到AWR相關表中的時候, 采取以下策略:

1.  MMON 默認每隔60分鐘 (可以調整) 將ash buffers 中的數據全部flush到磁盤 。
2.  MMNL 默認當ash buffers 滿66%的時候將ash buffers 中的1/10的數據寫入磁盤 (具體1/10是哪些數據,遵循FIFO原則) 。
3.  MMNL 寫入的采用數據百分比 10%  表示的是寫入磁盤的數據占 ash buffers 中采樣數據量的百分比 (而不是占ash buffers 總大小的比例)
4.  為了節省空間,AWR中采集的數據默認在7天後自動清除。

http://tw.myblog.yahoo.com/shin-chuan/article?mid=536&prev=-1&next=531