紅帽集羣RHCS

1、簡介:

RHCS是RedHatClusterSuite的縮寫,也就是紅帽子集羣套件,RHCS是一個能夠提供高可用性、高可靠性、負載均衡、存儲共享且經濟廉價的集羣工具集合,它將集羣系統中三大集羣架構融合一體,可以給web應用、數據庫應用等提供安全、穩定的運行環境。

特點:可以100多臺機器作爲節點

     服務不需要集羣軟件

     共享存儲是有用的,不是必須的

     網絡電源切換需要爲多機器服務

紅帽集羣套件進程:

123124604.png

這是RHCS集羣的一個基礎套件,提供一個集羣的基本功能,使各個節點組成集羣在一起工作,具體包含分佈式集羣管理器(CMAN)、成員關係管理、鎖管理(DLM)、配置文件管理(CCS)、柵設備(FENCE)。

集羣配置系統:ccsdcluster configure system

高可用管理:aisexec:集羣建通信、成員管理

           Rgmanager:集羣資源管理

共享存儲:dlm:分佈式鎖機制

部署:lucisystem-config-cluster方式配集羣

配置文件:

/etc/cluster/cluster.conf

2RHCS紅帽集羣部署

2.1 配置yum

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/

gpgcheck=1

[extras]

name=Red Hat Enterprise Linux $releasever -Extras

baseurl=http://ftp.twaren.net/Linux/CentOS/5/extras/$basearch/

gpgcheck=1

[addons]

name=Red Hat Enterprise Linux $releasever -Addons

baseurl=http://ftp.twaren.net/Linux/CentOS/5/addons/$basearch/

gpgcheck=1


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

如果是低版本,可以使用

rpm --import http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-centos4


如果本地沒有聯網,則可以配置一個本地光盤yum

#vi /etc/yum.conf

[Base]  

name=RHEL5 ISO Base  

baseurl=file:///media/cdrom/Server  

enabled=1

gpgcheck=0

[Cluster]  

name=RHEL5 ISO Cluster  

baseurl=file:///media/cdrom/Cluster  

enabled=1

gpgcheck=0

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配置集羣套件

https://管理ip:8084

123216718.png

集羣-》創建新集羣,輸入主機名和密碼

123240157.png

單擊提交,它就開始在節點進行軟件安裝和部署,成功後再集羣列表裏便可以看到創建的集羣,並可以進行集羣的開啓和停止與解散。

如果出現如下錯誤,則確認hosts文件和防火牆與selinux是否關閉。

123257343.png

123312376.png123328984.png

#chkconfig rgmanager on    這是一個可選組件,開啓資源管理

#service rgmanager restart

切換到集羣的節點,可以看到幾個功能框

Fence是一個虛擬的,分別在集羣下面配置自己的fence

Add a failover domain,設置優先級,如果優先級高的會優先,一般設爲一樣,不讓隨便跑。

123354429.png

Add a sharable fence device,選擇一個fence卡,切換機制。


123414457.png

2.4配置集羣服務

配置一個ip:集羣-》增加一個集羣ip

123430523.png

添加資源:輸入資源名,路徑和磁盤爲同一磁盤

123447361.png

配置服務:集羣-》配置一個服務

選擇服務名,選擇切換域,選擇輪訓策略,這裏選擇relocate輪訓。

123505851.png

通過單擊add resource to this service,選擇我們剛剛建立的資源,配置完畢在服務頁開啓開啓服務。

123525304.png

2.5 集羣測試

Ping  192.168.68.130     虛擬的出的服務ip

123540883.png

#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

      valid_lft forever preferred_lft forever

我們可以通過圖形界面更改服務ip

123557626.png

#Clustat -i 1

Cluster Status for cluster1 @ Mon Dec 16 15:39:16 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.129               started  

2.6 Sys-config-clustert使用

這是一個早期的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開始配置即可

3.1RHCS共享存儲配置

RHCS可以通過iscsi使用共享存儲,提高磁盤容量和工作效率。

Udev是一個策略,它使得linux對磁盤的識別變得簡單。

Iscsi使用tcp/ip協議,可以掛載共享存儲。

3.1配置iscsi服務器端

Yum install scsi-target*

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

           Online: Yes

           Removable media: No

           Readonly: No

           Backing store type: rdwr

           Backing store path: /dev/hdb11

           Backing store flags:

   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!

                                                          [確定]

3.3 配置iscsi客戶端:

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


  Device Boot      Start         End      Blocks   Id  System

/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會認爲此節點失敗,進而試圖重啓此節點,以使節點進入正常狀態。

待續……



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章