场景:
三台服务器作用gluster做server又做client端
首先保证三台服务器是通的
分别配置/etc/hosts
10.51.114.230 web1
10.51.116.7 web2
10.51.116.58 web3
三台服务器每一台都要安装gluster哦
#apt-get install bison #apt-get install flex #wget http://download.gluster.org/pub/gluster/glusterfs/3.6/3.6.4/glusterfs-3.6.4.tar.gz #tar -zxvf glusterfs-3.6.4.tar.gz #cd glusterfs-3.6.4 #./configure --prefix= > /dev/null #make #make insatll 安装完执行下 #ldconfig #glusterfs --version glusterfs 3.6.4 built on Aug 11 2015 14:59:37 Repository revision: git://git.gluster.com/glusterfs.git Copyright (c) 2006-2013 Red Hat, Inc. <http://www.redhat.com/> GlusterFS comes with ABSOLUTELY NO WARRANTY. It is licensed to you under your choice of the GNU Lesser General Public License, version 3 or any later version (LGPLv3 or later), or the GNU General Public License, version 2 (GPLv2), in all cases as published by the Free Software Foundation. 启动 #/etc/init.d/glusterd start
好了,这样子就给每一台都安装并启动了glusterfs
下面进入配置阶段,以下操作在其中一台服务器上执行就可以了,我们在WEB1上执行
root@Server1:/data# gluster #加入web1,web2,web3节点 gluster>peer probe web1 Probe successful gluster>peer probe web2 Probe successful gluster>peer probe web3 Probe successful #查看节点,我在web1上就可看到web2,web3,同理在其它服务器,可以看到其它服务器 gluster> peer status Number of Peers: 2 Hostname: web2 Uuid: b9f67621-80cd-4322-86f1-c7ca8daa7c0d State: Peer in Cluster (Connected) Hostname: web3 Uuid: 20986446-0b1a-41fb-b2cc-237740e70d62 State: Peer in Cluster (Connected) #创建卷名为filestore,路径为/data/filestore,名字和路径不一定要相同哦 gluster> volume create filestore replica 3 web1:/data/filestore web2:/data/filestore web3:/data/filestore volume create: filestore: success: please start the volume to access data #启动filestore卷, gluster> volume start filestore volume start: filestore: success #查看filestor卷信息 gluster> volume info filestore Volume Name: filestore Type: Replicate Volume ID: af99cc80-ac53-43a9-8e35-3aa21ff7627b Status: Started Number of Bricks: 1 x 3 = 3 Transport-type: tcp Bricks: Brick1: web1:/data/filestore Brick2: web2:/data/filestore Brick3: web3:/data/filestore 这样就在三台服务器上创建了/data/filestore,卷名为filestore,共享存储
附注
查看命令帮助,这个非常有用,gluster很多命令和别的软件有区别
gluster help gluster peer help gluster volume help
删除节点
gluster peer help gluster peer datach g133
删除birck
gluster volume info gluster volume remove-brick testvol g132:/data/data01
如果你要删除testvol卷,那么你需先要停止volume服务,再删除
gluster volume stop testvol gluster volume delete testvol
创建完后,在每台服务器进行挂载
WEB1挂载 注意挂载是节点名加卷名 #mount -t glusterfs web1:/filestore /www/appinfo 看下挂载 root@Server1:/data# mount /dev/xvda1 on / type ext4 (rw,errors=remount-ro) proc on /proc type proc (rw,noexec,nosuid,nodev) sysfs on /sys type sysfs (rw,noexec,nosuid,nodev) none on /sys/fs/fuse/connections type fusectl (rw) none on /sys/kernel/debug type debugfs (rw) none on /sys/kernel/security type securityfs (rw) udev on /dev type devtmpfs (rw,mode=0755) devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620) tmpfs on /run type tmpfs (rw,noexec,nosuid,size=10%,mode=0755) none on /run/lock type tmpfs (rw,noexec,nosuid,nodev,size=5242880) none on /run/shm type tmpfs (rw,nosuid,nodev) /dev/xvdb on /data type ext4 (rw) none on /proc/xen type xenfs (rw) web1:/filestore on /www/appinfo type fuse.glusterfs (rw,default_permissions,allow_other,max_read=131072) 这样就挂载上了,同理其它两台也是这样子挂载,
测试,就在这里不写了,这样三台服务器同时读写,实时搞定。