使用GlusterFS 3.2.x创建类NFS独立存储服务器在Ubuntu 12.04上

使用GlusterFS 3.2.x在Ubuntu 12.04上创建类似NFS的独立存储服务器

本教程将介绍如何在Ubuntu 12.04上设置独立存储服务器。 而不是NFS,我将在这里使用GlusterFS 。 客户端系统将能够访问存储,就像它是本地文件系统一样。 GlusterFS是一种能够缩放到几个peta字节的集群文件系统。 它将Infiniband RDMA或TCP / IP互连的各种存储砖聚合成一个大型并行网络文件系统。 存储砖可以由诸如具有SATA-II RAID和Infiniband HBA的x86_64服务器的任何商品硬件制成。

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

1初步说明

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

  • server1.example.com:IP地址192.168.0.100 (服务器)
  • client1.example.com:IP地址192.168.0.101 (客户端)

因为我们将使用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   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

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

2设置GlusterFS服务器

server1.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.com上打开TCP端口111,24007,24008,24009-(24009 +所有卷上的砖数)。

接下来,我们在/ data目录中的localhost (= server1 )上创建名为testvol的共享(如果不存在,将创建它)。

gluster volume create testvol server1.example.com:/data
root@server1:~# gluster volume create testvol server1.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:~#

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

gluster volume info
root@server1:~# gluster volume info
Volume Name: testvol
Type: Distribute
Status: Started
Number of Bricks: 1
Transport-type: tcp
Bricks:
Brick1: server1.example.com:/data
root@server1:~#

如果它告诉你音量开始,一切都很好,否则只需重新启动。

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

gluster volume set testvol auth.allow 192.168.0.101

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

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

gluster volume info
root@server1:~# gluster volume info
Volume Name: testvol
Type: Distribute
Status: Started
Number of Bricks: 1
Transport-type: tcp
Bricks:
Brick1: server1.example.com:/data
Options Reconfigured:
auth.allow: 192.168.0.101
root@server1:~#

3设置GlusterFS客户端

client1.example.com:

在客户端,我们可以安装GlusterFS客户端,如下所示:

apt-get install glusterfs-client

然后我们创建以下目录:

mkdir /mnt/glusterfs

而已! 现在我们可以使用以下命令将GlusterFS文件系统安装到/ mnt / glusterfs

mount.glusterfs server1.example.com:/testvol /mnt/glusterfs

你现在应该看到新产品中的新股份...

mount
root@client1:~# mount
/dev/mapper/client1-root on / type ext4 (rw,errors=remount-ro)
proc on /proc type proc (rw,noexec,nosuid,nodev)
sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
none on /sys/fs/fuse/connections type fusectl (rw)
none on /sys/kernel/debug type debugfs (rw)
none on /sys/kernel/security type securityfs (rw)
udev on /dev type devtmpfs (rw,mode=0755)
devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)
tmpfs on /run type tmpfs (rw,noexec,nosuid,size=10%,mode=0755)
none on /run/lock type tmpfs (rw,noexec,nosuid,nodev,size=5242880)
none on /run/shm type tmpfs (rw,nosuid,nodev)
/dev/sda1 on /boot type ext2 (rw)
server1.example.com:/testvol on /mnt/glusterfs type fuse.glusterfs (rw,allow_other,default_permissions,max_read=131072)
root@client1:~#

...和...

df -h
root@client1:~# df -h
Filesystem                    Size  Used Avail Use% Mounted on
/dev/mapper/client1-root       30G  1.5G   27G   6% /
udev                          237M  4.0K  237M   1% /dev
tmpfs                          99M  224K   99M   1% /run
none                          5.0M     0  5.0M   0% /run/lock
none                          246M     0  246M   0% /run/shm
/dev/sda1                     228M   25M  192M  12% /boot
server1.example.com:/testvol   30G  1.5G   27G   6% /mnt/glusterfs
root@client1:~#

您可以修改/ etc / fstab ,而不是在客户机上手动安装GlusterFS共享,以便在客户端启动时自动挂载共享。

打开/ etc / fstab并附加以下行:

vi /etc/fstab
[...]
server1.example.com:/testvol /mnt/glusterfs glusterfs defaults,_netdev 0 0

要测试您的/ etc / fstab是否正常工作,请重新启动客户端:

reboot

重新启动后,您应该在...的输出中找到共享

df -h

...和...

mount

4链接

赞(52) 打赏
未经允许不得转载:优客志 » 系统运维
分享到:

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

支付宝扫一扫打赏

微信扫一扫打赏