Showing posts with label drbd 환경설정. Show all posts
Showing posts with label drbd 환경설정. Show all posts

2016-01-04

Centos7에 DRBDMANAGE 설치




drbd-utils 패키지 안에는 drbdmanage가 포함되어 있지 않아서 git를 통한 개별 소스 빌드가 필요
drbdmanage 빌드에는 일반 업무 서버에는 기본 설치가 아닌 개발 패키지가 몇몇 포함 되어 있어서 사전 설치가 필요
# yum groupinstall "Development Tools"
# git clone --recursive http://git.drbd.org/drbdmanage.git
# make
# make install
※ 주의사항
  • drbdmanage명령은 python2이상이 필요
  • kernel-headers 패키지 및 일부 개발 패키지 필요

2015-10-18

drbd9 설치하기.

drbd9 rpm 패키지를 구하기가 쉽지 않다.
소스를  다운받아 컴파일 해보자.

환경 구성

O/S : CentOS 7 x64
DRBD : 9.0
DRBD Utils : 8.9.3


DRBD 빌드를 위한  개발 개발 라이브러리 설치

# yum install gcc libxslt kernel-headers kernel-devel-`uname -r` make wget rpm-build flex


DRBD 9 와 DRBD Utils 소스 다운로드

# cd /[소스 다운로드 디렉토리]
------ 소스 파일 압축 풀기 ---------
# tar xvfz drbd-utils-8.9.3.tar.gz
# tar xvfz drbd-9.0.0.tar.gz


DRBD-Utils 컴파일 및 설치

# cd /drbd9/drbd-utils-8.9.3
# ./configure --prefix=/usr --localstatedir=/var --with-initdir=/etc/init.d/ --sbindir=/usr/sbin/ --sysconfdir=/etc
# make
# make install


DRBD 9 컴파일 및 설치

# cd /drbd9/drbd-9.0.0
# make
# make install


DRBD9 서비스 시작

# service drbd start


2015-08-05

DRBD stacked resource 구성

DRBD stacked resource 구성
ver: DRBD 8.3.13




리눅스에서 drbd 설치 바로가기

구성도

총3개의 호스트를 기반으로 stacked 복제 리소스를 구성한 그림이다.
DRBD8 버전은 3노드와 4노드의 복제 방식을 명확하게 제안 하고 있다.
밑의 구성도는 그중에 3노드 구성에 대한 그림이다.


추가:
drbd9 버전 부터는 4노드 이상의 복수 노드에 대해서 stacked 리소스의 구성 없이 N:N 구성으로 복제 리소스를 구성 할 수 있다.






환경 설정

기본 환경 구성 파일이다.
import 방식이 아닌 전체 drbd.conf 파일을 저장한다. 또한, 3노드를 구성하는 모든 호스트에 동일한 설정 파일이 존재해야 한다.


global {
    usage-count no;
    disable-ip-verification;
}
common {
    startup {
            wfc-timeout 1;
    }
}
resource r0 {
    protocol     B;
    on hostA {
                               address 10.10.10.1:7788;         ----------------> 1
            disk /dev/sdb1;
            flexible-meta-disk internal;
            device  /dev/drbd0;
    }
    on hostB{
                               address 10.10.10.2:7788;
            disk /dev/sdb1;
            flexible-meta-disk internal;
            device  /dev/drbd0;
    }
}               
resource r0_1 {
              protocol A;
              meta-disk internal;
              stacked-on-top-of r0 {
                               device /dev/drbd10;           ----------------> 2
                               address 10.10.10.1:7789;
              }
              on hostC {
                               device   /dev/drbd10;
                               disk      /dev/sdb1;
                               address 10.10.10.3:7789;
                               meta-disk internal;        ----------------> 3
                               }
              }
}


  1. 호스트 A와 B 사이의 구성은 일반 복제 리소스 구성과 완전히 동일하다.
    하지만 제 3 노드인 호스트 C 는 호스트 A에서 복제 된다 ( 호스트 A가 primary라고 가정한다). 따라서 stacked 리소스 r0_1은 address가 호스트 A의 주소와 같다.
    별개의 네트워크 라인/포트를 가진다. 즉 완전히 별개의 라인으로 취급된다.


추가:
실제 구성에서는 호스트 B가 primary 가 될경우 10.10.10.1이라는 주소가 없기 때문에 데이터를 보낼 수  없다.
다라서 Stacked된 대상 리소스 ( 여기서는 r0) 의 리소스는 완전히 분리되어야 하며
호스트 A와 호스트 B에서 동시에 사용할수 있는 가상 IP(VIP) 여야 한다.


  1. 위에서 언급 한 것과 같이 호스트 A-B와 호스트 A-C가 완전히 별개의 라인이기 때문에 drbd에서 취급 하는 가상 디바이스 인덱스도 분리되어야 한다.
  2. Stacked구조의 target 리소스는 Internal 메타 데이터를 사용해야만 한다.
    그래야만 하나의 볼륨에 메타 데이터 정보를 포함 시킬수 있다.



생성 명령

호스트 A,B,C에 drbd.conf를 작성 후, service를 재 시작 한다.


  1.  먼저 호스트 A 에서 메타 데이터 생성

    drbdadm create-md r0
  2. 호스트 B에서 메타 데이터 생성

    drbdadm create-md r0
  3. 호스트 A에서 리소스 활성화 및 Stacked 리소스 메타 데이터 생성

    drbdadm up r0
    drbdadm -- --overwrite-data-of-peer primary r0
    >> 이 과정에서 동기화 진행
    drbdadm create-md --stacked r0-U
  4. 호스트 C에서 메타 데이터 생성

    drbdadm create-md r0-U
    service drbd start 혹은 drbdadm adjust r0 혹은 필요 없다.
  5. 호스트 A에서 stacked 리소스 활성화

    drbdadm up --stacked r0-U
    drbdadm primary --stacked r0-U
    drbdadm --stacked -- --overwrite-data-of-peer primary r0-U
    >> 이 과정에서 동기화 진행
    mount /dev/drbd10 /mountpoint


추가:
일반 복제 리소스 r0와 stacked리소스 r0_1 에 대해 두번 풀싱크를 별도로 해줘야 한다.
또한 Stacked 리소스가 primary가 되기 위해서는 r0리소스가 primary여야 한다.


사용


  1. 먼저 일반 리소스 r0를 primary 로 승격 시킨다.

    drbdadm primary r0
  2. stacked 리소스 r0_1을 활성화 한다.

    drbdadm up --stacked r0_1
  3. stacked 리소스 r0_1을 primary 로 승격 시킨다.

    drbdadm primary --stacked r0_1
  4. 볼륨 I/O를 하기 위해서 Stacked r0_1 리소스의 가상 장치를 os에 마운트 한다.

    mount /dev/drbd10 /mnt
    >> 이 과정 전에 primary 상태에서 format이 필요할  수 있다..
         
  5. 사용이 끝나면 반대의 순서로 drbd 리소스를 비 활성화 한다.

리눅스에서 drbd 설치

How to Install DRBD
& default Setting on Linux



Ends.


※ following steps should be performed both node that comprise the cluster.
 
  1. How to add Disk to OS.

I tested it on Virtual machine. if you use the VM, you cat it with VM setting page.
do the following steps..
<fig.1>
<fig.2>
  1. Make partition on new Disk with FDISK.

New Disk is only possiable check with fdisk command.
1. first, check disk list with ‘l’ option.
2. make a new partition on new Disk with ‘n’ option.
3. store Setting infomation to disk with ‘w’ option.
[root@left ~]# fdisk -l
…........................... (middle part Omission) ...............

Disk /dev/sdc: 268 MB, 268435456 bytes
64 heads, 32 sectors/track, 256 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes

  Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1         256      262128   83  Linux
[root@left ~]#
  1. Download DRBD RPMs from mirror site of centOS.

Download DRBD RPMs as follow List.
kmod-drbd83-8.3.13-1.el5.centos.x86_64.rpm
drbd83-8.3.13-2.el5.centos.x86_64.rpm
※ You can download from here.
if you use another Linux Distribution likes UBUNTU and SUSE, Check this page.


kernel-2.6.18-308.el5.x86_64.rpm


  1. Install DRBD package & kmod (kernel module)

simply done , just run rpms.
[root@right Download]# rpm -ivh drbd83-8.3.13-2.el5.centos.x86_64.rpm
warning: drbd83-8.3.13-2.el5.centos.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID e8562897
Preparing...                ########################################### [100%]
  1:drbd83                 ########################################### [100%]
[root@right Download]# rpm -ivh kmod-drbd83-8.3.13-1.el5.centos.x86_64.rpm
warning: kmod-drbd83-8.3.13-1.el5.centos.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID e8562897
Preparing...                ########################################### [100%]
  1:kmod-drbd83        ########################################### [100%]


  1. Make default drbd.conf

Very simple configure. just configure Active-Standby with Protocol C that means full syncronization.
resource r0
{
       protocol C;
       on left
       {
               device    /dev/drbd1;
               disk      /dev/sdc1;
               address   10.10.10.101:7789;
               meta-disk internal;
       }
       on right
       {
               device    /dev/drbd1;
               disk      /dev/sdc1;
               address   10.10.10.102:7789;
               meta-disk internal;
       }
}


  1. Make DRBD meta data

Internal meta-disk means that make mata-data on last part of the device.
howeve in this ‘internal’ case, it can’t create index.
[root@right ~]# drbdadm create-md r0
Writing meta data...
initializing activity log
NOT initialized bitmap
New drbd meta data block successfully created.
               --== Creating metadata ==--
As with nodes, we count the total number of devices mirrored by DRBD at
at http://usage.drbd.org.
The counter works anonymously. It creates a random number to identify
the device and sends that random number, along with
DRBD's version number, to usage.drbd.org.
http://usage.drbd.org/cgi-bin/insert_usage.pl?nu=7994833865736912708&ru=5179791256307207409&rs=268419072
* If you wish to opt out entirely, simply enter 'no'.
* To continue, just press [RETURN]
success


  1. Start drbd service

[root@right ~]# service drbd start
Starting DRBD resources: [ d(r0) s(r0) n(r0) ]..........
***************************************************************
DRBD's startup script waits for the peer node(s) to appear.
- In case this node was already a degraded cluster before the
  reboot the timeout is 120 seconds. [degr-wfc-timeout]
- If the peer was available before the reboot the timeout will
  expire after 0 seconds. [wfc-timeout]
  (These values are for resource 'r0'; 0 sec -> wait forever)
To abort waiting enter 'yes' [  20]:


  1. DO First sync.

do first full syncronization.
[root@left ~]# drbdadm -- --overwrite-data-of-peer primary all


  1. Check Mirror (primary-secondary) state.

[root@left ~]# drbdadm role all
Primary/Secondary
[root@left ~]# service drbd status
drbd driver loaded OK; device status:
version: 8.3.13 (api:88/proto:86-96)
GIT-hash: 83ca112086600faacab2f157bc5a9324f7bd7f77 build by mockbuild@builder10.centos.org, 2012-05-07 11:56:36
^[[A^[[Am:res  cs         ro                 ds                 p  mounted  fstype
1:r0   Connected  Primary/Secondary  UpToDate/UpToDate  C
[root@left ~]# cat /proc/drbd
version: 8.3.13 (api:88/proto:86-96)
GIT-hash: 83ca112086600faacab2f157bc5a9324f7bd7f77 build by mockbuild@builder10.centos.org, 2012-05-07 11:56:36

1: cs:Connected ro:Primary/Secondary ds:UpToDate/UpToDate C r-----
   ns:0 nr:16 dw:16 dr:0 al:0 bm:1 lo:0 pe:0 ua:0 ap:0 ep:1 wo:b oos:0
[root@left ~]#


  1. Ends.

To do failover test.