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: 

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  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  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--bc18-4bdbdc93d09d

Status: Started

Number of Bricks:  x  = 

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
option transport.socket.keepalive-interval
option transport.socket.read-fail-log off
option ping-timeout
option event-threads
# option transport.address-family inet6
# option base-port
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=131072)

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

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

客户端测试连接

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

[root@localhost glusterfs]# cd /mnt/glusterfs/

[root@localhost glusterfs]# touch file1 file2 file3

[root@localhost glusterfs]# ls -l

total 0

-rw-r--r--. 1 root root 0 Aug 29 21:07 file1

-rw-r--r--. 1 root root 0 Aug 29 21:07 file2

-rw-r--r--. 1 root root 0 Aug 29 21:07 file3

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

[root@server1 ~]# cd /data/gfsdata/

[root@server1 gfsdata]# ls -l

total 0

-rw-r--r--. 2 root root 0 Aug 29 21:07 file1

-rw-r--r--. 2 root root 0 Aug 29 21:07 file2

-rw-r--r--. 2 root root 0 Aug 29 21:07 file3

[root@server2 ~]# cd /data/gfsdata/

[root@server2 gfsdata]# ls -l

total 0

-rw-r--r--. 2 root root 0 Aug 29 21:07 file1

-rw-r--r--. 2 root root 0 Aug 29 21:07 file2

-rw-r--r--. 2 root root 0 Aug 29 21:07 file3

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

GlusterFS简单配置的更多相关文章

  1. GlusterFS源代码解析 —— GlusterFS 简单介绍

    原文地址:http://blog.csdn.net/wangyuling1234567890/article/details/24564185 -- -- 本系列博客源代码是基于GlusterFS 3 ...

  2. 小丁带你走进git世界一-git简单配置

    小丁带你走进git世界一-git简单配置 1.github的简单配置 配置提交代码的信息,例如是谁提交的代码之类的. git config  –global user.name BattleHeaer ...

  3. 以实际的WebGIS例子探讨Nginx的简单配置

    文章版权由作者李晓晖和博客园共有,若转载请于明显处标明出处:http://www.cnblogs.com/naaoveGIS/ 1.背景 以实际项目中的一个例子来详细讲解Nginx中的一般配置,其中涉 ...

  4. CentOS 7.0 使用 yum 安装 MariaDB 与 MariaDB 的简单配置

    1.安装MariaDB 安装命令 yum -y install mariadb mariadb-server 安装完成MariaDB,首先启动MariaDB,两条命令都可以 systemctl sta ...

  5. ssm简单配置

    MyBatis 是一个可以自定义SQL.存储过程和高级映射的持久层框架. MyBatis 摒除了大部分的JDBC代码.手工设置参数和结果集重获. MyBatis 只使用简单的XML 和注解来配置和映射 ...

  6. 安装MariaDB和简单配置

    1.安装MariaDB 安装命令 yum -y install mariadb mariadb-server 安装完成MariaDB,首先启动MariaDB systemctl start maria ...

  7. BIND的进程一:DNS简单配置与的主从配置

    DNS的简单配置和DNS的主从配置   摘要:DNS(Domain-Name Server) ,DNS的服务起到的作用就是名称解析,在网络通讯来说计算机与计算机是通过IP地址相互通信的, 当是IP地址 ...

  8. 转-squid介绍及其简单配置

    本文原始出处:http://linuxme.blog.51cto.com/1850814/372960 1.Squid是什么? Squid中文权威指南:http://zyan.cc/book/squi ...

  9. Linux中vim的简单配置

    本文主要分享Linux中vim的简单配置 ★配置文件的位置     在目录/etc.下面,有个名为vimrc的文件,这就是系统中公共的vim配置文件,对所有用户都开放.而在每个用户的主目录下,都可以自 ...

随机推荐

  1. 去除 Visual Studio 中臃肿的 ipch 和 sdf 文件

    使用VS2010建立C++解决方案时,会生成SolutionName.sdf和一个叫做ipch的文件夹,这两个文件再加上*.pch等文件使得工程变得非常的庞大,一个简单的程序都会占用几十M的硬盘容量, ...

  2. ArrayList and LinkedList

    ArrayList and LinkedList List代表一种线性表的数据结构,ArrayList则是一种顺序存储的线性表.ArrayList底层采用数组来保存每个集合元素,LinkedList则 ...

  3. 构建ASP.NET MVC4+EF5+EasyUI+Unity2.x注入的后台管理系统(32)-swfupload多文件上传[附源码]

    原文:构建ASP.NET MVC4+EF5+EasyUI+Unity2.x注入的后台管理系统(32)-swfupload多文件上传[附源码] 文件上传这东西说到底有时候很痛,原来的asp.net服务器 ...

  4. 构建ASP.NET MVC4+EF5+EasyUI+Unity2.x注入的后台管理系统(26)-权限管理系统-分配角色给用户

    原文:构建ASP.NET MVC4+EF5+EasyUI+Unity2.x注入的后台管理系统(26)-权限管理系统-分配角色给用户 构建ASP.NET MVC4+EF5+EasyUI+Unity2.x ...

  5. StopWatch

    附件 http://download.csdn.net/detail/teststudio/6575241 主窗体UNIT unit MainForm; interface uses Windows, ...

  6. 数学之路-分布式计算-disco(4)

    第一个參数iter是一个迭代器,涉及被map函数产生的键和值.它们是reduce实例. 在本例中.单词随机被托付给不同的reduce实例.然后,要单词同样,处理它的reduce也同样.可确保终于合计是 ...

  7. 分布式还是混合式? 谈CDN架构对服务质量的影响

    传统分布式模型 通 常,内容分发网络(CDN)採用分布式模型.在这样的模型里, 用户的文件存放在一个源server上.而且由大量边缘server负责分发这些文件.这些边缘server的磁盘空间比較小. ...

  8. hive运行query语句时提示错误:org.apache.hadoop.ipc.RemoteException: java.io.IOException: java.io.IOException:

    hive> select product_id, track_time from trackinfo limit 5; Total MapReduce jobs = 1 Launching Jo ...

  9. 跟踪MYSQL 的查询优化过程方法

    http://dev.mysql.com/doc/internals/en/tracing-example.html http://blog.chinaunix.net/uid-20785090-id ...

  10. iOS--RunLoop原理介绍

    什么是RunLoop RunLoop从字面上看是运行循环的意思,这一点也不错,它确实就是一个循环的概念,或者准确的说是线程中的循环. 本文一开始就提到有些程序是一个圈,这个圈本质上就是这里的所谓的Ru ...