安装环境:
系统平台:VMWare Workstation 6.5.1+RHEL5.2
Oracle版本:Oracle10g Release2 10.2.0.1 for linux(x86)
安装前的准备工作:
1.下载软件:
 
下载位置
解压软件:
将下载的Oracle安装包传送到/home目录下,然后使用以下方法解压,用root用户登录,然后执行以下命令:
 
[root@oracle home]# ls
10201_database_linux32.zip lost+found
 
[root@oracle home]#  unzip 10201_database_linux32.zip
解压后产生一个包含安装文件的database目录:
[root@oracle home]# ls
10201_database_linux32.zip  database  lost+found
 
2.检查安装Oracle 10G 所需软件包:
rpm -q setarch make glibc libaio compat-libstdc++-33 compat-gcc-34 compat-gcc-34-c++ gcc libXp openmotif22 compat-db
如果没有安装上面提到的软件包,请自行安装,例如:
[root@oracle home]# yum install setarch make glibc libaio compat-libstdc++-33 compat-gcc-34 compat-gcc-34-c++ gcc libXp openmotif22 compat-db -y
 
3.修改Linux系统版本说明,骗过Oracle:

因为Oracle 10g官方只支持到RHEL4为止,所以需要更改版本说明,编辑/etc/redhat-release文件:
把5.2替换为4就可以了,而不是其他文章所说的redhat-4,注意版本问题.
 
4.修改系统内核参数:
[root@oracle home]# vim /etc/sysctl.conf
加入下面的参数:
kernel.shmmni = 4096
# semaphores: semmsl, semmns, semopm, semmni
kernel.sem = 250 32000 100 128
fs.file-max = 65536
net.ipv4.ip_local_port_range = 1024 65000
net.core.rmem_default=262144
net.core.rmem_max=262144
net.core.wmem_default=262144
net.core.wmem_max=262144
使更改立即生效,使用下面的命令:
[root@oracle home]# sysctl -p
 
5.建立安装Oracle的用户、组、目录:
[root@oracle home]# groupadd oinstall
[root@oracle home]# groupadd dba
[root@oracle home]# useradd -g oinstall -G dba oracle
[root@oracle home]# passwd oracle
[root@oracle home]# mkdir -p /opt/oracle/product/10.2.0/db_1   //数据库安装目录
[root@oracle home]# mkdir -p /opt/oracle/oradata                         //数据库数据存储目录
[root@oracle home]# mkdir -p /opt/oracle/ora_bak_recovery      //数据库备份恢复目录
[root@oracle home]# chown -R oracle:oinstall /opt/oracle/product/10.2.0/db_1/ /opt/oracle/oradata/ /opt/oracle/ora_bak_recovery/
 
6.设置oracle用户的shell limit:
[root@oracle home]#vim /etc/security/limits.conf    //增加如下内容
        oracle soft nproc 2047
        oracle hard nproc 16384
        oracle soft nofile 1024
        oracle hard nofile 65536
接下来更改/etc/pam.d/login文件,添加下面的内容,使shell limit生效:
[root@oracle home]# vim /etc/pam.d/login
        session    required     /lib/security/pam_limits.so
        session    required     pam_limts.so
 
7.系统要采用静态IP和英文界面,正规的/etc/hosts写法,这里略过.
 
8.配置oracle用户的环境变量,如下:
[oracle@oracle ~]$ vim .bash_profile
export ORACLE_BASE=/opt/oracle
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1
export ORACLE_SID=oradb
export ORACLE_TERM=xterm
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib:/usr/lib:/usr/local/bin
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
export TMP=/tmp
export TMPDIR=$TMP
export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
 
开始安装Oracle 10G数据库:
1.由于我的/tmp空间不够大,我把database移动到oracle用户目录下,并赋予Oracle用户可执行的权利,以便安装oracle
[root@oracle home]# mv database/ /home/oracle/
[root@oracle home]# chown -R oracle.oinstall /home/oracle/database/
 
2.使用oracle用户身份开始安装oracle 10G数据库:
以oracle身份登录系统,进入database目录下,执行./runInstaller开始安装
[oracle@oracle ~]$ cd database/
[oracle@oracle database]$ ./runInstaller
如果你是从root用户su - oracle用户的,你可能会碰到安装画面出不来的情况,请退出oracle用户,使用root用户执行xhost +( 注意有安全隐患),然后再切换到oracle用户执行安装脚本就可以了,出错的情况如下图所示:
3.在出现的画面上我们选择高级安装,如下图:
 
4.指定证书存放路径,如图所示:
 
5.选择安装的数据库类型及oracle所支持的语言,这里选择企业版,语言选择英文简体中文和繁体中文,如下图所示:
 
6.指定oracle环境变量,安装路径.因为我们在.bash_profile中已经声明,所以这里会自动填充.如下图所示:
 
7.Oracle开始进行安装前的检查工作,如下图所示:
 
8.选择配置选项,如下图所示:
 
9.选择创建的数据库模式,如下图所示:
 
10.指定数据库配置的相关选项(SID、字符集等),如下图所示:
 
11.选择数据库管理选项,如下图所示:
 
12.指定数据库存储选项,如下图所示:
 
13.指定数据库备份恢复选项,如下图所示:
 
14.指定数据库相关用户密码,如下图所示:
 
15.显示安装概要,如下图所示:
 
16.开始安装,如下图所示:
 
安装过程中的数据库配置助理:
 
 
17. 在上面的窗口点击OK后,会出现下图显示的内容:
需要root权限执行
[root@oracle home]#/opt/oracle/oraInventory/orainstRoot.sh
[root@oracle home]# /opt/oracle/product/10.2.0/db_1/root.sh
 
执行情况如下图所示:
 
18.点击执行安装配置脚本图示上的Ok后,出现安装结束的图示:
 
19.安装完成后改回RHEL版本信息,编辑/etc/redhat-release文件,把4改回5.2
 
后续管理:
 
1.安装完成后,首先应该启动监听器.
监听器接受客户端的连接请求,并在验证证书后创建数据库连接.要使用OEM或iSQL*PLUS,必须先启动监听器.
[oracle@oracle ~]$ lsnrctl start
[oracle@oracle ~]$ lsnrctl stop
 
2.使用Oracle Enterprise Manager 10g进行数据库控制
启动和停止OEM的命令为:
[oracle@oracle ~]$ emctl start dbconsole
[oracle@oracle ~]$ emctl stop dbconsole
 
在web浏览器中,输入:
http://oarcle.8866.org:1158/em (如果服务器没有进行DNS解析,则可以用IP地址)
用户名: SYS
口令:< 安装过程中建立的口令>
连接为: SYSDBA
 
3.使用iSQL*Plus访问数据库
启动和停止iSQL*Plus命令:
[oracle@oracle ~]$ isqlplusctl start
[oracle@oracle ~]$ isqlplusctl stop
 
iSQL*Plus是历史悠久的SQL*Plus交互式工具的基于web的版本,用于访问数据库.要使用iSQL*Plus,请单击OEM控制台相关连接部分中的iSQL*Plus链接,或将浏览器指向安装过程中提供的iSQL*Plus URL.
在web浏览器中,输入:
用户名:SYSTEM
口令:<安装过程中创建的口令>
连接标识:oradb
4.启动和停止数据库
 
启动和停止数据库的最简单方法是从OEM 控制台启动和停止.要从命令行执行此操作,请以oracle 身份登录后使用 SQL*Plus,如下所示:
启动:
[oracle@oracle ~]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Wed Jul 29 19:43:50 2009
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area  285212672 bytes
Fixed Size                  1218992 bytes
Variable Size              96470608 bytes
Database Buffers          184549376 bytes
Redo Buffers                2973696 bytes
Database mounted.
Database opened.
SQL> exit
 
关闭:
[oracle@oracle ~]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Wed Jul 29 19:40:58 2009
Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL> shudown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>exit

 
5.使用脚本管控数据库
编辑/etc/oratab文件,将orcl:/opt/oracle/product/10.2.0/db_1:N
改为oradb:/opt/oracle/product/10.2.0/db_1:Y
编辑 $ Oracle_HOME/bin/dbstart 文件,因为这个文件里面的ORACLE_HOME_LISTNER=/ade/vikrkuma_new/oracle路径有问题,改为
$ORACLE_HOME即可.
如果不修改的话,启动数据库会出现:
Failed to auto-start Oracle Net Listene using /ade/vikrkuma_new/oracle/bin/tnslsnr
以root身份登录,建立/etc/init.d/oracle文件,内容如下:
 
#!/bin/bash
#
# chkconfig: 345 99 10
# description:starts the oracle database deamons
# /etc/init.d/oracle
export ORACLE_BASE=/opt/oracle/
export ORACLE_SID=oradb
export ORA_HOME=/opt/oracle/product/10.2.0/db_1
export ORA_OWNER=oracle
export PATH=$PATH:$ORACLE_HOME/bin
status() {
pid=`ps -ef | grep ora_pmon | grep -v grep | awk '{print $8}'`
if [ "X$pid" = "X" ]
then
echo "Oracle10g is not running!"
exit 1
else
echo "Oracle10g is running!"
exit 0
fi
}
case $1 in
start)
echo -n "***Starting Oracle***"
su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl start"
su - $ORA_OWNER -c "$ORA_HOME/bin/dbstart"
;;
stop)
echo -n "***Stopping Oracle***"
su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl stop"
su - $ORA_OWNER -c "$ORA_HOME/bin/dbshut"
;;
restart)
echo -n "***Restarting Oracle***"
$0 stop
$0 start
;;
status)
status
;;
 
isqlstart)
echo "***Starting Oracle iSQL PLus***"
su - $ORA_OWNER -c "$ORA_HOME/bin/isqlplusctl start"
echo "*** Note:You can access service at url:http://$(hostname):5560/isqlplus"
;;
isqlstop)
echo "***Stopping Oracle iSQL Plus***"
su - $ORA_OWNER -c "$ORA_HOME/bin/isqlplusctl stop"
;;
emstart)
echo "***Starting Oracle Enterprise Manager 10g Database control***"
su - $ORA_OWNER -c "$ORA_HOME/bin/emctl start dbconsole"
echo "Note:You can access service as url:http://$(hostname):1158/em"
;;
emstop)
echo "***Stopping Oracle Enterprise Manager 10g Database control***"
su - $ORA_OWNER -c "$ORA_HOME/bin/emctl stop dbconsole"
;;
 
*)
echo $"Usage: $0 {start|stop|status|isqlstart|isqlstop|emstart|emstop}"
exit 1
esac
exit 0
 
给脚本加上可执行的权限,并添加到系统服务中:
[root@oracle ~]# chmod a+x /etc/init.d/oracle
[root@oracle ~]# chkconfig --add oracle
 
6.删除数据库方法:
1). 运行 $ORACLE_HOME/bin/localconfig delete
2). rm -rf $ORACLE_BASE/*
3). rm -f /etc/oraInst.loc /etc/oratab
4). rm -rf /etc/oracle
5). rm -f /etc/inittab.cssd
6). rm -f /usr/local/bin/coraenv /usr/local/bin/dbhome /usr/local/bin/oraenv
7). 删除oracle用户和组.
 
关于Oracle 11g Release 1 的安装
 
Oracle 11gR1 已经支持RHEL5了,所以不用再更改redhat-release文件.
另外安装所依赖的包有如下:
      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
      glibc-2.5-12
      glibc-common-2.5-12
      glibc-devel-2.5-12
      gcc-4.1.1-52
      gcc-c++-4.1.1-52
      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
 
其它的步骤就跟安装Oracle 10gR2 没有什么区别了.
                                                     (完)
                                             Feiwupiaoxue 2009.07.29