在CentOS上安装Oracle11g

1,修改centos 的release文件以便oracle识别,并关闭SElinux
vi /etc/redhat-release
Red Hat Enterprise Linux AS release 5 (Taroon)

2,安装没有默认安装的一些包,在Oracle安装过程中会有些提示,但最好先装上。

binutils-2.17.50.0.6-2.el5
compat-libstdc++-33-3.2.3-61
elfutils-libelf-0.125-3.el5
elfutils-libelf-devel-0.125
gcc-4.1.1-52
gcc-c++-4.1.1-52
glibc-2.5-12
glibc-common-2.5-12
glibc-devel-2.5-12
glibc-headers-2.5-12
libaio-0.3.106
libaio-devel-0.3.106
libgcc-4.1.1-52
libstdc++-4.1.1
libstdc++-devel-4.1.1-52.e15
make-3.81-1.1
sysstat-7.0.0
unixODBC-2.2.11
unixODBC-devel-2.2.11

3,创建系统用户:
/usr/sbin/groupadd oinstall
/usr/sbin/groupadd dba
/usr/sbin/useradd -g oinstall -G dba oracle
passwd oracle

4,创建数据库安装目录,赋权:
mkdir -p /u01/app/oracle/product/  //设置oracle的安装目录
chown -R oracle:oinstall /u01  //设置安装目录所属的用户和组
chmod -R 775 /u01

5,修改系统参数:
vi /etc/sysctl.conf
在最末尾的地方加上:
kernel.shmall = 2097152 //固定大小为2M
kernel.shmmax = 2147483648 //一般设置为物理的一半
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 1024 65000
net.core.rmem_default = 4194304
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 262144

sysctl -p

6,修改系统limits.conf文件:
vi /etc/security/limits.conf 在末尾添加
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536

7,修改login配置
vi /etc/pam.d/login 在末尾添加
session required /lib/security/pam_limits.so
session required pam_limits.so

8,修改/etc/profile文件,在末尾添加
if [ $USER = “oracle” ]; then
if [ $SHELL = “/bin/ksh” ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi

9,修改Oracle用户的/home/oracle/.bash_profile 注意路径必须和安装目录一样
# User specific environment and startup programs

PATH=$PATH:$HOME/bin

export PATH
export ORACLE_BASE=/u01
export ORACLE_HOME=$ORACLE_BASE/app/oracle/product/11.2.0/dbhome_1
export ORACLE_HOME_LISTNER=$ORACLE_HOME
export ORACLE_SID=jmj
export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib

10,解压缩文件,./runInstaller 即可,当然,也可以远程打开VNC进行安装。

11,设置Oracle开机启动,编写一个脚本:oracleinit.sh

在这个脚本之前,有一点点准备工作,需要将环境变量参数加入到启动停止脚本:dbstart dbshut
在dbstart 和 dbshut 找到此段话,在最前端
# First argument is used to bring up Oracle Net Listener
ORACLE_HOME_LISTNER=$1
//需要将此处的 ORACLE_HOME_LISTNER=$1 修改为 ORACLE_HOME_LISTNER=$ORACLE_HOME
------
#!/bin/bash
# description: Oracle11g Server
# processname: oraserver  

RETVAL=0
prog="oraserver"  

ORACLE_HOME=/app/oracle/product/11.2.1/dbhome/
if [ ! -f $ORACLE_HOME/bin/dbstart ]
then
    echo "Oracle11g cannot start:Cannot find dbstart..."
    exit
fi  

start() {
    echo "Starting Oracle11g Server..."
    su - oracle -c "$ORACLE_HOME/bin/dbstart"
    RETVAL=$?
    [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
    su - oracle -c "$ORACLE_HOME/bin/emctl start dbconsole"
    return $RETVAL
}
stop() {
    su - oracle -c "$ORACLE_HOME/bin/emctl stop dbconsole"
    echo "Stoping Oracle10g Server..."
    su - oracle -c "$ORACLE_HOME/bin/dbshut"
    RETVAL=$?
    [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog
    return $RETVAL
}  

restart() {
echo "Restart Oracle11g Server"
stop
start
echo
}  

case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  restart|reload)
        stop
        start
        RETVAL=$?
        ;;
  condrestart)
        if [ -f /var/lock/subsys/$prog ]; then
            stop
            start
            RETVAL=$?
        fi
        ;;
  status)
        status $prog
        RETVAL=$?
        ;;
  *)
        echo $"Usage: $0 {start|stop|restart|condrestart|status}"
        exit 2
esac  

exit $RETVAL
------

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.