Ubuntudrbd dual-host mutual backup

Source: Internet
Author: User
Article Title: ubuntudrbd dual-host mutual backup. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

DRBD is composed of kernel modules and related scripts to build highly available clusters. The implementation method is to mirror the entire device through the network. You can think of it as a network RAID.

Drbd receives data, writes the data to a local disk, and sends it to another host. The other host then saves the data to its own disk. Other required components include cluster member services, such as TurboHA or heartbeat connections, and applications that can run on Block devices.

Drbd1: 192.168.6.106
Drbd2: 192.168.6.107

OS: ubuntu server 8.04.1
Software: drbd-8.2.6.tar.gz

Two machines are installed separately, and my machine partition is managed by LVM.
Therefore, I assigned a G to both machines, in/dev/www ~
1. To install drbd, you must install linux-headers because DRBD is compiled in the kernel.
# Uname-r check the kernel version
2.6.24-19-serve my kernel version
# Apt-get install flex linux-headers-2.6.24-19-server
2. Compile and install drbd
# Tar zxvf drbd-8.2.6.tar.gz
# Cd drbd-8.2.6
# Make clean clear previous history
# Make KDIR =/usr/scr/linux-headers-2.6.24-19-server compilation + kernel path
# Make install Installation
# Groupadd haclient create a group or a warning will be prompted
# Chgrp haclient/sbin/drbdsetup
# Chmod o-x/sbin/drbdsetup
# Chmod u + s/sbin/drbdsetup

3. modify the configuration file
# Mv/etc/drbd. conf/etc/drbd. conf. bak back up the original configuration file
# Vim/etc/drbd. conf
Paste
Common {
# Sets the maximum network rate for master-slave node synchronization, in bytes.
Syncer {rate 10 M ;}
}
Resource r0 {
# Use the Protocol C. After receiving the write confirmation from the remote host, the write is considered complete.
Protocol C;
Disk {on-io-error detach ;}
# The description of each host starts with "on", followed by the host name. The host configuration is in.
On drbd1 {
Device/dev/drbd0;
Disk/dev/www; (if it is a new home disk, write/dev/sdb1;/dev/sdc ...)
Address 192.168.6.106: 7788;
Meta-disk internal;
}
On drbd2 {
Device/dev/drbd0;
Disk/dev/www; (if it is a new home disk, write/dev/sdb1;/dev/sdc ...)
Address 192.168.6.107: 7788;
Meta-disk internal;
}
}
I am very simple. For testing, you need to modify it as needed ~
After the configuration file is written on both machines, run the following command on drbd1 and drbd2:
# Drbdadm create-md r0 "r0" is defined in drbd. conf.
Enter the pop-up information and press Enter. If drbd. conf is configured, some information will not pop up.

Now we can start DRBD and execute the following commands on the two hosts:
[Root @ drbd1 local] #/etc/init. d/drbd start
[Root @ drbd2 local] #/etc/init. d/drbd start

[Root @ drbd1 ~] # Cat/proc/drbd
Version: 8.0.11 (api: 86/proto: 86)
SVN Revision: 2713 build
Root @ drbd1
, 2008-06-27 14:07:14 1: cs: Connected st: 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
Resync: used: 0/31 hits: 0 misses: 0 starving: 0 dirty: 0 changed: 0
Act_log: used: 0/257 hits: 0 misses: 0 starving: 0 dirty: 0 changed: 0
"/Proc/drbd" shows the current status of drbd. The st in the first line indicates the status of the two hosts, both of which are "standby.
Ds is in the disk status and is in the "inconsistent" status.
This is because DRBD cannot determine which side is the host and which disk data is used as the standard data. Therefore, we need to initialize

Run the following command on drbd1:
[Root @ drbd1 local] # drbdsetup/dev/drbd0 primary-o

The status of the master and slave machines is "Master/Slave", the status of the host disk is "real-time", and the status of the slave machine is "inconsistent ".

[1] [2] Next page

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.