#!/bin/bash
#centos oracleg 前期安装环境检查脚本
#将所需要安装的包(rpm格式)与脚本放在一个目录下
ss=$PWD
cd $ss
rpm ivh *rpm
#ORACLE_BASE=/opt/oracle
echo n 输入ORACLE_BASE(默认/opt/oracle):
read ORACLE_BASE
if [ z $ORACLE_BASE ]
then
ORACLE_BASE=/opt/oracle
fi
#ORACLE_HOME=$ORACLE_BASE/product//db_
echo n 输入 HOME (默认 product//db_):
read HOME
if [ z $HOME ]
then
HOME=product//db_
fi
ORACLE_HOME=$ORACLE_BASE/$HOME
#ORACLE_SID=oral
echo n 输入 ORACLE_SID (默认 orcl):
read ORACLE_SID
if [ z $ORACLE_SID ]
then
ORACLE_SID=orcl
fi
USER=oracle
SYSCTL=/etc/nf
LIMITS=/etc/security/nf
PAM=/etc/pamd/login
PROFILE=/etc/profile
BASH_PROFILE=/home/oracle/bash_profile
#IPADDR=`ifconfig eth|grep inet addr|cut d : f | cut d f `
#HOSTS=/etc/hosts
#NETWORK=/etc/sysconfig/network
#hostname
#grep v HOSTNAME $NETWORK > $NETWORK
#echo HOSTNAME=$HOSTNAME >> $NETWORK
#echo $IPADDR $HOSTNAME>> $HOSTS
#加入用户
useradd g oinstall G dba $USER
groupadd oinstall
groupadd dba
mkdir p $ORACLE_BASE
chown R $USER:oinstall $ORACLE_BASE
#内核设置
cat >> $SYSCTL << EOF
kernelmsgmni=
kernelshmmni=
kernelsem=
fsfilemax=
netipvip_local_port_range=
netipvtcp_sack=
netipvtcp_timestamps=
netipvtcp_max_syn_backlog=
netipvtcp_keepalive_time=
rermem_default=
rermem_max=
rewmem_default=
rewmem_max=
EOF
#限制设置
cat>> $LIMITS <<EOF
oracle soft nproc
oracle hard nproc
oracle soft nofile
oracle hard nofile
EOF
#安全设置
cat >> $PAM <<EOF
session required /lib/security/pam_limitsso
session required pam_limitsso
EOF
#全局环境变量设置
cat >> $PROFILE <<EOF
if [ \$USER = oracle ]; then
if [ \$SHELL = /bin/ksh ]; then
ulimit p
ulimit n
else
ulimit u n
fi
fi
EOF
#oracle环境变量设置
cat >> $BASH_PROFILE <<EOF
export LC_CTYPE=en_USUTF
export ORACLE_SID=orcl
export ORACLE_BASE=/opt/oracle
export ORACLE_HOME=/opt/oracle/product//db_
export TNS_ADMIN=$ORACLE_HOME/network/admin
export ORA_DB=$ORACLE_HOME/dbs
export ORACLE_BDUMP=$ORACLE_BASE/shtkt/bdump
export ORACLE_TERM=xterm
export NLS_LANG=AMERICAN_AMERICAZHSGBK
export ORA_NLS=$ORACLE_HOME/ocommon/nls/admin/data
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib:/usr/local/lib
export LIBPATH=$ORACLE_HOME/lib:$ORACLE_HOME/ctx/lib
export CLASSPATH=$ORACLE_HOME/JRE/lib:$ORACLE_HOME/JRE/lib/rtjar:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
export PATH
umask
EOF
source /home/oracle/bash_profile
sleep
export DISPLAY=:
xhost +
export LC_ALL=en_US
/sbin/sysctl p