OCFS2 是 Oracle 開發(fā)的一個通用集群文件系統(tǒng),與 Enterprise Linux 內(nèi)核集成在一起。它允許所有節(jié)點在集群文件系統(tǒng)上同時共享文件,因而消除了管理原始設備的需求。這里,您將在 OCFS2 文件系統(tǒng)中寄宿 OCR 和表決磁盤。您可以從OCFS2 用戶指南獲取有關 OCFS2 的其他信息。
在 Enterprise Linux 安裝期間,您應該已經(jīng)安裝了 OCFS2 RPM。驗證 RPM 是否已經(jīng)安裝在兩個節(jié)點上。
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
創(chuàng)建 OCFS2 配置文件。在 rac1 上,以 root 用戶身份執(zhí)行
# ocfs2console
1. OCFS2 控制臺:選擇Cluster,然后選擇Configure Nodes。
2. “集群堆棧已經(jīng)啟動”:單擊Close。
3. 節(jié)點配置:單擊Add。
4. 新增節(jié)點:添加以下節(jié)點,然后單擊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 控制臺上選
擇Cluster 和 Propagate Configuration 以將配置文件傳播到 rac2。
配置 O2CB 驅(qū)動程序。O2CB 是一組集群服務,負責管理節(jié)點與集群文件系統(tǒng)之間的通信。下面是對各個服務的說明:
● NM:用于跟蹤 cluster.conf 中的所有節(jié)點的節(jié)點管理器
● HB:當節(jié)點加入或離開集群時向上/向下發(fā)出通知的心跳服務
● TCP:處理節(jié)點之間的通信
● DLM:用于跟蹤所有鎖、這些鎖的所有者以及狀態(tài)的分布式鎖管理器
● CONFIGFS:在 /config 中掛載的用戶空間驅(qū)動的配置文件系統(tǒng)
● DLMFS:用戶空間與內(nèi)核空間 DLM 的接口
在兩個節(jié)點上執(zhí)行下面的過程,將 O2CB 配置為在引導時啟動。
當系統(tǒng)提示您指定心跳死亡閾值時,您必須指定一個大于 7 的值,以防止節(jié)點由于較慢的 IDE 磁盤驅(qū)動器而崩潰。心跳死
亡閾值是一個用于計算隔離時間的變量。
Fence time (seconds) = (heartbeat dead threshold -1) * 2
在我們的環(huán)境中,120 秒的隔離時間很合適。兩個節(jié)點上的心跳死亡閾值應該完全相同。
以 root 用戶身份執(zhí)行
# /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
格式化文件系統(tǒng)。在格式化和掛載文件系統(tǒng)之前,應驗證 O2CB 在兩個節(jié)點上均聯(lián)機;O2CB 心跳當前沒有活動,因為文
件系統(tǒng)未掛載。
# /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
您只需在一個節(jié)點上格式化文件系統(tǒng)。在 rac1 上,以 root 用戶身份執(zhí)行
# ocfs2console
1. OCFS2 控制臺:選擇Tasks、Format。
2. 格式:
可用設備:/dev/sdb1
卷標:oracle
集群大。篈uto
節(jié)點插槽數(shù)量: 4
塊大。篈uto
3. OCFS2 控制臺:按 CTRL-Q 退出。
掛載文件系統(tǒng)。要掛載文件系統(tǒng),在兩個節(jié)點上執(zhí)行以下命令。
# mount -t ocfs2 -o datavolume,nointr /dev/sdb1 /ocfs
要在引導時掛載文件系統(tǒng),在兩個節(jié)點的 /etc/fstab 中添加以下行。
/etc/fstab
/dev/sdb1 /ocfs ocfs2 _netdev,datavolume,nointr 0 0
創(chuàng)建 Oracle 集群件目錄。在 OCR 和表決磁盤將駐留的 OCFS2 文件系統(tǒng)中創(chuàng)建目錄。
在 rac1 上執(zhí)行
# mkdir /ocfs/clusterware
# chown -R oracle:dba /ocfs
現(xiàn)在,您已經(jīng)完成了 OCFS2 的設置。驗證您可以在兩個節(jié)點的共享集群文件系統(tǒng)上讀寫文件。