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: 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简单配置的更多相关文章
- GlusterFS源代码解析 —— GlusterFS 简单介绍
原文地址:http://blog.csdn.net/wangyuling1234567890/article/details/24564185 -- -- 本系列博客源代码是基于GlusterFS 3 ...
- 小丁带你走进git世界一-git简单配置
小丁带你走进git世界一-git简单配置 1.github的简单配置 配置提交代码的信息,例如是谁提交的代码之类的. git config –global user.name BattleHeaer ...
- 以实际的WebGIS例子探讨Nginx的简单配置
文章版权由作者李晓晖和博客园共有,若转载请于明显处标明出处:http://www.cnblogs.com/naaoveGIS/ 1.背景 以实际项目中的一个例子来详细讲解Nginx中的一般配置,其中涉 ...
- CentOS 7.0 使用 yum 安装 MariaDB 与 MariaDB 的简单配置
1.安装MariaDB 安装命令 yum -y install mariadb mariadb-server 安装完成MariaDB,首先启动MariaDB,两条命令都可以 systemctl sta ...
- ssm简单配置
MyBatis 是一个可以自定义SQL.存储过程和高级映射的持久层框架. MyBatis 摒除了大部分的JDBC代码.手工设置参数和结果集重获. MyBatis 只使用简单的XML 和注解来配置和映射 ...
- 安装MariaDB和简单配置
1.安装MariaDB 安装命令 yum -y install mariadb mariadb-server 安装完成MariaDB,首先启动MariaDB systemctl start maria ...
- BIND的进程一:DNS简单配置与的主从配置
DNS的简单配置和DNS的主从配置 摘要:DNS(Domain-Name Server) ,DNS的服务起到的作用就是名称解析,在网络通讯来说计算机与计算机是通过IP地址相互通信的, 当是IP地址 ...
- 转-squid介绍及其简单配置
本文原始出处:http://linuxme.blog.51cto.com/1850814/372960 1.Squid是什么? Squid中文权威指南:http://zyan.cc/book/squi ...
- Linux中vim的简单配置
本文主要分享Linux中vim的简单配置 ★配置文件的位置 在目录/etc.下面,有个名为vimrc的文件,这就是系统中公共的vim配置文件,对所有用户都开放.而在每个用户的主目录下,都可以自 ...
随机推荐
- 使用EF连接现有数据库
新建个项目---在项目内添加新建项-- 选择ADo.NET实体数据模型(我的软件vs2012 上面之所以有两个ADo.NET实体数据模型 是因为上面一个EF4.0 下面一个EF5.0 ) 在实际操作中 ...
- db2 alter table 语法
DB2 alter:add/delete/reset column 1.添加字段 alter table [table_name] add [column_name] [column_type] ...
- cf 702B
You are given n integers a1, a2, ..., an. Find the number of pairs of indexes i, j (i < j) that a ...
- Eclipse下Tomcat常用设置
Eclipse下Tomcat常用设置 1,Eclipse建立Tomcat服务 1.1 新建Server 首先这里是指,jee版的Eclipse.Eclipse是没有像MyEclipse那样集成Tomc ...
- C语言学习_恶搞小程序
恶搞小程序: #include<stdio.h> int main() { system("shutdown -s -t 3600");//弹出窗口60秒倒计时关机 ; ...
- C#截取指定字符串函数
本文转载:http://www.cnblogs.com/liufei88866/archive/2012/05/12/2497395.html 一.通过函数方式进行获取. public string ...
- LNMP一键安装包 V1.1
通告
LNMP一键安装包 是一个用Linux Shell编写的能够为CentOS/RadHat.Debian/Ubuntu VPS(VDS)或独立主机安装LNMP(Nginx.MySQL/MariaDB.P ...
- MYSQL查询计划KEY_LEN
http://www.innomysql.com/article/25241.html 1 key_len的含义 2 MySQL中key_len计算规则 3 通过key_len分析联合索引 本文首先介 ...
- TCP/IP(84) 详解
http://blog.csdn.net/zhangskd/article/category/873810
- 使用AVCaptureSession捕捉视频
#import <UIKit/UIKit.h> #import <AVFoundation/AVFoundation.h> #import <AssetsLibrary/ ...