RHCS是RedHatClusterSuite的縮寫,也就是紅帽子叢集套件,RHCS是一個能夠提供高可用性、高可靠性、負載均衡、存儲共享且經濟廉價的叢集工具集合,它将叢集系統中三大叢集架構融合一體,可以給web應用、資料庫應用等提供安全、穩定的運作環境。
特點:可以100多台機器作為節點
服務不需要叢集軟體
共享存儲是有用的,不是必須的
網絡電源切換需要為多機器服務
紅帽叢集套件程序:
<a target="_blank" href="http://blog.51cto.com/attachment/201312/123124604.png"></a>
這是RHCS叢集的一個基礎套件,提供一個叢集的基本功能,使各個節點組成叢集在一起工作,具體包含分布式叢集管理器(CMAN)、成員關系管理、鎖管理(DLM)、配置檔案管理(CCS)、栅裝置(FENCE)。
叢集配置系統:ccsd(cluster configure system)
高可用管理:aisexec:叢集建通信、成員管理
Rgmanager:叢集資源管理
共享存儲:dlm:分布式鎖機制
部署:luci和system-config-cluster方式配叢集
配置檔案:
/etc/cluster/cluster.conf
1、配置centos源
如果可以聯網,我們可以使用centsos源來進行yum安裝
#vi /etc/yum.conf
[base]
name=Red Hat Enterprise Linux $releasever -Base
baseurl=http://ftp.twaren.net/Linux/CentOS/5/os/$basearch/
gpgcheck=1
[update]
name=Red Hat Enterprise Linux $releasever -Updates
baseurl=http://ftp.twaren.net/Linux/CentOS/5/updates/$basearch/
[extras]
name=Red Hat Enterprise Linux $releasever -Extras
baseurl=http://ftp.twaren.net/Linux/CentOS/5/extras/$basearch/
[addons]
name=Red Hat Enterprise Linux $releasever -Addons
baseurl=http://ftp.twaren.net/Linux/CentOS/5/addons/$basearch/
Yum install scsi-target*
RHA5上用yum安裝程式時候,出現下面的異常問題:
Is this ok [y/N]: y
Downloading Packages:
warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID e8562897
RHA5
解決辦法:
rpm --import http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-5
如果是低版本,可以使用
如果本地沒有聯網,則可以配置一個本地CD光牒yum源
[Base]
name=RHEL5 ISO Base
baseurl=file:///media/cdrom/Server
enabled=1
gpgcheck=0
[Cluster]
name=RHEL5 ISO Cluster
baseurl=file:///media/cdrom/Cluster
2.2部署叢集軟體
Yum install ricci
Chkconfig ricci on
Service ricci restart
Yum install luci 配置管理節軟體luci
[root@localhost iscsi]# luci_admin init 設定luci密碼
Initializing the luci server
Creating the 'admin' user
Enter password:
Confirm password:
Please wait...
The admin password has been successfully set.
Generating SSL certificates...
The luci server has been successfully initialized
You must restart the luci server for changes to take effect.
Run "service luci restart" to do so
#chkconfig luci on
#service luci restart
[root@localhost iscsi]# service luci restart
Shutting down luci: [确定]
Starting luci: Generating https SSL certificates... done
[确定]
Point your web browser to https://ipap.128:8084 to access luci
2.3配置叢集套件
<a>https://管理ip:8084</a>
<a target="_blank" href="http://blog.51cto.com/attachment/201312/123216718.png"></a>
叢集-》建立新叢集,輸入主機名和密碼
<a target="_blank" href="http://blog.51cto.com/attachment/201312/123240157.png"></a>
單擊送出,它就開始在節點進行軟體安裝和部署,成功後再叢集清單裡便可以看到建立的叢集,并可以進行叢集的開啟和停止與解散。
如果出現如下錯誤,則确認hosts檔案和防火牆與selinux是否關閉。
<a target="_blank" href="http://blog.51cto.com/attachment/201312/123257343.png"></a>
#chkconfig rgmanager on 這是一個可選元件,開啟資源管理
#service rgmanager restart
切換到叢集的節點,可以看到幾個功能框
Fence是一個虛拟的,分别在叢集下面配置自己的fence
Add a failover domain,設定優先級,如果優先級高的會優先,一般設為一樣,不讓随便跑。
<a target="_blank" href="http://blog.51cto.com/attachment/201312/123354429.png"></a>
Add a sharable fence device,選擇一個fence卡,切換機制。
<a target="_blank" href="http://blog.51cto.com/attachment/201312/123414457.png"></a>
2.4配置叢集服務
配置一個ip:叢集-》增加一個叢集ip
<a target="_blank" href="http://blog.51cto.com/attachment/201312/123430523.png"></a>
添加資源:輸入資源名,路徑和磁盤為同一磁盤
<a target="_blank" href="http://blog.51cto.com/attachment/201312/123447361.png"></a>
配置服務:叢集-》配置一個服務
選擇服務名,選擇切換域,選擇輪訓政策,這裡選擇relocate輪訓。
<a target="_blank" href="http://blog.51cto.com/attachment/201312/123505851.png"></a>
通過單擊add resource to this service,選擇我們剛剛建立的資源,配置完畢在服務頁開啟開啟服務。
<a target="_blank" href="http://blog.51cto.com/attachment/201312/123525304.png"></a>
2.5 叢集測試
Ping 192.168.68.130 虛拟的出的服務ip
<a target="_blank" href="http://blog.51cto.com/attachment/201312/123540883.png"></a>
#clustat -i 1 檢視叢集狀态
Cluster Status for cluster1 @ Mon Dec 16 15:35:51 2013
Member Status: Quorate
Member Name ID Status
------ ---- ---- ------
192.168.68.128 1 Online, Local, rgmanager
192.168.68.129 2 Online, rgmanager
Service Name Owner (Last) State
------- ---- ----- ------ -----
service:httpd 192.168.68.128 started
#ip addr list 檢視ip狀态
[root@localhost rc.d]# ip addr list
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: peth0: <BROADCAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000
link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
inet6 fe80::fcff:ffff:feff:ffff/64 scope link
我們可以通過圖形界面更改服務ip
<a target="_blank" href="http://blog.51cto.com/attachment/201312/123557626.png"></a>
#Clustat -i 1
Cluster Status for cluster1 @ Mon Dec 16 15:39:16 2013
service:httpd 192.168.68.129 started
這是一個早期的RHCS配置工具,我們首先再管理節點
Yum install sys-config-cluster安裝該工具
Yum install cman
Yum install rmanger
然後cp /etc/cluseter/cluster.conf 到所有節點
Chkconfig cman on
Chkconfig rgmanger on
Service cman start
Service rgmanager start
然後sys-config-clusetr開始配置即可
RHCS可以通過iscsi使用共享存儲,提高磁盤容量和工作效率。
Udev是一個政策,它使得linux對磁盤的識别變得簡單。
Iscsi使用tcp/ip協定,可以挂載共享存儲。
Chkconfig tgtd on
Service tgtd start
root@localhost yum.repos.d]# fdisk /dev/hdb 磁盤分區
The number of cylinders for this disk is set to 8322.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): n
Command action
l logical (5 or over)
p primary partition (1-4)
l
First cylinder (6403-8322, default 6403):
Using default value 6403
Last cylinder or +size or +sizeM or +sizeK (6403-8322, default 8322): +500MB
Command (m for help): p
Disk /dev/hdb: 4294 MB, 4294967296 bytes
16 heads, 63 sectors/track, 8322 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Device Boot Start End Blocks Id System
/dev/hdb1 1 8322 4194256+ 5 Extended
/dev/hdb5 1 195 98217 8e Linux LVM
/dev/hdb6 196 390 98248+ 8e Linux LVM
/dev/hdb7 391 585 98248+ 8e Linux LVM
/dev/hdb8 586 2524 977224+ 8e Linux LVM
/dev/hdb9 2525 4463 977224+ 8e Linux LVM
/dev/hdb10 4464 6402 977224+ 8e Linux LVM
/dev/hdb11 6403 7372 488848+ 83 Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: 裝置或資源忙.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
[root@localhost yum.repos.d]# partprobe /dev/hdb
[root@ipap ~]# mkfs.ext3 /dev/hdb11 格式化磁盤
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
122400 inodes, 488848 blocks
24442 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=67633152
60 block groups
8192 blocks per group, 8192 fragments per group
2040 inodes per group
Superblock backups stored on blocks:
8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 28 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@ipap ~]# mkfs.gfs2 -p lock_dlm -t cluster1:my-gfs2 -j 4 /dev/hdb11
This will destroy any data on /dev/hdb11.
It appears to contain a ext3 filesystem.
Are you sure you want to proceed? [y/n] y
3.2 建立挂載目标
建立挂載磁盤
#tgtadm --lld iscsi --op new --mode target --tid 1 -T ipap.2013-12.disk1
配置設定邏輯單元
#tgtadm --lld iscsi --op new --mode logicalunit --tid 1 --lun 1 -b /dev/hdb11
配置設定權限
tgtadm --lld iscsi --op bind --mode target --tid 1 -I 192.168.68.129
寫入開機腳本
history |tail -n 4 >>/etc/rc.d/rc.local
Vi /etc/rc.d/rc.local 修改開機腳本
顯示配置檔案
[root@localhost yum.repos.d]# tgtadm --lld iscsi --mode target --op show
Target 1: ipap.2013-12.disk1
System information:
Driver: iscsi
State: ready
I_T nexus information:
LUN information:
LUN: 0
Type: controller
SCSI ID: IET 00010000
SCSI SN: beaf10
Size: 0 MB, Block size: 1
Online: Yes
Removable media: No
Readonly: No
Backing store type: null
Backing store path: None
Backing store flags:
LUN: 1
Type: disk
SCSI ID: IET 00010001
SCSI SN: beaf11
Size: 501 MB, Block size: 512
Backing store type: rdwr
Backing store path: /dev/hdb11
Account information:
ACL information:
192.168.68.129
You have new mail in /var/spool/mail/root
授權模式
/etc/iscsi/iscsid.conf配置檔案
#node.session.auth.authmethod = CHAP
#node.session.auth.username = username
#node.session.auth.password = password
[root@localhost iscsi]# chkconfig iscsi on
[root@localhost iscsi]# service iscsi restart
Stopping iSCSI daemon: iscsiadm: can not connect to iSCSI daemon (111)!
iscsiadm: initiator reported error (20 - could not connect to iscsid)
iscsiadm: Could not stop iscsid. Trying sending iscsid SIGTERM or SIGKILL signals manually
iscsid 已停 [确定]
Turning off network shutdown. Starting iSCSI daemon: [确定]
設定 iSCSI 目标:iscsiadm: No records found!
rpm -ivh iscsi-initiator-utils-6.2.0.871-0.10.el5.x86_64.rpm
發現媒體
[root@localhost ~]# iscsiadm -m discovery -t sendtargets -p 192.168.68.128:3260192.168.68.128:3260,1 ipap.2013-12.disk1
挂載媒體
[root@localhost ~]# iscsiadm -m node -T ipap.2013-12.disk1 -p 192.168.68.128:3260 -l
Logging in to [iface: default, target: ipap.2013-12.disk1, portal: 192.168.68.128,3260]
Login to [iface: default, target: ipap.2013-12.disk1, portal: 192.168.68.128,3260]: successful
[root@localhost ~]# fdisk -l
Disk /dev/hda: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
/dev/hda1 * 1 13 104391 83 Linux
/dev/hda2 14 1044 8281507+ 8e Linux LVM
Disk /dev/sda: 500 MB, 500580864 bytes
16 heads, 60 sectors/track, 1018 cylinders
Units = cylinders of 960 * 512 = 491520 bytes
Disk /dev/sda doesn't contain a valid partition table
删除媒體
[root@localhost ~]# iscsiadm -m node -T ipap.2013-12.disk1 -p 192.168.68.128:3260 -u
[root@localhost ~]#Iscsiadm -m node -o delete -T ipap.2013-12.disk1 -p 192.168.68.128:3260
3.4 RHCS使用共享媒體
在一個多節點的RHCS叢集系統中,一個節點失敗後,叢集的服務和資源可以自動轉移到其它節點上,但是這種轉移是有條件的,例如,在一個四節點的叢集中,一旦有兩個節點發生故障,整個叢集系統将會挂起,叢集服務也随即停止,而如果配置了存儲叢集GFS檔案系統,那麼隻要有一個節點發生故障,所有節點挂載的GFS檔案系統将hung住。此時共享存儲将無法使用,這種情況的出現,對于高可用的叢集系統來說是絕對不允許的,解決這種問題就要通過表決磁盤來實作了。
mkdisk是一個叢集仲裁磁盤工具集,可以用來建立一個qdisk
共享磁盤也可以檢視共享磁盤的狀态資訊。mkqdisk操作隻能建立16
個節點的投票空間,Heuristics就是這麼一個擴充選項,它允許通過第三方應用程式來輔助定位節點狀态,常用的有ping網關或路由,或者通過腳本程式等,如果試探失敗,qdiskd會認為此節點失敗,進而試圖重新開機此節點,以使節點進入正常狀态。
待續……
本文轉自zsaisai 51CTO部落格,原文連結:http://blog.51cto.com/3402313/1343963