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. CentOS相关引导文件杂摘

    1,EFI文件

  2. 从物理执行的角度透视spark Job

    本博文主要内容: 1.再次思考pipeline 2.窄依赖物理执行内幕 3.宽依赖物理执行内幕 4.Job提交流程 一:再次思考pipeline 即使采用pipeline的方式,函数f对依赖的RDD中 ...

  3. shell从函数文件里调用函数

    碰到一个shell中函数调用的小问题,记录一下. shell中函数有三种调用方式,一种是在文件前面定义函数,然后在以下直接调用:一种是通过加载shell,在shell中直接调用:第三种是将函数写入文件 ...

  4. Android 颜色渲染(二) 颜色区域划分原理与实现思路

    版权声明:本文为博主原创文章,未经博主允许不得转载. 上一篇讲到颜色选择器,该demo不能选择黑白或者具体区间颜色,这是为什么呢,还是要从原理部分讲起,首先看一下两张图:            图1 ...

  5. InstallShield 12 制作安装包

    目  录 一. 二. 三. (一) 打开project... 2 (二) project助手页面... 3 1.Application Information:程序信息... 4 2.Installa ...

  6. java.sql.SQLException: Invalid parameter object type. Expected 'java.util.Map' but found 'java.lang.String 转载

    java.sql.SQLException: Invalid parameter object type. Expected 'java.util.Map' but found 'java.lang. ...

  7. WebLogic Server的单点登陆功能--转载

    在WebLogic 8.1最新的 SP4版本中,最引人注目的要算是在安全方面,提供了用于和Microsoft Windows客户端进行Single Sign-On的Single Pass Negoti ...

  8. Eclipse的修改编码插件使用

    最近因为编码问题,很是纠结,终于找到了一个Eclipse的修改编码插件com.lifesting.tool.encoding_1.0.0.jar,使用感觉还不错,记录一下使用方法. 第一步 将插件co ...

  9. Marketplace Client- Download

    Marketplace是Java平台被广泛使用的IDE(集成开发环境)Eclipse的软件商店.上面有个有种牛X的插件,可根据自己需要下载. Eclipse Marketplace官网地址:http: ...

  10. linux与Windows共享文件配置

    linux与Windows共享文件配置: 1.进入超级用户:$su root 2.启动tftp服务器:#netstat -a | grep tftp,出现如图所示的消息表示tftp服务器已安装成功: ...