V 10 glusterfs(2)

简介:

操作:

准备三台虚拟机:

client10.96.20.118/24,测试挂载使用)

server1eth010.96.20.113/24eth1192.168.10.113/24/dev/sdb5G))

server2eth010.96.20.114/24eth1192.168.10.114/24/dev/sdb5G))

/etc/hosts内容:

10.96.20.113   server1

10.96.20.114   server2

10.96.20.118   client

准备安装软件包的yum源:

http://download.gluster.org/pub/gluster/glusterfs/3.6/LATEST/CentOS/glusterfs-epel.repo

软件包位置:

http://download.gluster.org/pub/gluster/glusterfs/版本号/

准备测试工具:

atop-1.27-2.el6.x86_64.rpm

fio-2.0.13-2.el6.x86_64.rpm

iperf-2.0.5-11.el6.x86_64.rpm

iozone-3-465.i386.rpm

 

 

[root@server1 ~]# cat /etc/redhat-release

Red Hat Enterprise Linux Server release 6.5(Santiago)

[root@server1 ~]# uname -rm

2.6.32-431.el6.x86_64 x86_64

[root@server1 ~]# cat /proc/sys/net/ipv4/ip_forward

1

 

[root@server1 ~]# mount | grep brick1

/dev/sdb on /brick1 type ext4 (rw)

[root@server1 ~]# df -h | grep brick1

/dev/sdb        5.0G 138M  4.6G   3% /brick1

 

[root@server2 ~]# mount | grep brick1

/dev/sdb on /brick1 type ext4 (rw)

[root@server2 ~]# df -h | grep brick1

/dev/sdb        5.0G 138M  4.6G   3% /brick1

 

server1server2均执行:

[root@server1 ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo

[root@server1 ~]# vim /etc/yum.repos.d/CentOS-Base.repo

:%s/$releasever/6/g

[root@server1 ~]# yum -y install rpcbind libaio lvm2-devel  (用centosepelaliyumyum源安装依赖的包,这些源仅能安装用于clientglusterfs包,没有glusterfs-server包)

[root@server1 ~]# wget -P /etc/yum.repos.d/ http://download.gluster.org/pub/gluster/glusterfs/3.6/LATEST/CentOS/glusterfs-epel.repo

[root@server1 ~]# yum -y install glusterfs-server

Installing:

 glusterfs-server                   x86_64                   3.6.9-1.el6                     glusterfs-epel                   720 k

Installing for dependencies:

 glusterfs                          x86_64                   3.6.9-1.el6                     glusterfs-epel                   1.4 M

 glusterfs-api                      x86_64                   3.6.9-1.el6                     glusterfs-epel                    64 k

 glusterfs-cli                      x86_64                   3.6.9-1.el6                     glusterfs-epel                   143 k

 glusterfs-fuse                     x86_64                   3.6.9-1.el6                     glusterfs-epel                    93 k

 glusterfs-libs                     x86_64                   3.6.9-1.el6                     glusterfs-epel                   282 k

……

[root@server1 ~]# cd glusterfs/

[root@server1 glusterfs]# ll

total 1208

-rw-r--r--. 1 root root 108908 Jan 17  2014 atop-1.27-2.el6.x86_64.rpm

-rw-r--r--. 1 root root 232912 Dec 22  2015 fio-2.0.13-2.el6.x86_64.rpm

-rw-r--r--. 1 root root 833112 Sep 11 18:41iozone-3-465.i386.rpm

-rw-r--r--. 1 root root  54380 Jan 3  2014iperf-2.0.5-11.el6.x86_64.rpm

[root@server1 glusterfs]# rpm -ivh atop-1.27-2.el6.x86_64.rpm

[root@server1 glusterfs]# rpm -ivh fio-2.0.13-2.el6.x86_64.rpm

[root@server1 glusterfs]# rpm -ivh iozone-3-465.i386.rpm

[root@server1 glusterfs]# rpm -ivh iperf-2.0.5-11.el6.x86_64.rpm

[root@server1 ~]# service glusterd start

Starting glusterd:                                         [  OK  ]

 

server2

[root@server2 ~]# service glusterd start

Starting glusterd:                                         [ OK  ]

 

server1

[root@server1 ~]# gluster help   #gluster命令有交互模式)

peer probe<HOSTNAME> - probe peer specified by<HOSTNAME>   #(增加node,组建集群,主机名或IP均可)

peer detach <HOSTNAME> [force] -detach peer specified by <HOSTNAME>  #(删除node

peer status - list status of peers

volume info [all|<VOLNAME>] - list informationof all volumes   (查看卷信息)

volume create <NEW-VOLNAME> [stripe <COUNT>] [replica <COUNT>] [disperse[<COUNT>]] [redundancy <COUNT>] [transport<tcp|rdma|tcp,rdma>] <NEW-BRICK>?<vg_name>... [force] - create a new volume of specified type with mentioned bricks   #(创建卷)

volume delete <VOLNAME> - deletevolume specified by <VOLNAME>

volume start<VOLNAME> [force] - start volume specified by<VOLNAME>   #(启动卷)

volume stop <VOLNAME> [force] - stopvolume specified by <VOLNAME>

volume add-brick <VOLNAME> [<stripe|replica> <COUNT>] <NEW-BRICK> ...[force] - add brick to volume <VOLNAME>   (增加brick

volume remove-brick <VOLNAME>[replica <COUNT>] <BRICK> ...<start|stop|status|commit|force> - remove brick from volume<VOLNAME>

volume rebalance <VOLNAME> {{fix-layout start} | {start [force]|stop|status}} - rebalance operations  

[root@server1 ~]# gluster peer probe server2

peer probe: success.

[root@server1 ~]# gluster peer status

Number of Peers: 1

Hostname: server2

Uuid: 4762db74-3ddc-483a-a510-5756d7402afb

State: Peer in Cluster (Connected)

 

server2

[root@server2 ~]# gluster peer status

Number of Peers: 1

Hostname: server1

Uuid: b38bd899-6667-4253-9313-7538fcb5153f

State: Peer in Cluster (Connected)

 

server1

[root@server1 ~]# gluster volume create testvol server1:/brick1/b1 server2:/brick1/b1   #(默认创建的是hash卷;此步也可分开执行,先执行#gluster volume create testvol server1:/brick1/b1,再执行#glustervolume create testvol server2:/brick1/b1

volume create: testvol: success: pleasestart the volume to access data

[root@server1 ~]# gluster volume start testvol

volume start: testvol: success

[root@server1 ~]# gluster volume info

Volume Name: testvol

Type: Distribute

Volume ID:095708cc-3520-49f7-89f8-070687c28245

Status: Started

Number of Bricks: 2

Transport-type: tcp

Bricks:

Brick1: server1:/brick1/b1

Brick2: server2:/brick1/b1

 

client(挂载使用):

[root@client ~]# wget -P /etc/yum.repos.d/http://download.gluster.org/pub/gluster/glusterfs/3.6/LATEST/CentOS/glusterfs-epel.repo

[root@client ~]# yum -y install glusterfs glusterfs-fuse   #(客户端仅需安装glusterfsglusterfs-libsglusterfs-fuse

Installing:

 glusterfs                         x86_64                    3.6.9-1.el6                    glusterfs-epel                    1.4 M

 glusterfs-fuse                    x86_64                    3.6.9-1.el6                    glusterfs-epel                     93 k

Installing for dependencies:

 glusterfs-api                     x86_64                    3.6.9-1.el6                    glusterfs-epel                     64 k

 glusterfs-libs                    x86_64                    3.6.9-1.el6                    glusterfs-epel                    282 k

……

[root@client ~]# mount -t glusterfs server1:/testvol /mnt/glusterfs/

[root@client ~]# mount | grep gluster

server1:/testvol on /mnt/glusterfs typefuse.glusterfs (rw,default_permissions,allow_other,max_read=131072)

[root@client ~]# df -h | grep glusterfs   #(总容量是server1server2的和)

server1:/testvol  9.9G  277M 9.1G   3% /mnt/glusterfs

[root@client ~]# cd /mnt/glusterfs/

[root@client glusterfs]# for i in `seq 150` ; do touch test$i.txt ; done

 

server1:

[root@server1 ~]# ls /brick1/b1

test10.txt test17.txt  test1.txt   test24.txt test27.txt  test30.txt  test32.txt test35.txt  test38.txt  test43.txt test4.txt

test16.txt test18.txt  test22.txt  test26.txt test29.txt  test31.txt  test34.txt test37.txt  test3.txt   test46.txt test7.txt

[root@server1 ~]# ll /brick1/b1 | wc -l

23

 

server2:

[root@server2 ~]# ls /brick1/b1

test11.txt test14.txt  test20.txt  test25.txt test33.txt  test40.txt  test44.txt test48.txt  test5.txt  test9.txt

test12.txt test15.txt  test21.txt  test28.txt test36.txt  test41.txt  test45.txt test49.txt  test6.txt

test13.txt test19.txt  test23.txt  test2.txt  test39.txt  test42.txt  test47.txt test50.txt  test8.txt

[root@server2 mnt]# ll /brick1/b1/ | wc -l

29

 

 

 

总结:

配置信息(/etc/glusterd/*);日志信息(/var/log/gluster/*IinfoEerror);

 

#gluster peer probe server2   #(组建集群,在一个node上操作即可,若是添加一个新node要在已组成集群中的任意一个node上操作;可以是主机名或IP,若是主机名要有/etc/hosts解析)

#gluster peer probe server3

#gluster peer status

#gluster volume create testvol server1:/brick1/b1 server2:/brick1/b1   #(创建卷,仅在一个node上操作,默认是hash卷;也可用此种方式创建复制卷#gluster volume create testvol replica 2 server1:/brick1/b2 server2:/brick1/b2;创建条带卷用stripe 2

#gluster volume start testvol

#gluster volume info

#mount -t glusterfs server1:/testvol/mnt/glusterfs

 

删除卷:

#gluster volume stop testvol

#gluster volume delete testvol   #(卷删除后底层的内容还在)

#gluster volume info

#rm -rf /brick1/b1

#rm -rf /brick1/b2

#rm -rf /brick1/b3

 

将机器移除集群:

#gluster peer detach IP|HOSTNAME

 

增加集群机器:

#gluster peer probe server11

#gluster peer probe server12

#gluster peer status

#gluster volume add-brick testvol server11:/brick1/b1server12:/brick1/b1

#gluster volume rebalance testvol start   #(重新LB,此操作要在非访问高峰时做,分两步,先fix-layouthash算法重分配,再将数据重分配;#gluster volume rebalance <VOLNAME> {{fix-layout start} |{start [force]|stop|status}} - rebalance operations

#gluster volume rebalance testvol status

 

卷信息同步(在复制卷上操作):

#gluster volume sync server1 [all|VOLUME]   #(若server2的数据故障,指定与server1数据同步;all表示同步所有的卷;若只是某个卷的数据有问题指定VOLNAME即可)

 

修复磁盘数据(在使用server1时宕机,使用server2替换,执行数据同步):

#gluster volume replace-brick testvol server1:/brick1/b1 server2:/brick1/b1 commit force

#gluster volume heal testvol full

 

当复制卷数据不一致时(解决办法:遍历并访问文件,触发自修复):

#find /mnt/glusterfs -type f -print0 |xargs -0 head -c 1

 

复制卷中一个brick损坏,解决办法:

#getfattr -d -m -e hex /brick1/b1   #(在正常的一个node上查看扩展属性;查看如下三个属性信息,并paste到省略号位置处)

#setfattr -n trusted.gfid -v 0x000…… /brick1/b1

#setfattr -n trusted.glusterfs.dht -v 0x000…… /brick1/b1

#setfattr -n trusted.glusterfs.volume-id -v0x000…… /brick1/b1

#getfattr -d -m . -e hex /brick1/b1

#service glusterd restart   #(仅在出问题的node上重启)

#ps aux | grep gluster

 

 

卷参数配置(#gluster volume set <VOLNAME> <KEY> <VALUE> - set options for volume <VOLNAME>):

<KEY>  <VALUE>有如下:

auth.reject <IP>   #IP访问授权,默认allowall

auth.allow <IP>

cluster.min-free-disk <百分比>   #(剩余磁盘空间阈值,默认10%

cluster.strip-block-size <NUM>   #(条带大小,默认128KB

network.frame-timeout <0-1800>   #(请求等待时间,默认1800s

network.ping-timeout <0-42>   #(客户端等待时间,默认42s

nfs.disabled <off|on>   #(关闭nfs服务,默认off为开启)

performance.io-thread-count<0-65>   #IO线程数,默认16

performance.cache-refresh-timeout<0-61>   #(缓存校验周期,默认1s

performance.cache-size <NUM>   #(读缓存大小,默认32MB

 

网络配置测试:

IP检测(#ip addr#ifconfig);

网关测试(#ip route show#route -n);

DNS测试(#cat/etc/resolv.conf#nslookup);

连通性(#ping IP);

网络性能(在server-side执行#iperf -s;在client-side执行#iperf -c SERVER_IP [-P #]-P--parallel指定线程数);

 

gluster自身配置测试:

#gluster peer status   #(集群状态)

#gluster volume info   #(卷配置)

#gluster volume status   #(卷状态)

#gluster volume profile testvol start|info

 

性能测试(基本性能、带宽测试、iops测试、ops测试、系统监控):

基本性能:

#dd if=/dev/zero of=dd.dat bs=1M count=1k

#dd if=dd.dat of=/dev/null bs=1M count=1k

 

带宽测试:

iozone是目前应用非常广泛的文件系统测试标准工具,它能够产生并测量各种的操作性能,包括read, write, re-read, re-write, read backwards, read strided, fread,fwrite, random read, pread ,mmap, aio_read, aio_write等操作;Iozone目前已经被移植到各种体系结构计算机和操作系统上,广泛用于文件系统性能测试、分析与评估的标准工具

[root@server1 ~]# /opt/iozone/bin/iozone -h

          -r #  record size in Kb

             or -r #k .. size in kB

              or -r #m .. size in MB

              or -r #g .. size in GB

          -s #  file size in Kb

              or -s #k .. size in kB

              or -s #m .. size in MB

              or -s #g .. size in GB

          -t #  Number of threads or processes to use inthroughput test

          -i #  Test to run(0=write/rewrite, 1=read/re-read, 2=random-read/write

                 3=Read-backwards,4=Re-write-record, 5=stride-read, 6=fwrite/re-fwrite

                 7=fread/Re-fread,8=random_mix, 9=pwrite/Re-pwrite, 10=pread/Re-pread

                 11=pwritev/Re-pwritev,12=preadv/Re-preadv)

[root@server1 ~]# /opt/iozone/bin/iozone -r 1m -s 128m -t 4 -i 0 -i 1

……

         RecordSize 1024 kB

         Filesize set to 131072 kB

         Commandline used: /opt/iozone/bin/iozone -r 1m -s 128m -t 4 -i 0 -i 1

         Outputis in kBytes/sec

         TimeResolution = 0.000001 seconds.

         Processorcache size set to 1024 kBytes.

         Processorcache line size set to 32 bytes.

         Filestride size set to 17 * record size.

         Throughputtest with 4 processes

         Eachprocess writes a 131072 kByte file in 1024 kByte records

         Childrensee throughput for  4 initial writers       =  49269.04 kB/sec

         Parentsees throughput for  4 initial writers        =  41259.88 kB/sec

         Minthroughput per process                     =    9069.08 kB/sec

         Maxthroughput per process                             =   14695.71 kB/sec

         Avgthroughput per process                     =   12317.26 kB/sec

         Minxfer                                       =   80896.00 kB

……

 

iops测试:

fio是一个I/O标准测试和硬件压力验证工具,它支持13种不同类型的I/O引擎(sync, mmap, libaio, posixaio, SG v3, splice, null, network, syslet,guasi, solarisaio等),I/O priorities (for newer Linux kernels), rate I/O, forked orthreaded jobs等等;fio可以支持块设备和文件系统测试,广泛用于标准测试、QA、验证测试等,支持Linux, FreeBSD, NetBSD, OS X, OpenSolaris, AIX, HP-UX, Windows等操作系统

sata盘一般iops80

[root@server1 ~]# vim fio.conf

[global]

ioengine=libaio

direct=1

thread=1

norandommap=1

randrepeat=0

filename=/mnt/fio.dat

size=100m

[rr]

stonewall

group_reporting

bs=4k

rw=randread

numjobs=8

iodepth=4

[root@server1 ~]# fio fio.conf

rr: (g=0): rw=randread,bs=4K-4K/4K-4K/4K-4K, ioengine=libaio, iodepth=4

...

rr: (g=0): rw=randread,bs=4K-4K/4K-4K/4K-4K, ioengine=libaio, iodepth=4

fio-2.0.13

Starting 8 threads

rr: Laying out IO file(s) (1 file(s) /100MB)

Jobs: 1 (f=1): [_____r__] [99.9% done][721K/0K/0K /s] [180 /0 /0  iops] [eta00m:01s]

rr: (groupid=0, jobs=8): err= 0: pid=11470:Tue Sep 13 00:44:36 2016

 read : io=819296KB, bw=1082.4KB/s, iops=270 , runt=756956msec

   slat (usec): min=1 , max=35298 , avg=39.61, stdev=169.88

   clat (usec): min=2 , max=990254 , avg=117927.97, stdev=92945.30

    lat (usec): min=277 , max=990259 , avg=117967.87, stdev=92940.88

   clat percentiles (msec):

    |  1.00th=[    5], 5.00th=[   13], 10.00th=[   20], 20.00th=[   32],

    | 30.00th=[   48], 40.00th=[   72], 50.00th=[   98], 60.00th=[  126],

     | 70.00th=[ 159], 80.00th=[  198],90.00th=[  251], 95.00th=[  293],

    | 99.00th=[  379], 99.50th=[  416], 99.90th=[  545], 99.95th=[  603],

    | 99.99th=[  750]

   bw (KB/s)  : min=   46, max= 625, per=12.53%, avg=135.60, stdev=28.57

   lat (usec) : 4=0.01%, 10=0.01%, 20=0.01%, 100=0.01%, 250=0.01%

   lat (usec) : 500=0.03%, 750=0.02%, 1000=0.02%

   lat (msec) : 2=0.10%, 4=0.67%, 10=2.56%, 20=6.94%, 50=20.90%

   lat (msec) : 100=19.70%, 250=39.06%, 500=9.84%, 750=0.16%, 1000=0.01%

 cpu          : usr=0.00%, sys=0.10%, ctx=175327,majf=18446744073709551560, minf=18446744073709449653

  IOdepths    : 1=0.1%, 2=0.1%, 4=100.0%,8=0.0%, 16=0.0%, 32=0.0%, >=64=0.0%

    submit    : 0=0.0%, 4=100.0%,8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%

     complete : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%

    issued    :total=r=204824/w=0/d=0, short=r=0/w=0/d=0

Run status group 0 (all jobs):

  READ: io=819296KB, aggrb=1082KB/s, minb=1082KB/s, maxb=1082KB/s,mint=756956msec, maxt=756956msec

Disk stats (read/write):

 sda: ios=204915/36, merge=35/13, ticks=24169476/9352004,in_queue=33521518, util=100.00%

 

ops测试:

#yum -y install gcc

#gcc -o postmark postmark-1.52.c   #postmark软件包是.c的文件,要使用gcc编译)

#cp postmark /usr/bin/

postmark 是由著名的 NAS 提供商 NetApp 开发,用来测试其产品的后端存储性能,主要用于测试文件系统在邮件系统或电子商务系统中性能,这类应用的特点是:需要频繁、大量地存取小文件;Postmark 的测试原理是创建一个测试文件池;文件的数量和最大、最小长度可以设定,数据总量是一定的,创建完成后,postmark 对文件池进行一系列的transaction操作,根据从实际应用中统计的结果,设定每一个事务包括一次创建或删除操作和一次读或添加操作,在有些情况下,文件系统的缓存策略可能对性能造成影响,postmark 可以通过对创建/删除以及读/添加操作的比例进行修改来抵消这种影响;事务操作进行完毕后,post 对文件池进行删除操作,并结束测试,输出结果;postmark是用随机数来产生所操作文件的序号,从而使测试更加贴近于现实应用,输出结果中比较重要的输出数据包括测试总时间、每秒钟平均完成的事务数、在事务处理中平均每秒创建和删除的文件数,以及读和写的平均传输速度

#vim postmark.conf   #(此例10000个文件,100个目录每个目录下100个文件,默认会在当前路径下生成报告文件)

set size 1k

set number 10000

set location /mnt/

set subdirectories 100

set read 1k

set write 1k

run 60

show

quit

#postmark postmark.conf   #postmark有交互模式)

 

系统监控:

[root@server1 ~]# atop

[root@server1 ~]# iostat 1 10

 


本文转自 chaijowin 51CTO博客,原文链接:http://blog.51cto.com/jowin/1852348,如需转载请自行联系原作者

相关文章
|
存储 JSON Kubernetes
k8s配置glusterFS详解
k8s配置glusterFS详解
|
存储 Kubernetes 文件存储
CephFS 使用
Ceph 之前介绍了 RBD 的使用方法,有了 RBD,远程磁盘挂载的问题就解决了,但 RBD 的问题是不能多个主机共享一个磁盘,如果有一份数据很多客户端都要读写该怎么办呢?这时 CephFS 作为文件系统存储解决方案就派上用场了。
2317 0
|
网络协议 Unix Linux
|
网络协议 Unix Linux
|
网络安全
|
存储 监控 测试技术
|
API Linux
|
存储 RDMA 网络协议