下载 9i:
http://otn.oracle.com/software/products/oracle9i/htdocs/linuxsoft.htm
$ md5sum Linux9i_Disk1.cpio.gz Linux9i_Disk2.cpio.gz Linux9i_Disk3.cpio.gz
f1a99eb8c8aca1d69a9eeaa8858570d7 Linux9i_Disk1.cpio.gz
f2444c0fa53c898e7d2f78c184829d7d Linux9i_Disk2.cpio.gz
ec655402d8bc547ed031f14122da574b Linux9i_Disk3.cpio.gz
解包:
gunzip Linux9i_Disk1.cpio.gz Linux9i_Disk2.cpio.gz Linux9i_Disk3.cpio.gz
cpio -idmv < Linux9i_Disk1.cpio
cpio -idmv < Linux9i_Disk2.cpio
cpio -idmv < Linux9i_Disk3.cpio
刻盘:
mkisofs -r Disk1 | cdrecord -v --eject dev=0,0,0 speed=4 -
mkisofs -r Disk2 | cdrecord -v --eject dev=0,0,0 speed=4 -
mkisofs -r Disk3 | cdrecord -v --eject dev=0,0,0 speed=4 -
注:设备号可以通过执行 cdrecord -scanbus 得到
交换空间: 物理内存的两倍或者至少512MB
cat /proc/swaps
增加交换空间:
dd if=/dev/zero of=tmpswap bs=1k count=300000
chmod 600 tmpswap
mkswap tmpswap
swapon tmpswap
共享内存配置: 写入/etc/rc.d/rc.local或者/etc/rc.d/rc5.d/S78oradb:
echo 65536 > /proc/sys/fs/file-max #set max descriptors
echo 131072 > /proc/sys/kernel/shmmax #half of the physical memory
echo 4096 > /proc/sys/kernel/shmmni
echo 2097152 > /proc/sys/kernel/shmall
echo 100 32000 100 100 > /proc/sys/kernel/sem #semmsl semmns semopm semmni
echo 1024 65000 > /proc/sys/net/ipv4/ip_local_port_range
环境配置:写入oracle用户的.cshrc
ulimit -u 16384 #maximun processes
ulimit -n 66536 #maximum descriptors
"binutils" RPM 版本的问题
7.1 和 7.2 随带的 binutils RPM 包不兼容9i 的 Universial Installer,有两个解决方案:
a. “降级” Oracle 服务器上的 binutil :
ftp://ftp.redhat.com/pub/redhat/linux/7.0/en/os/i386/RedHat/RPMS/binutils-2.10.0.18-1.i386.rpm
#rpm -Uvh --force --nodeps binutils-2.10.0.18-1.i386.rpm #安装
注:安装完 Oracle 后,别忘了把 binutil 升级回去。
b. 在安装中等待出现下面的错误,然后手工修复:
"Error invoking target install of makefile /opt/oracle/product/9.0.1/plsql/lib/ins_plsql.mk"
请参考 Running Oracle Installation 以及 Oracle Installation Errors ,我推荐使用第二种方法。
安装 JDK
bzip2 -dc jdk118_v3-glibc-2.1.3.tar.bz2 | tar xf - -C /usr/local
ln -s /usr/local/jdk118_v3 /usr/local/java
建立 Oracle 用户
mkdir /home/oracle
groupadd -g 1001 dba
useradd -g 1001 -u 1001 -d /home/oracle oracle
passwd oracle
chown -R oracle:dba /home/oracle
注: 记得为oracle用户指定tcsh
建立相关目录
mkdir /home/tmp
chmod 777 /home/tmp
mkdir /home/oracle_app
chown -R oracle:dba /home/oracle_app
mkdir /home/oradata
mkdir /home/oradata/FREEDB
mkdir /home/oradata/FREEDB/admin
mkdir /home/oradata/FREEDB/admin/bdump
mkdir /home/oradata/FREEDB/admin/cdump
mkdir /home/oradata/FREEDB/admin/udump
mkdir /home/oradata/FREEDB/archive
mkdir /home/oradata/FREEDB/config
mkdir /home/oradata/FREEDB/control
mkdir /home/oradata/FREEDB/data
mkdir /home/oradata/FREEDB/redo
chown -R oracle:dba /home/oradata
ln -s /home/oradata /oradata
mkdir /var/opt/oracle
chown oracle:dba /var/opt/oracle
chmod 755 /var/opt/oracle
设置 Oracle 环境
以 Oracle 用户进入,建立 $HOME/.bashrc或者.cshrc
export ORACLE_BASE=/home/oracle_app
export ORACLE_HOME=/home/oracle_app
export ORACLE_SID=XFDB
export ORACLE_TERM=xterm
#export TNS_ADMIN= 设置这个变量,如果 sqlnet.ora, tnsnames.ora等不在$ORACLE_HOME/network/admin 目录下。
export NLS_LANG=american_america.ZHS16GBK;
export ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib:/usr/openwin/lib
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/td/lib:/usr/ucblib:/usr/local/lib
export LD_LIBRARY_PATH
# Set shell search paths:
PATH=/bin:/usr/bin:/usr/sbin:/etc:/opt/bin:/usr/ccs/bin:/usr/openwin/bin:/opt/local/GNU/bin
PATH=$PATH:/opt/local/bin:/opt/NSCPnav/bin:$ORACLE_HOME/bin
PATH=$PATH:/usr/local/samba/bin:/usr/ucb:
export PATH
# CLASSPATH must include the following JRE locations:
CLASSPATH=$CLASSPATH:$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
CLASSPATH=$CLASSPATH:$ORACLE_HOME/network/jlib
For RedHat 9.0:
export JAVA_HOME=/usr/local/java_1.4.1_or_above #否则runinstaller会挂死
export LD_ASSUME_KERNEL=2.4.1 #make sure to use java GUI tools such as netca, etc. when using Oracle.
启动 runInstaller
Oracle 不再支持字符模式的安装,因此必须设置 DISPLAY 变量。
a> yourdesktop:user$ xhost +oracleserver
b> 从 oracleserver 的控制台上以 Oracle 用户执行:
oracleserver:oracle$ export DISPLAY=yourdesktop:0.0
c> 从第一张 CD 或者从下载点(Disk1/RunInstaller)执行 runInstaller
oracleserver:oracle$ mount /mnt/cdrom
oracleserver:oracle$ /mnt/cdrom/runInstaller
注:不要 cd 到 /mnt/cdrom 去执行runInstaller,因为 unmount 不能把挂接着的 CD 卸下来
安装确认信息:
The base directory (Inventory Location): /home/oracle_app/oraInventory
UNIX Group Name (permission for updating Oracle software): dba
Full path name of the Oracle Home: /home/oracle_app
JDK Home Directory: /usr/local/java
忘记设置 DISPLAY 环境变量或者忘记在桌面 PC 上运行 xhost +oracleserver,将得到下面的错误:
Xlib: connection to ":0.0" refused by server
Xlib: Client is not authorized to connect to Server
对7.1,7.2,如果没有“降级” binutils 包,安装到第三张 CD 时会发生如下错误:
"Error invoking target install of makefile /opt/oracle/product/9.0.1/plsql/lib/ins_plsql.mk"
"Error invoking target install of makefile /opt/oracle/product/9.0.1/precomp/lib/ins-precomp.mk"
"Error invoking target install of makefile /opt/oracle/product/9.0.1/precomp/lib/ins-net-client"
"Error invoking target install of makefile /opt/oracle/product/9.0.1/precomp/lib/ins-oemagent"
解决方法:
编辑 $ORACLE_HOME/bin/genclntsh 把 LD_SELF_CONTAINED="-z defs" 改成: LD_SELF_CONTAINED=""
然后运行脚本:$ORACLE_HOME/bin/genclntsh
retry
ins_ctx.mk错误的解决方法:
edit $ORACLE_HOME/ctx/lib/env_ctx.mk.
add $(LDLIBFLAG)dl into the line INSO_LINK=-L$(CTXLIB) $(LDLIBFLAG)m right at the position.
retry.
Error in setting permissions of file/directory /home/oracle_app/jre/1.1.8/bin/i686/native_threads/.extract_args.
手工找到并从安装 jre 的目录下拷贝文件 .extract_args 到 runInstaller 提示文件丢失的地方。
For RedHat 9.0:
You will get make errors for oemadmin and a few others. Simply ignore.
其他注意事项:
当 runInstaller 开始配置工具时,"Oracle Net Configuration Assistant" 会挂起。简单的解决办法是停止其配置,重新配置或者继续安装,当其他安装结束后,再来一次“Retry"。
如果在安装中系统停止了反应,可能是没有足够的交换空间。如果发生这样的事情,只能等待到系统反应为止。
Oracle 的安装还需要运行 make 等程序,在生产环境中,你或许没有安装编译器和其他开发工具,所以,需要临时安装下面的几个包: cpp, egcs, egcs-c++, glibc-devel, kernel-headers 。
如果不能成功安装 9i 而需要重来的话,需要清除下面的文件和目录:
rm -rf /etc/oraInst.loc /etc/oratab /tmp/OraInstall
rm -rf $ORACLE_BASE/*
启动 Oracle 9i 数据库
9i 中已经没有 svrmgrl 了,所有的管理工作都通过 sqlplus 来完成:
dba$ sqlplus /nolog
SQL> connect / as sysdba
SQL> startup
补丁:
http://otn.oracle.com/support/patches.htm: 察看最新的patch set.
metalink.oracle.com: 下载patch, 需要csi注册账号,文件名为p<patch-id>_<oracle_ver>_<platform>.zip
以下以数据库SW为例
一、initSW.ora: 需要关注的参数
control_files
db_name = SW #for basic settings
db_block_size
db_block_buffers
shared_pool_size
log_buffer #for log and checkoint settings
log_checkpoint_interval
log_checkpoint_timeout
log_archive_start #for archive settings
log_archive_dest
log_archive_format
background_dump_dest #for log destinations
core_dump_dest
user_dump_dest
rollback_segments #for public rollback segments
job_queue_interval #for automatic jobs
job_queue_processes
二、 创建数据库
connect internal (for 8i) | connnect / as sysdba (for 9i)
startup nomount pfile=$ORACLE_HOME/dbs/initcws_0.orabangu
create database "FREELAND"
maxinstances 8
maxlogfiles 32
datafile
'/oradata/FREEDB/data/systemFREEDB01.dbf' size 100M,
'/oradata/FREEDB/data/systemFREEDB02.dbf' size 100M
logfile group 1 ( '/oradata/FREEDB/redo/logFREEDB1a.log',
'/oradata/FREEDB/redo/logFREEDB1b.log' ) size 10M,
group 2 ( '/oradata/FREEDB/redo/logFREEDB2a.log',
'/oradata/FREEDB/redo/logFREEDB2b.log' ) size 10M
character set ZHS16GBK
--- national character set ZHS16GBK;
disconnect
注:1. 8i 只需要80--100M的system表空间, 而9i需要150M--200M
2. 9i以后没有internal账号了。
3. 9i 不需要指定national character set。
三、 构建数据字典
connect internal/sys (8i) | connect / as sysdba or connect sys(9i)
@$ORACLE_HOME/rdbms/admin/catalog.sql
@$ORACLE_HOME/rdbms/admin/catproc.sql
@$ORACLE_HOME/rdbms/admin/catexp.sql
@$ORACLE_HOME/rdbms/admin/catdbsyn.sql
@$ORACLE_HOME/rdbms/admin/utlchain.sql
@/home/oracle_app/rdbms/admin/caths.sql
---Create Heterogeneous Services data dictionary objects.
@/home/oracle_app/rdbms/admin/otrcsvr.sql
---Creates stored procedures used by the Oracle Trace server.
@/home/oracle_app/rdbms/admin/dbmsstdx.sql
---使用trigger之前必须运行
connect system/manager
@/home/oracle_app/sqlplus/admin/pupbld.sql
@/home/oracle_app/ord/admin/ordinst.sql
@/home/oracle_app/sqlplus/admin/help/helptbl.sql
connect / as sysdba
create tablespace PAS_TMP temporary
datafile
'/oradata/FREEDB/data/tempFREEDB01.dbf' size 200M,
'/oradata/FREEDB/data/tempFREEDB02.dbf' size 200M
default storage
(initial 2M next 2M minextents 10 maxextents unlimited pctincrease 0);
create tablespace PAS_RBS
datafile
'/oradata/FREEDB/data/rbsFREEDB01.dbf' size 200M,
'/oradata/FREEDB/data/rbsFREEDB02.dbf' size 200M
default storage
(initial 1M next 1M minextents 10 maxextents unlimited pctincrease 0);
create tablespace PAS_IDX
datafile
'/dev/raw/raw6' size 512M autoextend on
default storage
(initial 2M next 2M minextents 10 maxextents unlimited pctincrease 0);
create tablespace PAS_IN_IDX
datafile
'/oradata/FREEDB/data/in_idxFREEDB01.dbf' size 200M autoextend on maxsize 1500M,
'/oradata/FREEDB/data/in_idxFREEDB02.dbf' size 200M autoextend on maxsize 1500M
default storage
(initial 2M next 2M minextents 10 maxextents unlimited pctincrease 0);
create tablespace PAS_BILL
datafile
'/dev/raw/raw1' size 512M autoextend on,
'/dev/raw/raw2' size 512M autoextend on,
'/dev/raw/raw3' size 512M autoextend on,
'/dev/raw/raw4' size 512M autoextend on,
'/dev/raw/raw5' size 512M autoextend on
default storage
(initial 2M next 2M minextents 20 maxextents unlimited pctincrease 0);
create tablespace PAS_FREE
datafile
'/oradata/FREEDB/data/inFREEDBa1.dbf' size 1000M autoextend on maxsize 2000M,
'/oradata/FREEDB/data/inFREEDBb2.dbf' size 1000M autoextend on maxsize 2000M
'/oradata/FREEDB/data/inFREEDBa3.dbf' size 1000M autoextend on maxsize 2000M,
'/oradata/FREEDB/data/inFREEDBb4.dbf' size 1000M autoextend on maxsize 2000M
'/oradata/FREEDB/data/inFREEDBa5.dbf' size 1000M autoextend on maxsize 2000M,
'/oradata/FREEDB/data/inFREEDBb6.dbf' size 1000M autoextend on maxsize 2000M
default storage
(initial 2M next 2M minextents 20 maxextents unlimited pctincrease 0);
create public rollback segment r01 tablespace PAS_RBS storage (optimal 20M);
create public rollback segment r02 tablespace PAS_RBS storage (optimal 20M);
create public rollback segment r03 tablespace PAS_RBS storage (optimal 20M);
create public rollback segment r04 tablespace PAS_RBS storage (optimal 20M);
create public rollback segment r05 tablespace PAS_RBS storage (optimal 20M);
create public rollback segment r06 tablespace PAS_RBS storage (optimal 20M);
alter rollback segment r01 online;
alter rollback segment r02 online;
alter rollback segment r03 online;
alter rollback segment r04 online;
alter rollback segment r05 online;
alter rollback segment r06 online;
alter user sys identified by "in core";
alter user system identified by "in core";
create user bill identified by "bill2002"
default tablespace PAS_BILL
temporary tablespace PAS_TMP
quota unlimited on PAS_BILL
quota unlimited on PAS_TMP;
create user xy identified by "xy2002"
default tablespace PAS_FREE
temporary tablespace PAS_TMP
quota unlimited on PAS_FREE
quota unlimited on PAS_TMP;
grant dba to bill with admin option;
alter user bill default role dba;
grant dba to xy with admin option;
alter user xy default role dba;
grant select any table to bill;
connect xy
grant select any table to bill; //for pl/sql
connect bill
grant select any table to xy; //for pl/sql