首页 > CentOS > Centos6.3 x86_64 Oracle x64_11gR2 安装环境设置脚本
2012
08-22

Centos6.3 x86_64 Oracle x64_11gR2 安装环境设置脚本

Centos6.3 x86_64 Oracle x64_11gR2 安装环境设置脚本

#!/bin/sh
#author:dnybz<cnfreebsd@163.com>
#file:install_oracle.sh
#data:2012/8/22

####chek env####
check_env(){

####check hostname####
IPADDR=`ifconfig eth0|grep "inet addr:"|awk '{print $2}'|sed "s/addr://g"`
HOSTNAME=`hostname`
echo "$IPADDR $HOSTNAME">>/etc/hosts

####check total memory####
TOTAL_MEM=`/usr/bin/free|grep Mem:|awk '{print $2}'`

if((TOTAL_MEM < 1024000))
then
echo "check total memory < 1024M!!"
fi

####check sysctl.conf args####
if [ ! -e /etc/sysctl.conf_bak ]
then
cp /etc/sysctl.conf /etc/sysctl.conf_bak
fi

grep "fs.aio-max-nr" /etc/sysctl.conf
if(($? != 0))
then
echo "fs.aio-max-nr = 1048576">>/etc/sysctl.conf
else
AIO_MAX_NR=`/sbin/sysctl -a|grep "fs.aio-max-nr"|awk '{print $3}'`
if((AIO_MAX_NR < 1048576))
then
AIO_MAX_NR_S=`cat /etc/sysctl.conf|grep "fs.aio-max-nr"`
sed -i "s/$AIO_MAX_NR_S/fs.aio-max-nr = 1048576/g" /etc/sysctl.conf
fi
fi

grep "fs.file-max" /etc/sysctl.conf
if(($? != 0))
then
echo "fs.file-max = 6815744">>/etc/sysctl.conf
else
FILE_MAX=`/sbin/sysctl -a|grep "fs.file-max"|awk '{print $3}'`
if((FILE_MAX < 1048576))
then
FILE_MAX_S=`cat /etc/sysctl.conf|grep "fs.file-max"`
sed -i "s/$FILE_MAX_S/fs.file-max = 6815744/g" /etc/sysctl.conf
fi
fi

grep "kernel.shmall" /etc/sysctl.conf
if(($? != 0))
then
echo "kernel.shmall = 2097152">>/etc/sysctl.conf
else
SHMALL=`/sbin/sysctl -a|grep "kernel.shmall"|awk '{print $3}'`
if((SHMALL < 2097152))
then
SHMALL_S=`cat /etc/sysctl.conf|grep "kernel.shmall"`
sed -i "s/$SHMALL_S/kernel.shmall = 2097152/g" /etc/sysctl.conf
fi
fi

grep "kernel.shmmax" /etc/sysctl.conf
if(($? != 0))
then
echo "kernel.shmmax = 536870912">>/etc/sysctl.conf
else
SHMMAX=`/sbin/sysctl -a|grep "kernel.shmmax"|awk '{print $3}'`
if((SHMMAX < 536870912))
then
SHMMAX_S=`cat /etc/sysctl.conf|grep "kernel.shmmax"`
sed -i "s/$SHMMAX_S/kernel.shmmax = 536870912/g" /etc/sysctl.conf
fi
fi

grep "kernel.shmmni" /etc/sysctl.conf
if(($? != 0))
then
echo "kernel.shmmni = 4096">>/etc/sysctl.conf
else
SHMMNI=`/sbin/sysctl -a|grep "kernel.shmmni"|awk '{print $3}'`
if((SHMMNI < 4096))
then
SHMMNI_S=`cat /etc/sysctl.conf|grep "kernel.shmmni"`
sed -i "s/$SHMMNI_S/kernel.shmmni = 4096/g" /etc/sysctl.conf
fi
fi

grep "kernel.sem" /etc/sysctl.conf
if(($? != 0))
then
echo "kernel.sem = 250 32000 100 128">>/etc/sysctl.conf
else
SEMMSL=`/sbin/sysctl -a | grep kernel.sem|awk '{print $3}'`
SEMMNS=`/sbin/sysctl -a | grep kernel.sem|awk '{print $4}'`
SEMOPM=`/sbin/sysctl -a | grep kernel.sem|awk '{print $5}'`
SEMMNI=`/sbin/sysctl -a | grep kernel.sem|awk '{print $6}'`

if((SEMMSL<250||SEMMNS<32000||SEMOPM<100||SEMMNI<128))
then
SEM_S=`cat /etc/sysctl.conf|grep "kernel.sem"`
sed -i "s/$SEM_S/kernel.sem = 250 32000 100 128/g" /etc/sysctl.conf
fi
fi

grep "net.ipv4.ip_local_port_range" /etc/sysctl.conf
if(($? != 0))
then
echo "net.ipv4.ip_local_port_range = 9000 65500">>/etc/sysctl.conf
else
IP_PORT_RANGE_BING=`/sbin/sysctl -a|grep "net.ipv4.ip_local_port_range"|awk '{print $3}'`
IP_PORT_RANGE_END=`/sbin/sysctl -a|grep "net.ipv4.ip_local_port_range"|awk '{print $4}'`
if((IP_PORT_RANGE_BING < 9000||IP_PORT_RANGE_END <65500))
then
IP_PORT_RANGE_S=`cat /etc/sysctl.conf|grep "net.ipv4.ip_local_port_range"`
sed -i "s/$IP_PORT_RANGE_S/net.ipv4.ip_local_port_range = 9000 65500/g" /etc/sysctl.conf
fi
fi

grep "net.core.rmem_default" /etc/sysctl.conf
if(($? != 0))
then
echo "net.core.rmem_default = 262144">>/etc/sysctl.conf
else
RMEM_DEFAULT=`/sbin/sysctl -a|grep "net.core.rmem_default"|awk '{print $3}'`
if((RMEM_DEFAULT < 262144))
then
RMEM_DEFAULT_S=`cat /etc/sysctl.conf|grep "net.core.rmem_default"`
sed -i "s/$RMEM_DEFAULT_S/net.core.rmem_default = 262144/g" /etc/sysctl.conf
fi
fi

grep "net.core.rmem_max" /etc/sysctl.conf
if(($? != 0))
then
echo "net.core.rmem_max = 4194304">>/etc/sysctl.conf
else
RMEM_MAX=`/sbin/sysctl -a|grep "net.core.rmem_max"|awk '{print $3}'`
if((RMEM_MAX < 4194304))
then
RMEM_MAX_S=`cat /etc/sysctl.conf|grep "net.core.rmem_max"`
sed -i "s/$RMEM_MAX_S/net.core.rmem_max = 4194304/g" /etc/sysctl.conf
fi
fi

grep "net.core.wmem_default" /etc/sysctl.conf
if(($? != 0))
then
echo "net.core.wmem_default = 262144">>/etc/sysctl.conf
else
WMEM_DEFAULT=`/sbin/sysctl -a|grep "net.core.wmem_default"|awk '{print $3}'`
if((WMEM_DEFAULT < 262144))
then
WMEM_DEFAULT_S=`cat /etc/sysctl.conf|grep "net.core.wmem_default"`
sed -i "s/$WMEM_DEFAULT_S/net.core.wmem_default = 262144/g" /etc/sysctl.conf
fi
fi

grep "net.core.wmem_max" /etc/sysctl.conf
if(($? != 0))
then
echo "net.core.wmem_max = 1048576">>/etc/sysctl.conf
else
WMEM_MAX=`/sbin/sysctl -a|grep "net.core.wmem_max"|awk '{print $3}'`
if((WMEM_MAX < 1048576))
then
WMEM_MAX_S=`cat /etc/sysctl.conf|grep "net.core.wmem_max"`
sed -i "s/$WMEM_MAX_S/net.core.wmem_max = 1048576/g" /etc/sysctl.conf
fi
fi

}

#call check fun
check_env
/sbin/sysctl -p

####install package####
yum -y install binutils compat-libstdc++-33 compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel gcc gcc-c++ glibc glibc glibc-common glibc-devel glibc-devel glibc-headers ksh libaio libaio libaio-devel libaio-devel libgcc libgcc libstdc++ libstdc++ libstdc++-devel make sysstat unixODBC unixODBC-devel

####add user and group####
/usr/sbin/groupadd oinstall
/usr/sbin/groupadd dba
/usr/sbin/useradd -g oinstall -G dba oracle
passwd oracle


####create oracle install directory####
mkdir -p /usr/local/oracle /usr/local/oraInventory /usr/local/oradata/
chown -R oracle:oinstall /usr/local/oracle /usr/local/oraInventory /usr/local/oradata/
chmod -R 775 /usr/local/oracle /usr/local/oraInventory /usr/local/oradata/


#### set limits.conf file
if [ !-e /etc/security/limits.conf_bak ]
then
mv /etc/security/limits.conf /etc/security/limits.conf_bak
fi
cat >/etc/security/limits.conf<<EOF
oracle              soft    nproc   2047
oracle              hard    nproc   16384
oracle              soft    nofile  1024
oracle              hard    nofile  65536
oracle              soft    stack   10240
EOF

####create oraIns.loc file####
cat >/etc/oraInst.loc<<EOF
inventory_loc=/usr/local/oraInventory
inst_group=oinstall
EOF

chown oracle:oinstall /etc/oraInst.loc
chmod 664 /etc/oraInst.loc


#### set oracle bash_profile
bash_profile=`cat <<EOF
export ORACLE_BASE=/usr/local/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
export ORACLE_SID=sales
export ORACLE_OWNER=oracle
export PATH=$PATH:$ORACLE_HOME/bin:$HOME/bin
EOF
` 

echo "$bash_profile" >>/home/oracle/.bash_profile

#### swich oracle user ####

echo "please manual swich oracle user install!!"
echo "su - oracle"
echo "source /home/oracle/.bash_profile"
echo "run oracle directory runInstaller script!!"

 

最后编辑:
作者:dnybz
这个作者貌似有点懒,什么都没有留下。