glusterfs安装

CentOS7下分布式系统GlusterFS安装配置

https://buildlogs.centos.org/centos/7/storage/x86_64/gluster-3.12/

标签:GlusterFS

原创作品,允许转载,转载时请务必以超链接形式标明文章原始出处、作者信息和本声明。否则将追究法律责任。http://hzde0128.blog.51cto.com/918211/1898622

一、主机规划

操作系统版本为CentOS 7.2.1511

node1:172.17.0.1 gfs1

node2:172.17.0.2 gfs2

node3:172.17.0.3 gfs3

node4:172.17.0.4 gfs

client:172.17.0.5

二、安装:

1.在node1-4上安装glusterfs-server

yum install -y centos-release-gluster38

yum install -y glusterfs glusterfs-server glusterfs-fuse

设置开机自启动并启动

systemctl enable glusterd.service

systemctl start glusterd.service

2.在gfs1-gfs4节点上配置整个GlusterFS集群,把各个节点加入到集群

vim /etc/hosts

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4

::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

172.17.0.1  gf1

172.17.0.2  gf2

172.17.0.3  gf3

172.17.0.4  gf4

将下面节点加入集群如下:

[root@redis1 ~]# gluster peer probe gf4

peer probe: success. Probe on localhost not needed

[root@redis1 ~]# gluster peer probe gf2

peer probe: success.

[root@redis1 ~]# gluster peer probe gf3

peer probe: success.

[root@redis1 ~]# gluster peer probe gf1

peer probe: success.

3.查看节点状态

[root@gredis1 ~]#gluster peer status

Number of Peers: 3

Hostname: gf2

Uuid: e3ee9ce6-ffb3-40e4-8e92-2a13619b9383

State: Peer in Cluster (Connected)

Hostname: gf3

Uuid: b1490f21-aa2c-4a02-ac75-1909ab4ba636

State: Peer in Cluster (Connected)

Hostname: gf1

Uuid: 5d2e75be-6573-4528-ac61-1618f0e6f064

State: Peer in Cluster (Connected)

4.在gfs{1-4}上创建数据存储目录

# mkdir -p  /usr/local/share/models

5.在gfs1上创建GlusterFS磁盘

注意:

加上replica 4就是4个节点中,每个节点都要把数据存储一次,就是一个数据存储4份,每个节点一份

如果不加replica 4,就是4个节点的磁盘空间整合成一个硬盘,

[root@redis1 ~]#  gluster volume create share replica 4 gf1:/share gf2:/share gf3:/share gf4:/share force

volume create: models: success: please start the volume to access data

6.启动

[root@redis1 ~]# gluster volume start share 

移除节点:

gluster peer detach gf1

查看逻辑卷状态

[root@redis1 ~]#  gluster volume info

Volume Name: models

Type: Replicate

Volume ID: 3834bc4e-0511-457e-9bde-51eb86e653fd

Status: Started

Snapshot Count: 0

Number of Bricks: 1 x 4 = 4

Transport-type: tcp

Bricks:

Brick1: gf1:/share

Brick2: gf2:/share

Brick3: gf3:/share

Brick4: gf4:/share

Options Reconfigured:

transport.address-family: inet

performance.readdir-ahead: on

nfs.disable: on

清除glusterfs配置

通过查看/etc/glusterfs/glusterd.vol可以得知glusterfs的工作目录是在/var/lib/glusterd中

[root@localhost ~]#cat /etc/glusterfs/glusterd.vol

volume management

type mgmt/glusterdoption working-directory /var/lib/glusterdoption transport-type socket,rdma

option transport.socket.keepalive-time10option transport.socket.keepalive-interval2option transport.socket.read-fail-log off

optionping-timeout0option event-threads1#  option transport.address-family inet6

#  option base-port49152end-volume

如果需要清除glusterfs配置,将工作目录删除后重启服务即可

[root@localhost ~]#rm-rf  /var/lib/glusterd/

[root@localhost ~]# /etc/init.d/glusterd restart

删除卷

gluster volume stop models

gluster volume delete models


客户端

1.部署GlusterFS客户端并mount GlusterFS文件系统

[root@client ~]# yum install -y centos-release-gluster38

[root@client ~]# yum install -y glusterfs glusterfs-fuse

[root@localhost ~]# cat /etc/hosts

127.0.0.1  localhost localhost.localdomain localhost4 localhost4.localdomain4

::1        localhost localhost.localdomain localhost6 localhost6.localdomain6

172.16.7.165 gf3

172.16.7.166 gf4

172.16.7.164   gf2

172.16.7.162 gf1

172.16.7.161 glusterfs-client

[root@localhost ~]# mkdir -p /gluster

[root@localhost ~]# mount -t glusterfs  gf1:/models /gluster

[root@localhost ~]# df -h

Filesystem          Size  Used Avail Use% Mounted on

/dev/mapper/cl-root  14G  12G  1.5G  90% /

devtmpfs            3.9G    0  3.9G  0% /dev

tmpfs                3.9G    0  3.9G  0% /dev/shm

tmpfs                3.9G  375M  3.5G  10% /run

tmpfs                3.9G    0  3.9G  0% /sys/fs/cgroup

/dev/sda1          1014M  139M  876M  14% /boot

tmpfs                783M    0  783M  0% /run/user/0

gf1:/models          14G  13G  882M  94% /gluster

2.查看效果

[root@client ~]# df -h

3.观察分布式文件系统的效果

umount /mnt/models

mount -t glusterfs -o rw gfs1:models /mnt/models/

[root@client ~]# cd /mnt/models/

[root@client mnt]# for i in `seq -w 10`; do mkdir $i ; done

[root@client models]# for i in `seq -w 10`; do mkdir $i ; done

[root@client models]# ll

total 40

drwxr-xr-x 2 root root 4096 Feb 14 21:56 01

drwxr-xr-x 2 root root 4096 Feb 14 21:59 02

drwxr-xr-x 2 root root 4096 Feb 14 21:56 03

drwxr-xr-x 2 root root 4096 Feb 14 21:56 04

drwxr-xr-x 2 root root 4096 Feb 14 21:56 05

drwxr-xr-x 2 root root 4096 Feb 14 21:56 06

drwxr-xr-x 2 root root 4096 Feb 14 21:59 07

drwxr-xr-x 2 root root 4096 Feb 14 21:56 08

drwxr-xr-x 2 root root 4096 Feb 14 21:56 09

drwxr-xr-x 2 root root 4096 Feb 14 21:59 10

分别在4台Server上查看新建的文件夹同步情况

[root@gfs1 ~]# ls /usr/local/share/models/ -l

total 0

drwxr-xr-x 2 root root 6 Feb 14 21:56 01

drwxr-xr-x 2 root root 6 Feb 14 21:59 02

drwxr-xr-x 2 root root 6 Feb 14 21:56 03

drwxr-xr-x 2 root root 6 Feb 14 21:56 04

drwxr-xr-x 2 root root 6 Feb 14 21:56 05

drwxr-xr-x 2 root root 6 Feb 14 21:56 06

drwxr-xr-x 2 root root 6 Feb 14 21:59 07

drwxr-xr-x 2 root root 6 Feb 14 21:56 08

drwxr-xr-x 2 root root 6 Feb 14 21:56 09

drwxr-xr-x 2 root root 6 Feb 14 21:59 10

可以看到4台服务器都同步过来了。

当单台Server出现故障,比如服务器断开连接的情况,创建一个文件需要比较长的时间。

但是当Server重新连上之后,文件可以及时的同步过来。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 194,088评论 5 459
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 81,715评论 2 371
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 141,361评论 0 319
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 52,099评论 1 263
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 60,987评论 4 355
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 46,063评论 1 272
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 36,486评论 3 381
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 35,175评论 0 253
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 39,440评论 1 290
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 34,518评论 2 309
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 36,305评论 1 326
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 32,190评论 3 312
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 37,550评论 3 298
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 28,880评论 0 17
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 30,152评论 1 250
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 41,451评论 2 341
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 40,637评论 2 335

推荐阅读更多精彩内容