在RedHat下建立群集實例(ZT)
難度等級:中級
作者:不詳
在RedHat下建立群集
環境說明:
1. 硬件:
說明:按照標準至少需要4塊網卡和其他相應硬件,但因為條件限制,故在硬件和設置上做了一些變通。
服務器:PE4300、PE4600
網卡:兩個
RAID:兩塊PERC2/SC
StorageV220S和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 aclearcase/" target="_blank" >ccess 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的步驟上有一些小的差別。
七、相關資料
http://www.redhat.com/docs/manuals/advserver/
http://www.redhat.com/docs/manuals/haserver/
八、補充
NFS 服務
在配置NFS是不需要手工建立locking目錄,因為NFS文件lock不會由cluster服務來管理,它由系統文件自身來完成。
在兩個節點上分別運行NFS服務
例:chkconfig nfs on
service nfs start
在其中一個節點上運行cluadmin-àservice add nfs