分类: Oracle
2009-07-10 18:21:07
红帽子AS4安装oracle9i
参考文章:
http://blog.csdn.net/navyforce/archive/2007/04/09/1557555.aspx
一,准备工作
1,先安装好RedHat AS4.0,保持系统的干净。
在oracle官方网站上下载Oracle 9i的安装文件:
ship_9204_linux_disk1.cpio.gz
ship_9204_linux_disk2.cpio.gz
ship_9204_linux_disk3.cpio.gz
由于安装oracle需要很多系统软件包,少一样都不行,真是一个都不能少。开一个终端,以root用户运行:
# rpm -qa | grep compat
检查当前系统所安装的compat软件包是否已有:
compat-db-4.1.25-9
compat-gcc-32-3.2.3-47.3 4
compat-gcc-32-c++-3.2.3-47.3 4
compat-libgcc-296-2.96-132.7.2 3
compat-libstdc++-296-2.96-132.7.2 3
compat-libstdc++-33-3.2.3-47.3 2
gcc-3.4.3-9.EL4
gcc-c++-3.4.3-9.EL4
gnome-libs-1.4.1.2.90-44
gnome-libs-devel-1.4.1.2.90-44 4
libaio-devel-0.3.102-1 3
libaio-0.3.102-1 3
make-3.80-5
openmotif21-2.1.30-11 3
xorg-x11-deprecated-libs-devel-6.8.1-23.EL
xorg-x11-deprecated-libs-6.8.1-23.EL
compat-oracle-rhel4-1.0-3
compat-libcwait-2.0-1
发如果少了上数包,AS4光盘安装RPM包(最后两个由Oralce补丁p4198954_21_linux.zip解压产生)
rpm -ivh compat-oracle-rhel4-1.0-5.i386.rpm (p4198954_21_linux.zip)
rpm -ivh compat-libcwait-2.0-2.i386.rpm (p4198954_21_linux.zip)
二,创建相关安装目录和环境变量
1,创建user/group;
#groupadd dba
#groupadd oinstall
#useradd oracle -g oinstall -G dba
#passwd oracle
2,建立oracle安装文件夹;
# mkdir -p /opt/ora9/product/9.2.0.4
# mkdir /var/opt/oracle
# chown oracle.dba /var/opt/oracle
# chown -R oracle.dba /opt/ora9
3,配置环境变量;
使用Oracle用户登陆:
#su – oracle
$vi .bash_profile
以下是配置文件的内容
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export ORACLE_BASE=/opt/ora9
export ORACLE_HOME=/opt/ora9/product/9.2.0.4
export PATH=$PATH:$ORACLE_HOME/bin:$ORACLE_HOME/Apache/Apache/bin
export ORACLE_OWNER=oracle
export ORACLE_SID=oradb
export ORACLE_TERM=xterm
export LD_ASSUME_KERNEL=2.4.19 ##********
export THREADS_FLAG=native
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib
export NLS_LANG=”American_america.utf8”
export ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data
export PATH
unset USERNAME
4,设置系统参数;
#su – root切换到root用户
a) 修改#vi /etc/sysctl.conf, 以下是配置文件的内容(其中红色字体为添加的内容):
# Kernel sysctl configuration file for Red Hat Linux
#
# For binary values, 0 is disabled, 1 is enabled. See sysctl(8) and
# sysctl.conf(5) for more details.
# Controls IP packet forwarding
net.ipv4.ip_forward = 0
# Controls source route verification
net.ipv4.conf.default.rp_filter = 1
# Controls the System Request debugging functionality of the kernel
kernel.sysrq = 0
# Controls whether core dumps will append the PID to the core filename.
# Useful for debugging multi-threaded applications.
kernel.core_uses_pid = 1
kernel.shmmax = 536870912
kernel.shmmni = 4096
kernel.shmall = 2097152
kernel.sem = 250 32000 100 128
fs.file-max = 65536
net.ipv4.ip_local_port_range = 1024 65000
修改后运行#sysctl –p命令使得内核改变立即生效;
(译者注:一般情况下可以设置最大共享内存为物理内存的一半,如果物理内存是 2G,则可以设置最大共享内存为 1073741824,如上;如物理内存是 1G,则可以设置最大共享内存为 512 * 1024 * 1024 = 536870912;以此类推。)
建议永久地增加 shmmax 设置。
sem 4个参数依次为SEMMSL(每个用户拥有信号量最大数);SEMMNS(系统信号量最大数);SEMOPM(每次semopm系统调用操作数); SEMMNI(系统辛苦量集数最大数).Shmmax 最大共享内存,官方文档建议是内存的1/2,Shmmni 最小共享内存 4096KB.Shmall 所有内存大小 。
###########################################没有作过
b) 设置oracle对文件的要求:
编辑文件:#vi /etc/security/limits.conf 加入以下语句:
oracle soft nofile 65536
oracle hard nofile 65536
oracle soft nproc 16384
oracle hard nproc 16384
c) gcc降级
#su – root
#mv /usr/bin/gcc /usr/bin/gcc34
#ln –s /usr/bin/gcc32 /usr/bin/gcc
#mv /usr/bin/g++ /usr/bin/g++34
#ln –s /usr/bin/g++32 /usr/bin/g++
############################################
打3238244补丁
同时要下载三个补丁:
p4198954_21_linux.zip 在运行 runInstaller 之前打
p2617419_220_GENERIC.zip 修复agent错误的补丁
p3238244_9204_LINUX.zip 打3238244补丁
5,安装oracle补丁
当你从 Oracle 9iR2 光盘执行 runInstaller 时,会出现错误信息:
Error occurred during initialization of VM
Unable to load native library:
/tmp/OraInstall2003-10-25_03-14-57PM/jre/lib/i386
/libjava.so symbol _libc_wait, version GLIBC_2.0 not
defined in file libc.so.6 with link time reference
为了解决 _libc_wait 符号问题,
从 下载补丁
compat-libcwait-2.0-2.i386.rpm compat-oracle-rhel4-1.0-5.i386.rpm.为了应用这个补丁,可以运行:
$su – root
# cd /orasetup
#ls compat*.rpm
compat-libcwait-2.0-2.i386.rpm compat-oracle-rhel4-1.0-5.i386.rpm
# rpm -Uvh compat*.rpm
Preparing... ########################################### [100%]
1:compat-libcwait-2.0-2.i386.rpm ##################################### [ 50%]
2:compat-oracle-rhel4-1.0-5.i386.rpm#################################### [100%]
三,开始安装Oracle9i
1,解压下载的安装文件:
zcat ship_9204_linux_disk1.cpio.gz | cpio –idmv 或者 cpio -idcmv < ship_9202_ia64_lnx_Disk1.cpio
zcat ship_9204_linux_disk2.cpio.gz | cpio –idmv
zcat ship_9204_linux_disk3.cpio.gz | cpio –idmv
cpio -idmv < ship_9204_linux_disk1.cpio
解包和解压过程中,自动创建了3个包含安装文件的目录:
Disk1
Disk2
Disk3
.以oracle用户登录系统,进行Oracle的安装:
$ cd Disk1
$ ./runInstaller过一会儿就会出现Oracle的安装界面
- Welcome Screen: Click Next
- Inventory Location: Click Next
- Unix Group Name: Use "oinstall" and click Next
When asked to run /tmp/orainstRoot.sh, run it before you click Continue
- At the end of the installation, exit runInstaller.
2.一步一个脚印安装下去就行了!
3,安装完后打补丁:
切换到root:#su – root 首先安装 opatch.
#cd /orasetup
#unzip p2617419_210_GENERIC.zip
Archive: p2617419_210_GENERIC.zip
creating: OPatch/
creating: OPatch/docs/
inflating: Opatch/docs/FAQ
......
inflating: README.txt
#export PATH=$PATH:/orasetup/OPatch:/sbin
(修改PATH时要要包括解压缩出来的Opatch 和 sbin目录)
# unzip p3238244_9204_LINUX.zip
# cd 3238244
# opatch apply
如果提示HOME变量错误可执行语句:
#export ORACLE_BASE=/opt/ora9
#export ORACLE_HOME=/opt/ora9/product/9.2.0.4
出现success的提示就全部安装成功.
补丁打完后,还要relinked一个.mk文件,切换到oracle用户窗口
cd $ORACLE_HOME/network/lib
make –f ins_oemagent.mk install
之后就可以启动Agent服务了.
4, 最后执行 #dbca 建oracle数据库
点击OK,然后退出即可,正常登陆并启动数据库的操作。
[oracle@oracle oracle]$ lsnrctl start
[oracle@oracle oracle]$ sqlplus /nolog
SQL*Plus: Release 9.2.0.4.0 - Production on Sat Mar 12 22:58:53 2005
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
SQL>; connect / as sysdba
Connected.
SQL>; shutdown immediate 关闭数据库
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>; startup; 启动数据库
ORACLE instance started.
Total System Global Area 236000356 bytes
Fixed Size 451684 bytes
Variable Size 201326592 bytes
Database Buffers 33554432 bytes
Redo Buffers 667648 bytes
Database mounted.
Database opened.
5, 为了方便管理,可以写一个启动脚本ora9i:
以root身份进入,编写以下脚本:
#!/bin/bash
#start and stop the oracle instance
# chkconfig –level 5 --add ora9i
#chkconfig: 345 91 19
# description: starts the oracle listener and instance
export ORACLE_HOME="/opt/ora9/product/9.2.0.4"
export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/Apache/Apache/bin:$PATH
export ORACLE_OWNER="oracle"
export ORACLE_SID=oradb
if [ ! -f $ORACLE_HOME/bin/dbstart -o ! -d $ORACLE_HOME ]
then
echo "oracle startup:cannot start"
exit 1
fi
case "$1" in
start)
#startup the listener and instance
echo -n "oracle startup: "
su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/lsnrctl start"
su - $ORACLE_OWNER -c $ORACLE_HOME/bin/dbstart
touch /var/lock/subsys/oracle
echo "finished"
;;
stop)
# stop listener, apache and database
echo -n "oracle shutdown:"
su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/lsnrctl stop"
su - $ORACLE_OWNER -c $ORACLE_HOME/bin/dbshut
rm -f /var/lock/subsys/oracle
echo "finished"
;;
reload|restart)
$0 stop
$0 start
;;
*)
echo "Usage: ora9i [start|stop|reload|restart]"
exit 1
esac
exit 0
存为ora9i后,然后用chmod a+x ora9,即可在以后以root身份运行 /etc/rc.d/init.d/ora9i start |stop 来管理oracle的启动和停止了。如果要将这个脚本加入到系统中使其可开机运行(不过官方是不建议开机自动运行的),那么要运行以下命令: chkconfig --level 3(或者是5) --add ora9i
或者以root用户执行如下命令:
#cp /orasetup/ora9i /etc/rc.d/init.d/
#chmod a+x /etc/rc.d/init.d /ora9
#cd /etc/rc.d/rc5.d
#ln -s /etc/rc.d/init.d/ora9i S99ora9i
#cd /etc/rc.d/rc0.d
#ln -s /etc/rc.d/init.d/ora9i K99ora9i
也可自启动oracle9i!
或者可在/etc/rc.d/rc.local中加入如下:
su - oracle -c "/opt/ora9/oracle/product/9.2.0.4/bin/lsnrctl start"
su - oracle -c "/opt/ora9/oracle/product/9.2.0.4/bin/dbstart start"
6,
关于数据库删除重新安装的问题:
把ORACLE安装目录删除及/etc/ora*.*删除就行了
#rm –f /etc/ora*.*
ok了,现在一切也就差不多了,你已经可以建议自己的数据库
运行dbca时出现问题:
[oracle@oracle bin]$ ./dbca
/u01/app/jre/1.1.8/bin/../lib/i686/green_threads/libzip.so: symbol errno,
version GLIBC_2.0 not defined in file libc.so.6 with link time reference
(libzip.so)
Unable to initialize threads: cannot find class java/lang/Thread
Could not create Java VM
解决办法:
vi ~/.bash_profile
添加如下两行:
export LD_ASSUME_KERNEL=2.4.19
export THREADS_FLAG=native
保存退出并使之生效
source ~/.bash_profile
问题解决
建库中间出现错误:
ORA-29807
这个软件bug,先忽略,待数据库建好后:
$cd $ORACLE_HOME/rdbms/admin
$sqlplus
sql>@utlrp.sql
所有文中提到的补丁已经下载在本机中