1.环境准备
使用GlusterFS创建集群NAS
1.配置三个节点网卡,完成后service network restart重启
vi /etc/sysconfig/network-scripts/ifcfg-eno16777736
IPADDR=192.168.100.60
GATEWAY=192.168.100.2
PREFIX=24
DNS1=114.114.114.114
2.分别修改三个节点主机名
echo "gluster_node1" > /etc/hostname
echo "gluster_node2" > /etc/hostname
echo "gluster_node3" > /etc/hostname
3. 在三个节点上修改hosts文件并互ping
192.168.100.60 gluster_node1
192.168.100.61 gluster_node2
192.168.100.62 gluster_node3
2.安装flex bison
yum install flex bison
3.安装GlusterFS源
yum install centos-release-gluster
5.在各个节点关闭防火墙,设置selinux为disabled模式
#service firewalld stop
#chkconfig firewalld off
#sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
#setenforce 0
6. 安装GlusterFS
yum install -y glusterfs glusterfs-server glusterfs-fuse glusterfs-rdma
7.在gluster_node1上配置分别开启服务service glusterd start && service glusterfsd start,设置自启systemctl enable glusterd && systemctl enable glusterfsd,将节点加入到集群
gluster peer probe 192.168.100.60
gluster peer probe 192.168.100.61
gluster peer probe 192.168.100.62
8.查看集群状态
gluster peer status
9. 在三个节点上分别创建数据存储目录
mkdir -p /opt/gluster/data
10.系统测试,创建一个卷并进行mount测试,假设在192.168.100.60上测试
Gluster volume create testvol 192.168.100.60:/opt/gluster/data/ 192.168.100.61:/opt/gluster/data/ 192.168.100.62:/opt/gluster/data/ force
11.启动并查看状态
12.挂载文件系统并查看
mount -t glusterfs 192.168.100.60:/testvol /mnt/
df –h
gluster volume info
13. 安装配置高可用集群NAS
1)ip配置
Single IP: 192.168.100.60(后面由LVS使用,对外提供单一IP访问)
Public IP: 192.168.100.61 (用于外部访问,或提供给LVS进行负载均衡)
Private IP: 192.168.100.62(用于内部访问,heartbeat及集群内部通信)
2)挂载集群文件系统
这里使用Glusterfs集群文件系统为所有节点提供共享存储空间,并为CTDB提供lock和status等共享存储空间。CTDB卷建议采用gluster replica volume,NAS卷可以根据实际需求选择distribute, stripe, replica及复合卷。创建两个卷在192.168.100.60上进行。在三个节点上分别创建目录mkdir -p /opt/gluster/nas
4)gluster volume create replica 192.168.100.60:/opt/gluster/nas/ force
5)gluster volume create ctdb 192.168.100.60:/opt/gluster/ctdb/ force
6) gluster volume create nas 192.168.100.60:/opt/gluster/lock force
6)分别启动并查看状态
gluster volume start replica
gluster volume start ctdb
gluster volume start nas
7)在三个节点上同时mount以上创建的nas和ctdb卷并查看
mkdir /opt/gluster/replica
mkdir /opt/gluster/nasdata
mount -t glusterfs 192.168.100.60:/nas /opt/gluster/nasdata/ (集群NAS使用)
mount -t glusterfs 192.168.100.60:/ctdb /opt/gluster/replica/ (CTDB使用)
df –h
gluster volume status