RHCS之用css_tool命令建立HA叢集及建立gfs2叢集檔案系統

來源:互聯網
上載者:User

標籤:rhcs之用css_tool命令建立ha叢集及建立gfs2叢集檔案系統

準備環境

node1:192.168.139.2

node2:192.168.139.4

node4:192.168.139.8

node5:192.168.139.9


node1 作為target端

node2 node4 node5 作為initiator端


並且將node2 node4 node5安裝cman+rgmanager後配置成一個三節點的RHCS高可用叢集,因為gfs2為一個叢集檔案系統,必須藉助HA高可用叢集將故障節點Fence掉,及藉助Message Layer進行節點資訊傳遞。

因為要將發現並登入的target做成整合檔案系統,所以必須在node2 node4 node5上安裝gfs2-utils


先將原來用luci/ricci建立的叢集服務stop掉(我以前實驗做的一個叢集服務,與此實驗無關)


[[email protected] mnt]# clusvcadm -d Web_Service

Local machine disabling service:Web_Service...

[[email protected] mnt]# clustat 

Cluster Status for zxl @ Wed Dec 21 17:55:46 2016

Member Status: Quorate


 Member Name                  ID   Status

 ------ ----                  ---- ------

 node2.zxl.com                1 Online, Local, rgmanager

 node4.zxl.com       

                          2 Online, rgmanager


 Service Name        Owner (Last)      State         

 ------- ----        ----- ------      -----         

 service:Web_Service   (node2.zxl.com)    disabled 

[[email protected] mnt]#  service rgmanager stop

[[email protected] mnt]#  service cman stop

[[email protected] mnt]#  service rgmanager stop

[[email protected] mnt]#  service cman stop

[[email protected] mnt]# rm -rf /etc/cluster/cluster.conf

[[email protected] mnt]# rm -rf /etc/cluster/cluster.conf

每次設定檔改變都會有備份也刪掉

[[email protected] mnt]# ls /etc/cluster/

cluster.conf.bak  cman-notify.d

[[email protected] mnt]# rm -f /etc/cluster/*



如果沒有裝cman,rgmanager,執行如下命令

[[email protected] mnt]#yum  -y install cman rgmanager


  用css_tool命令建立一個叢集,叢集名稱mycluster

[[email protected] mnt]# ccs_tool create mycluster

[[email protected] mnt]# cat /etc/cluster/cluster.conf 

<?xml version="1.0"?>

<cluster name="mycluster" config_version="1">


  <clusternodes>

  </clusternodes>


  <fencedevices>

  </fencedevices>


  <rm>

    <failoverdomains/>

    <resources/>

  </rm>

</cluster>


添加Fence裝置(RHCS叢集必須有)

[[email protected] mnt]# ccs_tool addfence meatware fence_manual

[[email protected] mnt]# ccs_tool lsfence

Name             Agent

meatware         fence_manual


-v 指定節點擁有票數

-n 指定節點標識符

-f 指定Fence裝置名稱


添加三個節點,RHCS叢集至少要有三個節點

[[email protected] mnt]# ccs_tool addnode -v 1 -n 1 -f meatware node2.zxl.com

[[email protected] mnt]# ccs_tool addnode -v 1 -n 2 -f meatware node4.zxl.com

[[email protected] mnt]# ccs_tool addnode -v 1 -n 3 -f meatware node5.zxl.com

查看叢集節點

[[email protected] mnt]# ccs_tool lsnode


Cluster name: mycluster, config_version: 5


Nodename                        Votes Nodeid Fencetype

node2.zxl.com                      1    1    meatware

node4.zxl.com                      1    2    meatware

node5.zxl.com                      1    3    meatware

複製設定檔,RHCS叢集會藉助cssd進程自動同步

[[email protected] mnt]# scp /etc/cluster/cluster.conf node4:/etc/cluster/

[[email protected] mnt]# scp /etc/cluster/cluster.conf node5:/etc/cluster/

每個節點啟動cman rgmanager

[[email protected] mnt]# service cman start

[[email protected] mnt]# service rgmanager start

[[email protected] mnt]# service cman start

[[email protected] mnt]# service rgmanager start

[[email protected] mnt]# service cman start

[[email protected] mnt]# service rgmanager start

[[email protected] mnt]# clustat 

Cluster Status for mycluster @ Wed Dec 21 18:40:26 2016

Member Status: Quorate


 Member Name           ID   Status

 ------ ----           ---- ------

 node2.zxl.com         1 Online, Local

 node4.zxl.com         2 Online

 node5.zxl.com         3 Online


[[email protected] mnt]# rpm -ql gfs2-utils

/etc/rc.d/init.d/gfs2 

/sbin/fsck.gfs2

/sbin/mkfs.gfs2 \\格式化建立gfs2檔案系統的

/sbin/mount.gfs2 \\掛載gfs2檔案系統的

/usr/sbin/gfs2_convert


mkfs.gfs2命令的使用

-j 指定日誌地區個數,有幾個就能被幾個節點掛載,因為格式化為叢集檔案系統後,每個節點都要有日誌記錄

-J 指定日誌大小,預設128M

-p {lock_dlm|lock_nolock} 分布式鎖管理|不用鎖

-t <name> 指定鎖表的名稱

註:一個叢集可以有多個檔案系統,如一個叢集中共用了兩個磁碟,兩個磁碟可以是gfs2和ocfs2檔案系統,不同的檔案系統進行加鎖時,要用不同的鎖表進行唯一標示,所以每個鎖都要有鎖名稱

鎖表名稱的格式

cluster_name:鎖表名

如:mycluster:lock_sda

-D 顯示詳細的Debug資訊


登入target,並格式化為gfs2檔案系統

[[email protected] mnt]# iscsiadm -m node -T iqn.2016-12.com.zxl:store1.disk1 -p 192.168.139.2 -l

[[email protected] mnt]# mkfs.gfs2 -j 2 -p lock_dlm -t mycluster:lock_sde1 /dev/sde1

Are you sure you want to proceed? [y/n] y


Device:                 /dev/sde1

Blocksize:               4096

Device Size              3.00 GB (787330 blocks)

Filesystem Size:           3.00 GB (787328 blocks)

Journals:                2

Resource Groups:           13

Locking Protocol:          "lock_dlm"

Lock Table:              "mycluster:lock_sde1"

UUID:                  9ebdc83b-9a61-9a4a-3ba7-9c80e59a0a2d

格式化完成,掛載測試

[[email protected] mnt]# mount -t gfs2 /dev/sde1 /mnt

[[email protected] mnt]# cd /mnt

[[email protected] mnt]# ll

total 0

[[email protected] mnt]# cp /etc/issue ./

[[email protected] mnt]# ll

total 8

-rw-r--r--. 1 root root 47 Dec 21 19:06 issue


ok,換node4

[[email protected] ~]# iscsiadm -m node -T iqn.2016-12.com.zxl:store1.disk1 -p 192.168.139.2 -l

node4不用再次格式化,直接掛載

[[email protected] ~]# mount -t gfs2 /dev/sdc1 /mnt

[[email protected] ~]# cd /mnt

[[email protected] mnt]# ll \\可以看到node1複製的檔案

total 8

-rw-r--r--. 1 root root 47 Dec 21 19:06 issue

node4建立一個檔案a.txt,會立馬通知給其他節點,讓其看到,這就是叢集檔案系統gfs2的好處

[[email protected] mnt]# touch a.txt

[[email protected] mnt]# ll

total 16

-rw-r--r--. 1 root root  0 Dec 21 19:10 a.txt

-rw-r--r--. 1 root root 47 Dec 21 19:06 issue


在加一個節點node5

[[email protected] ~]# iscsiadm -m node -T iqn.2016-12.com.zxl:store1.disk1 -p 192.168.139.2 -l

掛載不上去,因為只建立了兩個叢集記錄檔,有幾個日誌幾個節點就能掛載

[[email protected] ~]# mount -t gfs2 /dev/sdc1 /mnt

Too many nodes mounting filesystem, no free journals

添加日誌

[[email protected] mnt]# gfs2_jadd -j 1 /dev/sde1 \\-j 1 增加一個日誌

Filesystem:            /mnt

Old Journals           2

New Journals           3

[[email protected] mnt]# gfs2_tool journals /dev/sde1 \\此命令可以查看有幾個日誌,每個預設大小128M

journal2 - 128MB

journal1 - 128MB

journal0 - 128MB

3 journal(s) found.

[[email protected] ~]# mount -t gfs2 /dev/sdc1 /mnt \\node5掛載成功

[[email protected] ~]# cd /mnt 

[[email protected] mnt]# touch b.txt

[[email protected] mnt]# ll

total 24

-rw-r--r--. 1 root root  0 Dec 21 19:10 a.txt

-rw-r--r--. 1 root root  0 Dec 21 19:18 b.txt

-rw-r--r--. 1 root root 47 Dec 21 19:06 issue


gfs2叢集檔案系統一般支援的叢集數量不能超過16個,超過後,效能直線下降


本文出自 “11097124” 部落格,請務必保留此出處http://11107124.blog.51cto.com/11097124/1884864

RHCS之用css_tool命令建立HA叢集及建立gfs2叢集檔案系統

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.