#!/bin/bash
| 003 | # Script. Name: oracle_install.sh |
| 004 | # Description: This program is used for helping you install oracle10g automatically.Be used in Redhat 5 enterprise. |
| 006 | #
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. |
| 008 | # Author: Xinggang Wang - OpsEye.com |
| 009 | # Create Date: 2009/11/21 |
| 010 | # Last Modified: 2009/11/24 |
| 012 | # Set trap,so you can interrupt the program when it is running. |
| 015 | # Set the argument "shmmax" according to the memory size of your computer. |
| 016 | shmmax=$(($(free |awk 'NR==2{print $2}')*1024/2)) |
| 018 | read -p "Please input the oracle username that you want to create:" ooname |
| 019 | read -p "Please verify the oracle username:" oname |
| 021 | # Make judgment about if the variable $oname you given is null. |
| 022 | until [ ! -z "$oname" ] |
| 024 | read -p "Please verify the oracle username:" oname |
| 027 | username=$(awk -F: '{print $1}' /etc/passwd) |
| 028 | # Judge about if $oname already exists in your system. |
| 033 | echo "Error!The username you input is already exists in your system."; exit 1 |
| 037 | # Make sure that the input is the very one which you want. |
| 038 | until [ ${oname}x = ${ooname}x ] |
| 040 | read -p "Please input the oracle username that you want to create:" ooname |
| 041 | read -p "Please verify the oracle username:" oname |
| 043 | # If $oname is still null,then exit this program. |
| 051 | read -p "Please input rlwrap path:" rlpath |
| 053 | read -p "Please input the path of CD:" cdpath |
| 055 | # Make sure the path that you given is right. |
| 056 | until [ -e "$cdpath"/Server ] |
| 058 | read -p "Wrong path of CD,please retry:" cdpath |
| 061 | read -p "Please input your oracle tar.gz package name(include path) :" opackage |
| 063 | if [ ! -f "$opackage" ] |
| 065 | echo "The package is wrong!" |
| 072 | useradd -m -g oinstall -G dba $oname |
| 073 | mkdir -p /u01/app/$oname |
| 074 | chown -R $oname:oinstall /u01/app/$oname |
| 075 | chmod -R 775 /u01/app/$oname |
| 078 | tar -zxf $opackage -C /home/$oname &>/dev/null |
| 080 | # Make sure that the package you given is absolutely right. |
| 081 | until [ "$?" -eq "0" ] |
| 083 | read -p "Wrong package,please retry:" opachage |
| 084 | tar -zxf $opackage -C /home/$oname &>/dev/null |
| 087 | pushd $cdpath/Server &>/dev/null |
| 091 | rpm -Uvh compat-libstdc++-33-3* |
| 092 | rpm -Uvh compat-gcc-34-3* |
| 093 | rpm -Uvh compat-gcc-34-c++-3* |
| 098 | #rpm -Uvh glibc-2.5-12.i686.rpm |
| 109 | # Be used for judging if rlwrap was compiled successfully. |
| 115 | grep 'fs.file-max' /etc/sysctl.conf &>/dev/null |
| 117 | # Make jugdement if the configure file was already configured. |
| 121 | # Delete the argument "kernerl.shmmax" in the configure file. |
| 122 | sed -i '/^kernel.shmmax/d' /etc/sysctl.conf |
| 123 | # Delete the argument "kernel.shmall" in the configure file |
| 124 | sed -i '/^kernel.shmall/d' /etc/sysctl.conf |
| 126 | cat >> /etc/sysctl.conf < |
| 127 | kernel.shmall = 2097152 |
| 128 | kernel.shmmax = $shmmax |
| 130 | kernel.sem = 250 32000 100 128 |
| 132 | net.ipv4.ip_local_port_range = 1024 65000 |
| 133 | net.core.rmem_default=262144 |
| 134 | net.core.rmem_max=262144 |
| 135 | net.core.wmem_default=262144 |
| 136 | net.core.wmem_max=262144 |
| 141 | # Make the configured file come into effect immediately. |
| 144 | grep 'soft nproc' /etc/security/limits.conf &>/dev/null |
| 147 | cat >> /etc/security/limits.conf < |
| 156 | grep 'pam_limits.so' /etc/pam.d/login &>/dev/null |
| 159 | cat >> /etc/pam.d/login < |
| 160 | session required pam_limits.so |
| 165 | grep 'ORACLE_SID=orcl' /home/$oname/.bash_profile &>/dev/null |
| 168 | cat >>/home/$oname/.bash_profile < |
| 170 | export ORACLE_BASE=/u01/app/$oname |
| 171 | export ORACLE_HOME=\$ORACLE_BASE/product/10g |
| 172 | export ORACLE_SID=orcl |
| 173 | export PATH=\$ORACLE_HOME/bin:\$PATH |
| 174 | export LD_LIBRARY_PATH=\$ORACLE_HOME/lib:/lib:/usr/lib |
| 175 | export CLASSPATH=\$ORACLE_HOME/JRE:\$ORACLE_HOME/jlib:\$ORACLE_HOME/rdbms/jlib |
| 176 | alias sqlplus="rlwrap sqlplus" |
| 177 | alias rman="rlwrap rman" |
| 183 | . /home/$oname/.bash_profile |
| 185 | # Resovling the problems brought by the version of your system. |
| 186 | sed -i 's/5/4/' /etc/redhat-release |
| 191 | if [ "$flag" -eq "1" ] |
| 193 | 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" |
| 195 | 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" |
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/23757700/viewspace-721078/
,如需转载,请注明出处,否则将追究法律责任。