CentOS 5.3 安装配置Oracle 10g 手动启动及自启动服务


下面是文字描述Oracle 10g,CentOS 5.3 上安装过程

1,下载解压10201_database_linux32.zip到database文件,内存,swap是否合适请多查其他文章。

2,进入database目录,可以查看welcom.html文档里面的 Documentation的Quick Installation GuideQuick
这里就是参考上面的文档。

3,检查依赖文件,文档里面有,请自己查看,没有的yum一下,实在没有的就不用去管他,安装时的图形界面需要libXp,这里先yum -y install libXp

4,建立用户和组群,如果原先就有,照做下面命令也没冲突
$su -
#groupadd oinstall
#groupadd dba
#useradd -g oinstall -G dba oracle
#passwd oracle

5,安装需要修改的内核参数
执行下面命令的时候,先自己对比一下文档里面的要求,不符合的才改。
#vi /etc/sysctl.conf
kernel.shmall = 2097152
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

修改完了
/sbin/sysctl -p
一下

6,安全限制
#vi /etc/security/limits.conf 末尾加上

#use for oracle
oracle soft    nproc   2047
oracle hard    nproc   16384
oracle soft    nofile 1024
oracle hard    nofile 65536

#vi /etc/pam.d/login 末尾加上

#use for oracle
session required /lib/security/pam_limits.so

#vi /etc/profile 末尾加上

#use for oracle
if [ $USER = "oracle" ]; then
    if [ $SHELL = "/bin/ksh" ]; then
        ulimit -p 16384
        ulimit -n 65536
    else
        ulimit -u 16384 -n 65536
    fi
    fi

7,修改.bash_profile 我这oracle安装在/home/oracle/10G目录,www.bkjia.com如果要安装到/oracle/10G目录,请用root用户mkdir /oracle;mkdir /oracle/10G; chown -R oracle:oinstall /oracle
并对下面配置文件对ORACLE_BASE=/oracle做一下修改就是。

su - oracle
cd
vi .bash_profile 自己对照修改为

umask 022
ORACLE_BASE=/home/oracle
ORACLE_HOME=$ORACLE_BASE/10G
ORACLE_SID=orcl
PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin

export ORACLE_BASE
export ORACLE_HOME
export ORACLE_SID
export PATH

vi完后source .bash_profile一下

8,修改发行版本,centos是没有通过oracle认证的,不过不修改好像也能通过,这个随大家。
vi /etc/RedHat-release
将CentOS release 5.3 (Final) 修改成redhat-4
安装完了再改回来就是

9,安装oracle

su - oracle
cd到oracle 的 database安装目录

export LANG=en.UTF8
这条命令修改语言环境,是为了解决下面显示问题
避免出现zh.GB2312的警告和乱码

./runInstaller 或者sh runInstaller

到这就是图形安装界面,安装过程中,如果配置通不过,oracle是不让安装的,针对错误对照官方文档重先修改一下就是。安装过程中会要求你用root用户执行命令root.sh和orainstRoot.sh,自己照着提示的完整路径做就是。

安装完成oracle是默认启动了的,后你就可以访问下面的地址,请把下面yourIP替换成你的主机名 或者127.0.0.1 或者你的IP,推荐127.0.0.1
iSQL*Plus URL:
http://yourIP:5560/isqlplus

iSQL*Plus DBA URL:
http://yourIP:5560/isqlplus/dba

Enterprise Manager 10g Database Control URL:
http://yourIP:1158/em

8,oracle默认是不自启动的,一旦重启,oracle就需要手动启动:

su - oracle

启动数据库 ,密码就是安装时你填的密码
sqlpuls /nolog

sql> conn sys/密码 as sysdbasql> startup
sql> exit

sqlpuls具体路径为$ORACLE_HOME/bin/sqlplus
启动监听
lsnrctl start

lsnrctl具体路径为$ORACLE_HOME/bin/lsnrctl

上面只是启动了数据库和监听基本服务
要想启动上面3个带网页地址访问的服务,操作如下:

isqlplusctl start 启动iSQL*Plus,可以访问http://127.0.0.1:5560/isqlplus
或者http://127.0.0.1:5560/isqlplus/dba 这两个地址,如果能打开,则确定iSQL*Plus已经启动
isqlplusctl具体路径为$ORACLE_HOME/bin/isqlplusctl

emctl start dbconsole 启动Enterprise Manager 10g Database Control
可以访问http://127.0.0.1:1158/em能打开,则确定Enterprise Manager 10g Database Control已经启动。这个服务启动有点慢恩,慢慢等恩。
emctl具体路径为$ORACLE_HOME/bin/emctl

当然,oracle自己也有启动脚本dbstart和关闭脚本dbshut
先修改vi /etc/oratab
将最后一行N变成Y
然后修该$ORACLE_HOME/bin/dbstart内容

ORACLE_HOME_LISTNER=$ORACLE_HOME

su - oracle

dbstart 就可以启动oracle了,这个也只是启动oracle数据库和监听基本服务,不带3个网页的服务,相当于上面的sqlplus 和 lsnrctl start两个操作

dbshut 就可以停止oracle了。

不过要注意的是startup.log和shutdown.log最好确认一下他们的所有者是不是oracle
最好可以chown oracle.oinstall startup.log
    chown oracle.oinstall shutdown.log一下,不然服务自启动的时候会报一些错

9,把oracle添加为自启动服务dbstart,root用户进行如下操作
su - root
cd /etc/rc.d/init.d/
gedit dbstart

复制如下脚本1或者脚本2内容到dbstart文件:脚本1包括数据库和监听基本服务,iSQL*Plus,Enterprise Manager 10g Database Control所有服务

脚本1(启动所有服务)

#!/bin/bash

# chkconfig: 345 99 10

# description: Startup Script for oracle Databases

# /etc/rc.d/init.d/dbstart


export ORACLE_BASE=/home/oracle

export ORACLE_HOME=/home/oracle/10G

export ORACLE_SID=orcl

export PATH=$PATH:$ORACLE_HOME/bin


ORA_OWNR="oracle"

# if the executables do not exist -- display error

if [ ! -f $ORACLE_HOME/bin/dbstart -o ! -d $ORACLE_HOME ]

then

     echo "Oracle startup: cannot start"

     exit 1

fi

# depending on parameter -- startup, shutdown, restart

# of the instance and listener or usage display

case "$1" in

   start)

     # Oracle listener and instance startup

     echo -n "Starting Oracle: "

     su - $ORA_OWNR -c "$ORACLE_HOME/bin/dbstart"

     touch /var/lock/oracle

     su - $ORA_OWNR -c "$ORACLE_HOME/bin/isqlplusctrl start"

    su - $ORA_OWNR -c "$ORACLE_HOME/bin/emctl start dbconsole"


     echo "OK"

     ;;

   stop)

     # Oracle listener and instance shutdown

     echo -n "Shutdown Oracle: "

     su - $ORA_OWNR -c "$ORACLE_HOME/bin/emctl stop dbconsole"

     su - $ORA_OWNR -c "$ORACLE_HOME/bin/isqlplusctrl stop"

     su - $ORA_OWNR -c "$ORACLE_HOME/bin/dbshut"

     su - $ORA_OWNR -c "$ORACLE_HOME/bin/lsnrctl stop"

     rm -f /var/lock/oracle

     echo "OK"

     ;;

   reload|restart)

     $0 stop

     $0 start

     ;;

   *)

     echo "Usage: `basename $0` start|stop|restart|reload"

     exit 1

esac

exit 0

脚本2:(只启动数据库和监听)


#!/bin/bash

# chkconfig: 345 99 10

# description: Startup Script for oracle Databases

# /etc/rc.d/init.d/dbstart

export ORACLE_BASE=/home/oracle

export ORACLE_HOME=/home/oracle/10G

export ORACLE_SID=orcl

export PATH=$PATH:$ORACLE_HOME/bin

case "$1" in

start)

su oracle -c $ORACLE_HOME/bin/dbstart

touch /var/lock/oracle

echo "OK"

;;

stop)

echo -n "Shutdown oracle: "

su oracle -c $ORACLE_HOME/bin/dbshut

rm -f /var/lock/oracle

echo "OK"

;;

*)

echo "Usage: 'basename $0' start|stop"

exit 1

esac

exit 0

上面两个脚本如果

export ORACLE_BASE=/home/oracle

export ORACLE_HOME=/home/oracle/10G

和你所安装的oracle路径不相同,请参考修改就是,然后


chown oracle.oinstall /etc/rc.d/init.d/dbstart

chmod 775 /etc/rc.d/init.d/dbstart

/sbin/chkconfig --add dbstart

/sbin/chkconfig --list dbstart
运行结果:
dbstart         0:关闭 1:关闭 2:关闭 3:启用 4:启用 5:启用 6:关闭
可以
/sbin/service dbstart start
看看是否能启动

重启看看
然后自己可以测试下oracle所有服务是否启动
具体可以测试三个网页地址
sqlplus登录下等

好了,本文只是本人用来解决遗忘的记录,等不了几天我又忘很多了,希望也对你有所帮助,安装过程中出现错误的话多google,baidu下,学linux就需要一天100个google,200个baidu的精神。

相关内容