oracle设置环境变量脚本
#centos5.4 oracle10g 前期安装环境检查脚本
#将所需要安装的包(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/10.2.0/db_1
echo -n "输入 HOME (默认 product/10.2.0/db_1):"
read HOME
if [ -z $HOME ]
then
HOME=product/10.2.0/db_1
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/sysctl.conf
LIMITS=/etc/security/limits.conf
PAM=/etc/pam.d/login
PROFILE=/etc/profile
BASH_PROFILE=/home/oracle/.bash_profile #IPADDR=`ifconfig eth0|grep "inet addr"|cut -d : -f 2| cut -d ' ' -f 1`
#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
kernel.msgmni=1024
kernel.shmmni=4906
kernel.sem=1024 64000 200 512
fs.file-max=65536
net.ipv4.ip_local_port_range=1024 65000
net.ipv4.tcp_sack=0
net.ipv4.tcp_timestamps=0
net.ipv4.tcp_max_syn_backlog=8192
net.ipv4.tcp_keepalive_time=120
net.core.rmem_default=262144
net.core.rmem_max=262144
net.core.wmem_default=262144
net.core.wmem_max=262144
EOF
#限制设置
cat>> $LIMITS <<EOF
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
EOF
#安全设置
cat >> $PAM <<EOF
session required /lib/security/pam_limits.so
session required pam_limits.so
EOF#全局环境变量设置
cat >> $PROFILE <<EOF
if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi
EOF
#oracle环境变量设置
cat >> $BASH_PROFILE <<EOF
export LC_CTYPE=en_US.UTF-8
export ORACLE_SID=orcl
export ORACLE_BASE=/opt/oracle
export ORACLE_HOME=/opt/oracle/product/10.2.0/db_1
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_AMERICA.ZHS16GBK
export ORA_NLS33=$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/rt.jar:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
export PATH
umask 022
EOF
source /home/oracle/.bash_profile
sleep 1
export DISPLAY=:0.0
xhost +
export LC_ALL=en_US
/sbin/sysctl -p