DRBD Simple Installation and configuration

Source: Internet
Author: User
Tags echo b flushes hmac

System version: centos6.4 minimized

node1:192.168.31.111

node2:192.168.31.112

Compilation environment: Yum-y Groupinstall "Development Tools" "Server Platform Development"

DRBD version: Drbd-8.4.7-1.tar.gz, drbd-utils-8.9.5.tar.gz

Prerequisites:

1, node Node1, node2 based on SSH Trust

2. Time synchronization between nodes

3, the node name is consistent with hostname (UNAME-N), do not use DNS resolution

See the operation in detail:

Node1:

Ssh-keygen-t rsa-f ~/.ssh/id_rsa-p "

Ssh-copy-id-i. ssh/id_rsa.pub [Email protected]

Node2:

Ssh-keygen-t rsa-f ~/.ssh/id_rsa-p "

Ssh-copy-id-i. ssh/id_rsa.pub [Email protected]


Yum-y Install Rdate

Rdate- s time-b.nist.gov

Crontab-u ROOT-E

*/2 * * * */usr/bin/rdate- s time-b.nist.gov


Vim/etc/hosts

192.168.31.111 Node1

192.168.31.112 Node2

Hostname Node1

Vim/etc/sysconfig/network

Hostname=node1


Vim/etc/hosts

192.168.31.111 Node1

192.168.31.112 Node2

Hostname Node2

Vim/etc/sysconfig/network

Hostname=node2



Prepare for the operation. Then compile and install DRBD:

To avoid errors encountered by the compilation process, install the dependent packages first

Yum-y Install libxslt docbook-style-xsl

Tar XF drbd-8.4.7-1.tar.gz

CD drbd-8.4.7-1

Make && make install

Cd/root

Tar XF drbd-utils-8.9.5.tar.gz

CD drbd-utils-8.9.5

./configure--PREFIX=/USR/LOCAL/DRBD--sysconfdir=/etc/

Make && make install

Modprobe DRBD

Lsmod |grep DRBD


#########################################################

Add a 5G disk to my system (Node1 and Node2 respectively)

Node1:

Fdisk/dev/sdb

P,n,p,1,+3g,w

Partx/dev/sdb

Node2


To configure the DRBD file:

Three configuration files:

/etc/drbd.conf,/etc/drbd.d/global_common.conf, and then you create the resource profile/etc/drbd.d/web.res


VI global_common.conf

Global {

Usage-count Yes;

# Minor-count Dialog-refresh disable-ip-verification

# Cmd-timeout-short 5; Cmd-timeout-medium 121; Cmd-timeout-long 600;

}


Common {

Handlers {

# These is EXAMPLE handlers only.

# They may has severe implications,

# like hard resetting the node under certain circumstances.

# Be careful when chosing your poison.


Pri-on-incon-degr "/USR/LIB/DRBD/NOTIFY-PRI-ON-INCON-DEGR.SH; /usr/lib/drbd/notify-emergency-reboot.sh; echo B >/proc/sysrq-trigger; Reboot-f ";

PRI-LOST-AFTER-SB "/USR/LIB/DRBD/NOTIFY-PRI-LOST-AFTER-SB.SH; /usr/lib/drbd/notify-emergency-reboot.sh; echo B >/proc/sysrq-trigger; Reboot-f ";

Local-io-error "/USR/LIB/DRBD/NOTIFY-IO-ERROR.SH; /usr/lib/drbd/notify-emergency-shutdown.sh; echo o >/proc/sysrq-trigger; Halt-f ";

# fence-peer "/usr/lib/drbd/crm-fence-peer.sh";

# split-brain "/usr/lib/drbd/notify-split-brain.sh root";

# out-of-sync "/usr/lib/drbd/notify-out-of-sync.sh root";

# before-resync-target "/usr/lib/drbd/snapshot-resync-target-lvm.sh-p---c 16k";

# after-resync-target/usr/lib/drbd/unsnapshot-resync-target-lvm.sh;

}


startup {

# wfc-timeout Degr-wfc-timeout outdated-wfc-timeout WAIT-AFTER-SB

}


Options {

# Cpu-mask On-no-data-accessible

}


Disk {

# size On-io-error Fencing disk-barrier disk-flushes

# disk-drain md-flushes resync-rate resync-after al-extents

# c-plan-ahead C-delay-target c-fill-target c-max-rate

# c-min-rate Disk-timeout

On-io-error detach;

}


NET {

# protocol Timeout max-epoch-size max-buffers Unplug-watermark

# connect-int Ping-int sndbuf-size rcvbuf-size ko-count

# allow-two-primaries Cram-hmac-alg Shared-secret After-sb-0pri

# After-sb-1pri After-sb-2pri ALWAYS-ASBP rr-conflict

# ping-timeout Data-integrity-alg tcp-cork on-congestion

# Congestion-fill Congestion-extents csums-alg verify-alg

# Use-rle

Cram-hmac-alg "SHA1";

Shared-secret "Mydrbdlab";

}

}

Resource configuration file:

VI web.res

Resource Web {

On Node1 {

device/dev/drbd0;

DISK/DEV/SDB1;

Address 192.168.31.111:7789;

Meta-disk internal;

}

On Node2 {

device/dev/drbd0;

DISK/DEV/SDB1;

Address 192.168.31.112:7789;

Meta-disk internal;

}

}

Transfer the configured files on the Node1 to the Node2

Scp/etc/drbd.d/global_common.conf/etc/drbd.d/web.res node2:/etc/drbd.d/


Since two nodes are now beginning to build DRBD then initialize:

performed separately on Node1 and Node2:

Drbdadm CREATE-MD Web (web as resource name)


performed separately on Node1 and Node2:

Start DRBD

Service DRBD Start


To view the DRBD status:

Cat/proc/drbd

[Email protected] drbd.d]#

[Email protected] drbd.d]# CAT/PROC/DRBD

version:8.4.6 (api:1/proto:86-101)

git-hash:833d830e0152d1e457fa7856e71e11248ccf3f70 build by [email protected], 2016-05-13 20:06:11

0:cs:connected ro:secondary/secondary ds:inconsistent/inconsistent C r-----

ns:0 nr:0 dw:0 dr:0 al:0 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:3156604


It can be seen that two nodes are currently secondary, so the node1 is changed to primary, do the following:

Drbdsetup/dev/drbd0 primary-o (This command himself in his own system error) instead, replace this with the following command

DRBDADM----Overwrite-data-of-peer primary web (Web as resource name)

Watch-n 1 ' CAT/PROC/DRBD ': Synchronize the results of a command execution every second

Check CAT/PROC/DRBD again after synchronizing data is complete

[Email protected] drbd.d]# CAT/PROC/DRBD

version:8.4.6 (api:1/proto:86-101)

git-hash:833d830e0152d1e457fa7856e71e11248ccf3f70 build by [email protected], 2016-05-13 20:06:11

0:cs:syncsource ro:primary/secondary ds:uptodate/inconsistent C r-----

ns:1692760 nr:0 dw:0 dr:1693424 al:0 bm:0 lo:0 pe:2 ua:0 ap:0 ep:1 wo:f oos:1464956

[=========>...] Sync ' ed:53.7% (1464956/3156604) K

finish:0:00:56 speed:25,864 (17,804) k/sec


[Email protected] ~]# CAT/PROC/DRBD

version:8.4.6 (api:1/proto:86-101)

git-hash:833d830e0152d1e457fa7856e71e11248ccf3f70 build by [email protected], 2016-05-13 20:06:11

0:cs:connected ro:primary/secondary ds:uptodate/uptodate C r-----

ns:3272832 nr:0 dw:116228 dr:3157977 al:40 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:0

The installation configuration is now complete

Next mount the partition you just

Mkdir/mnt/drbd

Mke2fs-j/dev/drbd0

Mount/dev/drbd0/mnt/drbd

Cd/mnt/drbd

[[email protected] drbd]# ls

Lost+found

Create a file: dd If=/dev/zero of=/mnt/drbd/tmp.txt bs=10k count=20

[[email protected] drbd]# ls

Lost+found Tmp.txt


Note: Only primary nodes can be mounted

So in order to verify that the slave node is synchronized to the data, the master node must be unloaded, and then let the just mount from the node to view


The operation is as follows:

Umount/mnt/drbd

Drbdadm Secondary web

Cat/proc/drbd

[Email protected] ~]# CAT/PROC/DRBD

version:8.4.6 (api:1/proto:86-101)

git-hash:833d830e0152d1e457fa7856e71e11248ccf3f70 build by [email protected], 2016-05-13 20:06:11

0:cs:connected ro:secondary/secondary ds:uptodate/uptodate C r-----

ns:3273108 nr:0 dw:116504 dr:3158338 al:41 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:0


Node2:

DRBDADM Primary Web

[Email protected] mnt]# CAT/PROC/DRBD

version:8.4.6 (api:1/proto:86-101)

git-hash:833d830e0152d1e457fa7856e71e11248ccf3f70 build by [email protected], 2016-05-13 20:12:04

0:cs:connected ro:primary/secondary ds:uptodate/uptodate C r-----

ns:0 nr:3273108 dw:3273108 dr:664 al:0 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:0


Mkdir/mnt/drbd

Mount/dev/drbd0/mnt/drbd

[Email protected] ~]# cd/mnt/drbd/

[[email protected] drbd]# ls

Lost+found Tmp.txt


Can clearly view the Tmp.txt file, so that the synchronization data is complete

DRBD Simple Installation and configuration

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.