Linux下Oracle环境配置及自动安装脚本

阅读更多

大家可以根据自己的需要修改安装路径位置,以及根据服务器内存大小修改对应的参数值 "kernel.shmmax = 2147483648”

#!/bin/bash
echo "back file to oraclerpm"
cp /etc/redhat-release oraclerpm/back/etc_redhat-release
cp /etc/sysctl.conf oraclerpm/back/etc_sysctl.conf
cp /etc/security/limits.conf oraclerpm/back/etc_security_limits.conf
cp /etc/pam.d/login oraclerpm/back/etc_pam.d
echo "back over /etc/redhat-release /etc/sysctl.conf"
if [ $USER != "root" ] ; then
echo "the user must be root ,and now you user is '$USER',plaese su to root"
exit 0
else
echo "setup 1:check root ,OK!" | tee -a oracle.log
######send to display and oracle.log
fi
######check weather have edit kernel

#exg:if grep -q "your string" /your/file; then echo yes; else echo no; fi¡¡

if grep -c "kernel.shmall" /etc/sysctl.conf >>/dev/null; then
echo "you have already edit the Kernel" | tee -a oracle.log
else
cat >> /etc/sysctl.conf << EOF
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
EOF
fi
/sbin/sysctl -p >>/dev/null
echo ""setup 2:edit kernel,PASS!"" | tee -a oracle.log
cp /etc/redhat-release /etc/redhat-release.backup1
cat > /etc/redhat-release << EOF
Red Hat Enterprise Linux AS release 3 (Taroon)
EOF
echo "setup 3:edit the release,OK!" |tee -a oracle.log
if grep 'oinstall' /etc/group > /dev/null;then
echo "the group oinstall already existed!"
else
/usr/sbin/groupadd oinstall
fi
if grep 'dba' /etc/group > /dev/null;then
 echo "The group dba already existed!"
else
 /usr/sbin/groupadd dba
fi


if test -e /u01/app/oracle >/dev/null;then
echo "the setup_path for oracle "/u01/app/oracle" already have exits" | tee -a oracle.log
else
mkdir -p /u01/app/oracle
echo "/u01/app/oracle make" | tee -a oracle.log
fi
if test -e /data/oradata >/dev/null;then
echo "the data_path for oracle "/data/oradata" already have exits" | tee -a oracle.log
else
mkdir -p /data/oradata 
echo "/data/oradata make" | tee -a oracle.log
chown -R oracle:oinstall /u01/app/oracle /data/oradata
chmod -R 775 /u01/app/oracle /data/oradata
fi

#if grep /data/ "oracle"; then

#echo "the data_path for oracle "/data/oradata" already have given to user oracl"

#fi

echo "setup 3:add the oracle user,dba,install group ,oracle setup path,oracle data path OK!" | tee -a oracle.log
echo "now check for need rpm" | tee -a oracle.log
if rpm -q gcc make binutils openmotif setarch compat-db compat-gcc-32 openmotif compat-gcc-32-c++ compat-libstdc++-33 glibc | grep "not" >>oracle.log;then
echo "install rpm -----------------------" | tee -a oracle.log
rpm -ivh oraclerpm/*.rpm
else
echo "the rpm had install,then check it again!" | tee -a oracle.log
fi
if rpm -q gcc make binutils openmotif setarch compat-db compat-gcc-32 openmotif compat-gcc-32-c++ compat-libstdc++-33 glibc | grep "not" >>oracle.log;then
echo "install have wrong ,please check the log oracle.log" | tee -a oracle.log
exit 0;
else
echo "setup 5:rpm check OK!" | tee -a oracle.log
fi
#the rpm list: gcc make binutils openmotif setarch compat-db compat-gcc openmotif compat-gcc-c++ compat-libstdc++ compat-libstdc++-devel

#but the compat-gcc is not need thought the book said it is impartant

#at cenots46 compat-gcc ->compat-gcc-32 ,compat-gcc-c++ ->compat-gcc-c++-32,compat-libstdc++ ->compat-libstdc++33 compat-libstdc++-devel is not need

#if cat /etc/security/limits.conf | grep ^[^#];then

if grep "oracle" /etc/security/limits.conf >>/dev/null;then
echo "/etc/security/limits.conf have edited" | tee -a oracle.log
else
echo "/etc/security/limits.conf is going to edit"
echo "##############################oracle ####################### " >> /etc/security/limits.conf
echo "oracle soft nofile 65536" >> /etc/security/limits.conf 
echo "oracle hard nofile 65536" >> /etc/security/limits.conf 
echo "oracle soft nproc 16384" >> /etc/security/limits.conf 
echo "oracle hard nproc 16384" >> /etc/security/limits.conf
echo "####################################################################"
echo "##########################oracle########################### " >> /etc/pam.d/login 
echo "session required /lib/security/pam_limits.so" >> /etc/pam.d/login 
echo "session required pam_limits.so" >> /etc/pam.d/login 
echo "####################################################################"
fi
echo "setup 6:security have been set" | tee -a oracle.log
if grep "ORACLE_BASE" /home/oracle/.bash_profile >>/dev/null;then
echo "/home/oracle/.bash_profile have already been edited" | tee -a oracle.log
else
echo "now edit the /home/oracle/.bash_profile" | tee -a oracle.log
sid=orcl
read -p "Please type the oracle_sid in 20 minutes,if you dont type any,the default oracle_sid is orcl: " -t 20 sid
sed '/unset USERNAME/d' /home/oracle/.bash_profile >>/dev/null
sed '/PATH/d' /home/oracle/.bash_profile >>/dev/null
cat >> /home/oracle/.bash_profile <<"EOF"
ORACLE_BASE=/u01/app/oracle
ORACLE_HOME=$ORACLE_BASE/product/10.1.0/Db_1
EOF
echo "ORACLE_SID=$sid" |tee -a oracle.log
echo "ORACLE_SID=$sid">>/home/oracle/.bash_profile
cat >> /home/oracle/.bash_profile <<"EOF"
export ORACLE_BASE ORACLE_HOME ORACLE_SID
PATH=$PATH:$HOME/bin:$ORACLE_BASE/product/10.1.0/Db_1/bin:
export PATH
unset USERNAME
EOF
fi
echo "setup 7:/home/oracle/.bash_profile OK!" | tee -a oracle.log
echo "now begain to install oracle" | tee -a oracle.log
echo "===========now put all the important message to oracle.log===========" |tee -a oracle.log
echo "============rpm -q gcc make binutils openmotif setarch compat-db compat-gcc-32 openmotif compat-gcc-32-c++ compat-libstdc++-33 glibc========" >> oracle.log
rpm -q rpm -q gcc make binutils openmotif setarch compat-db compat-gcc-32 openmotif compat-gcc-32-c++ compat-libstdc++-33 glibc >> oracle.log
echo "============ /etc/sysctl.conf====================" |tee -a oracle.log
cat /etc/sysctl.conf >>oracle.log 
echo "============ /etc/redhat-release====================" |tee -a oracle.log
cat /etc/redhat-release >>oracle.log
echo "============ id oracle====================" |tee -a oracle.log
id oracle>>oracle.log
echo "============ /etc/security/limits.conf====================" |tee -a oracle.log
cat /etc/security/limits.conf >>oracle.log
echo "============ /etc/pam.d/login ====================" |tee -a oracle.log
cat /etc/pam.d/login >>oracle.log
echo "============ /home/oracle/.bash_profile====================" |tee -a oracle.log
cat /home/oracle/.bash_profile>>oracle.log

 

你可能感兴趣的:(oracle,linux)