• CentOS6.4安装GlusterFS


    主机分配:

    主机名             IP(Static)                        系统                                           配置                          角色

    gfs-server01    192.168.20.21    CentOS-6.4-x86_64-minimal         2CPU,4G,50G,1网卡          存储节点01

    gfs-server02    192.168.20.22    CentOS-6.4-x86_64-minimal         2CPU,4G,50G,1网卡          存储节点02

    gfs-client          192.168.20.20    CentOS-6.4-x86_64-minimal         2CPU,4G,50G,1网卡              客户端

    GlusterFS rpm下载地址:

    http://download.gluster.org/pub/gluster/glusterfs/LATEST/RHEL/epel-6/x86_64/

    Server端操作(192.168.20.21/22)

    1.安装

    (1).下载GlusterFS yum源:

    [root@gfs-server01 ~]# yum -y install wget

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

    (2).安装Gluster server:

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

    (3).启动Gluster server服务:

    [root@gfs-server01 ~]# service glusterd start

    [root@gfs-server01 ~]# chkconfig glusterd on

    gfs-server02采用同样步骤。

    2.配置

    (1).将两个存储节点添加到一个集群中,在其中一个存储节点操作即可,不用添加本机:

    [root@gfs-server02 ~]# gluster peer probe 192.168.20.21

    (2).检查集群节点信息

    [root@gfs-server02 ~]# gluster peer status

    Number of Peers: 1

    Hostname: 192.168.20.21

    Uuid: 81e52f87-9671-4f21-9e18-0213b4f4f2c9

    State: Peer in Cluster (Connected)

    [root@vm-ha02 ~]# 

    3440805e-95b0-4383-b59d-a58d1a79ab74

    (3).以/data/gluster为共享目录,创建名为volume-sql的卷,副本数为2

    [root@gfs-server02 ~]# gluster volume create volume-sql replica 2 192.168.20.21:/data/gluster 192.168.20.22:/data/gluster

    (4).启动卷

    [root@gfs-server02 ~]# gluster volume start volume-sql

    (5).查看卷状态

    [root@gfs-server02 ~]# gluster volume info

    Volume Name: volume-sql

    Type: Replicate

    Volume ID: a9fea762-0b46-4a0b-aa8f-27d21bd258d2

    Status: Started

    Number of Bricks: 1 x 2 = 2

    Transport-type: tcp

    Bricks:

    Brick1: 192.168.20.21:/data/gluster

    Brick2: 192.168.20.22:/data/gluster


    Client端操作(192.168.20.20)

    1.安装

    (1).下载GlusterFS yum源:

    [root@gfs-client ~]# yum -y install wget

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

    (2).安装Gluster client:

    [root@gfs-client ~]# yum -y install glusterfs glusterfs-fuse

    2.挂载

    (1).创建挂载目录

    [root@gfs-client ~]# mkdir -p /openstack/mysql

    (2).使用glusterfs挂载(挂载任意一个储存节点即可)

    [root@gfs-client ~]# mount -t glusterfs 192.168.20.21:/volume-sql /openstack/mysql

    [root@gfs-client ~]# echo "192.168.20.21:/volume-sql /openstack/mysql glusterfs defaults,_netdev 0 0" >> /etc/fstab

    (3).使用NFS挂载(注意远端的rpcbind服务必须开启)

    [root@gfs-client ~]# mount -t nfs -o mountproto=tcp,vers=3 192.168.20.21:/volume-sql /openstack/mysql

    [root@gfs-client ~]# echo "192.168.20.21:/volume-sql /openstack/mysql nfs mountproto=tcp,vers=3 0 0

    3.测试

    (1).拷贝文件到/openstack/mysql/

    [root@gfs-client ~]# cp -av /root/centos6.4_20G.qcow2 /openstack/mysql/

    (2).存储节点上查看文件:

    [root@gfs-server01 ~]# ls /data/gluster/

    centos6.4_20G.qcow2

    [root@gfs-server01 ~]# md5sum /data/gluster/centos6.4_20G.qcow2 

    94469f217dbe3cc54ebe2771b31d0fee  /data/gluster/centos6.4_20G.qcow2

    [root@gfs-server02 ~]# ls /data/gluster/

    [root@gfs-server02 ~]# md5sum /data/gluster/centos6.4_20G.qcow2 

    94469f217dbe3cc54ebe2771b31d0fee  /data/gluster/centos6.4_20G.qcow2

    4.常用命令

    (1).删除卷

    [root@gfs-servertest ~]# gluster volume stop volume-sql

    [root@gfs-servertest ~]# gluster volume delete volume-sql

    (2).将存储节点移除集群

    [root@gfs-servertest ~]# gluster peer detach 192.168.20.23

    (3).允许某些网段访问某个卷

    [root@gfs-servertest ~]# gluster volume set volume-sql auth.allow 192.168.20.*

    (4).添加新存储节点到集群

    [root@gfs-servertest ~]# gluster peer probe 192.168.20.24

    [root@gfs-servertest ~]# gluster peer probe 192.168.20.25

    [root@gfs-servertest ~]# gluster volume add-brick volume-sql 192.168.20.24:/data/gluster 192.168.20.25:/data/gluster

    (5).收缩卷

    先迁移数据到其他位置:

    [root@gfs-servertest ~]# gluster volume remove-brick volume-sql 192.168.20.26:/data/gluster/volume-sql 192.168.20.27:/data/gluster/volume-sql start

    查看数据迁移状态:

    [root@gfs-servertest ~]# gluster volume remove-brick volume-sql 192.168.20.26:/data/gluster/volume-sql 192.168.20.27:/data/gluster/volume-sql status

    迁移完成后提交:

    [root@gfs-servertest ~]# gluster volume remove-brick volume-sql 192.168.20.26:/data/gluster/volume-sql 192.168.20.27:/data/gluster/volume-sql commit

    (6).迁移卷

    添加存储节点:

    [root@gfs-servertest ~]# gluster peer probe 192.168.20.28

    开始卷迁移:

    [root@gfs-servertest ~]# gluster volume replace-brick volume-sql 192.168.20.21:/data/gluster/volume-sql 192.168.20.28:/data/gluster/volume-sql start

    查看迁移状态:

    [root@gfs-servertest ~]# gluster volume replace-brick volume-sql 192.168.20.21:/data/gluster/volume-sql 192.168.20.28:/data/gluster/volume-sql status

    迁移完毕后提交:

    [root@gfs-servertest ~]# gluster volume replace-brick volume-sql 192.168.20.21:/data/gluster/volume-sql 192.168.20.28:/data/gluster/volume-sql commit

    如果机器192.168.20.21出现故障已经不能运行,执行强制提交然后Gluster马上执行一次同步:

    [root@gfs-servertest ~]# gluster volume replace-brick img 192.168.20.21:/data/gluster/volume-sql 192.168.20.28:/data/gluster/volume-sql commit -force

    [root@gfs-servertest ~]# gluster volume heal imgs full


  • 相关阅读:
    singleton 创建static类型的对象
    记忆曲线 遗忘曲线
    创建classic 得到函数 调用函数
    abstract factory 创建相互关联的类
    log4j PatternLayout
    C#中override重写与new隐藏的区别,以及C#与Java的override区别 转
    iptables如何做内网的https端口映射 转
    得到一棵树 取自表内自递归(即ID 与ParentID)
    Common.TcpLibTcpClientT
    得到汉字的首拼音字符 ZT
  • 原文地址:https://www.cnblogs.com/myiaas/p/4161315.html
Copyright © 2020-2023  润新知