GlusterFS文件系统搭建
实验环境及配置:两台虚拟机,使用centos6.5系统、最小化安装,具体配置如下
| 主机名 | 系统 | CUP核心 | 系统用磁盘空间 | GlusterFS用磁盘空间 | IP(虚拟机使用NAT模式) |
|---|---|---|---|---|---|
| Gluster01 | CentOS 6.5 | 1*2 | 30GB | 10GB | 192.168.200.10 |
| Gluster02 | CentOS 6.5 | 1*2 | 30GB | 10GB | 192.168.200.20 |
注:以下操作须在不同server上进行,请看清后再行操作
基础配置
Gluster01 & Gluster02
更改IP到主机名映射
[root@Gluster01]# vi /etc/hosts
添加如下内容:1
2192.168.200.10 Gluster01
192.168.200.20 Gluster02更改DNS
[root@Gluster01]# vi /etc/resolv.conf
添加如下内容:nameserver 114.114.114.114修改主机名
[root@Gluster01]# vi /etc/sysconfig/network
修改HOSTNAME=Gluster01[root@Gluster01]# Hostname Gluster01关闭SElinux
[root@Gluster01]# vi /etc/selinux/config
修改SELINUX=disabled[root@Gluster01]# setenforce 0[root@Gluster01]# getenforce关闭防火墙
[root@Gluster01]# iptables -F[root@Gluster01]# iptables -X[root@Gluster01]# iptables -Z[root@Gluster01]# service iptables save[root@Gluster01]# service iptables stop[root@Gluster01]# chkconfig iptables off配置yum源
方法一:[root@Gluster01]# vi /etc/yum.repos.d/local.repo1
2
3
4
5[glusterfs]
name=glusterfs
baseurl=https://buildlogs.centos.org/centos/6/storage/x86_64/gluster-3.13/
gpgcheck=0
enable=1[root@Gluster01]# yum clean all[root@Gluster01]# yum makecache注:如提示ssl连接错误或连接超时请更换镜像,连接不到baseurl里的链接,请使用方法二
方法二:
[root@Gluster01]# vi /etc/yum.repos.d/local.repo1
2
3
4
5[glusterfs]
name=glusterfs
baseurl=file:///mnt/glusterfs
gpgcheck=0
enable=1点我下载glusterfs3.13到本地
将下载好的包解压后传入目录/mnt/glusterfs中[root@Gluster01]# mkdir /mnt/glusterfs[root@Gluster01]# yum clean all[root@Gluster01]# yum makecache安装glusterfs
[root@Gluster01]# yum install glusterfs-server xfsprogs -y[root@Gluster01]# service glusterd status[root@Gluster01]# service glusterd start[root@Gluster01]# chkconfig glusterd on
注:Gluster02也做如上操作,注意修改主机名时主机名不同
Gluster01
- 安装时间同步
[root@Gluster01]# yum install ntp -y[root@Gluster01]# vi /etc/ntp.conf - 编辑ntp配置文件,注释掉其他ntp服务器,加入下面两行
1
2server 127.127.1.0
fudge 127.127.1.0 stratum 10
- 启动ntp并设置为开机启动
[root@Gluster01]# service ntpd start[root@Gluster01]# chkconfig ntpd on
Gluster02
[root@Gluster02]# yum install ntp -y[root@Gluster02]# service ntpd start[root@Gluster02]# chkconfig ntpd on
同步Gluster01的时间到本地[root@Gluster02]# ntpdate 192.168.200.10
配置GlusterFS
Gluster01
- 邀请本机加入gluster
[root@Gluster01]# gluster peer probe 192.168.200.10 - 邀请gluster02加入
[root@Gluster01]# gluster peer probe 192.168.200.20 - 查看gluster状态
[root@Gluster01]# gluster peer status[root@Gluster01]# lsblk - 格式化sdb,创建xfs文件系统
[root@Gluster01]# mkfs.xfs /dev/sdb - 创建gluster使用的目录
[root@Gluster01]# mkdir -p /export/brick1 - 将sdb挂载到目录
[root@Gluster01]# mount /dev/sdb /export/brick1[root@Gluster01]# df -h[root@Gluster01]# mkdir /export/brick1/fn0 - 创建条带卷,ID为fn0,将brick1加入进来
[root@Gluster01]# gluster volume create fn0 stripe 2 192.168.200.10:/export/brick1/fn0 192.168.200.20:/export brick1/fn0 - 启动卷
[root@Gluster01]# gluster volume start fn0 - 查看卷信息
[root@Gluster01]# gluster volume info
Gluster02
[root@Gluster02]# lsblk
- 格式化sdb,创建xfs文件系统
[root@Gluster02]# mkfs.xfs /dev/sdb - 创建gluster使用的目录
[root@Gluster02]# mkdir -p /export/brick1 - 将sdb挂载到目录
[root@Gluster02]# mount /dev/sdb /export/brick1[root@Gluster02]# df -h[root@Gluster02]# mkdir /export/brick1/fn0 - GlusterFS2作为GlusterFS的客户端进行验证
[root@Gluster02]# mount -t glusterfs 192.168.200.111:/fn0 /mnt - 验证挂载是否成功
[root@Gluster02]# df -h

