在RedHat下建立群集

roninwei發表於2006-07-21
環境說明:
1. 硬體:

說明:按照標準至少需要4塊網路卡和其他相應硬體,但因為條件限制,故在硬體和設定上做了一些變通。

伺服器:PE4300、PE4600
網路卡:兩個
RAID:兩塊PERC2/SC
Storage:PV220S和SCSI cable

2. 軟體:
OS:RedHat Advance Server 2.1
Kernel: 2.4.9-e.3smp

配製分配:
IP: node1: 10.0.0.1/8
node2: 10.0.0.2/8
Cluster IP: 10.0.0.3 這個地址不同於Microsoft下的Cluster server IP address,該地址是用於管理上用的。


基本步驟:

一、安裝OS

說明:為了安裝可以順利進行,建議先移掉RAID卡,否則在複製完檔案後系統不能正常啟動。因為,當使用插卡(RAID/SCSI)連線外接磁碟櫃,它們將總是優先於本地硬碟被檢測,這個將導致本地的磁碟機代號被改變。

按照通常的步驟安裝OS,在系統安裝完後,將RAID或SCSI卡插回主機,在下次重啟時系統將自動發現新裝置。但為了保證在每次系統引導時該裝置能自動啟動,你仍需做以下兩步:

a. 編輯 /etc/modules.conf檔案,同時增加下面內容到檔案內容中

alias scsi_hostadapter megaraid
options scsi_mod max_scsi_luns=255 à可提前增加這一行,因為有共享磁碟櫃存
在,並且有多個LUN在上面時,系統要求這樣做。



b. 執行

Mkinitrd initrd-2.4.9-e.3smp.img 2.4.9-e.3smp à這行的內容主要還是由核心來決定。

例:
/etc/modules.conf:

alias scsi_hostadapter megaraid

options scsi_mod max_scsi_luns=255


二、物理連線

這部份的步驟與W2K一樣,即先用一個節點配製LUN,另一個節點從磁碟讀LUN配製,同時保證2塊RAID卡的Cluster功能開啟,SCSI ID 不能衝突,同時將PV220S的開關撥動到Cluster模式。

三、安裝和配製分割槽

1.建立分驅
說明:建議在此時只開一個節點。在系統啟動後,系統可以識別在磁碟櫃上新建的LUN。裝置名通常是在本地硬碟後順序編排。例如:當本地是/dev/sda,那麼新的裝置是/dev/sdb

分割槽的原則和要求:Quorum分割槽的要求:不能小於10M,必須是裸裝置,不能有檔案系統。
Quorum分割槽只能用於Cluster的狀態和配製資訊。
Quorum要求兩個分割槽,一個為primary,另一個為slave
Cluster 應用服務的分割槽:要求一個cluster服務一個分割槽。例如:你想有SQL、NFS、SAMBA三個Cluster應用服務,那麼你必須為三個服務各建一個分割槽。

例:fdisk /dev/sdb 建立新的分割槽

/dev/sdb1 àQuorum primary partition
/dev/sdb2 àQuorum slave partition
/dev/sdb3 àSql partition
/dev/sdb4 àNFS partition
/dev/sdb5 àsamba partition

注意:在建立完分驅後,一定要重啟主機,建議重啟所有裝置。

2.建立檔案系統――即格式化分割槽

說明:Quorum 必須是裸裝置,所以不需要格式化。但其他分割槽必須格式化,同時將預設的Block塊大小增大到4096,預設為1024。


例:
mkfs –t ext2 –j –b 4096 /dev/sdbx –-》X代表分割槽

3.為Cluster 建立Quorum分割槽
說明:使用命令 cat /proc/devices 確認系統是否支援裸裝置,如果你看到下面的輸出,說明系統可以支援裸裝置。

162 raw

在兩臺伺服器上分別編輯/etc/sysconfig/rawdevices檔案,以便將分割槽繫結到裸裝置。

例: /etc/sysconfig/rawdevices
# format:
#
# example: /dev/raw/raw1 /dev/sda1
# /dev/raw/raw2 8 5
/dev/raw/raw1 /dev/sdb1
/dev/raw/raw2 /dev/sdb2

重啟服務 service rawdevices restart


4.檢查和驗證Quoram分割槽

在兩個節點上分別cludiskutil –p 確保兩個節點都能有以下輸出:

----- Shared State Header ------
Magic# = 0x39119fcd
Version = 1
Updated on Thu Sep 14 05:43:18 2000
Updated by node 0




四、建立Cluster服務

說明:確保所有網路卡正常工作。同時,設定基本的網路要求。

1.編輯/etc/hosts 檔案

127.0.0.1 localhost.localdomain localhost
10.0.0.1 node1.test.com node1
10.0.0.2 node2.test.com node2
10.0.0.3 Clusteralias.test.com Clusteralias

2.執行/sbin/cluconfig

說明:系統將自動生成cluster的配製檔案/etc/cluster.conf,這一步只需要在其中一個節點上執行。

你將看到以下輸出:

Enter cluster name [Cluster]:Cluster
Enter IP address for cluster alias [x.x.x.x]: 10.0.0.3
--------------------------------
Information for Cluster Member 0
--------------------------------
Enter name of cluster member [storage0]: node1
Looking for host storage0 (may take a few seconds)...
Enter number of heartbeat channels (minimum = 1) [1]: 1
Information about Channel 0
Channel type: net or serial [net]:
Enter hostname of the cluster member on heartbeat channel 0
[node1]: node1
Looking for host node1 (may take a few seconds)...
Information about Quorum Partitions
Enter Primary Quorum Partition [/dev/raw/raw1]: /dev/raw/raw1
Enter Shadow Quorum Partition [/dev/raw/raw2]: /dev/raw/raw2
Information About the Power Switch That Power Cycles Member ’storage0’
Choose one of the following power switches:
o NONE
o RPS10
o BAYTECH
o APCSERIAL
o APCMASTER
o WTI_NPS
Power switch [NONE]: NONE

Information for Cluster Member 1
--------------------------------
Enter name of cluster member [node2]: node2
Looking for host storage1 (may take a few seconds)...
Information about Channel 0
Enter hostname of the cluster member on heartbeat channel 0
[node2]: node2
Looking for host storage1 (may take a few seconds)...
Information about Quorum Partitions
Enter Primary Quorum Partition [/dev/raw/raw1]: /dev/raw/raw1
Enter Shadow Quorum Partition [/dev/raw/raw2]: /dev/raw/raw2
Information About the Power Switch That Power Cycles Member ’node2’
Choose one of the following power switches:
o NONE
o RPS10
o BAYTECH
o APCSERIAL
o APCMASTER
o WTI_NPS
Power switch [NONE]: NONE

Cluster name: Development Cluster
Cluster alias IP address: 10.0.0.154
Cluster alias netmask: 255.255.254.0
--------------------
Member 0 Information
--------------------
Name: node1
Primary quorum partition: /dev/raw/raw1
Shadow quorum partition: /dev/raw/raw2
Heartbeat channels: 1
Channel type: net, Name: node1
Power switch IP address or hostname: node1
--------------------
Member 1 Information
--------------------
Name: node2
Primary quorum partition: /dev/raw/raw1
Shadow quorum partition: /dev/raw/raw2
Heartbeat channels: 1
Channel type: net, Name: node2
Save the cluster member information? yes/no [yes]:
Writing to configuration file...done
Configuration information has been saved to /etc/cluster.conf.
----------------------------
Setting up Quorum Partitions
----------------------------
Running cludiskutil -I to initialize the quorum partitions: done
Saving configuration information to quorum partitions: done
Do you wish to allow remote monitoring of the cluster? yes/no
[yes]: yes
----------------------------------------------------------------
Configuration on this member is complete.
To configure the next member, invoke the following command on that system:
# /sbin/cluconfig --init=/dev/raw/raw1
See the manual to complete the cluster installation

3.配製第二個節點

只需執行 cluconfig --init=/dev/raw/raw1


4.啟動Cluster服務

分別在兩個節點上執行 service cluster start
你將看到下面的幾個Daemon
• cluquorumd — Quorum daemon
• clusvcmgrd — Service manager daemon
• clupowerd — Power daemon
• cluhbd — Heartbeat daemon
• clumibd — Administrative system monitoring daemon

五、建立Cluster應用服務

說明:本次實驗只測試了Samba,其他應用服務的建立,請參考RedHat 文件。
.
1.Samba
說明:Samba在cluster的環境下與單機有一些不同,首先是配製檔案的改變,不在是/etc/samba/smb.conf,而是/etc/samba/smb.conf.xxxàxxx代表你的共享名字,可以是任何字母。Samba在cluster環境下需要自己的locking目錄/var/cache/samba/xxxx


2. 執行/sbin/cluadmin

說明:只需要在其中一個節點執行該命令,當你執行上面的命令你將看到以下輸出:

Service name: samba à所有黑色字型代表手工輸入接受其預設值
Preferred member [None]:Node1 à這行代表Samba服務將預設在node1上執行。
Relocate when the preferred member joins the cluster (yes/no/?) [no]: yes
User script (e.g., /usr/foo/script or None) [None]:
Status check interval [0]: 10
Do you want to add an IP address to the service (yes/no/?) [no]: yes
IP Address Information
IP address: 10.0.0.10 à這行代表Samba服務執行的IP地址,即windows客戶端訪問輸入的IP地址。
Netmask (e.g. 255.255.255.0 or None) [None]:
Broadcast (e.g. X.Y.Z.255 or None) [None]:
Do you want to (a)dd, (m)odify, (d)elete or (s)how an IP address, or
are you (f)inished adding IP addresses [f]:f
Do you want to add a disk device to the service (yes/no/?) [no]: yes
Disk Device Information
Device special file (e.g., /dev/sdb4): /dev/sdb3
Filesystem type (e.g., ext2, ext3 or None): ext3
Mount point (e.g., /usr/mnt/service1) [None]: /data à這行代表真正共享的存放地。
Mount options (e.g., rw,nosuid,sync): rw,nosuid,sync
Forced unmount support (yes/no/?) [yes]:
Would you like to allow NFS access to this filesystem (yes/no/?)
[no]: no
Would you like to share to Windows clients (yes/no/?) [no]: yes
You will now be prompted for the Samba configuration:
Samba share name: samba –>這行即windows客戶端在網路上的芳鄰看到的名字。
The samba config file /etc/samba/smb.conf.samba does not exist.
Would you like a default config file created (yes/no/?) [no]: yes
Successfully created daemon lock directory /var/cache/samba/acct.

Please run ‘mkdir /var/cache/samba/samba‘ on the other cluster member.
Successfully created /etc/samba/smb.conf.samba.
Please remember to make necessary customizations and then copy the file
over to the other cluster member.
Do you want to (a)dd, (m)odify, (d)elete or (s)how DEVICES, or
are you (f)inished adding DEVICES [f]: f
name: samba
preferred node:node1
relocate: yes
user script: None
monitor interval: 30
IP address 0: 10.0.0.10
netmask 0: None
broadcast 0: None
device 0: /dev/sdb12
mount point, device 0: /mnt/users/accounting
mount fstype, device 0: ext2
mount options, device 0: rw,nosuid,sync
force unmount, device 0: yes
samba share, device 0: samba
Add samba_acct service as shown? (yes/no/?) yes

3.配製第二個節點

• 複製 /etc/samba/smb.conf.xxx.
• mkdir /var/cache/samba/samba

4.配製windows客戶端訪問

在Linux端為windows使用者建立帳戶 useradd xxx

touch /etc/samba/smbpasswd

smbpasswd –a xxx

5.管理和測試Cluster

a. 當Samba在node1上執行時,你可以在node2執行Cluadmin –>service show
service relocate xxxx
這個時候服務和IP地址都應轉移到node2。

b. 假設node1是主節點,你將服務成功轉移到node2後,然後重啟node1,如果服務自動重新轉移到nose1。恭喜你,一個基本的cluster服務完成了。


六、可能遇到的問題

問題:不能初始化Quorum分割槽。

在分割槽後應立即從啟系統,以便能識別新的分割槽,同時確保不要建立檔案系統在Quorum和HOSTS檔案內容是否與主機名匹配。

問題:在建立Samba的服務時沒有成功。

共享分割槽沒有建立檔案系統。

問題:移掉一塊網路卡後,Cluster不能啟動。

因為IP地址改變,造成與quorum中不一致,更該IP地址與quorum相匹配。

問題:是否可以在PV660F 和CX400/CX600上實現。

這個還需要各位去實踐,但我個人認為應該沒有問題,只是在分配硬碟給Linux的步驟上有一些小的差別。


NFS 服務

在配置NFS是不需要手工建立locking目錄,因為NFS檔案lock不會由cluster服務來管理,它由系統檔案自身來完成。

在兩個節點上分別執行NFS服務
例:chkconfig nfs on
service nfs start
在其中一個節點上執行cluadmin-àservice add nfs
[@more@]

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/7507082/viewspace-850895/,如需轉載,請註明出處,否則將追究法律責任。

相關文章