본문 바로가기
정보의 바다/정리하자

DRBD를 이용한 MySQL HA Cluster 구축 on CentOS

by Ohdumak 2015. 10. 7.
728x90





DRBD (Distributed Replicated Block Device)


(DRBD overview 출처: http://www.drbd.org)


테스트 환경

CentOS 6.6 (2.6.32-504.el6.x86_64)

hostname

Type 

IP 

DISK

 test1

 Primary

192.168.3.175 

 8G

 test2

 Secondary 

192.168.3.176 

 8G


DRBD 설치

[root@test1 ~]# rpm -Uvh http://www.elrepo.org/elrepo-release-6-6.el6.elrepo.noarch.rpm
[root@test1 ~]# vi /etc/yum.repos.d/elrepo.repo
enabled=0
[root@test1 ~]# yum --enablerepo=elrepo install drbd84-utils kmod-drbd84

drbd83-utils, kmod-drbd83 설치 시 disk 두 개 사용 못함

Hostname 변경

[root@test1 ~]# vi /etc/hosts
192.168.3.175
192.168.3.176

환경 설정

[root@test1 ~]# vi /etc/drbd.d/global_common.conf
# 추가
common {
	startup { wfc-timeout 30; }

	syncer{ rate 50M; }  // 초당 50MB
}

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

	on test1 {
		device /dev/drbd0;
		disk /dev/sdb1;
		address 192.168.3.175:7791;  # 각 노드 IP
		meta-disk internal;
	}

	on test2 {
		device /dev/drbd0;
		disk /dev/sdb1;
		address 192.168.3.176:7791;
		meta-disk internal;
	}
}

MetaData 생성

기존에 MetaData 생성되어 있을 경우 덮어쓰기 메시지

 [root@test1 ~]# drbdadm create-md all
  --==  Thank you for participating in the global usage survey  ==--
The server's response is:

you are the 8787th user to install this version
You want me to create a v08 style flexible-size internal meta data block.
There appears to be a v08 flexible-size internal meta data block
already in place on /dev/sdb1 at byte offset 8587153408

Do you really want to overwrite the existing meta-data?
[need to type 'yes' to confirm] yes

md_offset 8587153408
al_offset 8587120640
bm_offset 8586858496

Found ext3 filesystem
     8385604 kB data area apparently used
     8385604 kB left usable by current configuration

Even though it looks like this would place the new meta data into
unused space, you still need to confirm, as this is only a guess.

Do you want to proceed?
[need to type 'yes' to confirm] yes

MetaData 생성 완료 메시지

initializing activity log
NOT initializing bitmap
Writing meta data...
New drbd meta data block successfully created.
initializing activity log
NOT initializing bitmap
Writing meta data...
New drbd meta data block successfully created.
success

DRBD 데몬 시작

test1 데몬 시작

[root@test1 /]# /etc/init.d/drbd start
Starting DRBD resources: 

  --==  Thank you for participating in the global usage survey  ==--
The server's response is:

you are the 8788th user to install this version
[
     create res: data
   prepare disk: data
    adjust disk: data
     adjust net: data
]
degr-wfc-timeout has to be shorter than wfc-timeout
degr-wfc-timeout implicitly set to wfc-timeout (30s)
outdated-wfc-timeout has to be shorter than degr-wfc-timeout
outdated-wfc-timeout implicitly set to degr-wfc-timeout (30s)
degr-wfc-timeout has to be shorter than wfc-timeout
degr-wfc-timeout implicitly set to wfc-timeout (30s)
outdated-wfc-timeout has to be shorter than degr-wfc-timeout
outdated-wfc-timeout implicitly set to degr-wfc-timeout (30s)
..........
***************************************************************
 DRBD's startup script waits for the peer node(s) to appear.
 - If this node was already a degraded cluster before the
   reboot, the timeout is 0 seconds. [degr-wfc-timeout]
 - If the peer was available before the reboot, the timeout
   is 30 seconds. [wfc-timeout]
   (These values are for resource 'data'; 0 sec -> wait forever)
 To abort waiting enter 'yes' [  15]: 
.
WARN: nothing stacked for this host (test1), nothing to do in stacked mode!
[root@test1 /]#

test2 데몬 시작

[root@test2 ~]# service drbd start
Starting DRBD resources: [
     create res: data
   prepare disk: data
    adjust disk: data
     adjust net: data
]
degr-wfc-timeout has to be shorter than wfc-timeout
degr-wfc-timeout implicitly set to wfc-timeout (30s)
outdated-wfc-timeout has to be shorter than degr-wfc-timeout
outdated-wfc-timeout implicitly set to degr-wfc-timeout (30s)
degr-wfc-timeout has to be shorter than wfc-timeout
degr-wfc-timeout implicitly set to wfc-timeout (30s)
outdated-wfc-timeout has to be shorter than degr-wfc-timeout
outdated-wfc-timeout implicitly set to degr-wfc-timeout (30s)
.
WARN: nothing stacked for this host (test2), nothing to do in stacked mode!
[root@test2 ~]# 

DISK sync 작업

*slave 서버에서의 별도의sync 작업은 필요 없다.

[root@test1 /]# drbdadm -- --overwrite-data-of-peer primary all

test1 DRBD 상태 확인

[root@test1 /]# cat /proc/drbd 
version: 8.4.6 (api:1/proto:86-101)
GIT-hash: 833d830e0152d1e457fa7856e71e11248ccf3f70 build by phil@Build64R6, 2015-04-09 14:35:00
 0: cs:SyncSource ro:Primary/Secondary ds:UpToDate/Inconsistent C r---n-
    ns:305152 nr:0 dw:0 dr:305816 al:0 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:8080452
	[>....................] sync'ed:  3.8% (7888/8188)M
	finish: 0:03:05 speed: 43,592 (43,592) K/sec
 1: cs:SyncSource ro:Primary/Secondary ds:UpToDate/Inconsistent C r---n-
    ns:273868 nr:0 dw:0 dr:275940 al:0 bm:0 lo:0 pe:2 ua:2 ap:0 ep:1 wo:f oos:3920384
	[>...................] sync'ed:  6.6% (3920384/4192768)K
	finish: 0:01:40 speed: 38,912 (38,912) K/sec

test2 DRBD 상태 확인

[root@test2 ~]# cat /proc/drbd 
version: 8.4.6 (api:1/proto:86-101)
GIT-hash: 833d830e0152d1e457fa7856e71e11248ccf3f70 build by phil@Build64R6, 2015-04-09 14:35:00
 0: cs:SyncTarget ro:Secondary/Primary ds:Inconsistent/UpToDate C r-----
    ns:0 nr:3801088 dw:3800064 dr:0 al:0 bm:0 lo:2 pe:3 ua:1 ap:0 ep:1 wo:f oos:4585540
	[========>...........] sync'ed: 45.4% (4476/8188)M
	finish: 0:01:48 speed: 42,212 (40,000) want: 41,000 K/sec
 1: cs:SyncTarget ro:Secondary/Primary ds:Inconsistent/UpToDate C r-----
    ns:0 nr:3716096 dw:3716096 dr:0 al:0 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:476672
	[================>...] sync'ed: 88.7% (476672/4192768)K
	finish: 0:00:11 speed: 42,136 (39,116) want: 41,000 K/sec

test1 데몬 시작 완료

[root@test1 /]# cat /proc/drbd 
version: 8.4.6 (api:1/proto:86-101)
GIT-hash: 833d830e0152d1e457fa7856e71e11248ccf3f70 build by phil@Build64R6, 2015-04-09 14:35:00
 0: cs:Connected ro:Primary/Secondary ds:UpToDate/UpToDate C r-----
    ns:8385604 nr:0 dw:0 dr:8386268 al:0 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:0
 1: cs:Connected ro:Primary/Secondary ds:UpToDate/UpToDate C r-----
    ns:4192768 nr:0 dw:0 dr:4193432 al:0 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:0

test2 서버 데몬 시작 완료

[root@test2 ~]# cat /proc/drbd 
version: 8.4.6 (api:1/proto:86-101)
GIT-hash: 833d830e0152d1e457fa7856e71e11248ccf3f70 build by phil@Build64R6, 2015-04-09 14:35:00
 0: cs:Connected ro:Secondary/Primary ds:UpToDate/UpToDate C r-----
    ns:0 nr:8385604 dw:8385604 dr:0 al:0 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:0
 1: cs:Connected ro:Secondary/Primary ds:UpToDate/UpToDate C r-----
    ns:0 nr:4192768 dw:4192768 dr:0 al:0 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:0

DRBD데몬 시작

DRBD데몬 시작






728x90

댓글