linux4.0下安装oracle RAC(三) 

1、使用 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

2、配置 Oracle 自动存储管理 (ASM)

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  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  ]
创建 ASM 磁盘。以 root 用户身份在任何一个节点上创建 ASM 磁盘。
# /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
VOL4

3、 配置 Oracle 集群文件系统 (OCFS2)

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
  1. OCFS2 控制台:选择 Cluster,然后选择 Configure Nodes
  2. “集群堆栈已经启动”:单击 Close
  3. 节点配置:单击 Add
  4. 新增节点:添加以下节点,然后单击 Apply
    • 名称:rac1
    • IP 地址: 192.168.2.131
    • IP 端口: 7777
    • 名称:rac2
    • IP 地址: 192.168.2.132
    • IP 端口: 7777
  5. 验证生成的配置文件。
    # 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
    
  6. 将配置文件传播到 rac2。您可以在 rac2 上重新运行上述步骤以生成配置文件,或者在 rac1 的 OCFS2 控制台上选择 ClusterPropagate Configuration 以将配置文件传播到 rac2。
配置 O2CB 驱动程序。O2CB 是一组集群服务,负责管理节点与集群文件系统之间的通信。下面是对各个服务的说明:
  • NM:用于跟踪 cluster.conf 中的所有节点的节点管理器
  • HB:当节点加入或离开集群时向上/向下发出通知的心跳服务
  • TCP:处理节点之间的通信
  • DLM:用于跟踪所有锁、这些锁的所有者以及状态的分布式锁管理器
  • CONFIGFS:在 /config 中挂载的用户空间驱动的配置文件系统
  • DLMFS:用户空间与内核空间 DLM 的接口

在两个节点上执行下面的过程,将 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 ('[]').  Hitting
 without 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 心跳当前没有活动,因为文件系统未挂载。
# /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
  1. OCFS2 控制台:选择 Tasks、Format
  2. 格式:
    • 可用设备:/dev/sdb1
    • 卷标:oracle
    • 集群大小:Auto
    • 节点插槽数量: 4
    • 块大小:Auto
  3. OCFS2 控制台:按 CTRL-Q 退出。
挂载文件系统。要挂载文件系统,在两个节点上执行以下命令。
# mount -t ocfs2 -o datavolume,nointr /dev/sdb1 /ocfs

要在引导时挂载文件系统,在两个节点的 /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 的设置。验证您可以在两个节点的共享集群文件系统上读写文件。

请使用浏览器的分享功能分享到微信等