glusterfs讀書(shū)筆記
前言

本文參考了,如下文章,根據(jù)自己需要完善了一些細(xì)節(jié)步驟,實(shí)為一篇讀書(shū)筆記:
https://www.cnblogs.com/jicki/p/5801712.html
https://jingyan.baidu.com/article/cbcede077f90bf02f40b4d94.html
規(guī)劃集群
后續(xù)用集群節(jié)點(diǎn),代表前三個(gè)節(jié)點(diǎn)
安裝前在所有節(jié)點(diǎn)上修改HOSTS文件,添加如下幾行
192.168.5.138?swarm-manager192.168.5.140?swarm-node-1192.168.5.141?swarm-node-2
安裝集群
集群節(jié)點(diǎn)上安裝glusterfs,設(shè)置開(kāi)機(jī)啟動(dòng),并關(guān)閉防火墻
#?安裝軟件yum?install?-y?centos-release-gluster yum?install?-y?glusterfs?glusterfs-server?glusterfs-fuse?glusterfs-rdma#?設(shè)置開(kāi)機(jī)啟動(dòng)systemctl?start?glusterd.service systemctl?enable?glusterd.service#?關(guān)閉防火墻systemctl?stop?firewalld.service? systemctl?disable?firewalld.service
在 swarm-manager 節(jié)點(diǎn)上配置,將 節(jié)點(diǎn) 加入到 集群中。
[root@swarm-manager?~]#?gluster?peer?probe?swarm-managerpeer?probe:?success.?Probe?on?localhost?not?needed [root@swarm-manager?~]#?gluster?peer?probe?swarm-node-1peer?probe:?success. [root@swarm-manager?~]#?gluster?peer?probe?swarm-node-2peer?probe:?success.
查看集群狀態(tài)
[root@swarm-manager?data]#?gluster?peer?statusNumber?of?Peers:?2Hostname:?swarm-node-1Uuid:?489859c1-60a7-4f9f-b950-f7d1be76b71eState:?Peer?in?Cluster?(Connected)Hostname:?swarm-node-2Uuid:?9f203314-16ec-4b0e-919a-daf341df8458State:?Peer?in?Cluster?(Connected) [root@swarm-manager?data]#
集群的三個(gè)節(jié)點(diǎn),分別創(chuàng)建目錄
[root@swarm-manager?~]#?mkdir?-p?/opt/gluster/data[root@swarm-node-1?~]#?mkdir?-p?/opt/gluster/data[root@swarm-node-2?~]#?mkdir?-p?/opt/gluster/data
查看volume 狀態(tài):
[root@swarm-manager?~]#gluster?volume?infoNo?volumes?present
創(chuàng)建一個(gè)名為models 的GlusterFS磁盤(pán):
[root@swarm-manager?~]#?gluster?volume?create?models?replica?3?swarm-manager:/opt/gluster/data?swarm-node-1:/opt/gluster/data?swarm-node-2:/opt/gluster/data?force volume?create:?models:?success:?please?start?the?volume?to?access?data
再查看 volume 狀態(tài):
[root@swarm-manager?~]#?gluster?volume?infoVolume?Name:?modelsType:?Replicate Volume?ID:?e539ff3b-2278-4f3f-a594-1f101eabbf1eStatus:?Created Number?of?Bricks:?1?x?3?=?3Transport-type:?tcpBricks:Brick1:?swarm-manager:/opt/gluster/dataBrick2:?swarm-node-1:/opt/gluster/dataBrick3:?swarm-node-2:/opt/gluster/dataOptions?Reconfigured:performance.readdir-ahead:?on
啟動(dòng) models
[root@swarm-manager?~]#?gluster?volume?start?modelsvolume?start:?models:?success
gluster 性能調(diào)優(yōu):
#?開(kāi)啟?指定?volume?的配額:?(models?為?volume?名稱)gluster?volume?quota?models?enable#?限制?models?中?/?(既總目錄)?最大使用?80GB?空間gluster?volume?quota?models?limit-usage?/?80GB#設(shè)置?cache?4GBgluster?volume?set?models?performance.cache-size?4GB#開(kāi)啟?異步?,?后臺(tái)操作gluster?volume?set?models?performance.flush-behind?on#設(shè)置?io?線程?32gluster?volume?set?models?performance.io-thread-count?32#設(shè)置?回寫(xiě)?(寫(xiě)數(shù)據(jù)時(shí)間,先寫(xiě)入緩存內(nèi),再寫(xiě)入硬盤(pán))gluster?volume?set?models?performance.write-behind?on
安裝客戶端
部署GlusterFS客戶端并mount GlusterFS文件系統(tǒng)
[root@client?~]#?yum?install?-y?glusterfs?glusterfs-fuse[root@client??~]#?mkdir?-p?/opt/gfsmnt[root@client?~]#?mount?-t?glusterfs?swarm-manager:models?/opt/gfsmnt/[root@client?~]#?df?-h文件系統(tǒng)?容量?已用?可用?已用%?掛載點(diǎn) /dev/mapper/vg001-root?98G?1.2G?97G?2%?/ devtmpfs?32G?0?32G?0%?/dev tmpfs?32G?0?32G?0%?/dev/shm tmpfs?32G?130M?32G?1%?/run tmpfs?32G?0?32G?0%?/sys/fs/cgroup /dev/mapper/vg001-opt?441G?71G?370G?17%?/opt /dev/sda2?497M?153M?344M?31%?/boot tmpfs?6.3G?0?6.3G?0%?/run/user/0 swarm-manager:models?441G?18G?424G?4%?/opt/gfsmnt
測(cè)試
可以client 上的/opt/gfsmnt 目錄下,新建、修改、刪除文件,查看集群節(jié)點(diǎn)上是否有對(duì)應(yīng)操作;
常用命令
啟動(dòng)/關(guān)閉/查看glusterd服務(wù)
#?/etc/init.d/glusterd?start#?/etc/init.d/glusterd?stop#?/etc/init.d/glusterd?status
開(kāi)機(jī)自動(dòng)啟動(dòng)glusterd服務(wù)
#?chkconfig?glusterd?on?#?Red?Hat#?update-rc.d?glusterd?defaults?#?Debian#?echo?"glusterd"?>>/etc/rc.local?#?Others
查看配置信息
#?cat?/etc/rc.local
4.為存儲(chǔ)池添加/移除服務(wù)器節(jié)點(diǎn)
在其中一個(gè)節(jié)點(diǎn)上操作即可:
#?gluster?peer?probe#?gluster?peer?detach
注意,移除節(jié)點(diǎn)時(shí),需要提前將該節(jié)點(diǎn)上的Brick移除。
查看所有節(jié)點(diǎn)的基本狀態(tài)(顯示的時(shí)候不包括本節(jié)點(diǎn)):
#?gluster?peer?status
掛載分區(qū)
#?mount?-t?ext4?/dev/sdd1?/mnt/brick1
創(chuàng)建/啟動(dòng)/停止/刪除卷
#?gluster?volume?create?[stripe?|?replica?]?[transport?[tcp?|?rdma?|?tcp,rdma]]?...#?gluster?volume?start#?gluster?volume?stop
gluster volume delete
注意,刪除卷的前提是先停止卷。
客戶端以glusterfs方式掛載
#?mount?-t?glusterfs?:/
對(duì)于OpenStack,計(jì)算和控制節(jié)點(diǎn)都要掛載/var/lib/nova/instances,控制節(jié)點(diǎn)還要掛載/var/lib/glance/images。
查看卷信息
列出集群中的所有卷:
#?gluster?volume?list
查看集群中的卷信息:
#?gluster?volume?info?[all]
查看集群中的卷狀態(tài):
#?gluster?volume?status?[all]#?gluster?volume?status?[detail|?clients?|?mem?|?inode?|?fd]
查看本節(jié)點(diǎn)的文件系統(tǒng)信息:
#?df?-h?[]
查看本節(jié)點(diǎn)的磁盤(pán)信息:
#?fdisk?-l
配置卷
#?gluster?volume?set
擴(kuò)展卷
#?gluster?volume?add-brick
注意,如果是復(fù)制卷或者條帶卷,則每次添加的Brick數(shù)必須是replica或者stripe的整數(shù)倍。
收縮卷
先將數(shù)據(jù)遷移到其它可用的Brick,遷移結(jié)束后才將該Brick移除:
#?gluster?volume?remove-brick?start
在執(zhí)行了start之后,可以使用status命令查看移除進(jìn)度:
#?gluster?volume?remove-brick?status
不進(jìn)行數(shù)據(jù)遷移,直接刪除該Brick:
#?gluster?volume?remove-brick?commit
注意,如果是復(fù)制卷或者條帶卷,則每次移除的Brick數(shù)必須是replica或者stripe的整數(shù)倍。
/var/lib/glusterd/peers/ 下文件決定了host name
數(shù)據(jù)遷移
版權(quán)聲明:本文內(nèi)容由網(wǎng)絡(luò)用戶投稿,版權(quán)歸原作者所有,本站不擁有其著作權(quán),亦不承擔(dān)相應(yīng)法律責(zé)任。如果您發(fā)現(xiàn)本站中有涉嫌抄襲或描述失實(shí)的內(nèi)容,請(qǐng)聯(lián)系我們jiasou666@gmail.com 處理,核實(shí)后本網(wǎng)站將在24小時(shí)內(nèi)刪除侵權(quán)內(nèi)容。
版權(quán)聲明:本文內(nèi)容由網(wǎng)絡(luò)用戶投稿,版權(quán)歸原作者所有,本站不擁有其著作權(quán),亦不承擔(dān)相應(yīng)法律責(zé)任。如果您發(fā)現(xiàn)本站中有涉嫌抄襲或描述失實(shí)的內(nèi)容,請(qǐng)聯(lián)系我們jiasou666@gmail.com 處理,核實(shí)后本網(wǎng)站將在24小時(shí)內(nèi)刪除侵權(quán)內(nèi)容。