来源: www.ixdba.net 作者: www.ixdba.net
一:组件包安装:
$ su -ITPUB个人空间iUg#e3I
# rpm -Uvh ocfs2-2.6.9-42.EL-1.2.3-1.i686.rpm \
;R['Y"Q ]nS0ocfs2console-1.2.1-1.i386.rpm \
IL0\,H}&o/D0ocfs2-tools-1.2.1-1.i386.rpmITPUB个人空间z-Kz7kwXB
Preparing... ############################## [100%]ITPUB个人空间%[/Gt6MvI
O&@k
1:ocfs2-tools ############################## [ 33%]
S;u(l
B1G&Lw,Ilg02:ocfs2-2.6.9-42.EL ######################### [ 67%]
1w_)Bq#bk03:ocfs2console ############################# [100%]
er)xP'x1u
C,M P9K0禁用SELinux(RHEL4 U2以及更高版本)
向RHEL4 U2以及更高版本(CentOS 4.4基于RHEL4 U2)的用户提供一个建议,即OCFS2当前无法在启用SELinux的情况下运行。如果您使用的是RHEL4 U2或更高版本(由于我们使用的是CentOS 4.4,因此我们也包括在内),则您需要禁用SELinux(使用工具system-config-securitylevel)才能执行O2CB服务。
IXDBA.NET技术社区ITPUB个人空间3wSX6^O8L
要禁用SELinux,运行“Security Level Configuration”GUI实用程序:
# /usr/bin/system-config-securitylevel &
现在,单击SELinux选项卡并取消选中“Enabled”复选框。单击[OK]后,将显示一个警告对话框。只需单击“Yes”确认该警告。禁用SELinux选项,
在集群中的两个节点上进行此更改后,将需要重新引导每个节点以实施更改:在继续配置OCFS2之前,必须禁用SELinux!
# init 6ITPUB个人空间"Q$i!Ehz'l~$a
配置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”对话框。ITPUB个人空间 XrappqP
在“Node Configuration”对话框上,单击[Add]按钮。
$S}6Gf_k5c2k0这将显示“Add Node”对话框。
{"T)De,Jz%{9O#]0在“Add Node”对话框中,输入集群中第一个节点的Host name和IP address。将IP Port设置为默认值7777。在我的示例中,我添加了两个节点,即使用linux1 / 192.168.1.100表示第一个节点,并使用linux2 / 192.168.1.101表示第二个节点。
+zOuAp/UD^4T0单击“Node Configuration”对话框上的[Apply] —所有节点现在将处于“Active”状态.ITPUB个人空间%HN/Y/TmE
单击“Node Configuration”对话框上的[Close]。
6I:~,o"?oi0确认所有值均正确后,使用[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中的所有节点的节点管理器
0~g$hMc/In I0HB:当节点加入或离开集群时向上/向下发出通知的心跳服务ITPUB个人空间y5\6Il
]%Xo
[
TCP:处理节点之间的通信ITPUB个人空间KL,F:?s4R
DLM:用于跟踪所有锁、这些锁的所有者和状态的分布式锁管理器ITPUB个人空间8qj(@*[:j)AoG
CONFIGFS:在/config中挂载的用户空间驱动的配置文件系统
S^b*N8@Pa0DLMFS:用户空间与内核空间DLM的接口ITPUB个人空间X"Y$ww9N7PCF8VAv&["M
已将以上所有集群服务打包到o2cb系统服务(/etc/init.d/o2cb)中。以下是o2cb系统服务的某些更有用的命令和选项的简要列表。
注意:以下命令仅用于演示目的,不应在安装和配置OCFS2时运行!
/etc/init.d/o2cb statusITPUB个人空间#ysa:[8d{B
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
2r/O
u"|W&u0 注意,本示例未加载所有服务。我在执行“status”选项之前执行了“unload”。如果要在使用ocfs2console实用程序配置OCFS2后立即检查o2cb服务的状态,则将加载所有这些服务。
5p;d_.{:W L,k5~;j t0 /etc/init.d/o2cb load
A5ax+`fk]1z0Loading 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模块ITPUB个人空间p6jNx7M6C&o
/etc/init.d/o2cb online ocfs2ITPUB个人空间j:Z
iC8`
g-cD@
Starting cluster ocfs2: OK
w"R2?4r-BM|gH0以上命令将使我们创建的集群ocfs2处于联机状态。
[:MJ#{rqU
R J h*x0
C]}@G-dE1? @0/etc/init.d/o2cb offline ocfs2ITPUB个人空间8b%mFf'Qn5h
}`
Unmounting ocfs2_dlmfs filesystem: OK
Unloading module "ocfs2_dlmfs": OK
Unmounting configfs filesystem: OK
Unloading module "configfs": OKITPUB个人空间u7l&e
y4`c
以上命令将使我们创建的集群ocfs2处于脱机状态。
K2E~2@xL0
*^Zf
^t[K(zo;o0/etc/init.d/o2cb unload
r$XerD!`!a~9c0Cleaning heartbeat on ocfs2: OK
Stopping cluster ocfs2: OKITPUB个人空间
fd
u%uxP
以上命令将卸载所有OCFS2模块。
三:将O2CB配置为在引导时启动
您现在需要配置OC2B驱动程序的引导属性,以便在每次引导时将启动集群堆栈服务。需要在集群的所有节点上执行本节中的所有任务。
注意:OCFS21.2.1之前的版本中包含一个错误,即不会在每次引导时加载驱动程序,即使将引导属性配置为执行此操作后也是如此。OCFS2 1.2.1版中已经修复了该错误,本文不再赘述。然而,如果您使用的是OCFS2 1.2.1之前的版本,请参阅疑难解答一节以获取有关该错误的变通方法。ITPUB个人空间PWX-P5oQ@
[
按如下所示设置引导属性:
# /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<ENTER> without typing an answer will keep that current value. Ctrl-Cwill abort.Load O2CB driver on boot (y/n) [n]: y
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