ITPub博客

首页 > Linux操作系统 > Linux操作系统 > Oracle 11g R2 RAC安装前的系统环境搭建

Oracle 11g R2 RAC安装前的系统环境搭建

原创 Linux操作系统 作者:wang_0720 时间:2013-11-06 14:57:12 0 删除 编辑
在安装Oracle 11g RAC时有很多的前期准备工作要做,在多个节点上做大量繁琐、重复的工作着实让人无法忍受。而用脚本代替手工操作无疑会使工作效率大大提高。本文是一个RAC环境搭建的shell脚本,在每个节点上对红色字体稍作更改,就可以用该脚本做如下工作:安装所需的软件包,创建用户,用户环境变量的配置以及系统参数的配置等。
#!/bin/bash
#oracle RAC enviroment configure
#./oracinstall.sh
#software setup
software()
{
for software in binutils\              
                compat-libstdc++\
                elfutils-libelf\
                elfutils-libelf-devel\
                elfutils-libelf-devel-static\
                gcc\
                gcc-c++\
                glibc\
                glibc-common\
                glibc-devel\
                glibc-headers\
                kernel-headers\
                ksh\
                libaio\
                libaio-devel\
                libgcc\
                libgomp\
                libstdc++\
                libstdc++-devel\
                make\
                sysstat\
                unixODBC\
                unixODBC-devel;do
        rpm -qa|grep ${software} >/dev/null
        if [ $? -ne 0 ];then
                echo "${software} is not installed"
                rpm -Uvh /cdrom/${software}-*
                if [ $? -eq 0 ];then
                        echo "${software} installed successful"
                fi
        fi
    echo "${software} has been installed"
done
}
#create user and group for grid infrastructure
grid()
{
groupadd -g 1000 oinstall
groupadd -g 1200 asmadmin
groupadd -g 1201 asmdba
groupadd -g 1202 asmoper
useradd -m -u 1100 -g oinstall -G asmadmin,asmdba,asmoper -d /home/grid -s /bin/bash -c "Grid Infrastructure Owner" grid
#grid登录密码,可以根据实际情况设定
echo "gridpassword" |passwd --stdin grid
cat >>/home/grid/.bash_profile< #ASM实例的sid,每个节点唯一
ORACLE_SID=+ASM1;export ORACLE_SID
JAVA_HOME=/usr/local/java; export JAVA_HOME
ORACLE_BASE=/u01/app/grid; export ORACLE_BASE
ORACLE_HOME=/u01/app/11.2.0/grid; export ORACLE_HOME
ORACLE_PATH=/u01/app/oracle/common/oracle/sql; export ORACLE_PATH
SQLPATH=/u01/app/common/oracle/sql; export SQLPATH
NLS_DATE_FORMAT="DD-MON-YYYY HH24:MI:SS"; export NLS_DATE_FORMAT
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}:/u01/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
export TEMP=/tmp
export TMPDIR=/tmp
umask 022
EOF
source /home/grid/.bash_profile
}

#create user and group for oracle
oracle()
{
groupadd -g 1300 dba
groupadd -g 1301 oper
useradd -m -u 1101 -g oinstall -G dba,oper,asmdba -d /home/oracle -s /bin/bash -c "Oracle Software Owner" oracle
#oracle用户登录密码,可以根据实际情况设定
echo "oraclepassword"|passwd --stdin oracle
cat >>/home/oracle/.bash_profile< alias sqlplus="rlwrap sqlplus"
alias rman="rlwrap rman"
alias lsnrctl="rlwrap lsnrctl"
#oracle实例的sid,每个节点唯一
ORACLE_SID=racdb1; export ORACLE_SID
ORACLE_UNQNAME=racdb; export ORACLE_UNQNAME
JAVA_HOME=/usr/local/java; export JAVA_HOME
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=\$ORACLE_BASE/product/11.2.0/dbhome_1; export ORACLE_HOME
ORACLE_PATH=/u01/app/common/oracle/sql; export ORACLE_PATH
SQLPATH=/u01/app/common/oracle/sql; export SQLPATH
NLS_DATE_FORMAT="DD-MON-YYYY HH24:MI:SS"; export NLS_DATE_FORMAT
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}:/u01/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
export TEMP=/tmp
export TMPDIR=/tmp
umask 022
EOF
source /home/oracle/.bash_profile
}
id nobody>/dev/null 2>&1
if [ $? -ne 0 ];then
useradd nobody
fi
#create home base for grid and oracle
homebase()
{
mkdir -p /u01/app/grid
mkdir -p /u01/app/11.2.0/grid
chown -R grid:oinstall /u01
mkdir -p /u01/app/oracle
chown oracle:oinstall /u01/app/oracle
chmod -R 775 /u01
}
limit()
{
cat >>/etc/security/limits.conf< 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
EOF
cat >>/etc/pam.d/login< session      required      pam_limits.so
EOF
}
profile()
{
cat >> /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
EOF
}
sys()
{
cat >/etc/sysctl.conf< net.ipv4.ip_forward = 0
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.default.accept_source_route = 0
kernel.sysrq = 0
kernel.core_uses_pid = 1
net.ipv4.tcp_syncookies = 1
kernel.msgmnb = 65536
kernel.msgmax = 65536
#4GB physical memory configure like this
kernel.shmmax = 4294967295
kernel.shmall = 268435456
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
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 = 1048576
fs.aio-max-nr = 1048576
EOF
}                                  
#==============
case ${1} in
       software)
       software
       ;;
       grid)
       grid
       ;;
       oracle)
       oracle
       ;;
       homebase)
       hoembase
       ;;
       limit)
       limit
       ;;
       profile)
       profile
       ;;
       sys)
       sys
       ;;
       all)
       software
       grid
       oracle
       homebase
       limit
       profile
       sys
       ;;
       *)
       exit 0
       ;;
esac

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/27181165/viewspace-775874/,如需转载,请注明出处,否则将追究法律责任。

上一篇: RAC概念及原理
下一篇: lvs arp抑制脚本
请登录后发表评论 登录
全部评论

注册时间:2013-11-05

  • 博文量
    111
  • 访问量
    914277