的,而且容易出錯,也比較耗時。對於初學Oracle的新手來說,可能會遇到經常重灌ORACLE的情況,如果把精力過多的用於安裝,感覺會有點得不償
失。
本指令碼所做的事情並不是完全的安裝好ORCLE,那也是不可能的事情,因為ORACLE安裝的後期是有圖形介面的互動模式,所以本指令碼所做的只是前期環境配置,但就是這些前期配置才是最耗時的,所以寫成指令碼很必要。
本指令碼只在RHEL5U3上做過測試,可以正常使用,對於其他版本有待驗證和完善。
#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
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 <<EOF
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 <<EOF
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 <<EOF
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 <<EOF
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.
1.export LANG=C
2.cd database/
3../runInstaller
4.Configure according to the Oracle GUI information.
“
else
echo -e “Configure successful!The following steps are your own work.Just do it.
1.export LANG=C
2.cd database/
3../runInstaller
4.Configure according to the Oracle GUI information.
“
fi
su – $oname