linux redhat 字符环境下,一键自动安装oracle、weblogic

#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
cat > /etc/redhat-release< RedHat Enterprise Linux Server release 4 (Tikanga)
EOF
cat >> /etc/sysctl.conf< kernel.shmall = 2097152
kernel.shmmax = 2147483648
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
EOF
/sbin/sysctl -p
cat >> /etc/security/limits.conf< oracle             soft    nproc   2047
oracle             hard    nproc   16384
oracle             soft    nofile  1024
oracle             hard    nofile  65536
EOF
cat >> /etc/pam.d/login< session    required     /lib/security/pam_limits.so
EOF
groupadd oinstall
groupadd dba
useradd -g oinstall -G dba oracle
echo "test" |passwd --stdin oracle
mkdir -p /DBSoft/app/oracle/product/10.2.0/db_1
chown -R oracle:oinstall /DBSoft/app/oracle
chmod -R 755 /DBSoft/app/oracle
cat >> /home/oracle/.bash_profile< # Oracle Environment
TMP=/tmp; export TMP
TMPDIR=\$TMP; export TMPDIR
export ORACLE_BASE=/DBSoft/app/oracle
export ORACLE_HOME=\$ORACLE_BASE/product/10.2.0/db_1
export ORACLE_SID=ora10
# export TNS_ADMIN= Set if sqlnet.ora, tnsnames.ora, etc. are not in \$ORACLE_HOME/network/admin
LD_LIBRARY_PATH=\$ORACLE_HOME/lib:/lib:/usr/lib
LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:/usr/local/lib
export LD_LIBRARY_PATH
CLASSPATH=\$ORACLE_HOME/JRE:\$ORACLE_HOME/jlib:\$ORACLE_HOME/rdbms/jlib
export CLASSPATH
# Set shell search paths
export PATH=\$PATH:\$ORACLE_HOME/bin
if [ \$USER = "oracle" ]; then
  if [ \$SHELL = "/bin/ksh" ]; then
    ulimit -p 16384
    ulimit -n 65536
  else
    ulimit -u 16384 -n 65536
  fi
fi
EOF
rpm -ivh myselfsoft.i386.rpm
cat >> /etc/ld.so.conf< /usr/local/mydir/mysoft
EOF
/sbin/ldconfig
cat > /etc/sysconfig/i18n< LANG="zh_CN.GB18030"
SUPPORTED="zh_CN.UTF-8:zh_CN:zh:en_US.UTF-8:en_US:en:zh_CN.GB18030"
SYSFONT="latarcyrheb-sun16"
EOF
source /etc/sysconfig/i18n
cat >> /root/.bash_profile< export JAVA_HOME=/wlserver/jdk1.6.0_22
export PATH=\$JAVA_HOME/bin:\$JAVA_HOME/jre/bin:\$PATH
export CLASSPATH=\$CLASSPATH:\$JAVA_HOME/lib:\$JAVA_HOME/jre/lib
export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH
EOF
source /root/.bash_profile
rpm -ivh libXp-1.0.0-8.1.el5.i386.rpm
unzip database.zip -d /home/
unzip wlserver.zip -d /
chmod 775 -R /wlserver
chmod +x install.rsp
chmod 777 /home/database/ -R
cp install.rsp /home/
su -l oracle -c 'source ~/.bash_profile;export LC_ALL=en_US;/home/database/runInstaller -silent -responseFile /home/install.rsp' >> ab.log&
echo "The database is being installed, please wait:"
a="The installation of Oracle Database 10g was successful"
while true; do
 result=`cat ab.log | grep "$a"`
 if [ $? -eq 1 ] ; then
  b=''
   for ((i=0;$i<=100;i+=2))  do
            printf "[%-50s]%d%%\r" $b $i
            sleep 8
            b=#$b
  done
  echo
 else
  sh /DBSoft/app/oracle/oraInventory/orainstRoot.sh
  sh /DBSoft/app/oracle/product/10.2.0/db_1/root.sh
  break
 fi
done


ORACLE_BASE=/DBSoft/app/oracle
ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1
ORACLE_SID=ora10
sed -i 's!/ade/vikrkuma_new/oracle!$ORACLE_HOME!' $ORACLE_HOME/bin/dbstart
sed -i 's!id:5:initdefault!id:3:initdefault!' /etc/inittab
sed -i 's!db_1:N!db_1:Y!' /etc/oratab
cat > /etc/rc.d/init.d/dbora< #!/bin/bash
# chkconfig: 35 85 90
# description: Oracle auto start-stop script.
# AUTH:seker

. /etc/init.d/functions

start(){
if ps aux | grep ora_ | grep -v grep &>/dev/null
then
echo -n \$"cannot start database: database is already running."
failure \$"cannot start database: database is already running."
echo
exit 1
else
echo -n \$"Starting Database: "
daemon su - \$ORA_OWNER -c "dbstart" && touch /var/lock/subsys/`basename \$0`
echo
fi

}
stop(){
if ps aux | grep ora_ | grep -v grep &>/dev/null
then
echo -n \$"Stoping Database: "
daemon su - \$ORA_OWNER -c "dbshut" && rm -f /var/lock/subsys/`basename \$0`
echo
else
echo -n \$"cannot stop database:Database is not already running."
failure \$"cannot stop database:Database is not already running."
echo
exit 1
fi
}

ORA_OWNER=oracle
case "\$1" in
start)
start
;;
stop)
stop
;;
emstart)
su - \$ORA_OWNER -c 'emctl status dbconsole &>/dev/null && echo "OEM is already running" || emctl start dbconsole'
;;
emstop)
su - \$ORA_OWNER -c 'emctl status dbconsole &>/dev/null && emctl stop dbconsole || echo "OEM is not running"'
;;
isqlstart)
su - \$ORA_OWNER -c 'ps aux | grep 'isqlplus/config/server.xml' | grep -v grep &>/dev/null || isqlplusctl start'
;;
isqlstop)
su - \$ORA_OWNER -c 'ps aux | grep 'isqlplus/config/server.xml' | grep -v grep &>/dev/null && isqlplusctl stop || echo "isqlplus is not running"'
;;
lsnstart)
su - \$ORA_OWNER -c 'lsnrctl status &>/dev/null && echo "listen is already running" || lsnrctl start &>/dev/null'
;;
lsnstop)
su - \$ORA_OWNER -c 'lsnrctl status &>/dev/null && lsnrctl stop &>/dev/null || echo "lsnrctl is not already running"'
;;
*)
echo "USAGE: \$0 {start|stop|lsnstart|lsnstop|emstart|emstop|isqlstart|isqlstop}"
echo -e "\tstart : database start"
echo -e "\tstop : database stop"
echo -e "\tlsnstart : listen start"
echo -e "\tlsnstop : listen stop"
echo -e "\temstart : OEM start"
echo -e "\temstop : OEM stop"
echo -e "\tisqlstart : isqlplus start"
echo -e "\tisqlstop : isqlplus stop"
esac
EOF
chmod +x /etc/rc.d/init.d/dbora
chkconfig --add dbora
chkconfig --level 345 dbora on
cat > /etc/rc.d/init.d/weblogic< #!/bin/bash
#
# ipsec [email protected]
# /etc/rc.d/init.d/weblogic
# init script for weblogic precesses
#
# processname: weblogic
# description: weblogic is a j2se server
# chkconfig: 2345 97 16
# description: Start up the Weblogic servlet engine.
rm -rf /wlserver/whapp/servers/AdminServer/tmp/*

PATH=\$PATH:\$HOME/bin
export JAVA_HOME=/wlserver/jdk1.6.0_22
export PATH=\$JAVA_HOME/bin:\$JAVA_HOME/jre/bin:\$PATH
export CLASSPATH=\$CLASSPATH:\$JAVA_HOME/lib:\$JAVA_HOME/jre/lib
export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH
source /etc/sysconfig/i18n
export PATH

CLASSPATH=/wlserver/patch_wls1031/profiles/default/sys_manifest_classpath/weblogic_patch.jar:/wlserver/jrockit_160_05_R27.6.2-

20/lib/tools.jar:/wlserver/utils/config/10.3.1.0/config-

launch.jar:/wlserver/wlserver_10.3/server/lib/weblogic_sp.jar:/wlserver/wlserver_10.3/server/lib/weblogic.jar:/wlserver/modules/features/weblogic.server.modules_10.3.1

.0.jar:/wlserver/wlserver_10.3/server/lib/webservices.jar:/wlserver/modules/org.apache.ant_1.7.0/lib/ant-all.jar:/wlserver/modules/net.sf.antcontrib_1.0.0.0_1-

0b2/lib/ant-

contrib.jar:/wlserver/lib/WhQryClient.jar:/wlserver/lib/whkit.jar:/wlserver/lib/WhUnprocClient.jar:/wlserver/lib/whlic.jar:/wlserver/wlserver_10.3/common/eval/pointbas

e/lib/pbclient57.jar:/wlserver/wlserver_10.3/server/lib/xqrl.jar::/wlserver/jdk1.6.0_22/lib:/wlserver/jdk1.6.0_22/jre/lib

PATH=/wlserver/wlserver_10.3/server/bin:/wlserver/modules/org.apache.ant_1.7.0/bin:/wlserver/jrockit_160_05_R27.6.2-20/jre/bin:/wlserver/jrockit_160_05_R27.6.2-

20/bin:/wlserver/jdk1.6.0_22/bin:/wlserver/jdk1.6.0_22/jre/bin:/usr/lib/qt-

3.3/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

export CLASSPATH PATH


WEBLOGIC_BASE=/wlserver/whapp
export WEBLOGIC_BASE

start() {
echo -n \$"Starting WebServer... "
\$WEBLOGIC_BASE/startWebLogic.sh &
RETVAL=\$?
echo done
[ \$RETVAL -eq 0 ]
return \$RETVAL
}

stop() {
echo -n \$"Stopping WebServer..."
\$WEBLOGIC_BASE/stopWebLogic.sh
RETVAL=\$?
echo
[ \$RETVAL -eq 0 ]
#rm -f /var/lock/subsys/weblogic;
return \$RETVAL
}
 
restart() {
stop
start
}

 
reload() {
echo -n \$"Reloading cron daemon configuration: "
killproc crond -HUP
RETVAL=\$?
echo
return \$RETVAL
}

case "\$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
reload)
reload
;;
status)
#rhstatus
;;
condrestart)
[ restart || :
;;
*)
echo \$"Usage: \$0 {start|stop|status|reload|restart|condrestart}"
exit 1
esac
EOF
chmod +x /etc/rc.d/init.d/weblogic
chkconfig --add weblogic
chkconfig --level 345 weblogic on

service acpid stop
chkconfig acpid off
chkconfig anacron off
chkconfig apmd off
service atd stop
chkconfig atd off
chkconfig avahi-daemon off
chkconfig avahi-dnsconfd off
service cpuspeed stop
chkconfig cpuspeed off
chkconfig dund off
service gpm stop
chkconfig gpm off
service hplip stop
chkconfig hplip off
service ip6tables stop
chkconfig ip6tables off
service iptables stop
service isdn stop
chkconfig isdn off
chkconfig lm_sensors off
chkconfig mdmonitor off
chkconfig microcode_ctl off
chkconfig netfs off
service portmap stop
chkconfig portmap off
chkconfig rawdevices off
chkconfig restorecond off
chkconfig rpcgssd off
service rpcidmapd stop
chkconfig rpcidmapd off
chkconfig setroubleshoot off
service ypbind stop
chkconfig ypbind off
service bluetooth stop
chkconfig bluetooth off
service cups stop
chkconfig cups off
service iscsi stop
chkconfig iscsi off
service iscsid stop
chkconfig iscsid off
service nfslock stop
chkconfig nfslock off
service sendmail stop
chkconfig sendmail off
chkconfig xfs off
chkconfig firstboot off
chkconfig lvm2-monitor off
chkconfig mcstrans off
chkconfig kudzu off
chkconfig xinetd off
service yum-updatesd stop
chkconfig yum-updatesd off
service dbora stop
su -l oracle -c 'lsnrctl stop'
su -l oracle -c 'emctl stop dbconsole'
unzip update.zip
cp -a 4612267/* /home/oracle/
mkdir /DBSoft/app/oracle/patches
mv 4612267/ /DBSoft/app/oracle/patches/
su -l oracle -c ' $ORACLE_HOME/OPatch/opatch apply'
su -l oracle -c '$ORACLE_HOME/OPatch/opatch lsinventory'
rm -rf /home/oracle/etc
rm -rf /home/oracle/files
service dbora start
rm -rf /home/database/
rm -rf ~/oinstall*
echo "End of the installation"

你可能感兴趣的:(oracle,linux,系统维护)