5290589 发表于 2019-2-1 11:41:49

GlusterFS in CentOS 6.5的实现和配置

   
[*]Gluster的几种实现
      
[*]1.striped volume 条带卷的实现      
[*]http://libincla.blog.运维网.com/attachment/201410/4/6249823_1412426738fiRW.png 如左图,条带卷内部的每一个文件都被分成4份用来保存,称为条带式存储。      
[*]2、Replication      
[*]http://libincla.blog.运维网.com/attachment/201410/4/6249823_1412426741wY2J.png 如左图,条带卷内部的每一个文件在不同的server中各存一份。      
[*]3、Distributed Volume      
[*]http://libincla.blog.运维网.com/attachment/201410/4/6249823_1412426744dbUU.png 如左图,条带卷内的各个文件被分散到各节点进行存储。      
[*]4、DHT      
[*]http://libincla.blog.运维网.com/attachment/201410/4/6249823_1412426746viZf.png   
      
[*]安装Gluster
      
[*]安装环境,三个节点分别是      
[*]172.16.24.100 node1.libincla.com      
[*]172.16.24.101 node2.libincla.com      
[*]172.16.24.102 node3.libincla.com      
[*]在此的环境下已经准备好了Gluster需要的rpm包      
[*]这里使用的如下方式            lftp 172.16.0.1:/pub/Sources/6.x86_64/glusterfs> cd ..            
lftp 172.16.0.1:/pub/Sources/6.x86_64> mirror glusterfs               
Total: 2 directories, 20 files, 0 symlinks                                                   
New: 20 files, 0 symlinks               
10241416 bytes transferred in 2 seconds (4.07M/s)               
lftp 172.16.0.1:/pub/Sources/6.x86_64>
      
[*]因为这个目录内含有repodata,可以编辑新的yum源来指向这个repodata。      
[*]如:# vim /etc/yum.repos.d/glusterfs.repo              
name=glfs            
baseurl=file:///root/glusterfs/            
gpgcheck=0
      
[*]使用yum repolist,列出repo查看是否生效      
[*]http://libincla.blog.运维网.com/attachment/201410/4/6249823_1412426748tEQw.png 果然能够被读取出来。      
[*]# yum install glusterfs-server 安装gluster的服务器包      
[*]http://libincla.blog.运维网.com/attachment/201410/4/6249823_1412426751DeM2.png 这些需要依赖的包      
[*]安装完成以后,将目录分别scp到其他两个节点上去,此处不再赘述。      
[*]如:  # scp -r glusterfs/ node2:/root            
The authenticity of host 'node2 (172.16.24.101)' can't be established.            
RSA key fingerprint is a4:8b:0f:37:a4:a0:31:59:6d:bb:56:52:23:f1:fc:4c.            
Are you sure you want to continue connecting (yes/no)? yes            
Warning: Permanently added 'node2,172.16.24.101' (RSA) to the list of known hosts.            
root@node2's password:            
glusterfs-libs-3.5.2-1.el6.x86_64.rpm                                                                              100%250KB 250.2KB/s   00:00   
glusterfs-extra-xlators-3.5.2-1.el6.x86_64.rpm                                                                     100%   46KB45.6KB/s   00:00   
glusterfs-devel-3.5.2-1.el6.x86_64.rpm                                                                           100%122KB 122.4KB/s   00:00   
glusterfs-server-3.5.2-1.el6.x86_64.rpm                                                                            100%563KB 563.3KB/s   00:00   
glusterfs-fuse-3.5.2-1.el6.x86_64.rpm                                                                              100%   92KB92.3KB/s   00:00   
glusterfs-3.5.2-1.el6.x86_64.rpm                                                                                 100% 1241KB   1.2MB/s   00:00   
be1304a9b433e6427e2bbb7e1749c5005d7454e8f7a6731da1217e2f45a2d1da-primary.sqlite.bz2                              100%   12KB11.7KB/s   00:00   
40b9dab11d26eb746c553eb57e6aa60d0ba9d1b66a935cb04c782815c05bf7c3-primary.xml.gz                                    100% 3785   3.7KB/s   00:00   
repomd.xml                                                                                                         100% 2985   2.9KB/s   00:00   
da5ee38acf32e0f9445a11d057b587634b874ce5a6dc3b900512f6afc133351f-filelists.xml.gz                                  100%   11KB10.6KB/s   00:00   
4e933e2701d32eac68670eeb53104b107bc8eac9879a199a1050852d7cf5994e-other.sqlite.bz2                                  100% 4417   4.3KB/s   00:00   
5a4290490160367cedd0d349fb8719fb7485d6cd1c7fb03e0a9caace98a5610c-other.xml.gz                                    100% 1475   1.4KB/s   00:00   
f9d4a1d6bfb573f34706f9cd84767959ec15599856f85b9d07a9310fda96b140-filelists.sqlite.bz2                              100%   18KB17.6KB/s   00:00   
glusterfs-rdma-3.5.2-1.el6.x86_64.rpm                                                                              100%   49KB49.5KB/s   00:00   
glusterfs-geo-replication-3.5.2-1.el6.x86_64.rpm                                                                   100%155KB 155.0KB/s   00:00   
glusterfs-regression-tests-3.5.2-1.el6.x86_64.rpm                                                                  100%114KB 114.1KB/s   00:00   
glusterfs-api-3.5.2-1.el6.x86_64.rpm                                                                               100%   69KB69.0KB/s   00:00   
glusterfs-api-devel-3.5.2-1.el6.x86_64.rpm                                                                         100%   29KB29.3KB/s   00:00   
glusterfs-cli-3.5.2-1.el6.x86_64.rpm                                                                               100%122KB 122.5KB/s   00:00   
glusterfs-debuginfo-3.5.2-1.el6.x86_64.rpm                                                                         100% 7095KB   6.9MB/s   00:01
      
[*]各节点分别创建所需要的目录,这里就叫gdata代表glusterfs的目录。      
[*]mkdir -pv /gdata/brick      
[*]然后就开始在各节点启动服务      
[*]service glusterd start      
[*]然后ss-tnlp查看哪个端口监听?  # ss -ntlp |grep glusterd            
LISTEN   0      128                     *:24007                  *:*      users:(("glusterd",35476,9))            
#
      
[*]24007这个端口监听。      
[*]可以用gluster peer probe 可以探测各节点。      
[*]# gluster peer probe node2         
peer probe: success.         
# gluster peer probe node3         
peer probe: success.         
#  显示都是成功的。
      
[*]另外还可以使用命令 gluster peer status查看各状态  # gluster peer status            
Number of Peers: 2
  Hostname: node2            
Uuid: 01f4c256-21a7-4b9b-a9ef-735182618bc6            
State: Peer in Cluster (Connected)
  Hostname: node3            
Uuid: 70cd5f4e-e3db-401b-8849-ced76ac3f6c8            
State: Peer in Cluster (Connected)
   
      
[*]准备工作已然完成,需要创建GlusterFS的卷
      
[*]分别在各节点上创建gv0      
[*]mkdir /usr/gdata/brick/gv0 -pv      
[*]在任意节点上使用命令  # gluster volume create gv0 replica 3 node1:/data/brick/gv0/ node2:/data/brick/gv0/ node3:/data/brick/gv0/ force            
volume create: gv0: success: please start the volume to access data
      
[*]这里我加了一个force,这里提醒大家如果想做Glusterfs最好在每个节点都提前准备好一个空闲的磁盘。      
[*]此时使用Gluster volume start gv0启动卷# gluster volume start gv0         
volume start: gv0: success      
[*]这里使用mount命令,随便找一个主机目录挂到此节点,看看效果。  # mount -t glusterfs node2:/gv0 /mnt/gluster/            
#
  随便存个文件试试
http://libincla.blog.运维网.com/attachment/201410/4/6249823_1412426753d1TG.png
http://libincla.blog.运维网.com/attachment/201410/4/6249823_1412426755GDNv.png
http://libincla.blog.运维网.com/attachment/201410/4/6249823_14124267575xJt.png
  使用命令,能够看到gv0信息
  # gluster volume info gv0            
Volume Name: gv0            
Type: Replicate            
Volume ID: 44a87154-fc05-449b-bc98-266bc7673b23            
Status: Started            
Number of Bricks: 1 x 3 = 3            
Transport-type: tcp            
Bricks:            
Brick1: node1:/data/brick/gv0            
Brick2: node2:/data/brick/gv0            
Brick3: node3:/data/brick/gv0            
#
   
      
[*]现在我们三个节点等于都有了此设备的副本,如果再其中一个节点存储数据,其他节点应该就能收到同样的数据。   



页: [1]
查看完整版本: GlusterFS in CentOS 6.5的实现和配置