转自:http://www.cnblogs.com/terrycy/p/5915263.html

GlusterFS简单配置

 

1.准备工作

准备三台机器(物理机或者虚拟机均可)用于安装和测试GlusterFS,其中两台用作服务器,一台用作客户端,主机名分别为:

Server1.zhaogang.int  10.0.21.241
Server2.zhaogang.int  10.0.21.242
Clinet.zhaogang.int

关闭iptables和selinux

2.安装glusterFS服务器

yum install centos-release-gluster -y
yum install glusterfs-server glusterfs glusterfs-fuse -y

启动glusterFS服务:

/etc/init.d/glusterd  start

设置glusterFS服务开机启动

chkconfig glusterd on

GlusterFS服务器设置

加入可信任存储池

在server1上运行一下命令:

[root@server1 ~]# gluster peer probe 10.0.21.242
peer probe: success.

查看状态:

[root@server1 ~]# gluster peer status
Number of Peers: 1
Hostname: 10.0.21.242
Uuid: ab640ab2-76ba-47a5-a868-be5514b70258
State: Peer in Cluster (Connected)

移除节点:

gluster peer detach  10.0.21.242

B.创建GlusterFS逻辑卷(Volume)

在server1和server2分别建立/data/gfsdata目录:

mkdir -p /data/gfsdata

然后执行以下命令(只需要在其中一台服务器上执行即可,本例使用server1):

[root@server1 ~]# gluster volume create gv0 replica 2 10.0.21.241:/data/gfsdata 10.0.21.242:/data/gfsdata
volume create: gv0: success: please start the volume to access data

这条命令的意思是使用Replicated的方式,建立一个名为gv0的卷(Volume),存储块(Brick)为2个,分别为server1:/data/gfsdata和server2:/data/gfsdata

volume create: testglustervol: failed: The brick 192.168.21.19:/data0/gluster1/brick1 is being created in the root partition. It is recommended that you don't use the system's root partition for storage backend. Or use 'force' at the end of the command if you want to override this behavior.

发现报错了,这是因为我们创建的brick在系统盘,这个在gluster的默认情况下是不允许的,生产环境下也尽可能的与系统盘分开,如果必须这样请使用force

[root@server1 ~]# gluster volume create gv0 replica 2 10.0.21.241:/data/gfsdata 10.0.21.242:/data/gfsdata force
volume create: gv0: success: please start the volume to access data

启用GlusterFS逻辑卷:

[root@server1 ~]# gluster volume start gv0
volume start: gv0: success

查看逻辑卷状态:

[root@server1 ~]# gluster volume info
Volume Name: gv0
Type: Replicate
Volume ID: da0f4439-824b-4606-bc18-4bdbdc93d09d
Status: Started
Number of Bricks: 1 x 2 = 2
Transport-type: tcp
Bricks:
Brick1: 10.0.21.241:/data/gfsdata
Brick2: 10.0.21.242:/data/gfsdata
Options Reconfigured:
performance.readdir-ahead: on

清除glusterfs配置

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

[root@localhost ~]# cat /etc/glusterfs/glusterd.vol
volume management
type mgmt/glusterd
option working-directory /var/lib/glusterd
option transport-type socket,rdma
option transport.socket.keepalive-time 10
option transport.socket.keepalive-interval 2
option transport.socket.read-fail-log off
option ping-timeout 0
option event-threads 1
# option transport.address-family inet6
# option base-port 49152
end-volume

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

[root@localhost ~]# rm -rf /var/lib/glusterd/
[root@localhost ~]# /etc/init.d/glusterd restart

删除卷

gluster volume stop gv0
gluster volume delete gv0

# 卷扩容(由于副本数设置为2,至少要添加2(4、6、8..)台机器)

gluster peer probe 10.0.21.243 # 加节点
gluster peer probe 10.0.21.244 # 加节点
gluster volume add-brick gv0 10.0.21.243:/data/glusterfs 10.0.21.244:/data/glusterfs # 合并卷

# 收缩卷(收缩卷前gluster需要先移动数据到其他位置)

gluster volume remove-brick gv0 10.0.21.243:/data/glusterfs 10.0.21.244:/data/glusterfs start # 开始迁移
gluster volume remove-brick gv0 10.0.21.243:/data/glusterfs 10.0.21.244:/data/glusterfs status # 查看迁移状态
gluster volume remove-brick gv0 10.0.21.243:/data/glusterfs 10.0.21.244:/data/glusterfs commit # 迁移完成后提交

# 迁移卷

gluster peer probe 10.0.21.245 # 将10.0.21.246数据迁移到10.0.21.245先将10.0.21.245加入集群
gluster volume replace-brick gv0 10.0.21.246:/data/glusterfs 10.0.21.245:/data/glusterfs start # 开始迁移
gluster volume replace-brick gv0 10.0.21.246:/data/glusterfs 10.0.21.245:/data/glusterfs status # 查看迁移状态
gluster volume replace-brick gv0 10.0.21.246:/data/glusterfs 10.0.21.245:/data/glusterfs commit # 数据迁移完毕后提交
gluster volume replace-brick gv0 10.0.21.246:/data/glusterfs 10.0.21.245:/data/glusterfs commit -force # 如果机器10.0.21.246出现故障已经不能运行,执行强制提交
gluster volume heal gv0 full # 同步整个卷

本文介绍的是GlusterFS基础的用法,感觉它的最大优点就是文件使用哈希散列,而不需要单独去维护MetaData以避开单点问题,而目录则是所有节点都一致的。节点信息会在变化过程中自动同步!不过增删节点,需要做Rebalance数据才会重新分布。

C.在clinet上安装客户端软件:

#yum -y install glusterfs glusterfs-fuse

GlusterFS客户端连接

在客户端client.zhaogang.int上使用mount命令,把服务器上新建的GlusterFS逻辑卷gv0挂载到本地目录/mnt/glusterfs上:

[root@localhost ~]# mkdir /mnt/glusterfs
[root@localhost ~]# mount -t glusterfs 10.0.21.241:/gv0 /mnt/glusterfs
[root@localhost ~]# 

确认挂载结果:

[root@localhost ~]# mount -t fuse.glusterfs
10.0.21.241:/gv0 on /mnt/glusterfs type fuse.glusterfs (rw,default_permissions,allow_other,max_read=)

如果希望系统重启后可以自动挂载,在/etc/fstab文件中加入此行:

10.0.0.241:/data/gfsdata      /mnt/glusterfs    glusterfs  defaults         

客户端测试连接

client端成功挂载逻辑卷之后,在挂载目录/mnt/glusterfs建立文件以测试GlusterFS是否正常工作。

[root@localhost glusterfs]# cd /mnt/glusterfs/
[root@localhost glusterfs]# touch file1 file2 file3
[root@localhost glusterfs]# ls -l
total
-rw-r--r--. root root Aug : file1
-rw-r--r--. root root Aug : file2
-rw-r--r--. root root Aug : file3

因为创建卷gv0的时候使用的是镜像存储(Replicated),所以在gv0上写入的文件应该同时出现在两个服务器的/data/gfsdata目录上。
在server1和server2查看/data/gfsdata/目录,可以看到两个服务器均出现这三个文件:

[root@server1 ~]# cd /data/gfsdata/
[root@server1 gfsdata]# ls -l
total
-rw-r--r--. root root Aug : file1
-rw-r--r--. root root Aug : file2
-rw-r--r--. root root Aug : file3
[root@server2 ~]# cd /data/gfsdata/
[root@server2 gfsdata]# ls -l
total
-rw-r--r--. root root Aug : file1
-rw-r--r--. root root Aug : file2
-rw-r--r--. root root Aug : file3

自此GlusterFS快速安装过程结束。

glusterFS的部署流程的更多相关文章

  1. glusterFS分布式存储部署流程

    转自:http://bangbangba.blog.51cto.com/3180873/1712061 GlusterFS是一款非常易于使用的分布式文件存储系统,实现了全部标准POSIX接口,并用fu ...

  2. Liferay7 BPM门户开发之45: 集成Activiti文件上传部署流程BPMN模型

    开发文件上传,部署流程模板. 首先,开发jsp页面,deploy.jsp <%@ include file="/init.jsp" %> <h3>${RET ...

  3. Jenkins环境拓扑及部署流程

    环境拓扑图: 部署流程:

  4. Activiti 部署流程定义及相关的表(classpath部署、zip部署)

    package com.mycom.processDefinition; import org.activiti.engine.ProcessEngine; import org.activiti.e ...

  5. OpenStack Keystone安装部署流程

    之前介绍了OpenStack Swift的安装部署,采用的都是tempauth认证模式,今天就来介绍一个新的组件,名为Keystone. 1. 简介 本文将详细描述Keystone的安装部署流程,并给 ...

  6. OpenStack Swift集群部署流程与简单使用

    之前介绍了<OpenStack Swift All In One安装部署流程与简单使用>,那么接下来就说一说Swift集群部署吧. 1. 简介 本文档详细描述了使用两台PC部署一个小型Sw ...

  7. activiti自定义流程之整合(四):整合自定义表单部署流程定义

    综合前几篇博文内容,我想在整合这一部分中应该会有很多模块会跳过不讲,就如自定义表单的表单列表那一块,因为这些模块在整合的过程中都几乎没有什么改动,再多讲也是重复无用功. 正因为如此,在创建了流程模型之 ...

  8. activiti自定义流程之Spring整合activiti-modeler5.16实例(四):部署流程定义

    注:(1)环境搭建:activiti自定义流程之Spring整合activiti-modeler5.16实例(一):环境搭建        (2)创建流程模型:activiti自定义流程之Spring ...

  9. Kent Beck揭秘Facebook开发部署流程

    http://www.infoq.com/cn/news/2013/10/facebook-development-deployment Facebook是世界上最大的社交网站,有超过10亿用户每月至 ...

随机推荐

  1. 报错:无法从int?转换为int

    □ 背景分析 在控制器方法中的一个参数允许为null值:public ActionResult GetByCategory(int? categoryId = null) 当把这里的categoryI ...

  2. 高性能 Socket 组件 HP-Socket v3.2.1 正式公布

    HP-Socket 是一套通用的高性能 TCP/UDP Socket 组件,包括服务端组件.client组件和 Agent 组件,广泛适用于各种不同应用场景的 TCP/UDP 通信系统,提供 C/C+ ...

  3. kafka-manager:kafak的管理界面的安装和使用

    下载打包 release下载:https://github.com/yahoo/kafka-manager/releases 源码位置:https://github.com/yahoo/kafka-m ...

  4. iOS:UIPickerView选择器的使用

    通过UIPickerView选择器做的一个类似于密码锁的日期时间表 源码如下: #import <UIKit/UIKit.h> @interface ViewController : UI ...

  5. java使用省略号代替多参数(参数类型... 参数名)

    J2SE 1.5提供了“Varargs”机制.借助这一机制,可以定义能和多个实参相匹配的形参.从而,可以用一种更简单的方式,来传递个数可变的实参.本文介绍这一机制的使用方法,以及这一机制与数组.泛型. ...

  6. 使用Topshelf 5步创建Windows 服务

    使用Topshelf创建Windows 服务简要的介绍了创建Windows服务的另一种方法,老外的一篇文章Create a .NET Windows Service in 5 steps with T ...

  7. Nginx zabbix 的监控

    Nginx zabbix 的监控 Nginx 配置 Nginx 必须包含:http_stub_status_module 模块 ./nginx -V |grep http_stub_status_mo ...

  8. 第十一章 springboot + mongodb(简单查询)

    1.mongodb在mac上的安装 下载mongodb,https://www.mongodb.org/ 解压缩到一个指定文件夹,如:/Users/enniu1/Desktop/zjg/mongodb ...

  9. Vulkan --vulkan in powervr

    zhankeng 跨平台 多线程 low cpu overhead object orientated vulkan有利于tile based的地方 明确依赖声明 细粒度同步 render passe ...

  10. Windows10下安装pytorch并导入pycharm

    1.安装Anaconda 下载:https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/ 安装Anaconda3,最新版本的就可以了,我安装的是5. ...