.RHCS简介:

RHCSRed Hat ClusterSuite的缩写。

RHCS是一个功能完备的集群应用解决方案,它从应用的前端访问到后端的数据存储都提供了一个行之有效的集群架构实现,通过RHCS提供的这种解决方案,不但能保证前端应用持久、稳定的提供服务,同时也保证了后端数据存储的安全。

 

RHCS集群的组成:

RHCS是一个集群套件,其主要包括以下几部分:

1.集群构架管理器:RHCS的基础套件,提供集群的基本功能,主要包括布式集群管理器(CMAN)、锁管理(DLM)、配置文件管理(CCS)、栅设备(FENCE

2.rgmanager高可用服务管理器

提供节点服务监控和服务故障转移功能,当一个节点服务出现故障时,将服务转移到另一个健康节点。

3.集群管理工具

RHCS通过system-config-cluster来进行配置,这是一个基于图形界面的工具,可以很简单、明了的进行配置

4.负载均衡工具

RHCS通过LVS实现服务之间的负载均衡,LVS是系统内核中的套件,所有性能比较好。

5.GFSv2

集群文件系统,这是由RedHat公司开发的,GFS文件系统允许多个服务同时读写一个磁盘分区,通过GFS可以实现数据的集中管理,免去了数据同步和拷贝的麻烦,但GFS并不能孤立的存在,安装GFS需要RHCS的底层组件支持。

6.Cluster Logical Volume Manager

Cluster逻辑卷管理,即CLVM,是LVM的扩展,这种扩展允许cluster中的机器使用LVM来管理共享存储,但是配置之前需要开启lvm支持集群功能。

7.ISCSI

iSCSI是一种在Internet协议上,利用tcp/ip机制对fcfc-xx等进行封装后在网络中进行传输。isici是基于C/S架构的,数据首先被封装成scsi报文,在封装成iscsi报文,最后封装tcp/ip报文进行传输!iscsi是基于tcp的,监听在3260上,通过3260端口向外提供tcp/ip的服务的,isisc的会话是一直保存建立的,知道会话介绍再断开。RHCS可以通过ISCSI技术来导出和分配共享存储的使用。

 

运行原理:

1 分布式集群管理器

管理集群成员,了解成员之间的运行状态。

 

2 锁管理

每一个节点都运行了一个后台进程DLM,当用记操作一个元数据时,会通知其它节点,只能读取这个元数据。

 

3 配置文件管理

Cluster Configuration System,主要用于集群配置文件管理,用于配置文件的同步。

每个节点运行了CSS后台进程。当发现配置文件变化后,马上将此变化传播到其它节点上去。

/etc/cluster/cluster.conf

 

4.栅设备(fence

工作原理:当主机异常,务机会调用栅设备,然后将异常主机重启,当栅设备操作成功后,返回信息给备机。

备机接到栅设备的消息后,接管主机的服务和资源。

 

Conga集群管理软件: 该工具包含在最新发布的RHEL中,通过使用Conga,你可以非常方便的配置和管理好你的服务器集群和存储阵列.conga由两部分组成,luciricciluci是跑在集群管理机器上的服务,而Ricci则是跑在各集群节点上的服务,集群的管理和配置由这两个服务进行通信.我们就使用Conga来管理RHCS集群。

 

 

.实验环境

实验使用CentOS 6.6 64bit系统搭建,各节点IP,软件规划表:

wKioL1Sr9pLCOtBHAAHHrTG_9YI713.jpg

RHCS实验架构图:

 wKiom1Sr9fzBRfxgAALzDkrfyoY770.jpg

.前期准备工作

1.节点之间时间必须同步,建议使用ntp协议进行;

2.节点之间必须要通过主机名互相通信;

建议使用hosts文件;

通信中使用的名字必须与其节点为上“uname -n”命令展示出的名字保持一致;

3.我们这里是三个存储节点,如果是2个节点需要提供:qdisk仲裁设备

4.节点之间彼此root用户能基于ssh密钥方式进行无密钥通信;

5.yum源也需要配置好。

 

前提的实现:

 

1.设置管理端:

将管理端的公钥私钥传输给各节点:

  1. [root@nfs ~]# ssh-keygen
  2. [root@nfs ~]# for i in {1..4} ;dossh-copy-id -i node$i; done

管理端实现无密钥登录。

 

2.各节点主机名解析一致;

先于管理端配置完毕;复制到各节点。

  1. [root@nfs ~]# cat /etc/hosts
  2. 127.0.0.1  localhost localhost.localdomain localhost4 localhost4.localdomain4
  3. ::1        localhost localhost.localdomain localhost6 localhost6.localdomain6
  4. 172.16.0.1 server.magelinux.com server
  5. 172.16.31.12 nfs.stu31.com nfs
  6. 172.16.31.10 node1.stu31.com node1
  7. 172.16.31.11 node2.stu31.com node2
  8. 172.16.31.13 node3.stu31.com node3
  9. 172.16.31.14 node4.stu31.com node4

 

  1. [root@nfs ~]# for i in {1..4} ; do scp/etc/hosts root@node$i:/etc/hosts ; done
  2. hosts                                                     100%  369    0.4KB/s   00:00   
  3. hosts                                                    100%  369     0.4KB/s  00:00   
  4. hosts                                                    100%  369     0.4KB/s  00:00   
  5. hosts                                                    100%  369     0.4KB/s  00:00

 

2.节点之间实现无密钥通信

  1. [root@node1 ~]# ssh-keygen -t rsa -P""
  2. [root@node1 ~]# for i in {1..4} ; dossh-copy-id -i .ssh/id_rsa.pub root@node$i ; done

其它节点依次实现:

 

最后实现时间测试:

 

  1. [root@node1 ~]# date; ssh node2 date; sshnode3 date ; ssh node4 date
  2. Mon Jan 5 20:05:16 CST 2015
  3. Mon Jan 5 20:05:16 CST 2015
  4. Mon Jan 5 20:05:16 CST 2015
  5. Mon Jan 5 20:05:17 CST 2015

或者在管理节点nfs上测试时间:

[root@nfs ~]# for i in {1..4} ;do sshnode$i 'date' ; done

 

节点的yum源都有特定服务器提供:

  1. [root@node1 ~]# cat/etc/yum.repos.d/centos6.6.repo
  2. [base]
  3. name=CentOS $releasever $basearch on localserver 172.16.0.1
  4. baseurl=http://172.16.0.1/cobbler/ks_mirror/CentOS-6.6-$basearch/
  5. gpgcheck=0
  6.  
  7. [extra]
  8. name=CentOS $releasever $basearch extras
  9. baseurl=http://172.16.0.1/centos/$releasever/extras/$basearch/
  10. gpgcheck=0
  11.  
  12. [epel]
  13. name=Fedora EPEL for CentOS$releasever$basearch on local server 172.16.0.1
  14. baseurl=http://172.16.0.1/fedora-epel/$releasever/$basearch/
  15. gpgcheck=0

 

 

.conga的安装配置

安装luciricci(管理端安装luci,节点安装ricci

Luci是运行WEB样式的Conga服务器端,它可以通过web界面很容易管理整个RHCS集群,每一步操作都会在/etc/cluster/cluster.conf生成相应的配置信息

 

1.在管理端安装luci

[root@nfs ~]# yum install -y luci

 

安装完成后启动luci

  1. [root@nfs ~]# /etc/rc.d/init.d/luci start
  2. Adding following auto-detected host IDs (IPaddresses/domain names), corresponding to `nfs.stu31.com' address, to theconfiguration of self-managed certificate `/var/lib/luci/etc/cacert.config'(you can change them by editing `/var/lib/luci/etc/cacert.config', removing thegenerated certificate `/var/lib/luci/certs/host.pem' and restarting luci):
  3.        (none suitable found, you can still do it manually as mentioned above)
  4.  
  5. Generating a 2048 bit RSA private key
  6. writing new private key to'/var/lib/luci/certs/host.pem'
  7. Starting saslauthd:                                        [  OK  ]
  8. Start luci...                                             [  OK  ]
  9. Point your web browser tohttps://nfs.stu31.com:8084 (or equivalent) to access luci

\\生成以上信息,说明配置成功,注意:安装luci会安装很多python包,python包尽量采用光盘自带的包,否则启动luci会出现报错现象。

 

2.在其他节点上安装ricci;在管理端运行安装简单一些。

[root@nfs ~]# for i in {1..4}; do sshnode$i "yum install ricci -y"; done

安装完成后启动ricci服务:

[root@nfs ~]# for i in {1..4}; do sshnode$i "chkconfig ricci on && /etc/rc.d/init.d/ricci start";done

为各节点的ricci设置密码,在Conga web页面添加节点的时候需要输入ricci密码。

[root@nfs ~]# for i in {1..4}; do sshnode$i "echo 'oracle' | passwd ricci --stdin"; done

 

4.添加节点node1-node3,设置3个节点满足RHCS集群的要求,password为各节点ricci的密码,然后勾选“DownloadPackages”(在各节点yum配置好的基础上,自动安装cmanrgmanager及相关的依赖包),勾选“Enable Shared Storage Support”,安装存储相关的包,并支持gfs2文件系统、DLM锁、clvm逻辑卷等。

 

5.访问https://172.16.31.13:8084或者https://nfs.stu31.com:8084

wKioL1Sr6cvyy4Z6AAEghMTUYWA389.jpg

警告忽略:

wKioL1Sr6deC04ADAAJWWAV3NUM538.jpg

选择Manage Clusters创建集群,点击Create

wKiom1Sr6SSS4AZiAAEO1v9PhtU579.jpg

集群名称,添加节点:

wKiom1Sr6XuxlhcQAAKCRqXf9VM326.jpg

RHCS必须存在3个节点哦!

wKioL1Sr6fDys1TkAALDqneyocc614.jpg

创建完成;将会自动安装cmanrgmanager,及自动安装lvm2-cluster,并自动启动服务:

wKioL1Sr6knQLXaUAAKtXKxYQHk446.jpg

注意:创建集群失败,启动cman失败,我们需要将NetworkManager服务关闭:

  1. [root@node1 ~]# service cman start
  2. Starting cluster:
  3.   Checking if cluster has been disabled at boot...        [ OK  ]
  4.   Checking Network Manager...
  5. Network Manager is either running orconfigured to run. Please disable it in the cluster.
  6.                                                           [FAILED]
  7. Stopping cluster:
  8.   Leaving fence domain...                                 [  OK  ]
  9.   Stopping gfs_controld...                                [  OK  ]
  10.   Stopping dlm_controld...                                [  OK  ]
  11.   Stopping fenced...                                      [  OK  ]
  12.   Stopping cman...                                        [  OK  ]
  13.   Unloading kernel modules...                             [  OK  ]
  14.   Unmounting configfs...                                  [  OK  ]
  15. [root@node1 ~]#

关闭 NetworkManager服务及其自启动:

  1. [root@nfs ~]# for i in {1..4}; do sshnode$i "chkconfig NetworkManager off &&/etc/rc.d/init.d/NetworkManager stop" ; done
  2. Stopping NetworkManager daemon: [  OK  ]
  3. Stopping NetworkManager daemon: [  OK  ]
  4. Stopping NetworkManager daemon: [  OK  ]
  5. Stopping NetworkManager daemon: [  OK  ]

 

再次加入节点创建集群成功。

 

7.我们需要将cmanrgmanagerclvmd服务设置为开机自启动。

[root@nfs ~]# for i in {1..3}; do sshnode$i "chkconfig cman on && chkconfig rgmanager on &&chkconfig clvmd on  " ; done

登录任意一个节点查看各服务的开机启动情况,为2-5级别自动启动。

  1. [root@nfs ~]# ssh node1 "chkconfig--list |grep cman "                                     
  2. cman            0:off   1:off  2:on    3:on    4:on   5:on    6:off
  3. [root@nfs ~]# ssh node1 "chkconfig--list |grep rgmanager "                                
  4. rgmanager       0:off  1:off   2:on    3:on   4:on    5:on    6:off
  5. [root@nfs ~]# ssh node1 "chkconfig--list |grep clvmd "                                    
  6. clvmd           0:off   1:off  2:on    3:on    4:on   5:on    6:off

 

8.查看集群节点状态:

  1. [root@node2 ~]# clustat
  2. Cluster Status for tcluster @ Tue Jan  6 12:39:48 2015
  3. Member Status: Quorate
  4.  
  5.  Member Name                             ID   Status
  6.  ------ ----                             ---- ------
  7.  node1.stu31.com                             1 Online
  8.  node2.stu31.com                             2 Online, Local
  9.  node3.stu31.com                             3 Online

 

 

.配置共享存储服务器

我们将node4设置为共享存储服务器

  1. 1.存在个空闲的磁盘,分别是sdb
  2. [root@node4 ~]# ls /dev/sd*
  3. /dev/sda /dev/sda1  /dev/sda2  /dev/sdb

我们将其格式化为一个LVS的逻辑卷

[root@node4 ~]# echo -e -n"n\np\n1\n\n\nt\n8e\nw\n" |fdisk /dev/sdb

2.安装iSCSI管理端

[root@node4 ~]# yum -y installscsi-target-utils

 

3.配置导出磁盘

  1. [root@node4 ~]# vim /etc/tgt/targets.conf
  2. <targetiqn.2015-01.com.stu31:node4.t1>
  3.        backing-store /dev/sdb1
  4.        initiator-address 172.16.31.0/24
  5. </target>

 

启动iSCSI服务器:

  1. [root@node4 ~]# service tgtd start
  2. Starting SCSI target daemon:                               [  OK  ]

 

查看存储导出状态:

  1. [root@node4 ~]# tgtadm -L iscsi -m target-o show
  2. Target 1: iqn.2015-01.com.stu31:node4.t1
  3.    System information:
  4.        Driver: iscsi
  5.        State: ready
  6.    I_T nexus information:
  7.    LUN information:
  8.        LUN: 0
  9.            Type: controller
  10.            SCSI ID: IET     00010000
  11.            SCSI SN: beaf10
  12.            Size: 0 MB, Block size: 1
  13.            Online: Yes
  14.            Removable media: No
  15.            Prevent removal: No
  16.            Readonly: No
  17.            Backing store type: null
  18.            Backing store path: None
  19.            Backing store flags:
  20.        LUN: 1
  21.            Type: disk
  22.            SCSI ID: IET     00010001
  23.            SCSI SN: beaf11
  24.            Size: 16105 MB, Block size: 512
  25.            Online: Yes
  26.            Removable media: No
  27.            Prevent removal: No
  28.            Readonly: No
  29.            Backing store type: rdwr
  30.            Backing store path: /dev/sdb1
  31.            Backing store flags:
  32.    Account information:
  33.    ACL information:
  34.        172.16.31.0/24

 

4.node1-node3节点安装iscsi客户端软件:

[root@nfs ~]# for i in {1..3} ; do sshnode$i "yum -y install iscsi-initiator-utils"; done

 

5.使用iscsi-iname生成iscsi的随机后缀,注意命令使用的节点

  1. [root@node1 ~]# for i in {1..3} ; do sshnode$i "echo "InitiatorName=`iscsi-iname -piqn.2015-01.com.stu31`" > /etc/iscsi/initiatorname.iscsi" ; done
  2. [root@node1 ~]# cat/etc/iscsi/initiatorname.iscsi
  3. InitiatorName=iqn.2015-01.com.stu31:c0d826102dbb

 

6.节点客户端发现共享存储

  1. [root@nfs ~]# for i in {1..3}; do sshnode$i "iscsiadm -m discovery -t st -p 172.16.31.14"; done
  2. [ OK  ] iscsid: [  OK  ]
  3. 172.16.31.14:3260,1iqn.2015-01.com.stu31:node4.t1
  4. [ OK  ] iscsid: [  OK  ]
  5. 172.16.31.14:3260,1iqn.2015-01.com.stu31:node4.t1
  6. [ OK  ] iscsid: [  OK  ]
  7. 172.16.31.14:3260,1iqn.2015-01.com.stu31:node4.t1

 

7.注册iscsi共享设备,节点登录,

  1. [root@nfs ~]# for i in {1..3}; do sshnode$i "iscsiadm -m node -l" ;done
  2. Logging in to [iface: default, target:iqn.2015-01.com.stu31:node4.t1, portal: 172.16.31.14,3260] (multiple)
  3. Login to [iface: default, target:iqn.2015-01.com.stu31:node4.t1, portal: 172.16.31.14,3260] successful.
  4. Logging in to [iface: default, target:iqn.2015-01.com.stu31:node4.t1, portal: 172.16.31.14,3260] (multiple)
  5. Login to [iface: default, target:iqn.2015-01.com.stu31:node4.t1, portal: 172.16.31.14,3260] successful.
  6. Logging in to [iface: default, target:iqn.2015-01.com.stu31:node4.t1, portal: 172.16.31.14,3260] (multiple)
  7. Login to [iface: default, target:iqn.2015-01.com.stu31:node4.t1, portal: 172.16.31.14,3260] successful.

 

8.存储共享服务器端查看共享情况

  1. [root@node4 ~]# tgtadm --lld iscsi --opshow --mod conn --tid 1
  2. Session: 3
  3.    Connection: 0
  4.        Initiator: iqn.2015-01.com.stu31:c1e7a22d5392
  5.        IP Address: 172.16.31.13
  6. Session: 2
  7.    Connection: 0
  8.        Initiator: iqn.2015-01.com.stu31:36dfc7f6171
  9.        IP Address: 172.16.31.11
  10. Session: 1
  11.    Connection: 0
  12.        Initiator: iqn.2015-01.com.stu31:34fc39a6696
  13.        IP Address: 172.16.31.10

 

9.各节点都会多出一个磁盘/sdb

  1. [root@nfs ~]# for i in {1..3} ; do sshnode$i "ls -l /dev/sd*|grep -v sda" ;done
  2. brw-rw---- 1 root disk 816 Jan  6 12:55 /dev/sdb
  3. brw-rw---- 1 root disk 816 Jan  6 12:55 /dev/sdb
  4. brw-rw---- 1 root disk 816 Jan  6 12:55 /dev/sdb

 

 

10.创建集群逻辑卷

将共享磁盘创建为集群逻辑卷

  1. [root@node1 ~]# echo -n -e"n\np\n1\n\n+10G\nt\n8e\nw\n" |fdisk /dev/sdb
  2. [root@node1 ~]# partx -a /dev/sdb
  3. BLKPG: Device or resource busy
  4. error adding partition 1

 

  1. [root@node1 ~]# ll /dev/sd*
  2. brw-rw---- 1 root disk 8,  0 Jan 6 02:40 /dev/sda
  3. brw-rw---- 1 root disk 8,  1 Jan 6 02:40 /dev/sda1
  4. brw-rw---- 1 root disk 8,  2 Jan 6 02:40 /dev/sda2
  5. brw-rw---- 1 root disk 816 Jan  6 14:29 /dev/sdb
  6. brw-rw---- 1 root disk 817 Jan  6 14:29 /dev/sdb1

并且sdb1的格式为逻辑卷磁盘:

  1. [root@node2 ~]# fdisk -l /dev/sdb
  2.  
  3. Disk /dev/sdb: 16.1 GB, 16105065984 bytes
  4. 64 heads, 32 sectors/track, 15358 cylinders
  5. Units = cylinders of 2048 * 512 = 1048576bytes
  6. Sector size (logical/physical): 512 bytes /512 bytes
  7. I/O size (minimum/optimal): 512 bytes / 512bytes
  8. Disk identifier: 0xc12c6dc5
  9.  
  10.   Device Boot      Start         End      Blocks  Id  System
  11. /dev/sdb1               1      10241    10486768   8e Linux LVM

 

 

开始创建逻辑卷:

  1. [root@node1 ~]# pvcreate /dev/sdb1
  2.  Physical volume "/dev/sdb1" successfully created
  3. [root@node1 ~]# vgcreate cvg /dev/sdb1
  4.  Clustered volume group "cvg" successfully created

[root@node1 ~]# lvcreate -L 5G -n clv cvg

  Error locking on nodenode3.stu31.com: Volume group for uuid not found:swue1b5PBQHolDi5LKyvkCvecXN7tMkCOyEHCz50q8HqwodCeacVZccNhZF2kDeb

  Error locking on node node2.stu31.com: Volumegroup for uuid not found: swue1b5PBQHolDi5LKyvkCvecXN7tMkCOyEHCz50q8HqwodCeacVZccNhZF2kDeb

  Failed to activate new LV.

报错了:

同步出现问题,我们去node2node3去重新格式化后创建pv

  1. [root@node2 ~]# ll /dev/sd*
  2. brw-rw---- 1 root disk 8,  0 Jan 6 02:40 /dev/sda
  3. brw-rw---- 1 root disk 8,  1 Jan 6 02:40 /dev/sda1
  4. brw-rw---- 1 root disk 8,  2 Jan 6 02:40 /dev/sda2
  5. brw-rw---- 1 root disk 816 Jan  6 14:54 /dev/sdb

 

事例node3,节点2同样操作:

  1. [root@node3 ~]# fdisk /dev/sdb
  2.  
  3. WARNING: DOS-compatible mode is deprecated.It's strongly recommended to
  4.         switch off the mode (command 'c') and change display units to
  5.         sectors (command 'u').
  6.  
  7. Command (m for help): d
  8. Selected partition 1
  9.  
  10. Command (m for help): 1
  11. 1: unknown command
  12. Command action
  13.   a   toggle a bootable flag
  14.   b   edit bsd disklabel
  15.   c   toggle the dos compatibilityflag
  16.   d   delete a partition
  17.   l   list known partition types
  18.   m   print this menu
  19.   n   add a new partition
  20.   o   create a new empty DOSpartition table
  21.   p   print the partition table
  22.   q   quit without saving changes
  23.   s   create a new empty Sundisklabel
  24.   t   change a partition's system id
  25.   u   change display/entry units
  26.   v   verify the partition table
  27.   w   write table to disk and exit
  28.   x   extra functionality (expertsonly)
  29.  
  30. Command (m for help): p
  31.  
  32. Disk /dev/sdb: 16.1 GB, 16105065984 bytes
  33. 64 heads, 32 sectors/track, 15358 cylinders
  34. Units = cylinders of 2048 * 512 = 1048576bytes
  35. Sector size (logical/physical): 512 bytes /512 bytes
  36. I/O size (minimum/optimal): 512 bytes / 512bytes
  37. Disk identifier: 0xc12c6dc5
  38.  
  39.   Device Boot      Start         End      Blocks  Id  System
  40.  
  41. Command (m for help): n
  42. Command action
  43.   e   extended
  44.   p   primary partition (1-4)
  45. p
  46. Partition number (1-4): 1
  47. First cylinder (1-15358default 1):
  48. Using default value 1
  49. Last cylinder, +cylinders or +size{K,M,G}(1-15358default 15358): +10G
  50.  
  51. Command (m for help): t
  52. Selected partition 1
  53. Hex code (type L to list codes): 8e
  54. Changed system type of partition 1 to 8e(Linux LVM)
  55.  
  56. Command (m for help): p
  57.  
  58. Disk /dev/sdb: 16.1 GB, 16105065984 bytes
  59. 64 heads, 32 sectors/track, 15358 cylinders
  60. Units = cylinders of 2048 * 512 = 1048576bytes
  61. Sector size (logical/physical): 512 bytes /512 bytes
  62. I/O size (minimum/optimal): 512 bytes / 512bytes
  63. Disk identifier: 0xc12c6dc5
  64.  
  65.    DeviceBoot      Start         End      Blocks  Id  System
  66. /dev/sdb1               1       10241   10486768   8e  Linux LVM
  67.  
  68. Command (m for help): w
  69. The partition table has been altered!
  70.  
  71. Calling ioctl() to re-read partition table.
  72. Syncing disks.
  1. [root@node3 ~]# partx -a /dev/sdb
  2. BLKPG: Device or resource busy
  3. error adding partition 1

创建PV:错误忽略

  1. [root@node3 ~]# pvcreate /dev/sdb1
  2.  Can't initialize physical volume "/dev/sdb1" of volume group"cvg" without -ff
  3. [root@node3 ~]# pvs
  4.  PV         VG   Fmt Attr PSize  PFree
  5.  /dev/sda2  vg0  lvm2 a-- 59.99g  7.99g
  6.  /dev/sdb1  cvg  lvm2 a-- 10.00g 10.00g

node2也是同样操作后创建pv

  1. [root@node2 ~]# pvcreate /dev/sdb1
  2.  Can't initialize physical volume "/dev/sdb1" of volume group"cvg" without -ff
  3. [root@node2 ~]# vgs
  4.  VG   #PV #LV #SN Attr   VSize VFree
  5.  cvg    1   0   0wz--nc 10.00g 10.00g
  6.  vg0    1   4   0wz--n- 59.99g  7.99g

  

 

node1重新创建:

  1. [root@node1 ~]# pvs
  2.  PV         VG   Fmt Attr PSize  PFree
  3.  /dev/sda2  vg0  lvm2 a-- 59.99g  7.99g
  4.  /dev/sdb1  cvg  lvm2 a-- 10.0010.00g
  5. [root@node1 ~]# vgs
  6.  VG   #PV #LV #SN Attr   VSize VFree
  7.  cvg    1   0   0wz--nc 10.0010.00g
  8.  vg0    1   4   0wz--n- 59.99g  7.99g
  9. [root@node1 ~]# lvcreate -L 5G -n clv cvg
  10.  Logical volume "clv" created

创建成功了


查看逻辑卷:

  1. [root@node1 ~]# lvs cvg
  2.  LV   VG   Attr      LSize Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  3.  clv  cvg  -wi-a----- 5.00g

 

格式化逻辑卷为集群文件系统:

  1. [root@node1 ~]# mkfs.gfs2 -j 3 -ttcluster:clv -p lock_dlm /dev/cvg/clv
  2. This will destroy any data on /dev/cvg/clv.
  3. It appears to contain: symbolic link to`../dm-4'
  4.  
  5. Are you sure you want to proceed? [y/n] y
  6.  
  7. Device:                    /dev/cvg/clv
  8. Blocksize:                 4096
  9. Device Size                5.00 GB (1310720 blocks)
  10. Filesystem Size:           5.00 GB (1310718 blocks)
  11. Journals:                  3
  12. Resource Groups:           20
  13. Locking Protocol:          "lock_dlm"
  14. Lock Table:                "tcluster:clv"
  15. UUID:                     8bdaeca4-aeeb-8fc7-a2d0-23cc7289ae4d

 

 

节点挂载上gfs2文件系统:

  1. [root@node1 ~]# mount -t gfs2 /dev/cvg/clv/var/www/html/
  2. [root@node1 ~]# echo "page fromCLVM@GFS2" > /var/www/html/index.html

 

 

我们去节点2挂载上:

  1. [root@node2 ~]# ls /var/www/html/
  2. [root@node2 ~]# mount -t gfs2 /dev/cvg/clv/var/www/html/
  3. [root@node2 ~]# ls /var/www/html/                       
  4. index.html

已经存在测试网页了。

 

然后我们在管理节点卸载:

[root@nfs ~]# for i in {1..3} ; do sshnode$i "umount /var/www/html" ;done

 

 

.登录Conga,进行web集群构建

构建失败转移域:

wKioL1Sr692zTs7JAAKBMcLMTTw106.jpg

创建资源:VIPhttpd服务,GFS共享存储

添加资源:

wKiom1Sr6zag-iGKAAHKEMaCx5w096.jpg

如下添加VIP地址:

wKioL1Sr7ArQhlcRAAKb1DkjU2g289.jpg

添加服务脚本httpd

wKioL1Sr7BuzacDbAAJ8XTDtZnw636.jpg

记住写入httpd脚本路径:

wKiom1Sr62-jKfniAAJ5p46_nug707.jpg

添加GFS2共享存储资源:

wKioL1Sr7ETjXNVYAAMJF326d7o503.jpg

 

将资源加入资源组:

wKioL1Sr7FWykJu-AAH1BMoQO9E012.jpg

创建资源组,并向其中加入设置好的自定义资源或者也可以直接添加设定资源:

wKioL1Sr7GuyMfqgAALD7gF-kIQ022.jpg

添加设置好的VIP资源:

wKioL1Sr7H-QFcrPAAMHIzTHbiI687.jpg

添加设置好的httpd服务资源:

wKioL1Sr7JKQ4lFnAAJW26gsXqA780.jpg

添加设置好的GFS2共享存储资源:

wKioL1Sr7KbwULxAAAJtboScPOI412.jpg

 

构建完成后启动webservice资源组:

wKiom1Sr6_yyo6wCAAO7VRM_F6A764.jpg

启动成功。

 

我们去管理端访问一下:

  1. [root@nfs ~]# curl http://172.16.31.180
  2. page from CLVM@GFS2

 

我们去节点1查看集群启动状态,喔,看怎么启动到node2了!!!!

  1. [root@node1 ~]# clustat
  2. Cluster Status for tcluster @ Tue Jan  6 13:22:07 2015
  3. Member Status: Quorate
  4.  
  5.  Member Name                             ID   Status
  6.  ------ ----                             ---- ------
  7.  node1.stu31.com                             1 Online, Local, rgmanager
  8.  node2.stu31.com                             2 Online,rgmanager
  9.  node3.stu31.com                             3 Online,rgmanager
  10.  
  11.  Service Name                   Owner (Last)                   State        
  12.  ------- ----                  ----- ------                   -----        
  13.  service:webservice             node2.stu31.com                started

 

 

我们在网页端刷新一下,喔,是node2啊,不能自动更新网页。

wKioL1Sr7PCAGPz9AAOLHbtfh1Y620.jpg

 

我们将集群切换到node1运行:

使用命令:

  1. [root@node2 ~]# clusvcadm -r webservice -mnode1.stu31.com
  2. Trying to relocate service:webservice tonode1.stu31.com...Success
  3. service:webservice is now running onnode1.stu31.com

 

到网页刷新一下:

wKiom1Sr7E-AKndaAAOuepeM1rc895.jpg

切换成功,ok,至此RHCS+Conga+GFS+cLVM共享存储的高可用性web集群就构建成功啦!