GlusterFS主要應(yīng)用在集群系統(tǒng)中,具有很好的可擴(kuò)展性。軟件的結(jié)構(gòu)設(shè)計(jì)良好,易于擴(kuò)展和配置,通過各個(gè)模塊的靈活搭配以得到針對(duì)性的解決方案??山鉀Q以下問題:網(wǎng)絡(luò)存儲(chǔ),聯(lián)合存儲(chǔ)(融合多個(gè)節(jié)點(diǎn)上的存儲(chǔ)空間),冗余備份,大文件的負(fù)載均衡(分塊)。
由于缺乏一些關(guān)鍵特性,可靠性也未經(jīng)過長時(shí)間考驗(yàn),還不適合應(yīng)用于需要提供 24 小時(shí)不間斷服務(wù)的產(chǎn)品環(huán)境。目前適合應(yīng)用于大數(shù)據(jù)量的離線應(yīng)用,下面一起來看GlusterFS分布式文件系統(tǒng)的安裝配置
GlusterFS是一個(gè)開源的分布式文件系統(tǒng),用戶可以使用多臺(tái)服務(wù)器,并通過以太網(wǎng)或者Infiniband RDMA互聯(lián)從而組成一個(gè)GlusterFS的集群
。
GlusterFS集群對(duì)外提供NFS,CIFS和Gluster Native(通過FUSE進(jìn)行掛載)的接口以便用戶訪問GlusterFS的存儲(chǔ)池。
GlusterFS使用了彈性哈希算法來定位文件存儲(chǔ)的位置。 由于使用了彈性哈希算法,GlusterFS不需要專門的Meta-Data Server來保存元數(shù)據(jù),因此可以避免因?yàn)樵獢?shù)據(jù)服務(wù)器宕機(jī)導(dǎo)致的整個(gè)集群不可用。
也正是因?yàn)椴恍枰獢?shù)據(jù)服務(wù)器,所以GlusterFS在多個(gè)掛載點(diǎn)同時(shí)進(jìn)行數(shù)據(jù)讀寫的時(shí)候,其整體性能很突出。
fuse-2.9.3.tar.gz #依賴于fuse
glusterfs-3.6.0.tar.gz #本文用的版本
準(zhǔn)備2臺(tái)機(jī)器,系統(tǒng)為centos6.5 64位。
IP地址 主機(jī)名
192.168.0.107 g1
192.168.0.136 g2
首先關(guān)閉iptables和selinux。
修改主機(jī)名,并添加hosts映射:
g1:
[root@localhost ~]# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=g1
[root@localhost ~]# hostname
g1
[root@localhost ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.0.107 g1
192.168.0.136 g2
g2:
[root@localhost ~]# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=g2
[root@localhost ~]# hostname
g2
[root@localhost ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.0.107 g1
192.168.0.136 g2
安裝預(yù)編譯環(huán)境:
[root@localhost ~]# yum install -y gcc gcc-c++ flex flex-devel bison bison-devel openssl openssl-devel libxml2 libxml2-devel
安裝fuse:
[root@localhost ~]# cd fuse-2.9.3
[root@localhost fuse-2.9.3]# ./configure && make && make install
[root@localhost fuse-2.9.3]# cd
安裝gluster:
[root@localhost ~]# cd glusterfs-3.6.0
[root@localhost glusterfs-3.6.0]# ./configure --prefix=http://www.3lian.com/usr/local/glusterfs && make && make install
g1和g2均執(zhí)行上面操作。
g1和g2啟動(dòng)gluster:
[root@localhost ~]# service glusterd start
添加集群:
[root@localhost ~]# ln -s /usr/local/glusterfs/sbin/gluster /usr/bin/gluster #做一個(gè)軟鏈接方便執(zhí)行命令
[root@localhost ~]# gluster peer probe g2 #在g1中將g2加入到gluster集群中,本機(jī)(g1)不需要加入。
peer probe: success. Probe on localhost not needed
查看集群信息:
[root@localhost ~]# gluster peer status
Number of Peers: 1
Hostname: g2
Uuid: c7aa664a-3161-4716-9f81-2dc4b4718fa1
State: Peer in Cluster (Connected) #已連接
剔除機(jī)器:
[root@localhost ~]# gluster peer detach g2
peer detach: success
創(chuàng)建卷:
[root@localhost ~]# gluster volume create test-volume replica 2 transport tcp g1:/data g2:/data force
volume create: test-volume: success: please start the volume to access data
test-volume 卷名 replica 副本數(shù) transport 傳輸協(xié)議 g1:/data 服務(wù)器名及存儲(chǔ)路徑
啟動(dòng)卷:
[root@localhost ~]# gluster volume start test-volume
volume start: test-volume: success
查看卷:
[root@localhost ~]# gluster volume info
Volume Name: test-volume
Type: Replicate
Volume ID: 104d73c5-17f5-4150-a40d-b97cd78dd6bb
Status: Started
Number of Bricks: 1 x 2 = 2
Transport-type: tcp
Bricks:
Brick1: g1:/data
Brick2: g2:/data
客戶端1掛載(同樣安裝fuse和glusterfs才能支持glusterfs文件系統(tǒng)):
[root@localhost ~]# mkdir /mnt/gfs
[root@localhost ~]# mount -t glusterfs g1:test-volume /mnt/gfs/
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 77G 3.7G 70G 6% /
tmpfs 499M 0 499M 0% /dev/shm
g1:test-volume 77G 3.8G 70G 6% /mnt/gfs
客戶端2掛載:
[root@localhost ~]# mkdir /mnt/gfs
[root@localhost ~]# mount -t glusterfs g2:test-volume /mnt/gfs
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 77G 3.8G 70G 6% /
tmpfs 499M 0 499M 0% /dev/shm
g2:test-volume 77G 3.8G 70G 6% /mnt/gfs
可以看到g1和g2都支持掛載。
gluster支持的參
[root@localhost ~]# gluster help #查看參數(shù)
安裝配置完成。