OS: Ubuntu-12.04-LTS
10.0.0.54 yarn-server-01
10.0.0.48 hd-server-01
10.0.0.60 hd-server-03
安装:
#!/bin/bash
filepath="/opt/software"
echo "Install glusterfs ..."
apt-get -y --force-yes purge glusterfs-server glusterfs-common
apt-get -y --force-yes install libssl-dev flex bison
rm -rf /var/lib/glusterd || true
if [ ! -x /usr/local/sbin/glusterd ];then
cd /tmp && tar xf ${filepath}/glusterfs-3.4.0.tar.gz
cd /tmp/glusterfs-3.4.0 && ./configure && make && make install && cd /opt && rm -rf /tmp/glusterfs-3.4.0
ldconfig && update-rc.d -f glusterd defaults
fi
service glusterd restart
echo "Finished install."
配置(10.0.0.54上进行):
1. 组集群
root@yarn-server-01:/opt# gluster peer probe 10.0.0.48
root@yarn-server-01:/opt# gluster peer probe 10.0.0.60
#查看集群状态:
root@yarn-server-01:/opt# gluster peer status
Number of Peers: 2
Hostname: 10.0.0.48
Port: 24007
Uuid: 08845703-39c2-466b-9fe5-24ae42969dd0
State: Peer in Cluster (Connected)
Hostname: 10.0.0.60
Port: 24007
Uuid: 3e9ba3a8-32ba-48db-8a01-95c563a1d476
State: Peer in Cluster (Connected)
2.建立volume
root@yarn-server-01:/opt# gluster volume create data_volume replica 2 10.0.0.{48,60}:/data/gluster/
#在此只选用了两台,因为replica必须大于1并且是node数目的倍数
3.启用volume
root@yarn-server-01:/# gluster volume start data_volume
4.挂载使用
root@yarn-server-01:/# mount -t glusterfs 10.0.0.60:data_volume /mnt
自己封装的glusterwrap:
https://github.com/kevinjs/glusterwrap
能够通过python代码直接调用gluster peer status及gluster volume info命令。