CentOS6.4+Cman+RGManager+iSCSI+GFS2+cLVM 实现廉价的可扩展的集群共享存储

Linux大全评论1.7K views阅读模式

大纲

前言
一、环境准备
二、iscsi 安装与配置
三、cman与rgmanager 集群安装与配置
四、cLVM 安装与配置
五、gfs2 安装与配置
六、测试

前言
  前面的几篇文章中我们一直在讲解高可用集群,但一直没有讲解共享存储,我们又说共享存储是十分重要的,在这一篇博文中我们重点来讲一下共享存储,与前面的文章有所不同的是在这一篇文章中我们重点讲解的是具体操作,理论知识不做重点说明,至于什么是RHCS集群套件、什么是iscsi,大家可以到网上去搜索一下,全都是我在这里就不重点说明。但有一点我得说明一下,有博友会说了现在共享存储不是NAS就是SAN,你这个应用范围也太小了吧,但我想说是,企业级的NAS或都SAN设备动不动就是几十万或都上百万(我这里说少了),不是什么公司都能承受的(毕竟大公司也就那几个),对于中小型企业来说,我们不想用NAS或者SAN但我们又想用共享存储,性能上不是要求太高,我想这种方案还个不错的选择。好了,引子就说到这里,下面我们来具体演示一下,这种共享存储的实现。

相关系列文章

Corosync+Pacemaker+DRBD+MySQL 实现高可用(HA)的MySQL集群 http://www.linuxidc.com/Linux/2013-08/89036.htm

Linux 高可用(HA)集群之DRBD详解 http://www.linuxidc.com/Linux/2013-08/89035.htm

Linux 高可用(HA)集群之Pacemaker详解  http://www.linuxidc.com/Linux/2013-08/89037.htm

Linux 高可用(HA)集群之Corosync详解  http://www.linuxidc.com/Linux/2013-08/88733.htm

Heartbeat+MySQL+NFS 实现高可用(HA)的MySQL集群 http://www.linuxidc.com/Linux/2013-08/88663.htm

Linux 高可用(HA)集群之heartbeat基于crm进行资源管理详解 http://www.linuxidc.com/Linux/2013-08/89167.htm

Heartbeat+httpd+NFS 实现高可用的Web服务器 http://www.linuxidc.com/Linux/2013-08/88520.htm

Linux 高可用(HA)集群之Heartbeat详解  http://www.linuxidc.com/Linux/2013-08/88521.htm

Linux 高可用(HA)集群基本概念详解 http://www.linuxidc.com/Linux/2013-08/88522.htm

一、环境准备
1.操作系统
CentOS 6.4 X86_64

2.软件版本
scsi-target-utils-1.0.24-3.el6_4.x86_64
iscsi-initiator-utils-6.2.0.873-2.el6.x86_64
cman-3.0.12.1-49.el6_4.1.x86_64
rgmanager-3.0.12.1-17.el6.x86_64
gfs2-utils-3.0.12.1-49.el6_4.1.x86_64
lvm2-cluster-2.02.98-9.el6.x86_64

3.实验拓扑

CentOS6.4+Cman+RGManager+iSCSI+GFS2+cLVM 实现廉价的可扩展的集群共享存储

简单说明:RHCS集群套件,要求节点最少得3个。所以这里有3个集群节点和一个共享存储。(注,shared storage不但是共享存储,还是跳板机,且shared storage的主机名是target.test.com)
4.集群环境
(1).配置各节点名称
node1:
[root@node1 ~]# uname -n 
node1.test.com 
[root@node1 ~]# cat /etc/hosts 
127.0.0.1  localhost localhost.localdomain localhost4 localhost4.localdomain4 
::1        localhost localhost.localdomain localhost6 localhost6.localdomain6 
192.168.18.201    node1.test.com    node1 
192.168.18.202    node2.test.com    node2 
192.168.18.203    node3.test.com    node3
192.168.18.208  target.test.com target

node2:
[root@node2 ~]# uname -n
node2.test.com
[root@node2 ~]# cat /etc/hosts
127.0.0.1  localhost localhost.localdomain localhost4 localhost4.localdomain4
::1        localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.18.201    node1.test.com    node1
192.168.18.202    node2.test.com    node2
192.168.18.203    node3.test.com    node3
192.168.18.208  target.test.com target

node3:
[root@node3 ~]# uname -n
node3.test.com
[root@node3 ~]# cat /etc/hosts
127.0.0.1  localhost localhost.localdomain localhost4 localhost4.localdomain4
::1        localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.18.201    node1.test.com    node1
192.168.18.202    node2.test.com    node2
192.168.18.203    node3.test.com    node3
192.168.18.208  target.test.com target

shared storage:
[root@target ~]# uname -n
target.test.com
[root@target ~]# cat /etc/hosts
127.0.0.1  localhost localhost.localdomain localhost4 localhost4.localdomain4
::1        localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.18.201    node1.test.com    node1
192.168.18.202    node2.test.com    node2
192.168.18.203    node3.test.com    node3 
192.168.18.208  target.test.com target

(2).配置各节点与跳板机ssh互信
node1:
[root@node1 ~]# ssh-keygen  -t rsa -f ~/.ssh/id_rsa  -P '' 
[root@node1 ~]# ssh-copy-id -i .ssh/id_rsa.pub root@target.test.com

node2:
[root@node2 ~]# ssh-keygen  -t rsa -f ~/.ssh/id_rsa  -P '' 
[root@node2 ~]# ssh-copy-id -i .ssh/id_rsa.pub root@target.test.com

node3:
[root@node3 ~]# ssh-keygen  -t rsa -f ~/.ssh/id_rsa  -P '' 
[root@node3 ~]# ssh-copy-id -i .ssh/id_rsa.pub root@target.test.com

shared storage:
[root@target ~]# ssh-keygen  -t rsa -f ~/.ssh/id_rsa  -P '' 
[root@target ~]# ssh-copy-id -i .ssh/id_rsa.pub root@node1.test.com
[root@target ~]# ssh-copy-id -i .ssh/id_rsa.pub root@node2.test.com
[root@target ~]# ssh-copy-id -i .ssh/id_rsa.pub root@node3.test.com

(3).配置各节点时间同步
node1:
[root@node1 ~]# ntpdate 202.120.2.101

node2:
[root@node2 ~]# ntpdate 202.120.2.101

node3:
[root@node3 ~]# ntpdate 202.120.2.101

shared storage:
[root@target ~]# ntpdate 202.120.2.101

大家有没有发现我们时间同步的操作包括下面的很操作都是相同的有没有一种方法,只要执行一次,方法有很多,我们来说一下最常用的方法,ssh。在上面的操作中我们已经配置了ssh互信,下面我们就在跳板机上操作一下。
[root@target ~]# alias ha='for I in {1..3}; do' #设置一个别名,因为每次都得用到时
[root@target ~]# ha ssh node$I 'ntpdate 202.120.2.101'; done #各节点都在时间同步 
20 Aug 14:32:40 ntpdate[14752]: adjust time server 202.120.2.101 offset -0.019162 sec 
20 Aug 14:32:41 ntpdate[11994]: adjust time server 202.120.2.101 offset 0.058863 sec 
20 Aug 14:32:43 ntpdate[1578]: adjust time server 202.120.2.101 offset 0.062831 sec

注:大家看到了吧,这就是配置跳板机的好处,配置只要执行一次。
(5).安装yum源
[root@target ~]# ha ssh node$I 'rpm -ivh http://download.Fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm'; done
[root@target ~]# ha ssh node$I 'rpm -ivh http://elrepo.org/elrepo-release-6-5.el6.elrepo.noarch.rpm'; done

(6).关闭防火墙与SELinux
[root@target ~]# ha ssh node$I 'service iptables stop'; done

node1:
[root@node1 ~]# cat /etc/selinux/config
# This file controls the state of SELinux on the system. 
# SELINUX= can take one of these three values: 
#    enforcing - SELinux security policy is enforced. 
#    permissive - SELinux prints warnings instead of enforcing. 
#    disabled - No SELinux policy is loaded. 
SELINUX=disabled 
# SELINUXTYPE= can take one of these two values: 
#    targeted - Targeted processes are protected, 
#    mls - Multi Level Security protection. 
SELINUXTYPE=targeted

node2:
[root@node2 ~]# cat /etc/selinux/config
# This file controls the state of SELinux on the system. 
# SELINUX= can take one of these three values: 
#    enforcing - SELinux security policy is enforced. 
#    permissive - SELinux prints warnings instead of enforcing. 
#    disabled - No SELinux policy is loaded. 
SELINUX=disabled 
# SELINUXTYPE= can take one of these two values: 
#    targeted - Targeted processes are protected, 
#    mls - Multi Level Security protection. 
SELINUXTYPE=targeted

企鹅博客
  • 本文由 发表于 2019年9月26日 23:08:26
  • 转载请务必保留本文链接:https://www.qieseo.com/159144.html

发表评论