読者です 読者をやめる 読者になる 読者になる

めもぶろぐ

お勉強したこと、趣味なんかを適当に書いてます。。。

DRBD Corosync PacemakerでHAクラスタ

ただただメモしていきます。

drbdは構成済みを前提とします。

 

chiita01.hatenablog.com

chiita01.hatenablog.com

 

 

 

 

 

  1. [root@ha01 ~]# yum -y install pcs corosync pacemaker
  2. [root@ha01 ~]# service pcsd start; passwd hacluster
  3. [root@ha02 ~]# service pcsd start; passwd hacluster
  4. [root@ha01 ~]# pcs cluster auth ha01 ha02 -u hacluster -p hacluster --force
  5. [root@ha01 ~]# pcs cluster setup --name drbd-cluster ha01 ha02 --force
  6. [root@ha01 ~]# pcs cluster start --all
  7. [root@ha01 ~]# pcs status
  8. [root@ha01 ~]# pcs resource cleanup # UNCLEANステータスになっていたら
  9. [root@ha01 ~]# pcs property set stonith-enabled=false
  10. [root@ha01 ~]# pcs property set default-resource-stickiness=200
  11. [root@ha01 ~]# pcs resource create vip ocf:heartbeat:IPaddr2 params ip="192.168.11.232" cidr_netmask="24" op start interval="0" timeou
    t="20" op stop interval="0" timeout="20" op monitor interval="10" timeout="20"
  12. [root@ha01 ~]# pcs resource create res_drbd ocf:linbit:drbd params drbd_resource="r0" op start interval="0" timeout="240" op stop inte
    rval="0" timeout="120" op monitor interval="20" role="Slave" timeout="20" op monitor interval="10" role="Master" timeout="20"
  13. [root@ha01 ~]# pcs resource master ms_drbd res_drbd master-max=1 master-node-max=1 clone-max=2 clone-node-max=1 notify=true
  14. [root@ha01 ~]# pcs resource create res_FS ocf:heartbeat:Filesystem params device="/dev/drbd0" directory="/cvol" fstype="ext4" op start
     interval="0" timeout="60" op stop interval="0" timeout="60" op monitor interval="20" timeout="40"
  15. [root@ha01 ~]# pcs resource group add drbd-ha vip res_FS
  16. [root@ha01 ~]# pcs constraint colocation add drbd-ha ms_drbd INFINITY with-rsc-role=Master
  17. [root@ha01 ~]# pcs constraint order promote ms_drbd then start drbd-ha
  18. [root@ha01 ~]# pcs resource cleanup
  19. [root@ha01 ~]# pcs status
  20. [root@ha01 ~]# pcs cluster stop --all
  21. [root@ha01 ~]# pcs cluster start --all
  22. [root@ha01 ~]# drbdadm role all
    Primary/Secondary
    [root@ha01 ~]# ll /cvol/
    合計 16
    drwx------  2 root root 16384  2月 25 01:44 2017 lost+found
    -rw-r--r--. 1 root root     0  2月 25 01:47 2017 testfile
    [root@ha01 ~]#
    [root@ha01 ~]#
    [root@ha01 ~]# ip a
    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
        link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
        inet 127.0.0.1/8 scope host lo
        inet6 ::1/128 scope host
           valid_lft forever preferred_lft forever
    2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
        link/ether 00:15:5d:14:0f:36 brd ff:ff:ff:ff:ff:ff
        inet 192.168.11.230/24 brd 192.168.11.255 scope global eth0
        inet 192.168.11.232/24 brd 192.168.11.255 scope global secondary eth0
        inet6 fe80::215:5dff:fe14:f36/64 scope link
           valid_lft forever preferred_lft forever
  23. [root@ha01 ~]# service pacemaker stop; service corosync stop
    Waiting for shutdown of managed resources.                 [  OK  ]
    Signaling Pacemaker Cluster Manager to terminate           [  OK  ]
    Waiting for cluster services to unload.                    [  OK  ]
    Stopping cluster:
       Leaving fence domain...                                 [  OK  ]
       Stopping gfs_controld...                                [  OK  ]
       Stopping dlm_controld...                                [  OK  ]
       Stopping fenced...                                      [  OK  ]
       Stopping cman...                                        [  OK  ]
       Waiting for corosync to shutdown:                       [  OK  ]
       Unloading kernel modules...                             [  OK  ]
       Unmounting configfs...                                  [  OK 
  24. [root@ha02 ~]# ip a
    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
        link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
        inet 127.0.0.1/8 scope host lo
        inet6 ::1/128 scope host
           valid_lft forever preferred_lft forever
    2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
        link/ether 00:15:5d:14:0f:37 brd ff:ff:ff:ff:ff:ff
        inet 192.168.11.231/24 brd 192.168.11.255 scope global eth0
        inet 192.168.11.232/24 brd 192.168.11.255 scope global secondary eth0
        inet6 fe80::215:5dff:fe14:f37/64 scope link
           valid_lft forever preferred_lft forever
    [root@ha02 ~]#
    [root@ha02 ~]#
    [root@ha02 ~]# ll /cvol/
    合計 16
    drwx------  2 root root 16384  2月 25 01:44 2017 lost+found
    -rw-r--r--. 1 root root     0  2月 25 01:47 2017 testfile
    [root@ha02 ~]#
  25. [root@ha01 ~]# service pacemaker start
  26. [root@ha02 ~]# service pacemaker restart
  27. [root@ha01 ~]# ip a; ls /cvol; drbdadm role all

 

夜も遅いので、明日あたり解説してみます。

とりあえず、フェイルオーバじにVIPとdrbdリソースが移動していればよいと思う。

 

マスターしたらものすごく簡単にHAクラスタが構成できる。

 

おわり

広告を非表示にする