来源: www.ixdba.net 作者: www.ixdba.net
一:组件包安装:
下载ocfs2软件包
http://oss.oracle.com/projects/ocfs2-tools/files/
http://oss.oracle.com/projects/ocfs2/files/
安装:
$ su -
# rpm -Uvh ocfs2-2.6.9-42.EL-1.2.3-1.i686.rpm \
ocfs2console-1.2.1-1.i386.rpm \
ocfs2-tools-1.2.1-1.i386.rpm
Preparing... ############################## [100%]
1:ocfs2-tools ############################## [ 33%]
2:ocfs2-2.6.9-42.EL ######################### [ 67%]
3:ocfs2console ############################# [100%]
禁用 SELinux(RHEL4 U2 以及更高版本)
向 RHEL4 U2 以及更高版本(CentOS 4.4 基于 RHEL4 U2)的用户提供一个建议,即 OCFS2 当前无法在启用 SELinux 的情况下运行。如果您使用的是 RHEL4 U2 或更高版本(由于我们使用的是 CentOS 4.4,因此我们也包括在内),则您需要禁用 SELinux(使用工具 system-config-securitylevel)才能执行 O2CB 服务。
要禁用 SELinux,运行“Security Level Configuration”GUI 实用程序:
# /usr/bin/system-config-securitylevel &
现在,单击 SELinux 选项卡并取消选中“Enabled”复选框。单击 [OK] 后,将显示一个警告对话框。只需单击“Yes”确认该警告。禁用 SELinux 选项,
在集群中的两个节点上进行此更改后,将需要重新引导每个节点以实施更改:在继续配置 OCFS2 之前,必须禁用 SELinux!
# init 6
配置 OCFS2
下一步是在集群中的两个节点上生成和配置 /etc/ocfs2/cluster.conf 文件。完成此操作最简单的方法是运行 GUI 工具 ocfs2console。在本节中,我们不但使用 ocfs2console 创建和配置 /etc/ocfs2/cluster.conf 文件,而且还创建和启动集群堆栈 O2CB。如果 /etc/ocfs2/cluster.conf 文件不存在(本示例中便是这种情况),ocfs2console 工具将创建该文件以及一个默认集群名为 ocfs2 的新集群堆栈服务 (O2CB)。您将需要以 root 用户帐户在集群中的两个节点上执行该操作:
$ su -# ocfs2console &
使用 ocfs2console GUI 工具执行以下步骤:
选择 [Cluster] -> [Configure Nodes...]。这将启动 OCFS2 集群堆栈并显示“Node Configuration”对话框。
在“Node Configuration”对话框上,单击 [Add] 按钮。
这将显示“Add Node”对话框。
在“Add Node”对话框中,输入集群中第一个节点的 Host name 和 IP address。将 IP Port 设置为默认值 7777。在我的示例中,我添加了两个节点,即使用 linux1 / 192.168.1.100 表示第一个节点,并使用 linux2 / 192.168.1.101 表示第二个节点。
单击“Node Configuration”对话框上的 [Apply] — 所有节点现在将处于“Active”状态.
单击“Node Configuration”对话框上的 [Close]。
确认所有值均正确后,使用 [File] -> [Quit] 退出应用程序。需要在集群的两个节点上执行该操作。
退出 ocfs2console 后,将获得一个类似如下所示的 /etc/ocfs2/cluster.conf。需要在集群中的两个节点上完成该过程,并且所有节点的 OCFS2 配置文件必须完全相同:
node: ip_port = 7777
ip_address = 192.168.1.100
number = 0
name = linux1
cluster = ocfs2node:
ip_port = 7777
ip_address = 192.168.1.101
number = 1
name = linux2
cluster = ocfs2cluster:
node_count = 2
name = ocfs2
二:O2CB 集群服务
在使用 OCFS2 执行任何操作(如格式化或挂载文件系统)之前,我们需要先运行 OCFS2 的集群堆栈 O2CB(它将是以上执行的配置过程的结果)。此堆栈包含以下服务:
NM:用于跟踪 cluster.conf 中的所有节点的节点管理器
HB:当节点加入或离开集群时向上/向下发出通知的心跳服务
TCP:处理节点之间的通信
DLM:用于跟踪所有锁、这些锁的所有者和状态的分布式锁管理器
CONFIGFS:在 /config 中挂载的用户空间驱动的配置文件系统
DLMFS:用户空间与内核空间 DLM 的接口
已将以上所有集群服务打包到 o2cb 系统服务 (/etc/init.d/o2cb) 中。以下是 o2cb 系统服务的某些更有用的命令和选项的简要列表。
注意:以下命令仅用于演示目的,不应在安装和配置 OCFS2 时运行!
/etc/init.d/o2cb status
Module "configfs": Not loaded
Filesystem "configfs": Not mounted
Module "ocfs2_nodemanager": Not loaded
Module "ocfs2_dlm": Not loaded
Module "ocfs2_dlmfs": Not loaded
Filesystem "ocfs2_dlmfs": Not mounted
注意,本示例未加载所有服务。我在执行“status”选项之前执行了“unload”。如果要在使用 ocfs2console 实用程序配置 OCFS2 后立即检查 o2cb 服务的状态,则将加载所有这些服务。
/etc/init.d/o2cb load
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
加载所有 OCFS2 模块
/etc/init.d/o2cb online ocfs2
Starting cluster ocfs2: OK
以上命令将使我们创建的集群 ocfs2 处于联机状态。
/etc/init.d/o2cb offline ocfs2
Unmounting ocfs2_dlmfs filesystem: OK
Unloading module "ocfs2_dlmfs": OK
Unmounting configfs filesystem: OK
Unloading module "configfs": OK
以上命令将使我们创建的集群 ocfs2 处于脱机状态。
/etc/init.d/o2cb unload
Cleaning heartbeat on ocfs2: OK
Stopping cluster ocfs2: OK
以上命令将卸载所有 OCFS2 模块。
三:将 O2CB 配置为在引导时启动
您现在需要配置 OC2B 驱动程序的引导属性,以便在每次引导时将启动集群堆栈服务。需要在集群的所有节点上执行本节中的所有任务。
注意:OCFS2 1.2.1 之前的版本中 包含一个错误,即不会在每次引导时加载驱动程序,即使将引导属性配置为执行此操作后也是如此。OCFS2 1.2.1 版中已经修复了该错误,本文不再赘述。然而,如果您使用的是 OCFS2 1.2.1 之前的版本,请参阅疑难解答一节以获取有关该错误的变通方法。
按如下所示设置引导属性:
# /etc/init.d/o2cb offline ocfs2
# /etc/init.d/o2cb unload
# /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 onboot. The current values will be shown in brackets ('[]'). Hitting
Cluster to start on boot (Enter "none" to clear) [ocfs2]: ocfs2
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