drbd + heartbead 설치 Linux

~drbd 설치~

[root@active ~]#/etc/init.d/iptables stop
[root@stanby ~]#/etc/init.d/iptables stop

[root@active ~]#rpm -Uvh http://elrepo.org/elrepo-release-5-4.el5.elrepo.noarch.rpm
[root@stanby ~]#rpm -Uvh http://elrepo.org/elrepo-release-5-4.el5.elrepo.noarch.rpm

[root@active ~]#yum --enablerepo=elrepo install -y drbd83-utils kmod-drbd83
[root@stanby ~]#yum --enablerepo=elrepo install -y drbd83-utils kmod-drbd83

[root@active ~]#vi /etc/drbd.conf
[root@stanby ~]#vi /etc/drbd.conf

----------------------------------------------------------------------
# You can find an example in  /usr/share/doc/drbd.../drbd.conf.example

#include "drbd.d/global_common.conf";
#include "drbd.d/*.res";

global { usage-count yes; }
common { syncer { rate 10M; } }

resource "r0" {
                 protocol C;
                 disk { on-io-error detach; }
                 syncer {
                        }

                 on active {
                     device /dev/drbd0;
                     disk /dev/sda2;
                     address 222.239.255.94:7791;
                     meta-disk internal;
                             }

                 on stanby {
                     device /dev/drbd0;
                     disk /dev/sda2;
                     address 222.239.255.95:7791;
                     meta-disk internal;
                                }
}
----------------------------------------------------------------------
[root@active ~]#vi /etc/hosts
[root@stanby ~]#vi /etc/hosts
----------------------------------------------------------------------
222.239.255.94  active
222.239.255.95  stanby
----------------------------------------------------------------------
[root@active ~]#umount /dev/sda2
[root@stanby ~]#umount /dev/sda2

[root@active ~]#dd if=/dev/zero of=/dev/sda2 bs=1M count=128
[root@stanby ~]#dd if=/dev/zero of=/dev/sda2 bs=1M count=128

[root@active ~]#drbdadm create-md all
[root@stanby ~]#drbdadm create-md all

[root@active ~]#/etc/init.d/drbd start
[root@stanby ~]#/etc/init.d/drbd start

[root@active ~]#drbdadm -- --overwrite-data-of-peer primary all
※active 가 primary 가 되도록 설정

[root@active ~]#cat /proc/drbd
---------------------------------------------------------------------------------------------------------------
version: 8.3.15 (api:88/proto:86-97)
GIT-hash: 0ce4d235fc02b5c53c1c52c53433d11a694eab8c build by mockbuild@builder17.centos.org, 2013-03-27 16:04:08
 0: cs:SyncSource ro:Primary/Secondary ds:UpToDate/Inconsistent C r-----
    ns:2290688 nr:0 dw:0 dr:2290688 al:0 bm:139 lo:0 pe:0 ua:0 ap:0 ep:1 wo:b oos:2954332
        [=======>............] sync'ed: 43.8% (2884/5120)M
        finish: 0:05:49 speed: 8,440 (8,208) K/sec
---------------------------------------------------------------------------------------------------------------
[root@stanby ~]#cat /proc/drbd
---------------------------------------------------------------------------------------------------------------
version: 8.3.15 (api:88/proto:86-97)
GIT-hash: 0ce4d235fc02b5c53c1c52c53433d11a694eab8c build by mockbuild@builder17.centos.org, 2013-03-27 16:04:08
 0: cs:SyncTarget ro:Secondary/Primary ds:Inconsistent/UpToDate C r-----
    ns:0 nr:2311168 dw:2311168 dr:0 al:0 bm:141 lo:0 pe:0 ua:0 ap:0 ep:1 wo:b oos:2933852
        [=======>............] sync'ed: 44.2% (2864/5120)M
        finish: 0:04:47 speed: 10,196 (10,224) want: 10,240 K/sec
---------------------------------------------------------------------------------------------------------------
전체 동기화가 다 끝나야한다!!

[root@active ~]#mkfs -t ext3 -j /dev/drbd0

[root@active ~]#mount /dev/drbd0 /home

[root@active ~]#df -h

[root@active ~]#vi /home/test.txt
---------------------------------- 여기까지만 해보고 heartbeat로 넘어가보자!!
[root@active ~]#umount /home

[root@active ~]#drbdadm secondary all

[root@stanby ~]#drbdadm primary all

[root@stanby ~]#mount /dev/drbd0 /home/

[root@stanby ~]#ls -la /home


~heartbeat 설치~

######################################################################################
### rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm #
### yum repolist
### 이거는 잠시보류합니다. 확정적인게 아닙니다. 이거를 제외하세요~
######################################################################################
[active / stanby 모두설치]
--------------------------------
yum install -y heartbeat heartbeat*
--------------------------------

############[active]############
--------------------------------
active ~]#vi /etc/ha.d/ha.cf
--------------------------------
debugfile /var/log/ha-debug.log
logfile /var/log/ha.log
keepalive 2
deadtime 10
initdead 120
#bcast eth0
ucast eth0 222.239.255.95
udpport 694
node active
node stanby
#ping 222.239.255.1
auto_failback off
--------------------------------
active ~]#vi /etc/ha.d/authkeys
--------------------------------
auth 2
2 sha1 test-ha
--------------------------------
chmod 600 /etc/ha.d/authkeys
--------------------------------

active ~]#vi /etc/ha.d/haresources
-------------------------------------------------------------------------------------
active IPaddr::192.168.1.4/32/eth0:0 drbddisk::r0 Filesystem::/dev/drbd0::/home::ext3
-------------------------------------------------------------------------------------

############[stanby]############
--------------------------------
stanby ~]#vi /etc/ha.d/ha.cf
--------------------------------
debugfile /var/log/ha-debug.log
logfile /var/log/ha.log
keepalive 2
deadtime 10
initdead 120
#bcast eth0
ucast eth0 222.239.255.94
udpport 694
node active
node stanby
#ping 222.239.255.1
auto_failback off
--------------------------------
stanby ~]#vi /etc/ha.d/authkeys
--------------------------------
auth 2
2 sha1 test-ha
--------------------------------
stanby ~]#chmod 600 /etc/ha.d/authkeys
--------------------------------
stanby ~]#vi /etc/ha.d/haresources
-------------------------------------------------------------------------------------
stanby IPaddr::192.168.1.5/32/eth0:0 drbddisk::r0 Filesystem::/dev/drbd0::/home::ext3
-------------------------------------------------------------------------------------

## 자 테스트해보시라~ ##
active ~]#/etc/init.d/heartbeat start
stanby ~]#/etc/init.d/heartbeat start
-------------------------------------------------------------------------------------
[root@active ~]# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:0C:29:2C:4A:66 
          inet addr:222.239.255.94  Bcast:222.239.255.127  Mask:255.255.255.128
          inet6 addr: fe80::20c:29ff:fe2c:4a66/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:7468826 errors:0 dropped:0 overruns:0 frame:0
          TX packets:5395335 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:2104443243 (1.9 GiB)  TX bytes:1671243860 (1.5 GiB)
          Interrupt:67 Base address:0x2000

eth0:0    Link encap:Ethernet  HWaddr 00:0C:29:2C:4A:66 
          inet addr:192.168.1.4  Bcast:192.168.1.4  Mask:255.255.255.255
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:67 Base address:0x2000

lo        Link encap:Local Loopback 
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:543 errors:0 dropped:0 overruns:0 frame:0
          TX packets:543 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:76944 (75.1 KiB)  TX bytes:76944 (75.1 KiB)
-------------------------------------------------------------------------------------
[root@active ~]# /etc/init.d/heartbeat stop
Stopping High-Availability services:
                                                           [  OK  ]
-------------------------------------------------------------------------------------
[root@stanby ~]# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:0C:29:D5:32:E8 
          inet addr:222.239.255.95  Bcast:222.239.255.127  Mask:255.255.255.128
          inet6 addr: fe80::20c:29ff:fed5:32e8/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:7600849 errors:0 dropped:0 overruns:0 frame:0
          TX packets:5268659 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:2355053255 (2.1 GiB)  TX bytes:1441726313 (1.3 GiB)
          Interrupt:67 Base address:0x2000

eth0:0    Link encap:Ethernet  HWaddr 00:0C:29:D5:32:E8 
          inet addr:192.168.1.5  Bcast:192.168.1.5  Mask:255.255.255.255
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:67 Base address:0x2000

lo        Link encap:Local Loopback 
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:552 errors:0 dropped:0 overruns:0 frame:0
          TX packets:552 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:75018 (73.2 KiB)  TX bytes:75018 (73.2 KiB)
-------------------------------------------------------------------------------------
[root@stanby ~]# cat /proc/drbd
version: 8.3.15 (api:88/proto:86-97)
GIT-hash: 0ce4d235fc02b5c53c1c52c53433d11a694eab8c build by mockbuild@builder17.centos.org, 2013-03-27 16:04:08
 0: cs:Connected ro:Primary/Secondary ds:UpToDate/UpToDate C r-----
    ns:5245040 nr:215168 dw:215188 dr:5245071 al:1 bm:321 lo:0 pe:0 ua:0 ap:0 ep:1 wo:b oos:0
-------------------------------------------------------------------------------------
[root@stanby ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda5              14G  2.4G   11G  19% /
/dev/sda1              99M   17M   77M  18% /boot
tmpfs                 506M     0  506M   0% /dev/shm
/dev/drbd0            5.0G  139M  4.6G   3% /home

자 stanby 에서도 heartbeat stop 하여 active 로 다시 동기화 되는것을 확인할수 있다!!!!!

Leave Comments