醬油DBA奉獻 Oracle 11gR2 RAC on linux 集成腳本化安裝(三)
醬油DBA奉獻 Oracle 11gR2 RAC on linux 集成腳本化安裝(三)
作為一個甲方醬油DBA,怎么可能不會搭建RAC?下面講講甲方醬油DBA是怎么腳本化安裝RAC的?(本人已有10+套RAC搭建經驗,AIX,HP-UNIX,LINUX,如有問題歡迎咨詢)
本文用途:Linux平臺下RAC集成腳本化安裝。
網上也有形形色色的腳本化安裝,有一些是問題的。本文把有問題的部分已經去除,現已安全使用。(僅限我的生產環境,其余朋友的生產環境慎用,如出現問題概不負責任)。
本文精華:“腳本化”三字概括,希望對醬油的DBA們有用
醬油DBA奉獻ORACLE數據庫監控健康腳本(一)
http://www.itpub.net/thread-1841912-1-1.html
醬油DBA奉獻expdp,impdp多用戶遷移數據(二)
http://www.itpub.net/thread-1868059-1-1.html
醬油DBA奉獻 Oracle 11gR2 RAC on linux 集成腳本化安裝(三)
http://www.itpub.net/thread-1900973-1-1.html
環境:
操作系統:redhat 6.2 64bit
數據庫:rac 11.2.0.4.0
存儲:EMC VNX5700
11gR2 RAC on linux 集成腳本化安裝
1.基本環境腳本安裝
cat dou.sh =>為了收集dou.1sh腳本日志
sh dou1.sh >dou.log
cat dou1.sh =>腳本如下:
echo "###Information Collection###"
##############################################
#Information Collection #
##############################################
echo "###redhat version###"
cat /etc/redhat-release
echo "###os memory###"
cat /proc/meminfo | grep MemTotal
echo "###os swap###"
cat /proc/meminfo | grep SwapTotal
echo "###os filesystem###"
df -h
echo "###os cpu numbers###"
cat /proc/cpuinfo |grep "processor"|wc -l
echo "###os cpu cores###"
cat /proc/cpuinfo |grep "cores"|uniq
echo "###create group and user###"
##############################################
#create group and user #
##############################################
/usr/sbin/groupadd -g 1000 oinstall
/usr/sbin/groupadd -g 1020 asmadmin
/usr/sbin/groupadd -g 1021 asmdba
/usr/sbin/groupadd -g 1022 asmoper
/usr/sbin/groupadd -g 1031 dba
/usr/sbin/groupadd -g 1032 oper
useradd -u 1100 -g oinstall -G asmadmin,asmdba,asmoper,dba grid
useradd -u 1101 -g oinstall -G dba,oper,asmdba oracle
echo "###create /etc/oraInst.loc###"
##############################################
#create /etc/oraInst.loc #
##############################################
echo "inventory_loc=/oracle/app/oracle/oraInventory" >>/etc/oraInst.loc
echo "inst_group=oinstall" >>/etc/oraInst.loc
echo "###create directory and Privilege###"
##############################################
#create directory and Privilege #
##############################################
mkdir -p /oracle/app/11.2.0/grid
mkdir -p /oracle/app/grid
mkdir -p /oracle/app/oracle/oraInventory
chown grid:oinstall /oracle/app/11.2.0/grid
chown grid:oinstall /oracle/app/grid
chmod -R 775 /oracle/
chown -R grid:oinstall /oracle
chown oracle:oinstall /oracle/app/oracle
echo "###LINUX optimize parameters####"
##############################################
#modify sysctl.conf | memory=64G #
##############################################
cat >> /etc/sysctl.conf <<done
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.file-max = 6553600
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
fs.file-max = 6815744
fs.aio-max-nr = 1048576
kernel.shmmax = 34359738368
kernel.shmall = 16777216
done
sleep 1
sysctl -p
sleep 1
###############################################
#modify /etc/security/limits.conf #
###############################################
cat >> /etc/security/limits.conf << done
grid soft nproc 2047
grid hard nproc 16384
grid soft nofile 1024
grid hard nofile 65536
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
done
sleep 1
################################################
#modify /etc/profile #
################################################
cat >> /etc/profile <<done
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
done
sleep 1
################################################
#modify /etc/pam.d/login #
################################################
echo "session required pam_limits.so">>/etc/pam.d/login
sleep 1
echo "###oracle environment variable ###"
################################################
# setting user oracle env #
################################################
cat >> /home/oracle/.bash_profile <<done
ORACLE_SID=doudoudb1; export ORACLE_SID
ORACLE_UNQNAME=doudoudb; export ORACLE_UNQNAME
JAVA_HOME=/usr/local/java; export JAVA_HOME
ORACLE_BASE=/oracle/app/oracle; export ORACLE_BASE
ORACLE_HOME=\$ORACLE_BASE/product/11.2.0/dbhome_1; export ORACLE_HOME
ORACLE_PATH=/oracle/app/common/oracle/sql; export ORACLE_PATH
ORACLE_TERM=xterm; export ORACLE_TERM
NLS_DATE_FORMAT="DD-MON-YYYY HH24:MI:SS"; export NLS_DATE_FORMAT
NLS_LANG=american_america.ZHS16GBK ; export NLS_LANG
TNS_ADMIN=\$ORACLE_HOME/network/admin; export TNS_ADMIN
ORA_NLS11=\$ORACLE_HOME/nls/data; export ORA_NLS11
PATH=.:\${JAVA_HOME}/bin:\${PATH}:\$HOME/bin:\$ORACLE_HOME/bin
PATH=\${PATH}:/usr/bin:/bin:/usr/bin/X11:/usr/local/bin
PATH=\${PATH}:/oracle/app/common/oracle/bin
export PATH
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=\$ORACLE_HOME/JRE
CLASSPATH=\${CLASSPATH}:\$ORACLE_HOME/jlib
CLASSPATH=\${CLASSPATH}:\$ORACLE_HOME/rdbms/jlib
CLASSPATH=\${CLASSPATH}:\$ORACLE_HOME/network/jlib
export CLASSPATH
THREADS_FLAG=native; export THREADS_FLAG
export TEMP=/tmp
export TMPDIR=/tmp
umask 022
done
done
sleep 1
echo "###grid environment variable ###"
###############################################
#setting user grid env #
###############################################
cat >> /home/grid/.bash_profile <<done
ORACLE_SID=+ASM1; export ORACLE_SID
JAVA_HOME=/usr/local/java; export JAVA_HOME
ORACLE_BASE=/oracle/app/grid; export ORACLE_BASE
ORACLE_HOME=/oracle/app/11.2.0/grid; export ORACLE_HOME
ORACLE_PATH=/oracle/app/oracle/common/oracle/sql; export ORACLE_PATH
ORACLE_TERM=xterm; export ORACLE_TERM
NLS_DATE_FORMAT="DD-MON-YYYY HH24:MI:SS"; export NLS_DATE_FORMAT
NLS_LANG=american_america.ZHS16GBK ; export NLS_LANG
TNS_ADMIN=\$ORACLE_HOME/network/admin; export TNS_ADMIN
ORA_NLS11=\$ORACLE_HOME/nls/data; export ORA_NLS11
PATH=.:\${JAVA_HOME}/bin:\${PATH}:\$HOME/bin:\$ORACLE_HOME/bin
PATH=\${PATH}:/usr/bin:/bin:/usr/bin/X11:/usr/local/bin
PATH=\${PATH}:/oracle/app/common/oracle/bin
export PATH
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=\$ORACLE_HOME/JRE
CLASSPATH=\${CLASSPATH}:\$ORACLE_HOME/jlib
CLASSPATH=\${CLASSPATH}:\$ORACLE_HOME/rdbms/jlib
CLASSPATH=\${CLASSPATH}:\$ORACLE_HOME/network/jlib
export CLASSPATH
THREADS_FLAG=native; export THREADS_FLAG
export TEMP=/tmp
export TMPDIR=/tmp
umask 022
done
sleep 1
#####以上為腳本內容########
2.腳本化后需要手工處理的一部分工作
###############################################
#System package collection and installation #
###############################################
檢查所需系統包
for i in binutils compat-libcap1 compat-libstdc++-33 \
gcc gcc-c++ glibc glibc-devel ksh libgcc libstdc++ \
libstdc++-devel libaio libaio-devel make sysstat unixODBC-devel unixODBC
do
rpm -q $i &>/dev/null || F="$F $i"
done ;echo $F;unset F
YUM安裝所需包
yum install binutils compat-libcap1 compat-libstdc++-33 gcc gcc-c++ glibc glibc-devel ksh libgcc libstdc++ libstdc++-devel libaio libaio-devel make sysstat unixODBC-devel unixODBC
###############################################
#modity oracle and grid password #
###############################################
passwd oracle
passwd grid
###############################################
#udev綁定LUN #
###############################################
醬油DBA奉獻 Oracle 11gR2 RAC on linux 集成腳本化安裝(三)
作為一個甲方醬油DBA,怎么可能不會搭建RAC?下面講講甲方醬油DBA是怎么腳本化安裝RAC的?(本人已有10+套RAC搭建經驗,AIX,HP-UNIX,LINUX,如有問題歡迎咨詢)
本文用途:Linux平臺下RAC集成腳本化安裝。
網上也有形形色色的腳本化安裝,有一些是問題的。本文把有問題的部分已經去除,現已安全使用。(僅限我的生產環境,其余朋友的生產環境慎用,如出現問題概不負責任)。
本文精華:“腳本化”三字概括,希望對醬油的DBA們有用
醬油DBA奉獻ORACLE數據庫監控健康腳本(一)
http://www.itpub.net/thread-1841912-1-1.html
醬油DBA奉獻expdp,impdp多用戶遷移數據(二)
http://www.itpub.net/thread-1868059-1-1.html
環境:
操作系統:redhat 6.2 64bit
數據庫:rac 11.2.0.4.0
存儲:EMC VNX5700
11gR2 RAC on linux 集成腳本化安裝
1.基本環境腳本安裝
cat dou.sh =>為了收集dou.1sh腳本日志
sh dou1.sh >dou.log
cat dou1.sh =>腳本如下:
echo "###Information Collection###"
##############################################
#Information Collection #
##############################################
echo "###redhat version###"
cat /etc/redhat-release
echo "###os memory###"
cat /proc/meminfo | grep MemTotal
echo "###os swap###"
cat /proc/meminfo | grep SwapTotal
echo "###os filesystem###"
df -h
echo "###os cpu numbers###"
cat /proc/cpuinfo |grep "processor"|wc -l
echo "###os cpu cores###"
cat /proc/cpuinfo |grep "cores"|uniq
echo "###create group and user###"
##############################################
#create group and user #
##############################################
/usr/sbin/groupadd -g 1000 oinstall
/usr/sbin/groupadd -g 1020 asmadmin
/usr/sbin/groupadd -g 1021 asmdba
/usr/sbin/groupadd -g 1022 asmoper
/usr/sbin/groupadd -g 1031 dba
/usr/sbin/groupadd -g 1032 oper
useradd -u 1100 -g oinstall -G asmadmin,asmdba,asmoper,dba grid
useradd -u 1101 -g oinstall -G dba,oper,asmdba oracle
echo "###create /etc/oraInst.loc###"
##############################################
#create /etc/oraInst.loc #
##############################################
echo "inventory_loc=/oracle/app/oracle/oraInventory" >>/etc/oraInst.loc
echo "inst_group=oinstall" >>/etc/oraInst.loc
echo "###create directory and Privilege###"
##############################################
#create directory and Privilege #
##############################################
mkdir -p /oracle/app/11.2.0/grid
mkdir -p /oracle/app/grid
mkdir -p /oracle/app/oracle/oraInventory
chown grid:oinstall /oracle/app/11.2.0/grid
chown grid:oinstall /oracle/app/grid
chmod -R 775 /oracle/
chown -R grid:oinstall /oracle
chown oracle:oinstall /oracle/app/oracle
echo "###LINUX optimize parameters####"
##############################################
#modify sysctl.conf | memory=64G #
##############################################
cat >> /etc/sysctl.conf <<done
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.file-max = 6553600
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
fs.file-max = 6815744
fs.aio-max-nr = 1048576
kernel.shmmax = 34359738368
kernel.shmall = 16777216
done
sleep 1
sysctl -p
sleep 1
###############################################
#modify /etc/security/limits.conf #
###############################################
cat >> /etc/security/limits.conf << done
grid soft nproc 2047
grid hard nproc 16384
grid soft nofile 1024
grid hard nofile 65536
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
done
sleep 1
################################################
#modify /etc/profile #
################################################
cat >> /etc/profile <<done
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
done
sleep 1
################################################
#modify /etc/pam.d/login #
################################################
echo "session required pam_limits.so">>/etc/pam.d/login
sleep 1
echo "###oracle environment variable ###"
################################################
# setting user oracle env #
################################################
cat >> /home/oracle/.bash_profile <<done
ORACLE_SID=doudoudb1; export ORACLE_SID
ORACLE_UNQNAME=doudoudb; export ORACLE_UNQNAME
JAVA_HOME=/usr/local/java; export JAVA_HOME
ORACLE_BASE=/oracle/app/oracle; export ORACLE_BASE
ORACLE_HOME=\$ORACLE_BASE/product/11.2.0/dbhome_1; export ORACLE_HOME
ORACLE_PATH=/oracle/app/common/oracle/sql; export ORACLE_PATH
ORACLE_TERM=xterm; export ORACLE_TERM
NLS_DATE_FORMAT="DD-MON-YYYY HH24:MI:SS"; export NLS_DATE_FORMAT
NLS_LANG=american_america.ZHS16GBK ; export NLS_LANG
TNS_ADMIN=\$ORACLE_HOME/network/admin; export TNS_ADMIN
ORA_NLS11=\$ORACLE_HOME/nls/data; export ORA_NLS11
PATH=.:\${JAVA_HOME}/bin:\${PATH}:\$HOME/bin:\$ORACLE_HOME/bin
PATH=\${PATH}:/usr/bin:/bin:/usr/bin/X11:/usr/local/bin
PATH=\${PATH}:/oracle/app/common/oracle/bin
export PATH
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=\$ORACLE_HOME/JRE
CLASSPATH=\${CLASSPATH}:\$ORACLE_HOME/jlib
CLASSPATH=\${CLASSPATH}:\$ORACLE_HOME/rdbms/jlib
CLASSPATH=\${CLASSPATH}:\$ORACLE_HOME/network/jlib
export CLASSPATH
THREADS_FLAG=native; export THREADS_FLAG
export TEMP=/tmp
export TMPDIR=/tmp
umask 022
done
done
sleep 1
echo "###grid environment variable ###"
###############################################
#setting user grid env #
###############################################
cat >> /home/grid/.bash_profile <<done
ORACLE_SID=+ASM1; export ORACLE_SID
JAVA_HOME=/usr/local/java; export JAVA_HOME
ORACLE_BASE=/oracle/app/grid; export ORACLE_BASE
ORACLE_HOME=/oracle/app/11.2.0/grid; export ORACLE_HOME
ORACLE_PATH=/oracle/app/oracle/common/oracle/sql; export ORACLE_PATH
ORACLE_TERM=xterm; export ORACLE_TERM
NLS_DATE_FORMAT="DD-MON-YYYY HH24:MI:SS"; export NLS_DATE_FORMAT
NLS_LANG=american_america.ZHS16GBK ; export NLS_LANG
TNS_ADMIN=\$ORACLE_HOME/network/admin; export TNS_ADMIN
ORA_NLS11=\$ORACLE_HOME/nls/data; export ORA_NLS11
PATH=.:\${JAVA_HOME}/bin:\${PATH}:\$HOME/bin:\$ORACLE_HOME/bin
PATH=\${PATH}:/usr/bin:/bin:/usr/bin/X11:/usr/local/bin
PATH=\${PATH}:/oracle/app/common/oracle/bin
export PATH
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=\$ORACLE_HOME/JRE
CLASSPATH=\${CLASSPATH}:\$ORACLE_HOME/jlib
CLASSPATH=\${CLASSPATH}:\$ORACLE_HOME/rdbms/jlib
CLASSPATH=\${CLASSPATH}:\$ORACLE_HOME/network/jlib
export CLASSPATH
THREADS_FLAG=native; export THREADS_FLAG
export TEMP=/tmp
export TMPDIR=/tmp
umask 022
done
sleep 1
#####以上為腳本內容########
2.腳本化后需要手工處理的一部分工作
###############################################
#System package collection and installation #
###############################################
檢查所需系統包
for i in binutils compat-libcap1 compat-libstdc++-33 \
gcc gcc-c++ glibc glibc-devel ksh libgcc libstdc++ \
libstdc++-devel libaio libaio-devel make sysstat unixODBC-devel unixODBC
do
rpm -q $i &>/dev/null || F="$F $i"
done ;echo $F;unset F
YUM安裝所需包
yum install binutils compat-libcap1 compat-libstdc++-33 gcc gcc-c++ glibc glibc-devel ksh libgcc libstdc++ libstdc++-devel libaio libaio-devel make sysstat unixODBC-devel unixODBC
###############################################
#modity oracle and grid password #
###############################################
passwd oracle
passwd grid
###############################################
#udev綁定LUN #
###############################################
for i in emcpowera emcpowerb emcpowerc emcpowerd emcpowere emcpowerf ;
do
echo "KERNEL==\"emcpower*\", SUBSYSTEM==\"block\", PROGRAM==\"/sbin/scsi_id -g -u -d --whitelisted --replace-whitespace --device=/dev/\$name\", RESULT==\"`/sbin/scsi_id -g -u -d --whitelisted --replace-whitespace --device=/dev/$i`\", NAME=\"asm-$i\", OWNER=\"grid\", GROUP=\"asmadmin\", MODE=\"0660\""
done