Debian Sarge 上安装 Oracle 10g


介绍一下我在Debian Sarge上安装Oracle 10g的过程。

首先说一下我的爱机配置情况:
AMD Duron 1.1G
RAM 512MB(Hy sdram 256*2)
Maxtor Diomand Plus 80G+40G

通过Oracle 官方认证的系统,只有redhat-2.1,redhat-3,UnitedLinux-1.0,并不包括对debian支持,所以在debian上安装Oracle会多出一些额外的步骤。
一、安装前的准备
1.硬件要求
Oracle建议内存为512MB或以上,至少1G交换分区,并且需要400MB的临时目录空间。
使用以下的命令查看你的内存和交换分区大小:

grep MemTotal /proc/meminfo

grep SwapTotal /proc/meminfo

你可以使用以下方法添加临时交换分区:
su - root
dd if=/dev/zero of=tmpswap bs=1k count=900000
chmod 600 tmpswap
mkswap tmpswap
swapon tmpswap

可以通过以下命令查看临时空间大小:
#df /tmp
可以自己新建临时目录,安装完后再删除
#su - root
#mkdir /opt/tmp
#chown root.root /opt/tmp/

chmod 1777 /opt/tmp

echo TEMP

export TEMP=/opt/tmp

export TEMPDIR=/opt/tmp

对硬盘空间大小的限制,建议预留3G空间,我按照标准安装,硬盘消耗接近1.9G。

2.系统参数调整
修改/etc/sysctl.conf,添加
kernel.shmmax = 2147483648
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.file-max = 65536
net.ipv4.ip_local_port_range = 1024 65000

执行
#/sbin/sysctl -p

设置shell限制,在/etc/security/limits.conf添加
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536

修改login设置,修改 /etc/pam.d/login,添加
session required /lib/security/pam_limits.so

在/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

3、安装设置
确保你已经安装了下列软件
make
binutils
libc6-dev
libmotif3
rpm
awk

确保你的系统中有以下组和用户,方法:
#grep dba /etc/group
#grep oinstall /etc/group
#grep nobody /etc/group

#id oracle
#id nobody

切换到root,添加oralce帐户
#su - root
#groupadd dba # group of users to be granted SYSDBA system privilege
#groupadd oinstall # group owner of Oracle files
#useradd -c "Oracle software owner" -g oinstall -G dba -d /opt/oracle oracle
#passwd oracle
输入oracle密码

debian中需要额外的添加nobody用户组:
#groupadd nobody
系统nogroup组中已经有nobody用户,把nobody用户添加到新建的nobody组中,
#usermod -G nobody nobody

建立oracle目录
#su root
#mkdir /opt/oracle
#chown -R oralce.oinstall /opt/oracle

debian需要额外的做以下操作:

ln -s /usr/bin/awk /bin/awk

ln -s /usr/bin/rpm /bin/rpm

ln -s /usr/bin/basename /bin/basename

ln -s /etc /etc/rc.d

模拟redhat-3进行安装,新建一个文件/etc/redhat-release,写入以下内容:
Red Hat Enterprise Linux AS release 3 (Taroon)

二、开始安装
你可以从http://mirrors.cn99.com上下载oracle 10g,按以下方法进行解压:
$ gunzip ship.db.cpio.gz
$ cpio -idmv < ship.db.cpio

这样会生成一个Disk1目录,进入Disk1目录。
切换到oracle用户,设置环境变量:
$ xhost +
$ su - oralce
$ export ORACLE_BASE=/opt/oracle
$ export ORACLE_SID=oralin#你可以自己命名sid

确保此时环境中没有ORACLE_HOME 和TNS_ADMIN
$ unset ORACLE_HOME
$ unset TNS_ADMIN

可以将这些写进.bash_profile
export ORACLE_BASE=/opt/oracle
export ORACLE_SID=oralin
unset ORACLE_HOME
unset TNS_ADMIN

umask 022

执行
$ ./runInstaller
我选择标准安装,安装大约30多分钟。安装过程截图,参见 http://www.linuxsir.org/bbs/showthread.php?s=&amp;threadid=140617

三、安装后

1.Oracle 管理工具
Ultra Search URL:
http://debian:5620/ultrasearch

Ultra Search 管理工具 URL:
http://debian:5620/ultrasearch/admin

iSQL*Plus URL:
http://debian:5560/isqlplus

Enteprise Manager 10g Database Control URL:
http://debian:5500/em

2.oracle启动脚本/etc/init.d/oracle
#!/bin/bash

Run-level Startup script for the Oracle Instance and Listener

chkconfig: 345 91 19

description: Startup/Shutdown Oracle listener and instance

ORA_HOME="/opt/oracle/product/10.1.0/db_1"
ORA_OWNR="oracle"

if the executables do not exist -- display error

if [ ! -f $ORA_HOME/bin/dbstart -o ! -d $ORA_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 "" in
start)

Oracle listener and instance startup

echo -n "Starting Oracle: "
su - $ORA_OWNR -c "$ORA_HOME/bin/lsnrctl start"
su - $ORA_OWNR -c $ORA_HOME/bin/dbstart

#Optional : for isqlplus only
su - $ORA_OWNR -c "$ORA_HOME/bin/isqlplusctl start"
#Optional : for Enterprise Manager software only
su - $ORA_OWNR -c "$ORA_HOME/bin/emctl start dbconsole"

touch /var/lock/oracle
echo "OK"
;;
stop)

Oracle listener and instance shutdown

echo -n "Shutdown Oracle: "

#Optional : for isqlplus only
su - $ORA_OWNR -c "$ORA_HOME/bin/isqlplusctl stop"
#Optional : for Enterprise Manager software only
su - $ORA_OWNR -c "$ORA_HOME/bin/emctl stop dbconsole"

su - $ORA_OWNR -c "$ORA_HOME/bin/lsnrctl stop"
su - $ORA_OWNR -c $ORA_HOME/bin/dbshut
rm -f /var/lock/oracle
echo "OK"
;;
reload|restart)
stop
start
;;
*)
echo "Usage: start|stop|restart|reload"
exit 1
esac
exit 0

可以通过/etc/init.d/oracle start来启动oracle.

参考资料:
1.GNU/Linux Desktop Survival Guide,学习debian的最佳资料,其中有Oracle 10g安装章节

2.Oracle 中文网站上官方安装教程: 在 Linux x86 官方安装 Oracle 数据库 10g

3.Oracle 官方论坛 :Oracle Linux Forum

Published At
Categories with 数据库类
Tagged with
comments powered by Disqus