使用GlusterFS 3.2.x在四个存储节点上的分布式复制存储在Ubuntu 12.04上

使用GlusterFS 3.2.x在四个存储节点上分布式复制存储在Ubuntu 12.04上

本教程将介绍如何将四个单一存储服务器(运行Ubuntu 12.04)与GlusterFS组合到分布式复制存储。 节点1和2( replication1 )以及3和4( replication2 )将彼此镜像,并且replication1replication2将被组合到一个较大的存储服务器(分发)。 基本上,这是通过网络的RAID10。 如果从replication1丢失一个服务器,而从replication2丢失一个服务器,则分布式卷将继续运行。 客户端系统(Ubuntu 12.04)将能够访问存储,就像它是本地文件系统一样。 GlusterFS是一种能够缩放到几个peta字节的集群文件系统。 它将Infiniband RDMA或TCP / IP互连的各种存储砖聚合成一个大型并行网络文件系统。 存储砖可以由诸如具有SATA-II RAID和Infiniband HBA的x86_64服务器的任何商品硬件制成。

我不会保证这将为您工作!

1初步说明

在本教程中,我使用五个系统,四个服务器和一个客户端:

  • server1.example.com:IP地址192.168.0.100 (服务器)
  • server2.example.com:IP地址192.168.0.101 (服务器)
  • server3.example.com:IP地址192.168.0.102 (服务器)
  • server4.example.com:IP地址192.168.0.103 (服务器)
  • client1.example.com:IP地址192.168.0.104 (客户端)

因为我们将使用root权限运行本教程中的所有步骤,我们可以使用字符串sudo来为本教程中的所有命令添加所有命令,也可以通过键入来成为root

sudo su

所有五个系统应该能够解析其他系统的主机名。 如果这不能通过DNS完成,您应该编辑/ etc / hosts文件,使其在所有五个系统上如下所示:

vi /etc/hosts
127.0.0.1       localhost.localdomain   localhost
192.168.0.100   server1.example.com     server1
192.168.0.101   server2.example.com     server2
192.168.0.102   server3.example.com     server3
192.168.0.103   server4.example.com     server4
192.168.0.104   client1.example.com     client1

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

(也可以在以下设置中使用IP地址而不是主机名,如果您希望使用IP地址,则不需要关心主机名是否可以解决。)

2设置GlusterFS服务器

server1.example.com/server2.example.com/server3.example.com/server4.example.com:

GlusterFS可作为Ubuntu 12.04的软件包提供,因此我们可以安装如下:

apt-get install glusterfs-server

命令

glusterfsd --version

现在应该显示您刚刚安装的GlusterFS版本(在这种情况下为3.2.5):

root@server1:~# glusterfsd --version
glusterfs 3.2.5 built on Jan 31 2012 07:39:58
Repository revision: git://git.gluster.com/glusterfs.git
Copyright (c) 2006-2011 Gluster Inc. <http://www.gluster.com>
GlusterFS comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of GlusterFS under the terms of the GNU General Public License.
root@server1:~#

如果使用防火墙,请确保在server1.example.comserver2.example.comserver3.example.com和...上打开TCP端口111,24007,24008,24009-(24009 +所有卷上的砖数) server4.example.com

接下来,我们必须将server2.example.comserver3.example.comserver4.example.com添加到受信任的存储池(请注意,我正在运行server1.example.com中的所有GlusterFS配置命令,但您可以可以从server2.example.comserver3.example.comserver4.example.com运行它们,因为配置在GlusterFS节点之间进行了复制 - 只需确保使用正确的主机名或IP地址):

server1.example.com:

server1.example.com上运行

gluster peer probe server2.example.com
gluster peer probe server3.example.com
gluster peer probe server4.example.com

产出应如下:

root@server1:~# gluster peer probe server2.example.com
Probe successful
root@server1:~#

可信存储池的状态现在应该类似于:

gluster peer status
root@server1:~# gluster peer status
Number of Peers: 3
Hostname: server2.example.com
Uuid: 600ff607-f7fd-43f6-af8d-419df703376d
State: Peer in Cluster (Connected)
Hostname: server3.example.com
Uuid: 1d6a5f3f-c2dd-4727-a050-0431772cc381
State: Peer in Cluster (Connected)
Hostname: server4.example.com
Uuid: 0bd9d445-0b5b-4a91-be6f-02b13c41d5d6
State: Peer in Cluster (Connected)
root@server1:~#

接下来,我们使用两个副本创建名为testvol的分布式复制共享(请注意,在这种情况下,由于我们要设置分布式复制,副本数量是服务器数量的一半) server1.example.com server2.example.comserver3.example.comserver4.example.com/ data目录中(如果不存在,将创建它):

gluster volume create testvol replica 2 transport tcp server1.example.com:/data server2.example.com:/data server3.example.com:/data server4.example.com:/data
root@server1:~# gluster volume create testvol replica 2 transport tcp server1.example.com:/data server2.example.com:/data server3.example.com:/data server4.example.com:/data
Creation of volume testvol has been successful. Please start the volume to access data.
root@server1:~#

启动音量:

gluster volume start testvol

上述命令有可能告诉您操作不成功:

root@server1:~# gluster volume start testvol
Starting volume testvol has been unsuccessful
root@server1:~#

在这种情况下,您应该检查...的输出

server1.example.com/server2.example.com/server3.example.com/server4.example.com:

netstat -tap | grep glusterfsd

在两台服务器上

如果你得到这样的输出...

root@server1:~# netstat -tap | grep glusterfsd
tcp        0      0 *:24009                 *:*                     LISTEN      1110/glusterfsd
tcp        0      0 localhost.localdom:1019 localhost.localdo:24007 ESTABLISHED 1110/glusterfsd
root@server1:~#

...一切都很好,但如果你没有得到任何输出...

root@server2:~# netstat -tap | grep glusterfsd
root@server2:~#
root@server3:~# netstat -tap | grep glusterfsd
root@server3:~#
root@server4:~# netstat -tap | grep glusterfsd
root@server4:~#

...重新启动相应服务器上的GlusterFS守护程序(在这种情况下, server2.example.comserver3.example.comserver4.example.com ):

server2.example.com/server3.example.com/server4.example.com:

/etc/init.d/glusterfs-server restart

然后检查输出...

netstat -tap | grep glusterfsd

...再次在这些服务器上 - 现在应该是这样的:

root@server2:~# netstat -tap | grep glusterfsd
tcp        0      0 *:24009                 *:*                     LISTEN      1152/glusterfsd
tcp        0      0 localhost.localdom:1018 localhost.localdo:24007 ESTABLISHED 1152/glusterfsd
root@server2:~#

root@server3:~# netstat -tap | grep glusterfsd
tcp        0      0 *:24009                 *:*                     LISTEN      1311/glusterfsd
tcp        0      0 localhost.localdom:1018 localhost.localdo:24007 ESTABLISHED 1311/glusterfsd
root@server3:~#

root@server4:~# netstat -tap | grep glusterfsd
tcp        0      0 *:24009                 *:*                     LISTEN      1297/glusterfsd
tcp        0      0 localhost.localdom:1019 localhost.localdo:24007 ESTABLISHED 1297/glusterfsd
root@server4:~#

现在回到server1.example.com

server1.example.com:

您可以使用命令检查卷的状态

gluster volume info
root@server1:~# gluster volume info
Volume Name: testvol
Type: Distributed-Replicate
Status: Started
Number of Bricks: 2 x 2 = 4
Transport-type: tcp
Bricks:
Brick1: server1.example.com:/data
Brick2: server2.example.com:/data
Brick3: server3.example.com:/data
Brick4: server4.example.com:/data
root@server1:~#

默认情况下,所有客户端都可以连接到卷。 如果您只想授予对client1.example.com (= 192.168.0.104 )的访问权限,请运行:

gluster volume set testvol auth.allow 192.168.0.104

请注意,可以使用通配符的IP地址(如192.168。* ),并且可以指定多个以逗号分隔的IP地址(例如192.168.0.104,192.168.0.105 )。

音量信息现在应显示更新的状态:

gluster volume info
root@server1:~# gluster volume info
Volume Name: testvol
Type: Distributed-Replicate
Status: Started
Number of Bricks: 2 x 2 = 4
Transport-type: tcp
Bricks:
Brick1: server1.example.com:/data
Brick2: server2.example.com:/data
Brick3: server3.example.com:/data
Brick4: server4.example.com:/data
Options Reconfigured:
auth.allow: 192.168.0.104
root@server1:~#
赞(52) 打赏
未经允许不得转载:优客志 » 系统运维
分享到:

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏