企業級Linux講座之在SAN上建立高可靠性SAMBA叢集
阿新 • • 發佈:2019-01-02
1) 安裝Red Hat 叢集管理員套件
用root 登入rhel3-1 安裝clumanager 與redhat-config-cluster 套件才能設定Red Hat 叢集管理員,將光碟收入光碟機中,便會自動執行安裝程式。請選擇「clumanager」及「redhat-config-cluster」套件進行安裝;在rhel3-2 亦重複此步驟,或利用rpm 方式安裝:
# rpm -ivh clumanager-1.2.12-1.i386.rpm
# rpm -ivh redhat-config-cluster-1.0.2-1.1.noarch.rpm
2) 編寫/etc/hosts
[
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
192.168.33.1 rhel3-1.example.com rhel3-1
192.168.33.2 rhel3-2.example.com rhel3-2
192.168.33.3 ha.example.com ha
[
3) 設定叢集共享分割槽(Configuring Shared Cluster Partitions)
在rhel3-1 上利用fdisk 切出兩個60MB 的分割槽sdb1、sdb2(須大於10MB)做Raw Device 用,再從其中切出500MB 分割槽,再利用「mke2fs –j /dev/sdb3」格式化此檔案系統。(圖16)
編寫/etc/sysconfig/rawdevices 檔案,編輯完/etc/sysconfig/rawdevices 檔案後,可以重新開機或者是執行下列指令「service rawdevices restart」來使其生效。
讀者可以用「raw –aq」查詢所有的raw 裝置
[
# raw device bindings
# format: <rawdev> <major> <minor>
# <rawdev> <blockdev>
# example: /dev/raw/raw1 /dev/sda1
# /dev/raw/raw2 8 5
/dev/raw/raw1 /dev/sdb1
/dev/raw/raw2 /dev/sdb2
圖16:hwbrowser 顯示share disk 分割槽狀況
4) 設定叢集名稱
選擇『主選單』/『系統設定』/「伺服器設定』/『叢集』。
或在shell 提示符號下輸入redhat-config-cluster 指令。
圖17:設定叢集名稱
5) 設定Share Raw Device
選擇redhat-config-cluster 上的「Cluster」/「Shared State」便可看到圖18的畫面,填入正確的Raw Device。
圖18:Share Raw Device
6) 新增Cluster Member
選擇「Member」,再點選「New」的按鈕。便會出現要求輸入Member 名稱的視窗。請輸入Cluster 中一部系統的主機名稱或地址,請注意每一個Member 必須位於與執行redhat-config-cluster 的機器在同一子網路中,而且必須在DNS或每一部集群系統的/etc/hosts 檔案中已經定義了。請新增兩個Cluster Member「rhel3-1」及「rhel3-2」。
圖19:Linux HA cluster Members
7) 設定Failover Domain
選擇「Failover Domain」的卷標頁,再點選「New」的按鈕。將會出現的「Failover Domain」對話視窗,設定Domain Name 及Add Members。
圖20:設定「Failover Domain」的屬性
8) 利用「SAMBA Druid」來快速設定一個客戶端可存取的SAMBA 共享
點選「Add Exports」/「SAMBA」,將會看到如圖21 的畫面,然後按下「Forward」。
圖21:SAMBA Druid 畫面
利用「SAMBA Druid」將/dev/sdb3 共享給Windows Client,首先設定「Service Name」及「Service IP」。(圖22)
圖22:設定Service Name 及Service IP Address
設定SAMBA service 所對應的Device Special File 及Device Mount Point 如圖23 所示。按下「Forward」鍵後會出現設定share name 的視窗(圖24)。
圖23:設定欲共享的Device 及對應的Mountpoint
圖24:設定Share Name
設定Share Name 後,按下「Forward」鍵,出現設成畫面。記得將/etc/samba/smb.conf.myshare 複製至其它的Cluster Memeber。
圖25:SAMBA Druid 設定完成畫面
最後點選「Apply」完成這個服務。並從「叢集設定工具」中選擇「File」/「Save」來儲存設定。(圖25)
9) 複製相關配置檔案至另一臺node
將相關配置檔案cluster.xml、/etc/samba/smb.conf.myshare 複製至rhel3-2
[[email protected] root]# scp /etc/cluster.xml rhel3-2:/etc/
[email protected]'s password:
cluster.xml 100% 1405
[[email protected] root]# scp /etc/samba/smb.conf.myshare rhel3-2:/etc/
[email protected]'s password:
smb.conf.myshare 100% 867
在rhel3-1 及rhel3-2 上啟用clumanager Daemon
[[email protected] rehl3-1 root]# service clumanager start
Starting Red Hat Cluster Manager...
Loading Watchdog Timer (softdog): [ OK ]
Starting Quorum Daemon:
[[email protected] rehl3-2 root]# service clumanager start
Starting Red Hat Cluster Manager...
Loading Watchdog Timer (softdog): [ OK ]
Starting Quorum Daemon:
10) 設定Cluster log
修改rhel3-1 及rhel302 上的/etc/syslog.conf 指定Cluster Log 存放位置,並重新啟用syslog Daemon。
[[email protected] root]# vi /etc/syslog.conf
# Add for cluster
local4.* /var/log/cluster
# service syslog restart
[[email protected] root]# vi /etc/syslog.conf
# Add for cluster
local4.* /var/log/cluster
# service syslog restart
11) 檢視Cluster 狀態
在終端視窗中鍵入「redhat-config-cluster」啟用Cluster 管理工具。點選視窗下方samba service,然後勾選啟用samba 服務。如果一切設定無誤,應會看到如圖26 的畫面。
圖26:RedHat SAMBA HA Cluster 狀態
3、 測試
筆者利用另一臺Windows 的機器聯機到HA Cluster 的service ip(圖26),此時可以對主要的伺服器rhel3-1 做強迫關機的動作,或是kill clumembd 的process 亦可模擬rhel3-1 當機。此時rhel3-2 便會Take Over SAMBA 服務,達到High Availability 目的。
圖27:Windows Client 聯機SAMBA HA Cluster 畫面
kill clumembd process
[[email protected] root]# ps -ef | grep clumembd
root 2597 1 0 11:46 ? 00:00:00 /usr/sbin/clumembd
root 3219 3167 0 11:48 pts/2 00:00:00 grep clumembd
[[email protected] root]# kill -9 2597
此時rhel3-1 會重新開機,rhel3-2 會take over Samba Service。我們可用「clustat」指令檢查Cluster 狀態。
檢查Cluster 狀態
[[email protected] root]# clustat
Cluster Status - IBM FAStT Cluster
Cluster Quorum Incarnation #19
Shared State: Shared Raw Device Driver v1.2
Member Status
------------ -------
rhel3-1 Inactive
rhel3-2 Active <-- You are here
Service Status Owner(Last) Last Transition Chk Restarts
-------------- -------- ---------------- ---------------------- ---- ----
samba started rhel3-2 11:49:31 Aug 19 0 0
後記
筆者在SAN 架構建置High Availability SAMBA Cluster。很多大型企業均採用SAN 的架構儲存企業的重要資料。而Linux 對SAN 相關的支援亦愈來愈完整,顯示Linux 巳慢慢走入大型企業,扮演起企業的重要關鍵系統。