Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2292400
  • 博文数量: 168
  • 博客积分: 6641
  • 博客等级: 准将
  • 技术积分: 1996
  • 用 户 组: 普通用户
  • 注册时间: 2007-06-02 11:49
文章存档

2020年(4)

2019年(6)

2017年(1)

2016年(3)

2015年(3)

2014年(8)

2013年(2)

2012年(12)

2011年(19)

2010年(10)

2009年(3)

2008年(17)

2007年(80)

分类: LINUX

2010-07-10 16:07:34

在RHEL5中安装Oracle 10g数据库系统
 
2010-06-01 TsengYia#126.com http://selinux.cublog.cn
 
####################################################################
系统环境:
    RHEL5.3 [ 2.6.18-128.el5PAE ]
软件环境:
    10201_database_linux32.zip、jdk-6u20-linux-i586.bin
####################################################################
 
一、安装JDK开发环境
[root@localhost ~]# cp /var/ftp/upload/jdk-6u20-linux-i586.bin /usr/local/
[root@localhost ~]# cd /usr/local/
[root@localhost local]# chmod a+x jdk-6u0-linux-i586.bin
[root@localhost local]# ./jdk-6u20-linux-i586.bin
…… //根据提示完成安装
[root@localhost local]# ln -s /usr/local/jdk1.6.0_20 /usr/local/jdk
[root@localhost local]# vi /etc/profile
JAVA_HOME=/usr/local/jdk
CLASSATH=$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
PATH=$PATH:%JAVA_HOME/bin
export JAVA_HOME CLASSPATH PATH
[root@localhost local]# source /etc/profile
[root@localhost local]# alternatives --install /usr/bin/java java /usr/local/jdk1.6.0_20/bin/java 1
[root@localhost local]# alternatives --install /usr/bin/javac javac /usr/local/jdk1.6.0_20/bin/javac 1
[root@localhost local]# alternatives --config java
[root@localhost local]# alternatives --config javac
 
 
二、安装oracle 10g数据库系统

    —— 1. 用于辅助安装的Shell脚本
#!/bin/bash
#### by TsengYia#126.com 2010-06-01
PKGS_DIR="/var/ftp/upload"
PKGS_NAME="10201_database_linux32.zip"
INST_DIR="/opt/oracle"
SYSV_FILE="oracle10g.server-script"
#############################################################
## 0. Post-Install Process //安装后的配置
#############################################################
if [ "$1" = "--postinstall"] ; then
    grep "ORACLE" /etc/profile &> /dev/null || (
        echo "export ORACLE_BASE=$INST_DIR" >> /etc/profile
        echo "export ORACLE_HOME=$INST_DIR" >> /etc/profile
        echo "export ORACLE_OWNER=oracle" >> /etc/profile
        echo "export ORACLE_SID=orcl" >> /etc/profile
        echo "export ORACLE_TERM=xterm" >> /etc/profile
        echo "export PATH=\$PATH:\$ORACLE_HOME/bin" >> /etc/profile
        source /etc/profile
    )
    sed -i 's/oracle:N/oracle:Y/g' /etc/oratab
    # 修正dbstart文件中的一个小错误
    sed -i 's/\/ade\/vikrkuma_new\/oracle/\$ORACLE_HOME/g' $INST_DIR/bin/dbstart
    # 添加oracle10g系统服务
    if [ -f $SYSV_FILE ] ; then
        cp $SYSV_FILE /etc/init.d/oracle10g
        chmod a+x /etc/init.d/oracle10g
        chkconfig --add oracle10g
    fi
    # 若EM平台的中文字体显示为方框,执行下列操作进行修复,并清空客户机浏览器缓存后重试即可
    cd $INST_DIR/jdk/jre/lib
    cp -p font.properties font.properties.bak
    cp -p font.properties.zh_CN.Redhat font.properties
    sed -i 's/zh_CN\/TrueType\/zysong.ttf/chinese\/TrueType\/uming.ttf/g' font.properties
    rm -f $INST_DIR/oc4j/j2ee/oc4j_applications/applications/em/em/cabo/images/cache/zhs/*
    su - oracle -c "emctl stop dbconsole"
    su - oracle -c "emctl start dbconsole"
    xhost - &> /dev/null
    exit 0
fi
#############################################################
## 1. Install Required RPM Packages //安装必需的RPM软件包
#############################################################
echo "###########################################################"
echo "Install Required RPM packages ..."
echo -n Please insert RHEl5 system disk (DVD), then press any key to continue."
read -n 1 $ch && echo
mkdir -p /media/cdrom
[ ! -d /media/cdrom/Server ] && mount /dev/cdrom /media/cdrom > /dev/null
cd /media/cdrom/Server
rpm -ivh compat-db-* openmotif22-* setarch-2.0* libXp-.0* libaio-0.3.106* compat-gcc-34-3.4* compat-gcc-34-c++* compat-libstdc++-296* --force
#############################################################
## 2. Create Oracle's User/Groups/Directory //创建用户及目录
#############################################################
echo "Create Oracle's User/Groups/Directory ... "
id oracle &> /dev/null || (
    groupadd oinstall
    groupadd dba
    useradd -d $INST_DIR -g oinstall -G dba oracle &> /dev/null
)
mkdir -p $INST_DIR
chmod -R 755 $INST_DIR
chown -R oracle:oinstall $INST_DIR
#############################################################
## 3. Configure Kernel Parameters //调整内核相关参数
#############################################################
echo "Configure Kernel Parameters ..."
cp /etc/sysctl.conf /etc/sysctl.conf.bak
sed -i '/kernel.shmax/d' /etc/sysctl.conf
sed -i '/kernel.shmall/d' /etc/sysctl.conf
echo "kernel.shmax = 4194304
kernel.shmall = 2097152
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.file-max = 65536
net.ipv4.ip_local_port_range = 1024 65000
net.core.rmem_default = 262144
net.core.rmem_max = 262144
net.core.wmem_default = 262144
net.core.wmem_max = 262144" >> /etc/sysctl.conf
sysctl -p &> /dev/null
# 禁用selinux机制
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
#############################################################
## 4. Configure Shell Parameters //调整Shell及会话参数
#############################################################
echo "Configure Shell Parameters ..."
grep "oracle" /etc/security/limits.conf &> /dev/null || (
    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 nproc 65536" >> /etc/security/limits.conf
    echo "session required /lib/security/pam_limits.so" >> /etc/pam.d/login
)
grep "ulimit -u" /etc/rc.local || echo "ulimit -u 16384 -n 65536" >> /etc/rc.local
grep "umask 0022" ~oracle/.bashrc || echo "umask 0022" >> ~oracle/.bashrc
ulimit -u 16384 -n 65536
#############################################################
## 5. Start To Install Oracle 10g //打开X访问权限,准备安装
#############################################################
xhost + &> /dev/null
echo "export TEMP=/tmp TMPDIR=/tmp LANG=en_US.UTF-8 DISPLAY=0.0" >> ~oracle/.bash_profile
cd $PKGS_DIR
[ ! -d "$PKGS_DIR/database" ] && unzip $PKGS_NAME &> /dev/null
echo "###########################################################"
echo "Now you can follow these steps:"
echo "1. Firstly, run \"su -oracle\", switch to user \"oracle\"."
echo "2. Secondly, run \"./runInstaller\" under directory \"$PKGS_DIR/database\", start to install Oracle 10g with GUI."
echo "3. Finally, please run \"$0 --postinstall\" by root user."
####
#### End. ####
####
 
    —— 2. Oracle 10g 系统服务控制脚本 oracle10g.server-script
#!/bin/bash
# chkconfig: 35 90 10
# description: Oracle Database Service Daemon.
ORACLE_HOME=/opt/oracle
ORACLE_OWNER=oracle
case "$1" in
  start)
    su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/lsnrctl start"
    su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/dbstart"
    su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/emctl start dbconsole"
    touch /var/lock/subsys/oracle10g
    ;;
  stop)
    su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/emctl stop dbconsole"
    su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/dbshut"
    su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/lsnrctl stop"
    rm -f /var/lock/subsys/oracle10g
    ;;
  status)
    if ( pgrep "tnslsnr" && netstat -anpt | grep ":1521" ) &> /dev/null
    then
        echo "Oracle 10g Net Listener is running."
    else
        echo "Oracle 10g Net Listener is not running."
    fi
    if ( netstat -anpt | grep ":1158" && netstat -anpt | grep ":5520" ) &> /dev/null
    then
        echo "Oracle 10g Enterprise Manager is running."
    else
        echo "Oracle 10g Enterprise Manager is running."
    fi
    ;;
  restart)
    $0 stop
    $0 start
    ;;
  *)
    echo "Usage: $0 {start|stop|restart|status}"
    exit 1
    ;;
esac
exit 0
####
#### End. ####
####
阅读(1669) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~