ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 安装oracl 前期工作

安装oracl 前期工作

原创 Linux操作系统 作者:yhj20041128001 时间:2012-05-11 13:30:31 0 删除 编辑
#!/bin/bash
#This program is used for helping you install oracle10g automatically.
#Be used in Redhat 5 enterprise.
#Statment:Before installing oracle10g by this program,you should prepare oracle10g tar.gz file, rlwrap and redhat install CD path.If you have any question about this program,you could contact me by the following email address.        
#Author:Xinggang
#Written on xxxx

trap 'echo;exit 0;' 2 #Set trap,so you can interrupt the program when it is running.

shmmax=$(($(free |awk 'NR==2{print $2}')*1024/2)) #Set the argument "shmmax" according to the memory size of your computer.

read -p "Please input the oracle username that you want to create:"        ooname
read -p "Please verify the oracle username:" oname

until [ ! -z "$oname" ] #Make judgment about if the variable $oname you given is null.
do
    read -p "Please verify the oracle username:" oname
done

username=$(awk -F: '{print $1}' /etc/passwd)
for i in $username        #Judge about if $oname already exists in your system.
do        
    if [ $oname = $i ]
    then
        echo "Error!The username you input is already exists in your system."; exit 1
    fi
done

until [ ${oname}x = ${ooname}x ] #Make sure that the input is the very one which you want.
do
                                read -p "Please input the oracle username that you want to create:"  ooname
                                read -p "Please verify the oracle username:" oname
    if [ -z "$oname" ] #If $oname is still null,then exit this program.
    then        
        echo "Error!"
        exit 1
    fi
done

read -p "Please input rlwrap path:" rlpath

read -p "Please input the path of CD:" cdpath
until [ -e "$cdpath"/Server ] #Make sure the path that you given is right.
do
                                read -p "Wrong path of CD,please retry:" cdpath
done

read -p "Please input your oracle tar.gz package name(include path) :" opackage

if [ ! -f "$opackage" ]
then
    echo "The package is wrong!"
    exit 1
fi

{
groupadd oinstall
groupadd dba
useradd -m -g oinstall -G dba $oname
mkdir -p /u01/app/$oname
chown -R $oname:oinstall /u01/app/$oname
chmod -R 775 /u01/app/$oname
}&>/dev/null

tar -zxf $opackage -C /home/$oname &>/dev/null

until [ "$?" -eq "0" ] #Make sure that the package you given is absolutely right.
do
    read -p "Wrong package,please retry:"        opachage
    tar -zxf $opackage -C /home/$oname &>/dev/null
done

pushd $cdpath/Server &>/dev/null
{
rpm -Uvh compat-db-4*
rpm -Uvh libaio-0*
rpm -Uvh compat-libstdc++-33-3*
rpm -Uvh compat-gcc-34-3*
rpm -Uvh compat-gcc-34-c++-3*
rpm -Uvh libXp-1*
rpm -Uvh openmotif-2*
rpm -Uvh gcc-4*
}&>/dev/null
#rpm -Uvh glibc-2.5-12.i686.rpm
popd &>/dev/null

flag=0
{
pushd $rlpath
$rlpath/configure
make && make install
popd
}&>/dev/null

if [ "$?" -eq "1" ] #Be used for judging if rlwrap was compiled successfully.
then
    flag=1
fi

grep 'fs.file-max' /etc/sysctl.conf &>/dev/null
if [ "$?" -eq "1" ] #Make jugdement if the configure file was already configured.
then

sed -i '/^kernel.shmmax/d' /etc/sysctl.conf #Delete the argument "kernerl.shmmax" in the configure file.
sed -i '/^kernel.shmall/d' /etc/sysctl.conf #Delete the argument "kernel.shmall" in the configure file

cat >> /etc/sysctl.conf <kernel.shmall = 2097152
kernel.shmmax = $shmmax
kernel.shmmni = 4096
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
#signaturelevin
EOF
fi

sysctl -p &>/dev/null #Make the configured file come into effect immediately.

grep 'soft nproc' /etc/security/limits.conf &>/dev/null
if [ "$?" -eq "1" ]
then
cat >> /etc/security/limits.conf <soft nproc        2047
hard nproc        16384
soft nofile 1024
hard nofile 65536
#signaturelevin
EOF
fi

grep 'pam_limits.so' /etc/pam.d/login &>/dev/null
if [ "$?" -eq "1" ]
then
cat >> /etc/pam.d/login <session required pam_limits.so
#signaturelevin
EOF
fi

grep 'ORACLE_SID=orcl' /home/$oname/.bash_profile &>/dev/null
if [ "$?" -eq "1" ]
then
cat >>/home/$oname/.bash_profile <export TMP=/tmp
export ORACLE_BASE=/u01/app/$oname
export ORACLE_HOME=\$ORACLE_BASE/product/10g
export ORACLE_SID=orcl
export PATH=\$ORACLE_HOME/bin:\$PATH
export LD_LIBRARY_PATH=\$ORACLE_HOME/lib:/lib:/usr/lib
export CLASSPATH=\$ORACLE_HOME/JRE:\$ORACLE_HOME/jlib:\$ORACLE_HOME/rdbms/jlib
alias sqlplus="rlwrap sqlplus"
alias rman="rlwrap rman"
alias fox="firefox"
#signaturelevin
EOF
fi

. /home/$oname/.bash_profile

sed -i 's/5/4/' /etc/redhat-release #Resovling the problems brought by the version of your system.

xhost + &>/dev/null

echo -e "\a"
if [ "$flag" -eq "1" ]
then
    echo -e "Configure successful but the rlwrap was not compiled successfully.You should compile it by your own after finishing installs of oracle10g.Now,the following steps are your own work.\n \n 1.export LANG=C \n 2.cd database/\n 3../runInstaller\n 4.Configure according to the Oracle GUI information.\n"
else
    echo -e "Configure successful!The following steps are your own work.Just do it.\n \n 1.export LANG=C \n 2.cd database/\n 3../runInstaller\n 4.Configure according to the Oracle GUI information.\n"
fi

su - $oname

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

请登录后发表评论 登录
全部评论

注册时间:2010-09-17

  • 博文量
    162
  • 访问量
    352256