分类: Oracle
2010-07-01 18:45:45
2007 年 1 月发表
于 10 月份 Oracle OpenWorld 2006 上推介的 Oracle 坚不可摧的 Linux 旨在为 Red Hat Linux 提供企业级支持服务,更快地修复错误,以及显著降低支持价格。此外,Oracle 自己的 Enterprise Linux(基于包含额外错误修补的 Red Hat Advanced Server 第 4 版 (Update 4))提供免费。
因此,现在可以通过 VMware Server(VMware 提供的一个免费虚拟环境)在家用电脑上免费使用运行在 Red Hat Advanced Server 上的 Oracle 真正应用集群 (RAC) 10g。
VMware Server 允许您在一台物理计算机上运行多个操作系统。每个虚拟机都是一个独立的操作环境,并带有一组自己的虚拟组件,如磁盘、处理器和内存。虚拟技术在计算环境中十分有用,它允许您在同一物理主机上独立地开发和测试软件以防止数据或软件损坏。VMware 软件广泛地用于服务器整合,以降低总拥有成本并加快应用程序开发和测试周期。
在本指南中,您将了解如何安装和配置两个在 Enterprise Linux 和 VMware Server 上运行 Oracle RAC 10g 第 2 版的节点。注意,本指南仅用于教学/评估目的;Oracle 及其他供应商不会为本配置提供支持。
本指南分为以下几个部分:
在本指南中,您将安装 32 位 Linux 客户操作系统。只有在主机上运行的以下 64 位处理器支持 64 位客户操作系统:
如果您决定安装 64 位客户操作系统,请确定上面列出了您的处理器。您还需要确保在 BIOS 中启用了虚拟技术 (VT)。一些主流制造商在默认情况下禁用了该技术。提供了有关处理器兼容性的其他信息。
要验证您的处理器是否受支持,请从 VMware 网站处理器兼容性检查工具。
为每个虚拟机至少分配 700MB 内存;为所有虚拟机预留至少 30GB 磁盘空间。
主机操作系统环境概况:
主机名 | 操作系统 | 处理器 | 内存 | 磁盘 | 网卡 |
pacu | Windows XP Professional Service Pack 2(32 位) | Intel Pentium 4 550, 3.4MHz, HT | 2 GB DDR2 SDRAM, 533 MHz | 250 GB, Ultra ATA/133, 7200 RPM | Intel Pro/1000 MT |
客户操作系统环境概况:
主机名 | 操作系统 | 处理器 | 内存 |
rac1 | Oracle Enterprise Linux 4(32 位) | 1 | 700 MB |
rac2 | Oracle Enterprise Linux 4(32 位) | 1 | 700 MB |
虚拟磁盘布局概况:
主机操作系统上的虚拟磁盘 | 客户操作系统上的虚拟磁盘 | 虚拟设备节点 | 大小 (MB) | 描述 |
d:vmraclocaldisk.vmdk | /dev/sda1 /dev/sda2 /dev/sda3 | SCSI 0:0 | 20 | “/”挂载点 交换空间 Oracle 二进制文件 |
d:vmracsharedstorageocfs2disk.vmdk | /dev/sdb | SCSI 1:0 | 512 | OCFS2 磁盘 |
d:vmracsharedstorageasmdisk1.vmdk | /dev/sdc | SCSI 1:1 | 3072 | ASM 磁盘组 1 |
d:vmracsharedstorageasmdisk2.vmdk | /dev/sdd | SCSI 1:2 | 3072 | ASM 磁盘组 1 |
d:vmracsharedstorageasmdisk3.vmdk | /dev/sde | SCSI 1:3 | 2048 | ASM 闪回恢复区 |
(要配置共享存储,客户 OS 不能与共享存储共享同一个 SCSI 总线。指定客户 OS 使用 SCSI0,共享磁盘使用 SCSI1。)
RAC 数据库环境概况:
主机名 | ASM 实例名 | RAC 实例名 | 数据库名 | 数据库文件存储 | OCR 与表决磁盘 (Voting Disk) |
rac1 | +ASM1 | devdb1 | devdb | ASM | OCFS2 |
rac2 | +ASM2 | devdb2 | devdb | ASM | OCFS2 |
您将在每个节点上安装 Oracle 主目录供冗余使用。每个节点上的 ASM 和 Oracle RAC 实例共享同一个 Oracle 主目录。
要创建和配置第一个虚拟机,您需要添加虚拟硬件设备,如磁盘和处理器。在继续执行安装之前,请创建以下 windows 文件夹以存放虚拟机和共享存储。
D:>mkdir vmracrac1 D:>mkdir vmracrac2 D:>mkdir vmracsharedstorage
双击桌面上的 VMware Server 图标以启动应用程序:
重复步骤 16-24 以创建四个虚拟 SCSI 硬盘 — ocfs2disk.vmdk (512MB)、asmdisk1.vmdk (3GB)、asmdisk2.vmdk (3GB) 和 asmdisk3.vmdk (2GB)。
最后,额外添加一个虚拟网卡以用于专用互联,并移除软盘驱动器(如果有)。
修改虚拟机配置文件。还需要设置其他参数以启用两个虚拟 RAC 节点之间的磁盘共享。打开配置文件 d:vmracrac1Red Hat Enterprise Linux 4.vmx,并添加下面列出的粗体参数。
config.version = "8" virtualHW.version = "4" scsi0.present = "TRUE" scsi0.virtualDev = "lsilogic" memsize = "700" scsi0:0.present = "TRUE" scsi0:0.fileName = "localdisk.vmdk" ide1:0.present = "TRUE" ide1:0.fileName = "auto detect" ide1:0.deviceType = "cdrom-raw" floppy0.fileName = "A:" Ethernet0.present = "TRUE" displayName = "rac1" guestOS = "rhel4" priority.grabbed = "normal" priority.ungrabbed = "normal" disk.locking = "FALSE" diskLib.dataCacheMaxSize = "0" scsi1.sharedBus = "virtual" scsi1.present = "TRUE" scsi1:0.present = "TRUE" scsi1:0.fileName = "D:vmracsharedstorageocfs2disk.vmdk" scsi1:0.mode = "independent-persistent" scsi1:0.deviceType = "disk" scsi1:1.present = "TRUE" scsi1:1.fileName = "D:vmracsharedstorageasmdisk1.vmdk" scsi1:1.mode = "independent-persistent" scsi1:1.deviceType = "disk" scsi1:2.present = "TRUE" scsi1:2.fileName = "D:vmracsharedstorageasmdisk2.vmdk" scsi1:2.mode = "independent-persistent" scsi1:2.deviceType = "disk" scsi1:3.present = "TRUE" scsi1:3.fileName = "D:vmracsharedstorageasmdisk3.vmdk" scsi1:3.mode = "independent-persistent" scsi1:3.deviceType = "disk" scsi1.virtualDev = "lsilogic" ide1:0.autodetect = "TRUE" floppy0.present = "FALSE" Ethernet1.present = "TRUE" Ethernet1.connectionType = "hostonly"
并解压缩文件:
恭喜,您已经在 VMware Server 上安装了 Enterprise Linux!
安装 VMware 工具。VMware 工具要求同步主机和客户机的时间。在 VMware 控制台上,以 root 用户身份登录。
"/bin/tar: ./inventory/Components21/oracle.ordim.server/10.2.0.1.0: time stamp 2006-11-04 06:24:04 is 25 s in the future"要确保成功安装 Oracle RAC,虚拟机上的时间必须与主机上的时间同步。执行下面的步骤,以 root 用户身份同步时间。
#boot=/dev/sda default=0 timeout=5 splashimage=(hd0,0)/boot/grub/splash.xpm.gz hiddenmenu title Enterprise (2.6.9-42.0.0.0.1.ELsmp) root (hd0,0) kernel /boot/vmlinuz-2.6.9-42.0.0.0.1.ELsmp ro root=LABEL=/ rhgb quiet clock=pit nosmp noapic nolapic initrd /boot/initrd-2.6.9-42.0.0.0.1.ELsmp.img title Enterprise-up (2.6.9-42.0.0.0.1.EL) root (hd0,0) kernel /boot/vmlinuz-2.6.9-42.0.0.0.1.EL ro root=LABEL=/ rhgb quiet clock=pit nosmp noapic nolapic initrd /boot/initrd-2.6.9-42.0.0.0.1.EL.img
# reboot
# groupadd oinstall # groupadd dba # mkdir -p /export/home/oracle /ocfs # useradd -d /export/home/oracle -g oinstall -G dba -s /bin/ksh oracle # chown oracle:dba /export/home/oracle /u01 # passwd oracle New Password: Re-enter new Password: passwd: password successfully changed for oracle创建 oracle 用户环境文件。
/export/home/oracle/.profile
export PS1="`/bin/hostname -s`-> " export EDITOR=vi export ORACLE_SID=devdb1 export ORACLE_BASE=/u01/app/oracle export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1 export ORA_CRS_HOME=$ORACLE_BASE/product/10.2.0/crs_1 export LD_LIBRARY_PATH=$ORACLE_HOME/lib export PATH=$ORACLE_HOME/bin:$ORA_CRS_HOME/bin:$PATH umask 022创建文件系统目录结构。以 oracle 用户身份执行
rac1-> mkdir -p $ORACLE_BASE/admin rac1-> mkdir -p $ORACLE_HOME rac1-> mkdir -p $ORA_CRS_HOME rac1-> mkdir -p /u01/oradata/devdb
提高 Oracle 用户的 shell 限制。使用文本编辑器将下面列出的行添加到 /etc/security/limits.conf、/etc/pam.d/login 和 /etc/profile。其他信息可以从中获得。
/etc/security/limits.conf
oracle soft nproc 2047 oracle hard nproc 16384 oracle soft nofile 1024 oracle hard nofile 65536/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安装 Enterprise Linux 软件程序包。安装 Oracle 软件需要以下附加程序包。如果您已经安装了 64 位版本的 Enterprise Linux,则安装程序应该已安装了这些程序包。
从 ISO CD 解压缩这些程序包,并以 root 用户身份执行下面的命令。
# ls libaio-0.3.105-2.i386.rpm openmotif21-2.1.30-11.RHEL4.6.i386.rpm # # rpm -Uvh *.rpm warning: libaio-0.3.105-2.i386.rpm: V3 DSA signature: NOKEY, key ID b38a8516 Preparing... ########################################### [100%] 1:openmotif21 ########################################### [ 50%] 2:libaio ########################################### [100%]配置内核参数。使用文本编辑器将下面列出的行添加到 /etc/sysctl.conf。要使更改立即生效,请执行 /sbin/sysctl –p。
# more /etc/sysctl.conf kernel.shmall = 2097152 kernel.shmmax = 2147483648 kernel.shmmni = 4096 kernel.sem = 250 32000 100 128 fs.file-max = 65536 net.ipv4.ip_local_port_range = 1024 65000 net.core.rmem_default = 1048576 net.core.rmem_max = 1048576 net.core.wmem_default = 262144 net.core.wmem_max = 262144修改 /etc/hosts 文件。
# more /etc/hosts 127.0.0.1 localhost 172.16.4.182 rac1 rac1 172.16.4.184 rac1-vip rac1-vip 10.10.10.31 rac1-priv rac1-priv 172.16.4.183 rac2 rac2 172.16.4.185 rac2-vip rac2-vip 10.10.10.32 rac2-priv rac2-priv配置 hangcheck timer 内核模块。hangcheck timer 内核模块可监控系统的运行情况,并重新启动出现故障的 RAC 节点。它使用两个参数,即 hangcheck_tick(定义系统检查频率)和 hangcheck_margin(定义在重置 RAC 节点前的最大挂起延时)来确定节点是否出现故障。
在 /etc/modprobe.conf 中添加以下行,以设置 hangcheck 内核模块参数。
/etc/modprobe.conf
options hangcheck-timer hangcheck_tick=30 hangcheck_margin=180
要立即加载模块,执行“modprobe -v hangcheck-timer”。
为 OCFS2 和 Oracle ASM 创建磁盘分区。为 OCFS2 (/dev/sdb) 和 Oracle ASM(/dev/sdc、/dev/sdd、/dev/sde)准备一组原始磁盘。
在 rac1 上,以 root 用户身份执行
# fdisk /dev/sdb
Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-512, default 1): Using default value 1 Last cylinder or +size or +sizeM or +sizeK (1-512, default 512): Using default value 512 Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.
# fdisk /dev/sdc
Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-391, default 1): Using default value 1 Last cylinder or +size or +sizeM or +sizeK (1-391, default 391): Using default value 391 Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.
# fdisk /dev/sdd
Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-391, default 1): Using default value 1 Last cylinder or +size or +sizeM or +sizeK (1-391, default 391): Using default value 391 Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.
# fdisk /dev/sde
Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-261, default 1): Using default value 1 Last cylinder or +size or +sizeM or +sizeK (1-261, default 261): Using default value 261 Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.
# fdisk -l
Disk /dev/sda: 21.4 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sda1 * 1 910 7309543+ 83 Linux /dev/sda2 911 1170 2088450 82 Linux swap /dev/sda3 1171 2610 11566800 83 Linux Disk /dev/sdb: 536 MB, 536870912 bytes 64 heads, 32 sectors/track, 512 cylinders Units = cylinders of 2048 * 512 = 1048576 bytes Device Boot Start End Blocks Id System /dev/sdb1 1 512 524272 83 Linux Disk /dev/sdc: 3221 MB, 3221225472 bytes 255 heads, 63 sectors/track, 391 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sdc1 1 391 3140676 83 Linux Disk /dev/sdd: 3221 MB, 3221225472 bytes 255 heads, 63 sectors/track, 391 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sdd1 1 391 3140676 83 Linux Disk /dev/sde: 2147 MB, 2147483648 bytes 255 heads, 63 sectors/track, 261 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sde1 1 261 2096451 83 Linux安装 oracleasmlib 程序包。 从 OTN ASM 库,并以 root 用户身份安装 ASM RPM。
# rpm -Uvh oracleasmlib-2.0.2-1.i386.rpm Preparing... ########################################### [100%] 1:oracleasmlib ########################################### [100%]
在这个阶段,您应该已经安装了以下 ASM 程序包。
[root@rac1 swdl]# rpm -qa | grep oracleasm oracleasm-support-2.0.3-2 oracleasm-2.6.9-42.0.0.0.1.ELsmp-2.0.3-2 oracleasmlib-2.0.2-1为 ASM 磁盘映射原始设备。仅当您打算使用标准 Linux I/O 创建 ASM 磁盘时,才需要原始设备映射。创建 ASM 磁盘的另一个方法是使用 Oracle 提供的 ASM 库驱动程序。稍后,您将使用 ASM 库驱动程序配置 ASM 磁盘。
执行以下任务,将原始设备映射到先前创建的共享分区。每次引导集群节点时,原始设备都必须与块设备绑定。
将以下行添加到 /etc/sysconfig/rawdevices 中。
/etc/sysconfig/rawdevices
/dev/raw/raw1 /dev/sdc1 /dev/raw/raw2 /dev/sdd1 /dev/raw/raw3 /dev/sde1要使映射立即生效,以 root 用户身份执行以下命令:
# /sbin/service rawdevices restart Assigning devices: /dev/raw/raw1 --> /dev/sdc1 /dev/raw/raw1: bound to major 8, minor 33 /dev/raw/raw2 --> /dev/sdd1 /dev/raw/raw2: bound to major 8, minor 49 /dev/raw/raw3 --> /dev/sde1 /dev/raw/raw3: bound to major 8, minor 65 done # chown oracle:dba /dev/raw/raw[1-3] # chmod 660 /dev/raw/raw[1-3] # ls -lat /dev/raw/raw* crw-rw---- 1 oracle dba 162, 3 Nov 4 07:04 /dev/raw/raw3 crw-rw---- 1 oracle dba 162, 2 Nov 4 07:04 /dev/raw/raw2 crw-rw---- 1 oracle dba 162, 1 Nov 4 07:04 /dev/raw/raw1
以 oracle 用户身份执行
rac1-> ln -sf /dev/raw/raw1 /u01/oradata/devdb/asmdisk1 rac1-> ln -sf /dev/raw/raw2 /u01/oradata/devdb/asmdisk2 rac1-> ln -sf /dev/raw/raw3 /u01/oradata/devdb/asmdisk3
修改 /etc/udev/permissions.d/50-udev.permissions。原始设备在引导时会重新映射。默认情况下,在引导时原始设备的拥有者将更改为 root 用户。如果拥有者不是 oracle 用户,则 ASM 在访问共享分区时会出现问题。在 /etc/udev/permissions.d/50-udev.permissions 中为原始行“raw/*:root:disk:0660”添加注释,然后添加一个新行“raw/*:oracle:dba:0660”。
/etc/udev/permissions.d/50-udev.permissions
# raw devices ram*:root:disk:0660 #raw/*:root:disk:0660 raw/*:oracle:dba:0660
要创建第二个虚拟机,只需关闭第一个虚拟机,将 d:vmracrac1 中的所有文件复制到 d:vmracrac2,然后更改几个配置即可。
修改网络配置。
- 单击 Start this virtual machine 启动 rac2,保留 rac1 为电源关闭状态。
- rac2 — 虚拟机:选择 Create a new identifier。
IP 地址:双击每个以太网设备,并使用下面的表进行必要的更改。
设备 | IP 地址 | 子网掩码 | 默认网关地址 |
eth0 | 192.168.2.132 | 255.255.255.0 | 192.168.2.1 |
eth1 | 10.10.10.32 | 255.255.255.0 | <保留空白> |
MAC 地址:导航到 Hardware Device 选项卡,并探测每个以太网设备的新 MAC 地址。
主机名和 DNS:使用下面的表对 DNS 选项卡中的项进行必要的更改,然后按 CTRL-S 保存。
主机名 | 首选 DNS | 备用 DNS | DNS 搜索路径 |
rac2.mycorpdomain.com | 输入 DNS IP 地址或保留空白。 | 输入 DNS IP 地址或保留空白。 | 接受默认设置或保留空白。 |
最后,激活每个以太网设备。
修改 /etc/hosts。将以下项添加到 /etc/hosts 中。
127.0.0.1 localhost
稍后,在 Oracle 集群件软件安装期间,VIPCA 将尝试使用回送地址。
修改 /export/home/oracle/.profile。用 devdb2 替换 ORACLE_SID 的值。
使用 SSH 建立用户等效性。在集群就绪服务 (CRS) 和 RAC 安装过程中,Oracle Universal Installer (OUI) 必须能够以 oracle 的身份将软件复制到所有 RAC 节点,而不提示输入口令。在 Oracle 10g 中,可以使用 ssh 代替 rsh 完成此操作。
要建立用户等效性,请在两个节点上以 oracle 用户身份生成用户的公钥和私钥。打开 rac1 的电源,在这两个节点上执行以下任务。
在 rac1 上执行
rac1-> mkdir ~/.ssh rac1-> chmod 700 ~/.ssh rac1-> ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/export/home/oracle/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /export/home/oracle/.ssh/id_rsa. Your public key has been saved in /export/home/oracle/.ssh/id_rsa.pub. The key fingerprint is: 87:54:4f:92:ba:ed:7b:51:5d:1d:59:5b:f9:44:da:b6 oracle@rac1.mycorpdomain.com rac1-> ssh-keygen -t dsa Generating public/private dsa key pair. Enter file in which to save the key (/export/home/oracle/.ssh/id_dsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /export/home/oracle/.ssh/id_dsa. Your public key has been saved in /export/home/oracle/.ssh/id_dsa.pub. The key fingerprint is: 31:76:96:e6:fc:b7:25:04:fd:70:42:04:1f:fc:9a:26 oracle@rac1.mycorpdomain.com
在 rac2 上执行
rac2-> mkdir ~/.ssh rac2-> chmod 700 ~/.ssh rac2-> ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/export/home/oracle/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /export/home/oracle/.ssh/id_rsa. Your public key has been saved in /export/home/oracle/.ssh/id_rsa.pub. The key fingerprint is: 29:5a:35:ac:0a:03:2c:38:22:3c:95:5d:68:aa:56:66 oracle@rac2.mycorpdomain.com rac2-> ssh-keygen -t dsa Generating public/private dsa key pair. Enter file in which to save the key (/export/home/oracle/.ssh/id_dsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /export/home/oracle/.ssh/id_dsa. Your public key has been saved in /export/home/oracle/.ssh/id_dsa.pub. The key fingerprint is: 4c:b2:5a:8d:56:0f:dc:7b:bc:e0:cd:3b:8e:b9:5c:7c oracle@rac2.mycorpdomain.com在 rac1 上执行
rac1-> cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys rac1-> cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys rac1-> ssh rac2 cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys The authenticity of host 'rac2 (192.168.2.132)' can't be established. RSA key fingerprint is 63:d3:52:d4:4d:e2:cb:ac:8d:4a:66:9f:f1:ab:28:1f. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 'rac2,192.168.2.132' (RSA) to the list of known hosts. oracle@rac2's password: rac1-> ssh rac2 cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys oracle@rac2's password: rac1-> scp ~/.ssh/authorized_keys rac2:~/.ssh/authorized_keys oracle@rac2's password: authorized_keys 100% 1716 1.7KB/s 00:00在每个节点上测试连接。验证当您再次运行以下命令时,系统是否不提示您输入口令。
ssh rac1 date ssh rac2 date ssh rac1-priv date ssh rac2-priv date ssh rac1.mycorpdomain.com date ssh rac2.mycorpdomain.com date ssh rac1-priv.mycorpdomain.com date ssh rac2-priv.mycorpdomain.com date
Oracle ASM 与 Oracle 数据库紧密集成在一起,并与 Oracle 的数据管理工具套件配合工作。它可以简化数据库存储管理,并提供原始磁盘 I/O 的性能。
配置 ASMLib。以 root 用户身份在两个节点上配置 ASMLib。# /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创建 ASM 磁盘。以 root 用户身份在任何一个节点上创建 ASM 磁盘。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 ] Loading module "oracleasm": [ OK ] Mounting ASMlib driver filesystem: [ OK ] Scanning system for ASM disks: [ OK ]
# /etc/init.d/oracleasm createdisk VOL1 /dev/sdc1 Marking disk "/dev/sdc1" as an ASM disk: [ OK ] # /etc/init.d/oracleasm createdisk VOL2 /dev/sdd1 Marking disk "/dev/sdd1" as an ASM disk: [ OK ] # /etc/init.d/oracleasm createdisk VOL3 /dev/sde1 Marking disk "/dev/sde1" as an ASM disk: [ OK ] Verify that the ASM disks are visible from every node. # /etc/init.d/oracleasm scandisks Scanning system for ASM disks: [ OK ] # /etc/init.d/oracleasm listdisks VOL1 VOL2 VOL3
OCFS2 是 Oracle 开发的一个通用集群文件系统,与 Enterprise Linux 内核集成在一起。它允许所有节点在集群文件系统上同时共享文件,因而消除了管理原始设备的需求。这里,您将在 OCFS2 文件系统中寄宿 OCR 和表决磁盘。您可以从 OCFS2 用户指南获取有关 OCFS2 的其他信息。
在 Enterprise Linux 安装期间,您应该已经安装了 OCFS2 RPM。验证 RPM 是否已经安装在两个节点上。
rac1-> rpm -qa | grep ocfs ocfs2-tools-1.2.2-2 ocfs2console-1.2.2-2 ocfs2-2.6.9-42.0.0.0.1.ELsmp-1.2.3-2创建 OCFS2 配置文件。 在 rac1 上,以 root 用户身份执行
# ocfs2console
# more /etc/ocfs2/cluster.conf node: ip_port = 7777 ip_address = 192.168.2.131 number = 0 name = rac1 cluster = ocfs2 node: ip_port = 7777 ip_address = 192.168.2.132 number = 1 name = rac2 cluster = ocfs2 cluster: node_count = 2 name = ocfs2
在两个节点上执行下面的过程,将 O2CB 配置为在引导时启动。
当系统提示您指定心跳死亡阈值时,您必须指定一个大于 7 的值,以防止节点由于较慢的 IDE 磁盘驱动器而崩溃。心跳死亡阈值是一个用于计算隔离时间的变量。
Fence time (seconds) = (heartbeat dead threshold -1) * 2
在我们的环境中,120 秒的隔离时间很合适。两个节点上的心跳死亡阈值应该完全相同。
以 root 用户身份执行
# /etc/init.d/o2cb unload Stopping O2CB cluster ocfs2: OK Unmounting ocfs2_dlmfs filesystem: OK Unloading module "ocfs2_dlmfs": OK Unmounting configfs filesystem: OK Unloading module "configfs": OK # /etc/init.d/o2cb configure Configuring the O2CB driver. This will configure the on-boot properties of the O2CB driver. The following questions will determine whether the driver is loaded on boot. The current values will be shown in brackets ('[]'). Hittingwithout typing an answer will keep that current value. Ctrl-C will abort. Load O2CB driver on boot (y/n) [y]: y Cluster to start on boot (Enter "none" to clear) [ocfs2]: Specify heartbeat dead threshold (>=7) [7]: 61 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 O2CB cluster ocfs2: OK
格式化文件系统。在格式化和挂载文件系统之前,应验证 O2CB 在两个节点上均联机;O2CB 心跳当前没有活动,因为文件系统未挂载。注:如果发生类似 o2cb_ctl: Internal logic failure failed while adding RAC1这样的错误,请检查主机名配置是否正确。
# /etc/init.d/o2cb status Module "configfs": Loaded Filesystem "configfs": Mounted Module "ocfs2_nodemanager": Loaded Module "ocfs2_dlm": Loaded Module "ocfs2_dlmfs": Loaded Filesystem "ocfs2_dlmfs": Mounted Checking O2CB cluster ocfs2: Online Checking O2CB heartbeat: Not active
您只需在一个节点上格式化文件系统。在 rac1 上,以 root 用户身份执行
# ocfs2console
# mount -t ocfs2 -o datavolume,nointr /dev/sdb1 /ocfs
注:如果mount时发生错误或,检查主机名是否配置正确。
要在引导时挂载文件系统,在两个节点的 /etc/fstab 中添加以下行。
/etc/fstab
/dev/sdb1 /ocfs ocfs2 _netdev,datavolume,nointr 0 0创建 Oracle 集群件目录。在 OCR 和表决磁盘将驻留的 OCFS2 文件系统中创建目录。
在 rac1 上执行
# mkdir /ocfs/clusterware # chown -R oracle:dba /ocfs
现在,您已经完成了 OCFS2 的设置。验证您可以在两个节点的共享集群文件系统上读写文件。
下载后,在 rac1 上以 oracle 用户身份执行
rac1-> /u01/staging/clusterware/runInstaller
rac1-> /u01/app/oracle/product/10.2.0/crs_1/bin/cluvfy stage -post crsinst -n rac1,rac2 Performing post-checks for cluster services setup Checking node reachability... Node reachability check passed from node "rac1". Checking user equivalence... User equivalence check passed for user "oracle". Checking Cluster manager integrity... Checking CSS daemon... Daemon status check passed for "CSS daemon". Cluster manager integrity check passed. Checking cluster integrity... Cluster integrity check passed Checking OCR integrity... Checking the absence of a non-clustered configuration... All nodes free of non-clustered, local-only configurations. Uniqueness check for OCR device passed. Checking the version of OCR... OCR of correct Version "2" exists. Checking data integrity of OCR... Data integrity check for OCR passed. OCR integrity check passed. Checking CRS integrity... Checking daemon liveness... Liveness check passed for "CRS daemon". Checking daemon liveness... Liveness check passed for "CSS daemon". Checking daemon liveness... Liveness check passed for "EVM daemon". Checking CRS health... CRS health check passed. CRS integrity check passed. Checking node application existence... Checking existence of VIP node application (required) Check passed. Checking existence of ONS node application (optional) Check passed. Checking existence of GSD node application (optional) Check passed. Post-check for cluster services setup was successful.
下载后,在 rac1 上以 oracle 用户身份执行
rac1-> /u01/staging/database/runInstaller
- 磁盘组名称:RECOVERYDEST。
- 选择 External 冗余。
- 选择磁盘路径 ORCL:VOL3。如果您已经使用标准 Linux I/O 配置了 ASM 磁盘,则请选择 /u01/oradata/devdb/asmdisk3。
- 单击 OK。
恭喜,您已经在 Enterprise Linux 上成功安装了 Oracle RAC 数据库 10g!
现在,您已经成功安装了虚拟双节点 RAC 数据库,下面我们来探究一下您刚刚配置的环境。
检查应用程序资源的状态。rac1-> crs_stat -t Name Type Target State Host ------------------------------------------------------------ ora.devdb.db application ONLINE ONLINE rac1 ora....b1.inst application ONLINE ONLINE rac1 ora....b2.inst application ONLINE ONLINE rac2 ora....SM1.asm application ONLINE ONLINE rac1 ora....C1.lsnr application ONLINE ONLINE rac1 ora.rac1.gsd application ONLINE ONLINE rac1 ora.rac1.ons application ONLINE ONLINE rac1 ora.rac1.vip application ONLINE ONLINE rac1 ora....SM2.asm application ONLINE ONLINE rac2 ora....C2.lsnr application ONLINE ONLINE rac2 ora.rac2.gsd application ONLINE ONLINE rac2 ora.rac2.ons application ONLINE ONLINE rac2 ora.rac2.vip application ONLINE ONLINE rac2 rac1-> srvctl status nodeapps -n rac1 VIP is running on node: rac1 GSD is running on node: rac1 Listener is running on node: rac1 ONS daemon is running on node: rac1 rac1-> srvctl status nodeapps -n rac2 VIP is running on node: rac2 GSD is running on node: rac2 Listener is running on node: rac2 ONS daemon is running on node: rac2 rac1-> srvctl status asm -n rac1 ASM instance +ASM1 is running on node rac1. rac1-> srvctl status asm -n rac2 ASM instance +ASM2 is running on node rac2. rac1-> srvctl status database -d devdb Instance devdb1 is running on node rac1 Instance devdb2 is running on node rac2 rac1-> srvctl status service -d devdb rac1->检查 Oracle 集群件的状态。
rac1-> crsctl check crs CSS appears healthy CRS appears healthy EVM appears healthy rac2-> crsctl check crs CSS appears healthy CRS appears healthy EVM appears healthy
在命令行执行 crsctl 以查看所有可用选项。
列出 RAC 实例。SQL> select 2 instance_name, 3 host_name, 4 archiver, 5 thread#, 6 status 7 from gv$instance; INSTANCE_NAME HOST_NAME ARCHIVE THREAD# STATUS -------------- --------------------- ------- -------- ------ devdb1 rac1.mycorpdomain.com STARTED 1 OPEN devdb2 rac2.mycorpdomain.com STARTED 2 OPEN检查连接。
验证您能够连接到每个节点上的实例和服务。
sqlplus system@devdb1 sqlplus system@devdb2 sqlplus system@devdb检查数据库配置。
rac1-> export ORACLE_SID=devdb1 rac1-> sqlplus / as sysdba SQL> show sga Total System Global Area 209715200 bytes Fixed Size 1218556 bytes Variable Size 104859652 bytes Database Buffers 100663296 bytes Redo Buffers 2973696 bytes SQL> select file_name,bytes/1024/1024 from dba_data_files; FILE_NAME BYTES/1024/1024 ------------------------------------------- --------------- +DG1/devdb/datafile/users.259.606468449 5 +DG1/devdb/datafile/sysaux.257.606468447 240 +DG1/devdb/datafile/undotbs1.258.606468449 30 +DG1/devdb/datafile/system.256.606468445 480 +DG1/devdb/datafile/undotbs2.264.606468677 25 SQL> select 2 group#, 3 type, 4 member, 5 is_recovery_dest_file 6 from v$logfile 7 order by group#; GROUP# TYPE MEMBER IS_ ------ ------- --------------------------------------------------- --- 1 ONLINE +RECOVERYDEST/devdb/onlinelog/group_1.257.606468581 YES 1 ONLINE +DG1/devdb/onlinelog/group_1.261.606468575 NO 2 ONLINE +RECOVERYDEST/devdb/onlinelog/group_2.258.606468589 YES 2 ONLINE +DG1/devdb/onlinelog/group_2.262.606468583 NO 3 ONLINE +DG1/devdb/onlinelog/group_3.265.606468865 NO 3 ONLINE +RECOVERYDEST/devdb/onlinelog/group_3.259.606468875 YES 4 ONLINE +DG1/devdb/onlinelog/group_4.266.606468879 NO 4 ONLINE +RECOVERYDEST/devdb/onlinelog/group_4.260.606468887 YES rac1-> export ORACLE_SID=+ASM1 rac1-> sqlplus / as sysdba SQL> show sga Total System Global Area 92274688 bytes Fixed Size 1217884 bytes Variable Size 65890980 bytes ASM Cache 25165824 bytes SQL> show parameter asm_disk NAME TYPE VALUE ------------------------------ ----------- ------------------------ asm_diskgroups string DG1, RECOVERYDEST asm_diskstring string SQL> select 2 group_number, 3 name, 4 allocation_unit_size alloc_unit_size, 5 state, 6 type, 7 total_mb, 8 usable_file_mb 9 from v$asm_diskgroup; ALLOC USABLE GROUP UNIT TOTAL FILE NUMBER NAME SIZE STATE TYPE MB MB ------ ------------ -------- ------- ------ ------ ------- 1 DG1 1048576 MOUNTED NORMAL 6134 1868 2 RECOVERYDEST 1048576 MOUNTED EXTERN 2047 1713 SQL> select 2 name, 3 path, 4 header_status, 5 total_mb free_mb, 6 trunc(bytes_read/1024/1024) read_mb, 7 trunc(bytes_written/1024/1024) write_mb 8 from v$asm_disk; NAME PATH HEADER_STATU FREE_MB READ_MB WRITE_MB ----- ---------- ------------ ---------- ---------- ---------- VOL1 ORCL:VOL1 MEMBER 3067 229 1242 VOL2 ORCL:VOL2 MEMBER 3067 164 1242 VOL3 ORCL:VOL3 MEMBER 2047 11 354创建表空间。
SQL> connect system/oracle@devdb Connected. SQL> create tablespace test_d datafile '+DG1' size 10M; Tablespace created. SQL> select 2 file_name, 3 tablespace_name, 4 bytes 5 from dba_data_files 6 where tablespace_name='TEST_D'; FILE_NAME TABLESPACE_NAME BYTES ---------------------------------------- --------------- ---------- +DG1/devdb/datafile/test_d.269.606473423 TEST_D 10485760创建在线重做日志文件组。
SQL> connect system/oracle@devdb Connected. SQL> alter database add logfile thread 1 group 5 size 50M; Database altered. SQL> alter database add logfile thread 2 group 6 size 50M; Database altered. SQL> select 2 group#, 3 thread#, 4 bytes, 5 members, 6 status 7 from v$log; GROUP# THREAD# BYTES MEMBERS STATUS ---------- ---------- ---------- ---------- ---------------- 1 1 52428800 2 CURRENT 2 1 52428800 2 INACTIVE 3 2 52428800 2 ACTIVE 4 2 52428800 2 CURRENT 5 1 52428800 2 UNUSED 6 2 52428800 2 UNUSED SQL> select 2 group#, 3 type, 4 member, 5 is_recovery_dest_file 6 from v$logfile 7 where group# in (5,6) 8 order by group#; GROUP# TYPE MEMBER IS_ ------ ------- ---------------------------------------------------- --- 5 ONLINE +DG1/devdb/onlinelog/group_5.271.606473683 NO 5 ONLINE +RECOVERYDEST/devdb/onlinelog/group_5.261.606473691 YES 6 ONLINE +DG1/devdb/onlinelog/group_6.272.606473697 NO 6 ONLINE +RECOVERYDEST/devdb/onlinelog/group_6.262.606473703 YES检查闪回恢复区空间使用率。
SQL> select * from v$recovery_file_dest; NAME SPACE_LIMIT SPACE_USED SPACE_RECLAIMABLE NUMBER_OF_FILES ------------- ----------- ---------- ----------------- --------------- +RECOVERYDEST 1572864000 331366400 0 7 SQL> select * from v$flash_recovery_area_usage; FILE_TYPE PERCENT_SPACE_USED PERCENT_SPACE_RECLAIMABLE NUMBER_OF_FILES ------------ ------------------ ------------------------- --------------- CONTROLFILE .97 0 1 ONLINELOG 20 0 6 ARCHIVELOG 0 0 0 BACKUPPIECE 0 0 0 IMAGECOPY 0 0 0 FLASHBACKLOG 0 0 0启动和停止应用程序资源。
遵循以下步骤启动和停止单独的应用程序资源。
srvctl start nodeapps -nsrvctl start nodeapps -n srvctl start asm -n srvctl start asm -n srvctl start database -d srvctl start service -d -s crs_stat -t srvctl stop service -d -s srvctl stop database -d srvctl stop asm -n srvctl stop asm -n srvctl stop nodeapps -n srvctl stop nodeapps -n crs_stat -t
Oracle TAF 中的故障切换机制使任何失败的数据库连接能够重新连接到集群中的其他节点。故障切换对用户是透明的。Oracle 在故障切换实例上重新执行查询并继续向用户显示余下的结果。
创建一个新的数据库服务。首先,创建一个名为 CRM 的新服务。可以使用 DBCA 或 srvctl 实用程序来创建数据库服务。这里,您将使用 DBCA 在 devdb1 上创建 CRM 服务。
服务名 | 数据库名 | 首选实例 | 可用实例 | TAF 策略 |
CRM | devdb | devdb1 | devdb2 | BASIC |
在 rac1 上,以 oracle 用户身份执行
rac1-> dbca