在Centos6.5版本分布式安装Glusterfs3.8版本

1. 登入root用户

sudo su root

 

2. 设置主机名

修改hostname文件,以及hosts文件添加如下设置,使集群中的主机可以通过主机名进行访问:

10.0.101.2 gfs1

10.0.101.191 gfs2

10.0.101.213 gfs3

10.0.101.61 gfs_cli

 

10.20.32.19 VM_32_19_centos

10.20.52.19 VM_52_19_centos

10.10.64.27 VM_64_27_centos

 

3. 查看防火墙状态

systemctl status firewalld

 

* firewalld.service - firewalld - dynamic firewall daemon

   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)

   Active: inactive (dead)

处于关闭状态,不做修改。

 

4. 下载安装包

下载地址http://buildlogs.centos.org/centos/6/storage/x86_64/gluster-3.8/

选择glusterfs3.8版本,下载

glusterfs-libs-3.8.7-1.el6.x86_64.rpm

glusterfs-3.8.7-1.el6.x86_64.rpm

glusterfs-client-xlators-3.8.7-1.el6.x86_64.rpm

glusterfs-fuse-3.8.7-1.el6.x86_64.rpm

glusterfs-api-3.8.7-1.el6.x86_64.rpm

glusterfs-cli-3.8.7-1.el6.x86_64.rpm

userspace-rcu-0.7.16-2.el6.x86_64.rpm

glusterfs-server-3.8.7-1.el6.x86_64.rpm

glusterfs-geo-replication-3.8.7-1.el6.x86_64.rpm

 

 

5. 查看linux系统是否存在glusterfs相关插件

rpm –qa | grep gluster

如果返回为空,则无需任何操作,如果返回相关已经安装的rpm包,先进行卸载,然后进行后续安装

6. 安装glusterfs3.8

yum install nfs-utils

 

安装脚本:

#!/bin/bash

rpm -ivh glusterfs-libs-3.8.7-1.el6.x86_64.rpm \

glusterfs-3.8.7-1.el6.x86_64.rpm \

glusterfs-client-xlators-3.8.7-1.el6.x86_64.rpm \

glusterfs-fuse-3.8.7-1.el6.x86_64.rpm \

glusterfs-api-3.8.7-1.el6.x86_64.rpm \

glusterfs-cli-3.8.7-1.el6.x86_64.rpm \

userspace-rcu-0.7.16-2.el6.x86_64.rpm \

glusterfs-server-3.8.7-1.el6.x86_64.rpm \

glusterfs-geo-replication-3.8.7-1.el6.x86_64.rpm

注意:根据环境作适当调整。

7. 启动glusterd服务

/etc/init.d/glusterd start

chkconfig glusterd on

chkconfig glusterfsd on

 

查看当前glusterd服务启动状态:

chkconfig --list | grep glusterd

8. 配置gluster信任池

gfs1上执行:

gluster peer probe gfs2

检查加入可信任存储池中的服务器状态

 命令:gluster peer status

[root@gfs1 soft]# gluster peer status

Number of Peers: 1

 

Hostname: gfs2

Uuid: d0c78a12-95e4-4904-a7f9-5f28ec5a6213

State: Peer in Cluster (Connected)

9. 创建两副本模式

1)、创建两副本

gluster volume create dfs-vm-2 replica 2 gfs1:/data/brick gfs2:/data/brick

 

删除dfs-vm-2

setfattr -x trusted.glusterfs.volume-id /data/brick

setfattr -x trusted.gfid /data/brick

rm -rf /data/brick/.glusterfs

 

 

Es生产环境创建snapshot

/data/es_data/snapshot

gluster volume create es-snapshot 10.10.36.36:/data/es_data/snapshot 

10. 创建三副本模式

1)、创建三副本

gluster volume create gfs_vm replica 3 gfs1:/data/brick gfs2:/data/brick gfs3:/data/brick

 

查看创建的卷的信息

 命令:gluster volume info

 

Volume Name: gfs_vm

Type: Replicate

Volume ID: b89cbb0a-a72c-4069-8abc-c68d2394dcbe

Status: Created

Snapshot Count: 0

Number of Bricks: 1 x 3 = 3

Transport-type: tcp

Bricks:

Brick1: gfs1:/data/brick

Brick2: gfs2:/data/brick

Brick3: gfs3:/data/brick

Options Reconfigured:

transport.address-family: inet

performance.readdir-ahead: on

nfs.disable: on

 

 启动volumes

gluster volume start gfs_vm

volume start: gfs_vm: success

11. 配置客户端

1.软件准备:

glusterfs-libs-3.8.7-1.el6.x86_64.rpm

glusterfs-3.8.7-1.el6.x86_64.rpm

glusterfs-client-xlators-3.8.7-1.el6.x86_64.rpm

glusterfs-fuse-3.8.7-1.el6.x86_64.rpm

 

2.安装rpm包脚本:

#!/bin/bash

rpm -ivh glusterfs-libs-3.8.7-1.el6.x86_64.rpm \

glusterfs-3.8.7-1.el6.x86_64.rpm \

glusterfs-client-xlators-3.8.7-1.el6.x86_64.rpm \

glusterfs-fuse-3.8.7-1.el6.x86_64.rpm

3.挂载gluster集群设置

mkdir /gfsdata

mount.glusterfs gfs1:/gfs_vm /gfsdata

 

4.使用df命令查看挂载结果:

[root@gfs4 soft]# df

Filesystem     1K-blocks    Used Available Use% Mounted on

/dev/vda1       51605116 2327640  46656112   5% /

/dev/vdb        41284928  290740  38897036   1% /data

gfs1:/gfs_vm    41284864  182912  39004800   1% /gfsdata

可以查看到gfs1:/gfs_vm 已经成功挂载到/gfsdata中去了

 

5.测试

/gfsdata写入文件

vim test

输入:hello glusterfs

在集群gfs1 gfs2 gfs3/data/brick目录下均可以看到该文件存在。

12. 超时时间设置

glusterfs集群中某台服务器断线,判断超时时间,该时间的设置关系到glusterfs挂载客户端访问速度。设置命令如下:

 gluster volume set gfs_vm network.ping-timeout 10

 

脑裂测试

1. 高可用性测试

1)、情景一:glusterfs集群存在一台主机存活

gfs2gfs3断网情况下,glusterfs集群只存在一台主机:

此时可以保证正常的读取操作无法写入文件此时文件均处于read-only状态。

这个是glusterfs默认机制导致的,当集群中的机器少于50%时,客户端便无法向集群中写入文件,此时文件处于只读状态。

 

2)、情景二:glusterfs集群存在两台主机存活

gfs3断网情况下:

echo “hello glusterfs” >> hello

在服务器gfs1gfs2均可以看到该文件。

打开gfs3网络设置,文件亦同步到gfs3服务器,无脑裂现象产生。

 

3)、在执行情景三的时候:每台服务器执行

getfattr -m . -d -e hex hello

均返回:

trusted.afr.dirty=0x000000000000000000000000

此时集群处于INNOCENT 状态,各个节点数据均正常。

 

情景三:来回切断gfs1gfs2gfs3的网络

 

gfs3断网情况下:

echo “gfs3_stop” >> hello

在服务器gfs1gfs2均可以看到该文件,程序正常,无脑裂现象产生。

此时:

gfs1:

trusted.afr.dirty=0x000000000000000000000000

trusted.afr.three-vm-client-2=0x000000010000000000000000

表明:gfs1认为自己的正确的处于WISE状态,gfs3data是不正确的,需要进行同步。

 

gfs2:

trusted.afr.dirty=0x000000000000000000000000

trusted.afr.three-vm-client-2=0x000000010000000000000000

表明:gfs2认为自己的正确的处于WISE状态,gfs3data是不正确的,需要进行同步。

 

 

断开gfs2的网络,打开gfs3的网络:

此时会将gfs1的数据同步到gfs3

 gfs1:

    trusted.afr.dirty=0x000000000000000000000000

trusted.afr.three-vm-client-2=0x000000000000000000000000

表明数据已经同步成功,认为自己的gfs3的数据均为有效数据。

gfs3:

trusted.afr.dirty=0x000000000000000000000000

 

然后在挂载的客户端输入:

echo “gfs2_stop”>>hello

此时:

gfs1:

trusted.afr.dirty=0x000000000000000000000000

trusted.afr.three-vm-client-1=0x000000010000000000000000

trusted.afr.three-vm-client-2=0x000000000000000000000000

此时gfs1认为自己和gfs3的数据都是正确的,gfs2的数据需要进行同步。

gfs3:

trusted.afr.dirty=0x000000000000000000000000

trusted.afr.three-vm-client-1=0x000000010000000000000000

此时gfs3认为自己的数据也是正确的,gfs2的数据需要同步。

 

断开gfs1的网络,打开gfs2的网络:

glusterfs挂载客户端执行:cat hello

出现:hello: Input/output error,此时便出现脑裂的情况了

gfs2:

trusted.afr.dirty=0x000000000000000000000000

trusted.afr.three-vm-client-2=0x000000010000000000000000

此时gfs2认为自己是正确的处于WISE状态,认为gfs3是错误的,需要被同步。

 

gfs3:

trusted.afr.dirty=0x000000000000000000000000

trusted.afr.three-vm-client-1=0x000000010000000000000000

gfs3的认为自己也是正确的处于WISE状态,而gfs2的是错误的。

 

此时集群中便存在两个WISE节点并且相互存在冲突从而导致脑裂的产生。此时打开gfs1的网络,脑裂的问题就解决了,因为gfs1也处于WISE状态,如果存在WISE副本,且没有其他WISE副本或者其他WISE副本没有冲突,这时候该副本就可以作为source并将该source同步至gfs1gfs2

 

13. 高可靠性

打开:

gluster volume set three-vm cluster.server-quorum-type server

gluster volume set all cluster.server-quorum-ratio 50%

 

1)、情景一:glusterfs集群存在一台主机存活

gfs2gfs3断网情况下,glusterfs集群只存在一台主机:

此时glusterfs挂载客户端无法访问glusterfs集群,出现异常信息:

ls: cannot open directory .: Transport endpoint is not connected

 

2)、情景二:glusterfs集群存在两台主机存活

gfs3断网情况下:

echo “hello glusterfs” >> hello

在服务器gfs1gfs2均可以看到该文件。

 

 

 

3)、情景三测试同高可用性一致。

14. 设置自动脑裂修复

查看自动脑裂修复的帮助:

gluster volume set help|grep -A3 cluster.favorite-child-policy

 

执行自动修复命令:

gluster volume set gfs_vm2 cluster.favorite-child-policy mtime

 

 

glusterfs调优:

默认值为on,可设置值为on/off

gluster volume set gfs_vm2 performance.flush-behind on

 

客户端:Translator performance/writebehind

默认值为1mb,可设置值524288 - 1073741824

现在设置值:512M

gluster volume set gfs_vm2 performance.write-behind-window-size 524288


服务端:Translator performance/io-threads

默认值为16,可设置值为0-65,当前设置值16

gluster volume set gfs_vm2 performance.io-thread-count 16

 

 

默认值为32 MB,可设置值为:[4194304 - 34359738368]

当前设置值:4G

gluster volume set gfs_vm2 performance.cache-size 4194304

 

 

 

writebehind 默认值为1mb io-threads默认值为16 cache-size32mb flush-behind默认值为on

 

 

GEO-rep配置

   gluster volume create strip-vm stripe 2 replica 2 gfs1:/data/strip_brick1 gfs2:/data/strip_brick1 gfs1:/data/strip_brick2 gfs2:/data/strip_brick2

gluster volume geo-replication strip-vm gfs3::strip_gep_rep create push-pem

 

gluster volume geo-replication strip-vm gfs3::strip_gep_rep start

 

gluster volume geo-replication strip-vm gfs3::strip_gep_rep stop [force]

 

 

gluster volume geo-replication strip-vm gfs3::strip_gep_rep  resume force

 

 

Strip-vm调优参数

gluster volume set strip-vm performance.flush-behind on

 

gluster volume set strip-vm performance.write-behind-window-size 524288

 

gluster volume set strip-vm performance.io-thread-count 4

 

gluster volume set strip-vm performance.cache-size 4194304

 

mount.glusterfs gfs1:/strip-vm /data/strip_gfsdata

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值