#!/bin/sh ####Author: Majesty ####RHCE OCP ####Mail: fatpander0215@qq.com ####blog: 51cto emperor_majesty http:// ####1 ####create user and group and environment var. groupadd oinstall groupadd dba useradd -g oinstall -G dba -c "Oracle" -d /home/oracle oracle v_oracle=$( grep en_US /home/oracle/.bash_profile ) if [ "$v_oracle" == '' ] then rm -rf /home/oracle/.bash_profile echo "if [ -f ~/.bashrc ]; then" >> /home/oracle/.bash_profile echo " . ~/.bashrc" >> /home/oracle/.bash_profile echo "fi" >> /home/oracle/.bash_profile echo " " >> /home/oracle/.bash_profile echo " " >> /home/oracle/.bash_profile echo "oracle" | passwd --stdin oracle echo "export ORACLE_BASE=/u01/app/oracle" >> /home/oracle/.bash_profile echo 'export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1' >> /home/oracle/.bash_profile echo "export ORACLE_SID=orcl" >> /home/oracle/.bash_profile echo 'export LD_LIBRARY_PATH=$ORACLE_HOME/lib' >> /home/oracle/.bash_profile echo 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib:/usr/X11R6/lib' >> /home/oracle/.bash_profile echo 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/jdk/jre/lib/i386' >> /home/oracle/.bash_profile echo 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/jdk/jre/lib/i386/server' >> /home/oracle/.bash_profile echo 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/rdbms/lib' >> /home/oracle/.bash_profile echo 'export CLASS_PATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib' >> /home/oracle/.bash_profile echo 'export CLASS_PATH=$CLASS_PATH:$ORACLE_HOME/rdbms/jlib' >> /home/oracle/.bash_profile echo 'export CLASS_PATH=$CLASS_PATH:$ORACLE_HOME/network/jlib' >> /home/oracle/.bash_profile echo 'export TNS_ADMIN=$ORACLE_HOME/network/admin' >> /home/oracle/.bash_profile echo "export NLS_LANG=american_america.AL32UTF8" >> /home/oracle/.bash_profile echo "export ORACLE_TERM=xterm" >> /home/oracle/.bash_profile echo "export EDITOR=vi" >> /home/oracle/.bash_profile echo 'export PATH=$ORACLE_HOME/bin:$PATH' >> /home/oracle/.bash_profile echo "export LANG=en_US" >> /home/oracle/.bash_profile else echo "your "/home/oracle/.bash_profile" already was setted." fi ####2 ####modify the release and create direcotry v_release=$( grep 4 /etc/system-release ) if [ "$v_release" == '' ] then rm -rf /etc/system-release echo "Red Hat Enterprise Linux Server release 4 (Santiago)" > /etc/system-release mkdir -p /u01/app/oracle chown -R oracle:oinstall /u01 chown oracle:oinstall /home/oracle else echo "your release had modified." fi v_release2=$( grep 4 /etc/redhat-release ) if [ "$v_release2" == '' ] then rm -rf /etc/redhat-release echo "Red Hat Enterprise Linux Server release 4 (Santiago)" > /etc/redhat-release else echo "your release had modified." fi ####3 ####limit the oracle process. v_limit=$( grep 65536 /etc/security/limits.conf ) if [ "$v_limit" == '' ] then cp /etc/security/limits.conf /etc/security/limits.conf.bak echo "oracle soft nproc 2047" >>/etc/security/limits.conf echo "oracle hard nproc 16384" >>/etc/security/limits.conf echo "oracle soft nofile 1024" >>/etc/security/limits.conf echo "oracle hard nofile 65536" >>/etc/security/limits.conf else echo "/etc/security/limits.conf had modified." fi v_pam=$( grep pam_limits.so /etc/pam.d/login ) if [ "$v_pam" == '' ] then cp /etc/pam.d/login /etc/pam.d/login.bak echo "session required /lib/security/pam_limits.so" >>/etc/pam.d/login echo "session required pam_limits.so" >>/etc/pam.d/login else echo "/etc/pam.d/login had modified." fi v_profile=$( grep 'ulimit -n 65536' /etc/profile ) if [ "$v_profile" == '' ] then cp /etc/profile /etc/profile.bak echo 'if [ $USER = "oracle" ]; then' >> /etc/profile echo 'if [ $SHELL = "/bin/ksh" ]; then' >> /etc/profile echo 'ulimit -p 16384' >> /etc/profile echo 'ulimit -n 65536' >> /etc/profile echo 'else' >> /etc/profile echo 'ulimit -u 16384 -n 65536' >> /etc/profile echo 'fi' >> /etc/profile echo 'fi' >> /etc/profile else echo "/etc/profile had modified." fi v_sysctl=$( grep net.core.rmem_max /etc/sysctl.conf ) if [ "$v_sysctl" == '' ] then cp /etc/sysctl.conf /etc/sysctl.conf.bak echo "fs.file-max = 65536" >> /etc/sysctl.conf echo "kernel.sem = 250 32000 100 128" >> /etc/sysctl.conf echo "kernel.shmall = 2097152" >> /etc/sysctl.conf echo "kernel.shmmni = 4096" >> /etc/sysctl.conf echo "kernel.shmmax = 2147483648" >> /etc/sysctl.conf echo "net.core.rmem_default=1048576" >> /etc/sysctl.conf echo "net.core.rmem_max=262144" >> /etc/sysctl.conf echo "net.core.wmem_default=262144" >> /etc/sysctl.conf echo "net.core.wmem_max=262144" >> /etc/sysctl.conf echo "net.ipv4.ip_local_port_range = 1024 65000" >> /etc/sysctl.conf echo "Modifing the /etc/sysctl.conf has been succeed." echo "Now make the changes take effect....." sysctl -p else echo "/etc/sysctl.conf had modified." fi v_group=$( grep 'root:x:0:root,oracle' /etc/group ) if [ "$v_group" == '' ] then echo "please modify add oracle to root group" echo "cat /etc/group" sed -i 's#root:x:0:root#root:x:0:root,oracle#g' /etc/group else echo "oracle was already the memeber of root group." fi ####4 ####install all required packages. rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release cd /mnt/Packages yum -y localinstall libXp-1.0.0-15.1.el6* yum -y localinstall libXp-devel-1.0.0-15.1.el6* yum -y localinstall openmotif-2.3.3-4.el6* yum -y localinstall openmotif-devel-2.3.3-4.el6* yum -y localinstall gcc-4.4.6-3.el6.x86_64.rpm yum -y localinstall libaio-0.3.107-10.el6* yum -y localinstall libaio-devel-0.3.107-10.el6* yum -y localinstall make-3.81-19.el6.x86_64.rpm yum -y localinstall glibc-2.12-1.47.el6* yum -y localinstall compat-libstdc++* yum -y localinstall compat-db-4.6.21-15.el6* yum -y localinstall compat-gcc-34-c++-3.4.6-19.el6.x86_64.rpm rpm -q gcc make binutils openmotif yum -y install xterm.x86_64 yum -y install libXp.i686 yum -y install libXt.i686 yum -y install libXtst.i686 libXtst.x86_64 yum -y install make.x86_64 yum -y install gcc.x86_64 yum -y install binutils.x86_64 yum -y install libaio.i686 yum -y install libstdc++-devel.i686 yum -y install glibc-devel.i686 yum -y install compat-libstdc* yum -y groupinstall "Chinese Support" yum -y install cjkuni-fonts* xorg-x11-*