你好,游客 登录 注册 搜索
背景:
阅读新闻

用shell脚本配置Oracle安装需求

[日期:2013-08-16] 来源:Linux社区  作者:crushlinux [字体: ]

用shell脚本配置Oracle安装需求

1.配置好yum
yum -y install libXp
yum -y install libaio

2.按照自己的需求修改chprofile文件内的SID

3.rpm -ivh rlwrap-0.30-1.el5.i386.rpm

4.执行脚本  #install目录下存放了一下脚本:adduser.sh、chprofile.sh、install.sh、limits.sh、mkdir.sh、sysctl.sh
./install

adduser脚本内容

#/bin/bash
ADDGROUPS="oinstall dba"
ADDUSERS="oracle"
for group in $ADDGROUPS ; do
        if [ -z "$( awk -F: '{print $1}' /etc/group |grep $group)" ]; then
                groupadd  $group
                echo " Add new group $group"
        else
                echo " Group $group already existed"
        fi 
done
for user in $ADDUSERS ; do
        if [ -z "$( awk -F: '{print $1}' /etc/passwd |grep $user)" ]; then
                useradd  $user
                echo " Add new user $user"
        else
                echo " User $user already existed"
        fi
done
if $(usermod -g oinstall -G dba oracle) ;  then
  echo " Modify user oracle account success"
else
  echo " Modify user oracle account failure"
fi
chprofile脚本内容
#/bin/bash
PROFILES="/home/oracle/.bashrc"
for PROFILE in $PROFILES ; do
if [ -f "$PROFILE" ] ; then
        if [ -z "$(grep "Oracle" $PROFILE)" ] ; then
                cat >>$PROFILE << END
# Oracle configure profile parameters success
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=\$ORACLE_BASE/product/10.2.0/db_1
export PATH=\$ORACLE_HOME/bin:\$PATH
export ORACLE_OWNER=oracle
export ORACLE_SID=cctv
export ORACLE_TERM=vt100
export THREADS_FLAG=native
export LD_LIBRARY_PATH=\$ORACLE_HOME/lib:\$LD_LIBRARY_PATH
export PATH=\$ORACLE_HOME/bin:\$PATH
export SQLPATH=/home/oracle
export EDITOR=vi
alias sqlplus='rlwrap sqlplus'
#
# change this NLS settings to suit your country:
# example:
# german_germany.we8iso8859p15, american_america.we8iso8859p2 etc.
#
export LANG=en_US
END
                echo " Add Oracle configure $PROFILE parameters success"
        else
                echo " Oracle configure $PROFILE parameters already existed"
        fi
else
        echo "$0: $PROFILE not found "
fi
done
install脚本内容
#/bin/bash
. ./adduser.sh
. ./sysctl.sh
. ./limits.sh
. ./mkdir.sh
. ./chprofile.sh
limits脚本内容
#/bin/bash
LIMITS_FILE="/etc/security/limits.conf"
if [ -f "$LIMITS_FILE" ] ; then
        if [ -z "$(grep "Oracle" $LIMITS_FILE)" ] ; then
                cat >>$LIMITS_FILE << END
#Oracle configure  shell parameters
oracle soft nofile 65536
oracle hard nofile 65536
oracle soft nproc 16384
oracle hard nproc 16384
END
                echo " Add Oracle configure  shell parameters success"
        else
                echo " Oracle configure  shell parameters already existed"
        fi
else
        echo "$0: $LIMITS_FILE not found "
fi
mkdir脚本内容
#/bin/bash
ORACLE_FILE_BASE="/u01/app/oracle"
ORACLE_FILE_VAR="/var/opt/oracle"
ORACLE_FILE_HOME="$ORACLE_FILE_BASE/product/10.2.0/db_1"
for directory in $ORACLE_FILE_BASE $ORACLE_FILE_VAR $ORACLE_FILE_HOME ; do
        if [ -d $directory ]; then
                echo " Directory $directory  already existed"
        else
                mkdir -p $directory
                chown -R oracle.dba $directory
                echo " Change directory $directory owner and group success"
        fi
done     
sysctl脚本内容
#/bin/bash
# echo 250 32000 100 128 > /proc/sys/kernel/sem
# echo 536870912 > /proc/sys/kernel/shmmax
# echo 4096 > /proc/sys/kernel/shmmni
# echo 2097152 > /proc/sys/kernel/shmall
# echo 65536 > /proc/sys/fs/file-max
# echo 1024 65000 > /proc/sys/net/ipv4/ip_local_port_range
SYSCTL_FILE="/etc/sysctl.conf"
RCLOCAL_FILE="/etc/rc.local"
if [ -f "$SYSCTL_FILE" ] ; then
        if [ -z "$(grep "Oracle" $SYSCTL_FILE)" ] ; then
                cat >>$SYSCTL_FILE << END
#Oracle configure kernel parameters
kernel.shmmax = 2147483648
kernel.shmmni = 4096
kernel.shmall = 2097152
kernel.sem = 250 32000 100 128
fs.file-max = 65536
net.ipv4.ip_local_port_range = 1024 65000
net.core.rmem_default = 262144
net.core.rmem_max = 262144
net.core.wmem_default = 262144
net.core.wmem_max = 262144
END
                /sbin/sysctl -p
                echo " Add Oracle configure kernel parameters success"
        else
                echo " Oracle configure kernel parameters already existed"
        fi
else
        if [ -z "$(grep "Oracle" $RCLOCAL_FILE)" ] ; then
                cat >>$RCLOCAL_FILE << END
#Oracle configure kernel parameters
echo 536870912 > /proc/sys/kernel/shmmax
echo 4096 > /proc/sys/kernel/shmmni
echo 2097152 > /proc/sys/kernel/shmall
echo 250 32000 100 128 > /proc/sys/kernel/sem
echo 65536 > /proc/sys/fs/file-max
echo 1024 65000 > /proc/sys/net/ipv4/ip_local_port_range
END
                . $RCLOCAL_FILE
                echo " Add Oracle configure kernel parameters success"
        else
                echo " Oracle configure kernel parameters already existed"
        fi
fi

推荐阅读:

CentOS 6.3(x32)下安装Oracle 10g R2 http://www.linuxidc.com/Linux/2012-11/74253.htm

Linux-6-64下安装Oracle 12C笔记 http://www.linuxidc.com/Linux/2013-07/86805.htm

更多Oracle相关信息见Oracle 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=12

linux
相关资讯       Oracle安装  Oracle shell脚本 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款