Installing Oracle RAC 10g Release 2 on Linux x86

来源:百度文库 编辑:神马文学网 时间:2024/04/26 09:23:27
目录
Overview
Background
Part I: Install Linux
Part II: Configure Linux for Oracle
Part III: Prepare the Shared Disks
Part IV: Install Oracle RAC Software
Conclusion
Overview
这篇文档是关于安装Oracle Database 10g Release 2 RAC database在一个常见的硬件环境中用于学习和研究。如果你是一个linux或者Oracle的新手,这个文档就是为你而作的。它将从基本的概念开始,使你一步一步了解Oracle RAC的安装过程。
我们将以最简单最少的步骤来完成安装。那就意味着,它可能并不是适合所有环境,特别是它不是为生产环境而搭建的,也没有达到最优的性能。
适合Oracle 10g Release 2 RAC 的3个linux版本是:
Red Hat Enterprise Linux  4 (RHEL4)
Red Hat Enterprise Linux 3 (RHEL3)
Novell SUSE Linux Enterprise Server 9
我们将涵盖两个Linux 2.6 kernel-based版本:RHEL4 and SLES9。RHEL3 没有包含。
Background
下面这幅图显示了Oracle RAC 10g Release 2主要的结构。集群的节点一般是独立服务器。
硬件
在硬件层,每一个RAC的节点共享了三种资源:
访问共享磁盘存储
通过一个内部网络连接
访问公共网络
共享磁盘存储
Oracle RAC是依靠一个共享的磁盘结构体系。数据库文件,在线重做日志和控制文件必须能够被集群内每一个节点访问。共享磁盘也可以存储在Oracle的集群注册和投票磁盘上。(稍候讨论)有很多种不同的方法来配置共享磁盘存储,包括直接访问磁盘(典型的是通过SCSI铜缆或光纤),存储区域网络(SAN)和网络存储(NAS)。
内部网络
每一个集群节点连接到其它节点通过一个高速网络,也就是大家所知的集群互联或者高速互联(HSI)。它使用Oracle的缓存合并技术(Cache Fusion)来有效的把每个节点主机的物理内存融合为一个独立缓冲区。Oracle缓存合并允许存储在某一台Oracle实例的数据也可以被其它实例通过内部网络高速访问。它同时保证了数据的完整,缓冲区的一致性通过一些锁定和同步机制。
典型的网络是由千M网卡构成,但是在数据量更大的环境,很多开发商也提供更低响应时间更高带宽的RAC解决方案。Linux也提供了一种并发物理网卡的方案,这里不会讨论它。
公共网络
为了维持高可用性,每个节点都被指派了一个虚拟IP地址。如果一个节点崩溃,那失败节点的IP被分配给正常节点,从而保证应用一直可以通过一个固定IP访问数据库。
配置集群的硬件设备
有很多种不同的RAC硬件方案。我们这里的配置是两个CPU,1GB的内存,两个千兆网卡,一个双通道SCSI主机控制器dual channel SCSI host bus adapter (HBA),和8个由铜钎连接到每个主机的SCSI磁盘(每个磁盘一个通道)。磁盘的配置为磁盘组,那就是说没有任何硬件RAID控制器。
软件
在软件层,在RAC中的每个节点需要:
操作系统
Oracle 集群软件
Oracle RAC 软件
Oracle自动存储管理 (ASM) 实例 (可选)
操作系统
Oracle RAC 支持很多种不同的操作系统。我们这里讲述的是在Linux下面的安装。操作系统必须使用适当的配置,例如安装必要的软件包,设置内核参数,配置网络,建立合适安全的账户,配置磁盘和创建目录结构。所有的这些任务,我们都会在稍后讨论。
Oracle集群软件的Oracle集群就绪服务
Oracle RAC 10g Release 1 介绍了Oracle 集群就绪服务(CRS),一种跨平台系统服务。在Release 2,Oracle重新把它命名为Oracle Clusterware。
集群软件包含两个文件:Oracle集群注册(OCR)和投票磁盘(Voting Disk)。OCR和Voting Disk 必须以裸分区或集群系统文件的形式存在于共享磁盘上。本指南说明了使用这两种方法创建 OCR 和 Voting Disk 的过程,并逐步演示了 CRS 的安装。
Oracle RAC 软件
Oracle RAC 10g Release 2 软件是RAC数据库的核心,它必须安装于每个集群节点。幸运的是,它可以通过Oracle Universal Installer (OUI)完成在每个节点的绝大多数安装工作。您只需在一个节点上安装 RAC — OUI 会完成其余的工作。
Oracle 自动存储管理(ASM)
ASM是Oracle 10g的一个新特性,它提供一个文件系统服务,逻辑卷管理和跨平台的软RAID。Oracle ASM能够条带化和镜像磁盘(stripe and mirror),从而实现了在数据库被加载的情况下添加或移除磁盘以及自动平衡 I/O 以避免“热点”。它还支持直接和异步的 I/O,并使用 Oracle9i 中引入的 Oracle 数据管理器 API(简化的 I/O 系统调用接口)。
Oracle ASM 并不是一个通用的文件系统,它仅仅是用于Oracle数据文件,重做日志,控制文件和RMAN 闪回区。ASM中的文件能够被数据库自动创建和管理(通过使用Oracle自动管理特性)或者DBA手工管理。应为ASM中的文件并不是由操作系统管理,唯一的备份和恢复方式是通过Recovery Manager (RMAN)。
ASM 作为单独的 Oracle 实例实现,只有它在运行时其他数据库才能访问它。ASM 需要的内存不多: 对大部分系统来说只需 64MB。 在 Oracle RAC 环境中,ASM 实例必须运行在每个集群节点上。
Part I: 安装Linux
安装和配置Linux是该文档描述的第一步。每个服务器需要3个IP地址:一个是内部网络地址,一个是公共网络地址,一个是虚拟IP地址。使用操作系统的网络配置工具分配内部和公共IP地址,但不要包括虚拟IP地址。虚拟IP通过Oracle虚拟IP配置助手(VIPCA)在Oracle RAC软件安装中配置。
Red Hat Enterprise Linux 4 (RHEL4)
必要的内核:
2.6.9-11.EL 或者更高
检验内核的命令:
# uname -r
2.6.9-22.ELsmp
Other required package versions (or higher):
binutils-2.15.92.0.2-10.EL4
compat-db-4.1.25-9
control-center-2.8.0-12
gcc-3.4.3-9.EL4
gcc-c++-3.4.3-9.EL4
glibc-2.3.4-2
glibc-common-2.3.4-2
gnome-libs-1.4.1.2.90-44.1
libstdc++-3.4.3-9.EL4
libstdc++-devel-3.4.3-9.EL4
make-3.80-5
pdksh-5.2.14-30
sysstat-5.0.5-1
xscreensaver-4.18-5.rhel4.2
检验安装包:
# rpm -q binutils compat-db control-center gcc gcc-c++ glibc glibc-common \
gnome-libs libstdc++ libstdc++-devel make pdksh sysstat xscreensaver
binutils-2.15.92.0.2-15
compat-db-4.1.25-9
control-center-2.8.0-12.rhel4.2
gcc-3.4.4-2
gcc-c++-3.4.4-2
glibc-2.3.4-2.13
glibc-common-2.3.4-2.13
gnome-libs-1.4.1.2.90-44.1
libstdc++-3.4.4-2
libstdc++-devel-3.4.4-2
make-3.80-5
pdksh-5.2.14-30.3
sysstat-5.0.5-1
xscreensaver-4.18-5.rhel4.9
SUSE Linux Enterprise Server 9 (SLES9)
需要设置的包:
Basis Runtime System
YaST
Graphical Base System
Linux Tools
KDE Desktop Environment
C/C++ Compiler and Tools (not selected by default)
不要安装:
Authentication Server (NIS, LDAP, Kerberos)
必须的内核:
2.6.5-7.97 或者更高
检验内核版本:
# uname -r
2.6.5-7.97-smp
其它需要的包的版本(或者更高):
gcc-3.3
gcc-c++-3.3.3-43
glibc-2.3.3-98.28
libaio-0.3.98-18
libaio-devel-0.3.98-18
make-3.80
openmotif-libs-2.2.2-519.1
检验安装包:
# rpm -q gcc gcc-c++ glibc libaio libaio-devel make openmotif-libs
gcc-3.3.3-43.24
gcc-c++-3.3.3-43.24
libaio-0.3.98-18.3
libaio-devel-0.3.98-18.3
make-3.80-184.1
openmotif-libs-2.2.2-519.1
Part II: 配置Linux
配置Oracle用户和用户组
下一步我们将创建维护和安装Oracle 10个Release 2软件的Linux用户和用户组。这些账户被命名为‘oracle’,组为'oinstall' 和 'dba'。用root用户在每个节点执行下面的命令:
/usr/sbin/groupadd oinstall
/usr/sbin/groupadd dba
/usr/sbin/useradd -m -g oinstall -G dba oracle
id oracle
Ex:
# /usr/sbin/groupadd oinstall
# /usr/sbin/groupadd dba
# /usr/sbin/useradd -m -g oinstall -G dba oracle
# id oracle
uid=501(oracle) gid=501(oinstall) groups=501(oinstall),502(dba)
用户ID和组ID在所有节点必须一致。使用id oracle命令查看信息,然后在剩余的节点创建Oracle用户和组:
/usr/sbin/groupadd -g 501 oinstall
/usr/sbin/groupadd -g 502 dba
/usr/sbin/useradd -m -u 501 -g oinstall -G dba oracle
Ex:
# /usr/sbin/groupadd -g 501 oinstall
# /usr/sbin/groupadd -g 502 dba
# /usr/sbin/useradd -m -u 501 -g oinstall -G dba oracle
# id oracle
uid=501(oracle) gid=501(oinstall) groups=501(oinstall),502(dba)
设置oracle账户的密码:
# passwd oracle
Changing password for user oracle.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
创建挂载点
现在我们来创建安装Oracle10g软件的挂载点。我们将以最灵活的命名习惯来创建目录结构Optimal Flexible Architecture (OFA)。如果想了解更多关于OFA的信息,请参考Oracle Database 10g Release 2 Installation Guide的附录D。
确保用root用户来运行下面的命令:
mkdir -p /u01/app/oracle
chown -R oracle:oinstall /u01/app/oracle
chmod -R 775 /u01/app/oracle
Ex:
# mkdir -p /u01/app/oracle
# chown -R oracle:oinstall /u01/app/oracle
# chmod -R 775 /u01/app/oracle
配置核心参数
在每个节点用root登录,然后配置Linux的核心参数。
cat >> /etc/sysctl.conf << EOF
kernel.shmall = 2097152
kernel.shmmax = 536870912
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.file-max = 658576
net.ipv4.ip_local_port_range = 1024 65000
net.core.rmem_default = 262144
net.core.wmem_default = 262144
net.core.rmem_max = 1048536
net.core.wmem_max = 1048536
EOF
/sbin/sysctl -p
在 SUSE Linux Enterprise Server 9.0 只需要:
设置内核参数 disable_cap_mlock 如下:
disable_cap_mlock = 1
Run the following command after completing the steps above:
/sbin/chkconfig boot.sysctl on
为oracle用户设置Shell的限制
Oracle建议设置进程的限制数和每个Linux账户的open files 数。用root用户运行下面的命令。
cat >> /etc/security/limits.conf << EOF
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
EOF
cat >> /etc/pam.d/login << EOF
session required /lib/security/pam_limits.so
EOF
For Red Hat Enterprise Linux releases, use the following:
cat >> /etc/profile << EOF
if [ \$USER = "oracle" ]; then
if [ \$SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
umask 022
fi
EOF
cat >> /etc/csh.login << EOF
if ( \$USER == "oracle" ) then
limit maxproc 16384
limit descriptors 65536
umask 022
endif
EOF
For Novell SUSE releases, use the following:
cat >> /etc/profile.local << EOF
if [ \$USER = "oracle" ]; then
if [ \$SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
umask 022
fi
EOF
cat >> /etc/csh.login.local << EOF
if ( \$USER == "oracle" ) then
limit maxproc 16384
limit descriptors 65536
umask 022
endif
EOF
配置Hangcheck Timer
所有 RHEL 版本:
modprobe hangcheck-timer hangcheck_tick=30 hangcheck_margin=180
cat >> /etc/rc.d/rc.local << EOF
modprobe hangcheck-timer hangcheck_tick=30 hangcheck_margin=180
EOF
所有 SLES 版本:
modprobe hangcheck-timer hangcheck_tick=30 hangcheck_margin=180
cat >> /etc/init.d/boot.local << EOF
modprobe hangcheck-timer hangcheck_tick=30 hangcheck_margin=180
EOF
配置 /etc/hosts
一些Linux的版本分配主机名loopback(127.0.0.1),那么需要改变它为:
/etc/hosts 使用下面的设置:
127.0.0.1 localhost.localdomain localhost
192.168.100.51 ds1-priv.orademo.org ds1-priv # ds1 private
192.168.100.52 ds2-priv.orademo.org ds2-priv # ds1 private
192.168.200.51 ds1.orademo.org ds1 # ds1 public
192.168.200.52 ds2.orademo.org ds2 # ds2 public
192.168.200.61 ds1-vip.orademo.org ds1-vip # ds1 virtual
192.168.200.62 ds2-vip.orademo.org ds2-vip # ds2 virtual
为用户互信而配置SSH
在安装Oracle RAC 10g Release 2的过程中,OUI需要在集群的其它节点拷贝文件和运行程序。为了赋予OUT运行的权限,你必须配置SSH达到用户互信(等价)。建立用户互信提供了一种安全可靠的方法在集群任一节点复制文件和运行程序而不需要输入密码。
第一步是生成SSH公共和内部密匙。现在有两个版本的SSH协议,版本1使用RSA;版本2使用DSA,所以我们将创建两种类型的密匙来确保SSH能够在不同协议下运行正常。Ssh密码生成程序将根据传递给它的参数生成任一类型的生成公共和内部密匙。
当你运行ssh生成器的时候,你将获得一个输入保存密匙位置的提示。直接按回车将使用默认位置。随后将输入一个口令。输入密码,再输入一次确认密码。
当你完成上述操作,你将有4个文件在~/.ssh目录:id_rsa, id_rsa.pub, id_dsa, 和 id_dsa.pub。id_rsa 和 id_dsa文件是你的内部密匙,不能告诉其它人。id_rsa.pub 和 id_dsa.pub是你的公共密匙,必须将其复制到集群中其他每个主机上。
在每个节点, 用oracle登录:
mkdir ~/.ssh
chmod 755 ~/.ssh
/usr/bin/ssh-keygen -t rsa
分别剪切和粘贴以下各行:
/usr/bin/ssh-keygen -t dsa
Ex:
$ mkdir ~/.ssh
$ chmod 755 ~/.ssh
$ /usr/bin/ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/oracle/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/oracle/.ssh/id_rsa.
Your public key has been saved in /home/oracle/.ssh/id_rsa.pub.
The key fingerprint is:
4b:df:76:77:72:ba:31:cd:c4:e2:0c:e6:ef:30:fc:37 oracle@ds1.orademo.org
$ /usr/bin/ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/home/oracle/.ssh/id_dsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/oracle/.ssh/id_dsa.
Your public key has been saved in /home/oracle/.ssh/id_dsa.pub.
The key fingerprint is:
af:37:ca:69:3c:a0:08:97:cb:9c:0b:b0:20:70:e3:4a oracle@ds1.orademo.org
现在每个节点的公共密匙文件id_rsa.pub 和 id_dsa.pub都应该复制为~/.ssh/authorized_keys文件。使用ssh复制每个文件内容为~/.ssh/authorized_keys文件。请注意,当您使用 ssh 第一次访问远程主机时,其 RSA 密钥将是未知的,从而将提示您确认是否希望连接该主机。 SSH 将记录该远程主机的 RSA 密钥,并在以后连接该主机时不再做出相关提示。
只需要在第一个节点上坐,用oracle登录(复制本地帐户的密钥,以便连接本地主机的 ssh 能够起作用)
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
现在复制密匙到其它节点,以便我们能使用ssh访问远程节点而无需密码。
ssh oracle@ds2 cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
(如果你剪切和粘贴这些命令,分别的运行这些命令。SSH每次都将提示你输入oracle用户密码,如果同时粘贴这些命令,那么剩下的命令将被装入缓冲区而无效)
ssh oracle@ds2 cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
chmod 644 ~/.ssh/authorized_keys
Ex:
$ cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
$ cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
$ ssh oracle@ds2 cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
The authenticity of host 'ds2 (192.168.200.52)' can't be established.
RSA key fingerprint is d1:23:a7:df:c5:fc:4e:10:d2:83:60:49:25:e8:eb:11.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'ds2,192.168.200.52' (RSA) to the list of known hosts.
oracle@ds2's password:
$ ssh oracle@ds2 cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
oracle@ds2's password:
$ chmod 644 ~/.ssh/authorized_keys
Now do the same for the second node. Notice that this time SSH will prompt for the passphrase you used when creating the keys rather than the oracle password. This is because the first node (ds1) now knows the public keys for the second node and SSH is now using a different authentication protocol.  Note, if you didn't enter a passphrase when creating the keys with ssh-keygen, you will not be prompted for one here.
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
ssh oracle@ds1 cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
ssh oracle@ds1 cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
chmod 644 ~/.ssh/authorized_keys
Ex:
$ cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
$ cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
$ ssh oracle@ds1 cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
The authenticity of host 'ds1 (192.168.200.51)' can't be established.
RSA key fingerprint is bd:0e:39:2a:23:2d:ca:f9:ea:71:f5:3d:d3:dd:3b:65.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'ds1,192.168.200.51' (RSA) to the list of known hosts.
Enter passphrase for key '/home/oracle/.ssh/id_rsa':
$ ssh oracle@ds1 cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
Enter passphrase for key '/home/oracle/.ssh/id_rsa':
$ chmod 644 ~/.ssh/authorized_keys
建立用户互信
最后,在生成完所有的密匙后,在生成密钥、复制文件并重复地输入口令和口令短语(安全性有意思吧?)你就可以建立用户互信了。 在建立用户互信后,不会再提示你输入口令。
在即将安装Oracle 10g Release 2软件的节点上以oracle登录:
exec /usr/bin/ssh-agent $SHELL
/usr/bin/ssh-add
Ex:
$ exec /usr/bin/ssh-agent $SHELL
$ /usr/bin/ssh-add
Enter passphrase for /home/oracle/.ssh/id_rsa:
Identity added: /home/oracle/.ssh/id_rsa (/home/oracle/.ssh/id_rsa)
Identity added: /home/oracle/.ssh/id_dsa (/home/oracle/.ssh/id_dsa)
(Note that user equivalence is established for the current session only. If you switch to a different session or log out and back in, you will have to run ssh-agent and ssh-add again to re-establish user equivalence.注意用户互信仅仅是当前会话有效。如果你切换了会话或者重新登录,你需要重新运行ssh-agent 和 ssh-add来建立用户互信)
测试连通性
如果所有的准备都OK了,你可以使用ssh登录,运行程序,复制文件在其它节点而不需要输入密码。你可以通过运行一个简单的date命令来检验远程节点的连通性。
$ ssh ds2 date
Sat Jan 21 13:31:07 PST 2006
在所有服务器上测试每个节点所有方向的连通性是非常重要的。这样会确保当 OUI 在 CRS 和数据库软件安装期间试图复制文件时不会出现类似以下的消息。 该消息只有在远程节点上第一次操作时才会出现,因此通过测试连通性,您不仅确保了远程操作的正常运行,还完成了初始的安全密钥交换。
The authenticity of host 'ds2 (192.168.200.52)' can't be established.
RSA key fingerprint is 8f:a3:19:76:ca:4f:71:85:42:c2:7a:da:eb:53:76:85.
Are you sure you want to continue connecting (yes/no)? yes
Part III: Prepare the Shared Disks配置共享磁盘
Oracle 集群软件和RAC都需要访问共享每个节点的磁盘。共享磁盘配置必须使用下面之一的方法。注意你不能使用“标准”的文件系统,诸如ext3,它不适合集群系统。
集群软件:
OCFS (Release 1 or 2)
裸设备
第三方集群文件系统诸如GPFS或者Veritas
RAC 数据库存储:
OCFS (Release 1 or 2)
ASM
裸设备
第三方集群文件系统诸如GPFS或者Veritas
这个向导包含了安装和使用OCFS2和ASM。如果你的共享磁盘数量很少,你可能希望使用OCFS2用于集群软件和RAC。如果的共享磁盘多一些,那么考虑使用ASM用于Oracle RAC 数据库文件,可以获得更好的性能。注意:ASM不能用于存储Oracle集群软件,集群软件必须比ASM先安装(ASM依靠集群软件的服务)。我们这里使用了OCFS2用于Oracle集群文件。
磁盘分区
为了使用OCFS2或者ASM,你必须可用的磁盘分区。这个章节描述了怎么创建OCFS2和ASM使用的分区。
警告:不正确的磁盘分区可能清除你硬盘上的所有数据。如果你没有确信怎么做,最后停下来寻求帮助,否则将会有丢失数据的风险。
这个例子使用/dev/sdb(一个空的SCSI 磁盘 未分区)来把所有磁盘创建成一个单独的分区(36GB)。
Ex:
# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.
设备即不能包含有效的DOS分区表也不能包含Sun,SGI或者OSF磁盘卷标。创建一个新的DOS卷标。在你决定在里面写入之前,改变只是在内存中。之后,当然,之前目录不能恢复。
这个磁盘的柱面设置为4427。这是没有错的,但是它大于1024,就可能导致下列一些问题:
1) software that runs at boot time在开机的时候运行的软件 (e.g., old versions of LILO)
2) booting and partitioning software from other OSs从其他源码导入和分割软件
(e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): p
Disk /dev/sdb: 255 heads, 63 sectors, 4427 cylinders
Units = cylinders of 16065 * 512 bytes
Device Boot Start End Blocks Id System
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-4427, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-4427, default 4427):
Using default value 4427
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
警告:如果你创建或者修改任何DOS 6.x分区,请参考fdisk手册需求额外的信息。
Syncing disks.
现在校验新的分区:
Ex:
# fdisk -l /dev/sdb
Disk /dev/sdb: 36.4 GB, 36420075008 bytes
255 heads, 63 sectors/track, 4427 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *           1        4427    35559846   83  Linux
Repeat the above steps for each disk to be partitioned.   Disk partitioning should be done from one node only.  When finished partitioning, run the 'partprobe' command as root on each of the remaining cluster nodes in order to assure that the new partitions are configured.
在每个磁盘重复上面的步骤。磁盘分区应该一个一个的做。当完成分区后,在每个集群节点用root用户运行'partprobe'命令,确保分区是正确的。
Ex:
# partprobe
Oracle 集群文件系统 (OCFS) Release 2
OCFS2是一个通用的集群文件系统用于使用存储Oracle集群软件文件,Oracle RAC数据库文件,Oracle软件,或者其它类型的存储了标准文件系统诸如ext3里面的文件。相比OCFS1,这是一个非常有意义的改进,OCFS1只支持Oracle集群软件文件和RAC数据库文件。
获得 OCFS2
OCFS2可以免费获得,包括三个RPM:一个kernel module,support tools, 和 console。各个Linux支持的kernel版本不同,所以要确认获得合适的kernel。OCFS2 kernel modules可以在下面的连接下载 http://oss.oracle.com/projects/ocfs2/files/,在http://oss.oracle.com/projects/ocfs2-tools/files/获得tools 和 console。
为了确认kernel的版本,你可以运行如下命令:
# uname -r
2.6.9-22.ELsmp
例如我下载了:
ocfs2console-1.0.3-1.i386.rpm
ocfs2-tools-1.0.3-1.i386.rpm
ocfs2-2.6.9-22.ELsmp-1.0.7-1.i686.rpm
在每个节点用root安装OCFS2:
# rpm -ivh ocfs2console-1.0.3-1.i386.rpm \
ocfs2-tools-1.0.3-1.i386.rpm \
ocfs2-2.6.9-22.ELsmp-1.0.7-1.i686.rpm
Preparing...                ########################################### [100%]
1:ocfs2-tools            ########################################### [ 33%]
2:ocfs2console           ########################################### [ 67%]
3:ocfs2-2.6.9-22.ELsmp   ########################################### [100%]
配置 OCFS2
用root运行 ocfs2console:
# ocfs2console
选择 Cluster → Configure Nodes
点击Add,输入集群中每个节点的Name 和IP Address。
添加完所有的节点后,点击Cluster --> Propagate配置。这将拷贝OCFS2配置到集群的每个节点。你可能会被要求输入root密码使用ssh传输配置文件。关闭console,点击FileàQuit。可以使用ocfs2console格式化和加载OCFS2分区,但,我们这里将使用命令行模式。
在系统启动时激活OCFS2:
用root,在每个节点运行下面命令,使得OCFS2在系统启动时加载:
/etc/init.d/o2cb enable
Ex:
# /etc/init.d/o2cb enable
Writing O2CB configuration: OK
Loading module "configfs": OK
Mounting configfs filesystem at /config: OK
Loading module "ocfs2_nodemanager": OK
Loading module "ocfs2_dlm": OK
Loading module "ocfs2_dlmfs": OK
Mounting ocfs2_dlmfs filesystem at /dlm: OK
Starting cluster ocfs2: OK
创建一个OCFS文件系统的挂载点
用root在每个节点运行,创建OCFS2文件系统挂载点目录。
Ex:
# mkdir /u03
Create the OCFS2 filesystem on the unused disk partition
在未使用的磁盘上创建OCFS2文件系统分区
The example below creates an OCFS2 filesystem on the unused /dev/sdc1 partition with a volume label of "/u03" (-L /u03), a block size of 4K (-b 4K) and a cluster size of 32K (-C 32K) with 4 node slots (-N 4).  See theOCFS2 Users Guide for more information on mkfs.ocfs2 command line options.
这个例子是在未使用的/dev/sdc1分区卷标"/u03" (-L /u03)上创建OCFS2文件系统,一种数据块大小4k(-b 4K)和一种集群大小32K(-C 32K)with 4 node slots (-N 4).  See theOCFS2 Users Guide for more information on mkfs.ocfs2 command line options.
Ex:
# mkfs.ocfs2 -b 4K -C 32K -N 4 -L /u03 /dev/sdc1
mkfs.ocfs2 1.0.3
Filesystem label=/u03
Block size=4096 (bits=12)
Cluster size=32768 (bits=15)
Volume size=36413280256 (1111245 clusters) (8889960 blocks)
35 cluster groups (tail covers 14541 clusters, rest cover 32256 clusters)
Journal size=33554432
Initial number of node slots: 4
Creating bitmaps: done
Initializing superblock: done
Writing system files: done
Writing superblock: done
Writing lost+found: done
mkfs.ocfs2 successful
装载OCFS2文件系统
在文件系统包含Oracle集群文件和RAC数据库文件后,我们必须确保这些文件的I/O是直接I/O(O_DIRECT)。在加载OCFS2文件系统时使用"datavolume"选项确保使用直接I/O。如果失败会导致数据库丢失。
Ex:
# mount -t ocfs2 -L /u03 -o datavolume /u03
Notice that the mount command uses the filesystem label (-L  u03) used during the creation of the filesystem. This is a handy way to refer to the filesystem without having to remember the device name.
注意mount命令使用文件系统卷标(-L  u03)。
检验OCFS2文件系统的加载,允许mount命令或者df:
# mount -t ocfs2
/dev/sdc1 on /u03 type ocfs2 (rw,_netdev,datavolume)
# df /u03
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sdc1             35559840    138432  35421408   1% /u03
下面在其它节点加载OCFS2文件系统.
为了在启动的时候自动的加载OCFS2文件,在每个节点的/etc/fstab添加一行。
LABEL=/u03   /u03    ocfs2   _netdev,datavolume,nointr 0 0
创建共享文件的目录
CRS 文件
mkdir /u03/oracrs
chown oracle:oinstall /u03/oracrs
chmod 775 /u03/oracrs
数据库文件
mkdir /u03/oradata
chown oracle:oinstall /u03/oradata
chmod 775 /u03/oradata
自动存储管理 (ASM)
ASM was a new storage option introduced with Oracle Database 10gR1 that provides the services of a filesystem, logical volume manager, and software RAID in a platform-independent manner. ASM can stripe and mirror your disks, allow disks to be added or removed while the database is under load, and automatically balance I/O to remove "hot spots." It also supports direct and asynchronous I/O and implements the Oracle Data Manager API (simplified I/O system call interface) introduced in Oracle9i.
ASM is not a general-purpose filesystem and can be used only for Oracle data files, redo logs, control files, and flash recovery area. Files in ASM can be created and named automatically by the database (by use of the Oracle Managed Files feature) or manually by the DBA. Because the files stored in ASM are not accessible to the operating system, the only way to perform backup and recovery operations on databases that use ASM files is through Recovery Manager (RMAN).
ASM is implemented as a separate Oracle instance that must be up if other databases are to be able to access it. Memory requirements for ASM are light: only 64 MB for most systems.
ASM是作为一个独立的实例来运行的,必须使得其它数据库能够访问它。它的最小内存是64M或者更多。
安装 ASM
在Linux平台,ASM能够使用裸设备或者通过ASMLib接口管理设备。Oracle建议使用后者,更加易于使用和更优的性能。ASMLib2.0可以在OTN免费下载(frsee download)。这个章节将描述通过使用ASMLib2.0来创建一个ASM实例,和创建一个使用的ASM进行磁盘管理的数据库。
选择你需要的ASMLib的版本
ASMLib 2.0包含3个Linux包:
oracleasmlib-2.0 - ASM 类库
oracleasm-support-2.0 – 用于管理 ASMLib
oracleasm - ASM 类库的核心模块
每个Linux版本都有它自己的ASMLib2.0包,每个版本都有相应的内核版本。下面的段落,讲述怎么检查自己需要的内核版本。
首先,用root登录运行下面的命令:
uname -rm
Ex:
# uname -rm
2.6.9-22.ELsmp i686
这个例子显示内核是2.6.9-22 kernel,为多处理系统,使用Intel i686 CPU。
使用这些信息在OTN上寻找正确的ASMLib包:
访问 http://www.oracle.com/technology/tech/linux/asmlib/index.html
选择你的Linux版本的连接
下载oracleasmlib和oracleasm-support包。
下载你的内核对应的oracleasm包。在这个例子里,使用oracleasm-2.6.9-22.ELsmp-2.0.0-1.i686.rpm。
接着,用root安装包,运行下面的命令:
rpm -Uvh oracleasm-kernel_version-asmlib_version.cpu_type.rpm \
oracleasmlib-asmlib_version.cpu_type.rpm \
oracleasm-support-asmlib_version.cpu_type.rpm
Ex:
# rpm -Uvh \
> oracleasm-2.6.9-22.ELsmp-2.0.0-1.i686.rpm \
> oracleasmlib-2.0.1-1.i386.rpm \
> oracleasm-support-2.0.1-1.i386.rpm
Preparing...                ########################################### [100%]
1:oracleasm-support      ########################################### [ 33%]
2:oracleasm-2.6.9-22.ELsm########################################### [ 67%]
3:oracleasmlib           ########################################### [100%]
配置 ASMLib
在使用ASMLib之前,你必须运行一个配置脚本来准备驱动程序。用root运行下面的命令,将出现以下提示。在每个节点运行。
# /etc/init.d/oracleasm configure
Configuring the Oracle ASM library driver.
This will configure the on-boot properties of the Oracle ASM library
driver.  The following questions will determine whether the driver is
loaded on boot and what permissions it will have.  The current values
will be shown in brackets ('[]').  Hitting without typing an
answer will keep that current value.  Ctrl-C will abort.
Default user to own the driver interface []: oracle
Default group to own the driver interface []: dba
Start Oracle ASM library driver on boot (y/n) [n]: y
Fix permissions of Oracle ASM disks on boot (y/n) [y]: y
Writing Oracle ASM library driver configuration:           [  OK  ]
Creating /dev/oracleasm mount point:                       [  OK  ]
Loading module "oracleasm":                                [  OK  ]
Mounting ASMlib driver filesystem:                         [  OK  ]
Scanning system for ASM disks:                             [  OK  ]
接下来告诉ASM驱动使用哪个磁盘。Oracle建议每个磁盘包含一个单独完整的磁盘分区。参考前面的章节关于分区的内容。
在每个节点用root运行下面的命令标记用于ASMLib的磁盘:
/etc/init.d/oracleasm createdisk DISK_NAME device_name
Tip: Enter the DISK_NAME in UPPERCASE letters.
Ex:
# /etc/init.d/oracleasm createdisk VOL1 /dev/sdb1
Marking disk "/dev/sdb1" as an ASM disk:                   [  OK  ]
# /etc/init.d/oracleasm createdisk VOL1 /dev/sdc1
Marking disk "/dev/sdc1" as an ASM disk:                   [  OK  ]
# /etc/init.d/oracleasm createdisk VOL1 /dev/sdd1
Marking disk "/dev/sdd1" as an ASM disk:                   [  OK  ]
检验 ASMLib 标记到磁盘:
# /etc/init.d/oracleasm listdisks
VOL1
VOL2
VOL3
On all other cluster nodes, run the following command as root to scan for configured ASMLib disks:
/etc/init.d/oracleasm scandisks
Part IV: Install Oracle Software安装Oracle软件
Oracle Database 10g Release 2能在OTN下载。Oracle提供一个开发和测试的免费license。但是不能用于生产环境。关于完整版本的license说明见OTN。
使用oracle用户登录
创建一个目录,用于放置安装文件:
mkdir 10gR2
在OTN下载数据库,用浏览器访问http://www.oracle.com/technology/software/products/database/oracle10g/htdocs/10201linuxsoft.html. 找到合适的版本,阅读License说明,如果你没有什么异议,点击I Accept。
点击10201_database_linux32.zip连接,保存文件到你创建的目录。
还要下载Oracle Clusterware Release 2,点击10201_clusterware_linux32.zip连接并保存文件。
解压文件:
cd 10gR2
unzip 10201_database_linux32.zip
unzip 10201_clusterware_linux32.zip
建立用户互信和设置环境变量
如果你没有准备好做这些,登录oracle,在每个节点确立用户互信:
exec /usr/bin/ssh-agent $SHELL
/usr/bin/ssh-add
Enter passphrase for /home/oracle/.ssh/id_rsa:
Identity added: /home/oracle/.ssh/id_rsa (/home/oracle/.ssh/id_rsa)
Identity added: /home/oracle/.ssh/id_dsa (/home/oracle/.ssh/id_dsa)
Set the ORACLE_BASE environment variable:
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
安装 Oracle Clusterware
在安装数据库前,你必须先安装Oracle集群件。Oracle集群件需要在节点间共享两个文件:Oracle Cluster Registry (100MB)和Voting Disk (20MB)。这些文件可能存储在裸设备或者在一个集群文件系统中。(NFS也是通过认证的NAS系统,在本文并没有讨论)Oracle ASM可能不会使用这些文件,因为ASM依靠集群件的服务。本文将使用OCFS2作为集群文件系统来存储Oracle Cluster Registry 和 Voting Disk 文件。
开始安装,运行 "runInstaller" 在 "clusterware" 目录:
Welcome
点击 Next
Specify Inventory Directory and Credentials
The defaults should be correct
Click on Next
Specify Home Details
Name: OraCRS_Home
Path: /u01/app/oracle/product/crs
3.
Product-Specific Prerequisite Checks
Correct any problems found before proceeding.
Click on Next
Specify Cluster Configuration
Enter the cluster name (or accept the default of "crs");
Specify Network Interface Usage - Specify the Interface Type (public, private, or "do no use") for each interface
Specify Oracle Cluster Registry (OCR) Location
Choose External Redundancy and enter the full pathname of the OCR file (ex: /u03/oracrs/ocr.crs).
Specify Voting Disk Location
Choose External Redundancy and enter the full pathname of the voting disk file (ex: /u03/oracrs/vote.crs)
Summary
Click on Install
Execute Configuration Scripts
Execute the scripts as root on each node, one at a time, starting with the installation node.
Do not run the scripts simultaneously. Wait for one to finish before starting another.
Click on OK to dismiss the window when done.
Clusterware 安装后
检验安装是否成功,通过运行olsnodes($ORACLE_BASE/product/crs/bin),例如:
$ /u01/app/oracle/product/crs/bin/olsnodes
ds1
ds2
当Oracle Clusterware安装运行后,现在就该安装Oracle RAC软件了。
创建ASM 实例
如果你计划使用OCFS2作为数据库存储,那么就跳过这个章节,继续创建RAC数据库。按下面的步骤来使用ASM,在每个节点创建ASM实例。请确认你已经安装好了ASMLib。
Start the installation using "runInstaller" from the "database" directory:
Welcome
Click on Next
Select Installation Type
Select Enterprise Edition
Click on Next
Specify Home Details
Name:   Ora10gASM
Path:      /u01/app/oracle/product/10.2.0/asm
Note:Oracle recommends using a different ORACLE_HOME for ASM than the ORACLE_HOME used for the database for ease of administration.
Click on Next
Specify Hardware Cluster Installation Mode
Select Cluster Installation
Click on Select All
Click on Next
Product-specific Prerequisite Checks
If you've been following the steps in this guide, all the checks should pass without difficulty. If one or more checks fail, correct the problem before proceeding.
Click on Next
Select Configuration Option
Select Configure Automatic Storage Management (ASM)
Enter the ASM SYS password and confirm
Click on Next
Configure Automatic Storage Management
Disk Group Name:  DATA
Redundancy
- High mirrors data twice.
- Normal mirrors data once.  This is the default.
- External does not mirror data within ASM. This is typically used if an external RAID array is providing redundancy.
Add Disks
The disks you configured for use with ASMLib are listed as Candidate Disks.  Select each disk you wish to include in the disk group.
Click on Next
Summary
A summary of the products being installed is presented.
Click on Install.
Execute Configuration Scripts
At the end of the installation, a pop up window will appear indicating scripts that need to be run as root.  Login as root and run the indicated scripts.
Click on OK when finished.
End of Installation
Make note of the URLs presented in the summary, and click on Exit when ready.
Congratulations! Your new Oracle ASM Instance is up and ready for use.
创建RAC 数据库
Start the installation using "runInstaller" from the "database" directory:
Welcome
Click on Next
Select Installation Type
Select Enterprise Edition
Click on Next
Specify Home Details
Name:   OraDb10g_home1
Path:      /u01/app/oracle/product/10.2.0/db_1
Note:Oracle recommends using a different ORACLE_HOME for the database than the ORACLE_HOME used for ASM.
Click on Next
Specify Hardware Cluster Installation Mode
Select Cluster Installation
Click on Select All
Click on Next
Product-specific Prerequisite Checks
If you've been following the steps in this guide, all the checks should pass without difficulty. If one or more checks fail, correct the problem before proceeding.
Click on Next
Select Configuration Option
Select Create a Database
Click on Next
Select Databse Configuration
Select General Purpose
Click on Next
Specify Database Configuration Options
Database Naming:  Enter the Global Database Name and SID
Database Character Set:  Accept the default
Database Examples:  Select Create database with sample schemas
Click on Next
Select Database Management Option
Select Use Database Control for Database Management
Click on Next
Specify Database Storage Option
If you are using OCFS2 for database storage
Select File System
Specify Database fle location: Enter the path name to the OCFS2 filesystem directory you wish to use.
ex: /u03/oradata/racdemo
If you are using ASM for database storage
Select Automatic Storage Management (ASM)
Click on Next
Specify Backup and Recovery Options
Select Do not enable Automated backups
Click on Next
For ASM Installations Only:
Select ASM Disk Group
Select the DATA disk group created in the previous section
Click on Next
Specify Database Schema Passwords
Select Use the same password for all the accounts
Enter the password and confirm
Click on Next
Summary
A summary of the products being installed is presented.
Click on Install.
Configuration Assistants
The Oracle Net, Oracle Database, and iSQL*Plus configuration assistants will run automatically
Execute Configuration Scripts
At the end of the installation, a pop up window will appear indicating scripts that need to be run as root.  Login as root and run the indicated scripts.
Click on OK when finished.
End of Installation
Make note of the URLs presented in the summary, and click on Exit when ready.
Congratulations! Your new Oracle Database is up and ready for use.