您好,登錄后才能下訂單哦!
本篇內(nèi)容介紹了“怎么使用Glusterfs的peer/volume/brick”的有關(guān)知識(shí),在實(shí)際案例的操作過(guò)程中,不少人都會(huì)遇到這樣的困境,接下來(lái)就讓小編帶領(lǐng)大家學(xué)習(xí)一下如何處理這些情況吧!希望大家仔細(xì)閱讀,能夠?qū)W有所成!
查看peer的情況,當(dāng)前的glusterfs集群中,有當(dāng)前節(jié)點(diǎn)和11、12三個(gè)節(jié)點(diǎn)組成。
List-1
[root@master1 /]# gluster peer status Number of Peers: 2 Hostname: 192.168.33.11 Uuid: 8c22b08f-7232-4ac9-b5d8-8262db2d4ee7 State: Peer in Cluster (Connected) Hostname: 192.168.33.12 Uuid: 7906f9a9-c58b-4c6e-93af-f4d9960b6220 State: Peer in Cluster (Connected)
也可以用peer list來(lái)查看,如下List-2
List-2
[root@master1 /]# gluster pool list UUID Hostname State 8c22b08f-7232-4ac9-b5d8-8262db2d4ee7 192.168.33.11 Connected 7906f9a9-c58b-4c6e-93af-f4d9960b6220 192.168.33.12 Connected a2d23b65-381e-45ea-a488-e9fee45e5928 localhost Connected
加入工作節(jié)點(diǎn),如下List-3,將13這個(gè)工作節(jié)點(diǎn)加入進(jìn)來(lái),可以使用hostname,也可以使用IP地址。
List-3
[root@master1 /]# gluster peer probe -h -h is an invalid address Usage: peer probe { <HOSTNAME> | <IP-address> } [root@master1 /]# gluster peer probe 192.168.33.13
取消工作節(jié)點(diǎn),如下List-4所示,使用detach命令來(lái)取消,執(zhí)行之后,再使用peer status來(lái)查看,就會(huì)看到效果了。
List-4
gluster peer detach HOSTNAME gluster peer detach 192.168.33.13
創(chuàng)建卷,如下List-5所示,10/11/12上的/data_gluster目錄必須存在,不然會(huì)報(bào)錯(cuò)目錄不存在,如果有警告之類的信息,可以加上force。要注意的是不加replica則,集群中只會(huì)保留一份,不會(huì)復(fù)制到其它節(jié)點(diǎn)上。
List-5
gluster volume create hive_db_volume replica 3 192.168.33.10:/data_gluster/hive_db_volume \ 192.168.33.11:/data_gluster/hive_db_volume 192.168.33.12:/data_gluster/hive_db_volume #加上force gluster volume create hive_db_volume replica 3 192.168.33.10:/data_gluster/hive_db_volume \ 192.168.33.11:/data_gluster/hive_db_volume 192.168.33.12:/data_gluster/hive_db_volume force
啟用數(shù)據(jù)卷,用volume start啟動(dòng)卷,如下List-6,因?yàn)槲乙呀?jīng)啟動(dòng)那個(gè)卷了,所以提示卷已經(jīng)啟動(dòng)。
List-6
[root@master1 /]# gluster volume start hive_db_volume volume start: hive_db_volume: failed: Volume hive_db_volume already started #查看卷的信息 [root@master1 /]# gluster volume info hive_db_volume Volume Name: hive_db_volume Type: Replicate Volume ID: b34d2970-27b9-421a-8680-c242b38946e5 Status: Started Snapshot Count: 0 Number of Bricks: 1 x 3 = 3 Transport-type: tcp Bricks: Brick1: 192.168.33.10:/data_gluster/hive_db_volume Brick2: 192.168.33.11:/data_gluster/hive_db_volume Brick3: 192.168.33.12:/data_gluster/hive_db_volume Options Reconfigured: transport.address-family: inet nfs.disable: on performance.client-io-threads: off
之后要先掛載才能使用,不能直接操作/data_gluster/hive_db_volume,如下List-7,掛載之后,在10這臺(tái)機(jī)器的/mnt/gluster/hive_db下,我們就可以存儲(chǔ)數(shù)據(jù)了,注意是我們手動(dòng)寫數(shù)據(jù)是到/mnt/gluster/hive_db,glusterfs會(huì)自動(dòng)同步到/data_gluster/hive_db_volume下,不能直接操作/data_gluster/hive_db_volume這個(gè)目錄,更不要手動(dòng)刪除/data_gluster/hive_db_volume里面的數(shù)據(jù)。
List-7
#在/mnt下創(chuàng)建目錄用于掛載 mkdir -p /mnt/gluster/hive_db #如下命令進(jìn)行掛載,hive_db_volume是我們之前創(chuàng)建的卷 mount -t glusterfs 192.168.33.10:/hive_db_volume /mnt/gluster/hive_db
在10這臺(tái)機(jī)器的/mnt/gluster/hive_db下操作文件,看其它機(jī)器上的情況,如下List-8,創(chuàng)建文件hello,寫入"hello world",之后進(jìn)入/data_gluster/hive_db_volume——因?yàn)長(zhǎng)ist-5我們指定了路徑是/data_gluster/hive_db_volume,看到的就是我們剛才創(chuàng)建的那個(gè)文件。我們?nèi)タ?1和12上的/data_gluster/hive_db_volume。
我們只能在10這臺(tái)機(jī)器的/mnt/gluster/hive_db下操作才有效,在11/12的這個(gè)目錄下操作,沒有作用,因?yàn)長(zhǎng)ist-7中掛載到10這臺(tái)上了。
List-8
[root@master1 hive_db]# pwd /mnt/gluster/hive_db [root@master1 hive_db]# more hello hello world #之后進(jìn)入/data_gluster/hive_db_volume查看,如下 [root@master1 hive_db_volume]# pwd /data_gluster/hive_db_volume [root@master1 hive_db_volume]# more hello hello world #在11上查看 [root@node1 hive_db_volume]# pwd /data_gluster/hive_db_volume [root@node1 hive_db_volume]# more hello hello world #在12上查看也是一樣的
刪除brick,如下List-9,
使用volume remove-brick 卷名稱
replica 2參數(shù),開始我們創(chuàng)建卷時(shí)復(fù)制數(shù)是3,現(xiàn)在變?yōu)?。
最后的那個(gè)192.168.33.12:/data_gluster/hive_db_volume參數(shù),表示192.168.33.12:/data_gluster/hive_db_volume將不存儲(chǔ)卷hive_db_volume的數(shù)據(jù)
List-9
[root@master1 /]# gluster volume remove-brick hive_db_volume replica 2 192.168.33.12:/data_gluster/hive_db_volume force Remove-brick force will not migrate files from the removed bricks, so they will no longer be available on the volume. Do you want to continue? (y/n) y volume remove-brick commit force: success
List-9的操作之后,再查看該volume的詳情,如下List-10,發(fā)現(xiàn)對(duì)比List-6,少了一個(gè)brick,這樣大致應(yīng)該了解brick是什么了,大體可以理解為卷的數(shù)據(jù)存儲(chǔ)在這三個(gè)brick中,glusterfs自動(dòng)幫我們保持各個(gè)brick的同步,我們也可以刪除brick,這樣存儲(chǔ)數(shù)據(jù)的brick個(gè)數(shù)就減少了。
List-10
[root@master1 hive_db_volume]# gluster volume info hive_db_volume Volume Name: hive_db_volume Type: Replicate Volume ID: b34d2970-27b9-421a-8680-c242b38946e5 Status: Started Snapshot Count: 0 Number of Bricks: 1 x 2 = 2 Transport-type: tcp Bricks: Brick1: 192.168.33.10:/data_gluster/hive_db_volume Brick2: 192.168.33.11:/data_gluster/hive_db_volume Options Reconfigured: transport.address-family: inet nfs.disable: on performance.client-io-threads: off
增加brick,之前刪除brick之后,還可以增加上去,如下List-11所示,使用add-brick增加卷,之后再查看卷信息,發(fā)現(xiàn)對(duì)比List-10,brick多了個(gè),即多了192.168.33.12:/data_gluster/hive_db_volume這個(gè)brick。
注:gluster volume status可以查看所有的卷狀態(tài)信息。
List-11
[root@master1 /]# gluster volume add-brick hive_db_volume replica 3 192.168.33.12:/data_gluster/hive_db_volume force volume add-brick: success [root@master1 /]# gluster volume info hive_db_volume Volume Name: hive_db_volume Type: Replicate Volume ID: b34d2970-27b9-421a-8680-c242b38946e5 Status: Started Snapshot Count: 0 Number of Bricks: 1 x 3 = 3 Transport-type: tcp Bricks: Brick1: 192.168.33.10:/data_gluster/hive_db_volume Brick2: 192.168.33.11:/data_gluster/hive_db_volume Brick3: 192.168.33.12:/data_gluster/hive_db_volume Options Reconfigured: transport.address-family: inet nfs.disable: on performance.client-io-threads: off
還可以替換brick,用replace-brick命令,如下List-12
卷hive_db_volume是已經(jīng)存在的
192.168.33.12:/data_gluster/hive_db_volume這個(gè)brick被替換為192.168.33.12:/data_gluster/hive_db_volume2,這個(gè)例子中是同一臺(tái)機(jī)器上的不同目錄,也可以替換為另一臺(tái)機(jī)器
List-12
gluster volume replace-brick hive_db_volume 192.168.33.12:/data_gluster/hive_db_volume 192.168.33.12:/data_gluster/hive_db_volume2 commit force
卷啟動(dòng)之后才可以使用,我們可以停止卷,使用stop,如下List-13,停止之后不能使用了。
List-13
[root@master1 hive_db_volume]# gluster volume stop hive_b_volume
刪除卷,使用delete命令刪除卷
List-14
[root@master1 hive_db_volume]# gluster volume delete hive_b_volume
“怎么使用Glusterfs的peer/volume/brick”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關(guān)的知識(shí)可以關(guān)注億速云網(wǎng)站,小編將為大家輸出更多高質(zhì)量的實(shí)用文章!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。