未加星标

Install and configure DRDB for network filesystem replication on Debian 8

字体大小 | |
[系统(linux) 所属分类 系统(linux) | 发布者 店小二04 | 时间 2016 | 作者 红领巾 ] 0人收藏点击收藏

Let's talk about Network Filesystem Replication.

Network filesystem replication is often used today in many scenarios:

Replication of a filesystem for security reasons: if one node fails, the other node isaccessible. To replicate a filesystem to another company headquarter, so each emplyee has accessto his data locally and not through a public network. But if he goes to the other headquarter he has all his data, and again he can access locally.

As you can imagine, this kind of system isoften used to build filesystems for cluster environment.

We have chosen to implement the solution with DRDB. It's main porpouse is (as other systems like this) High Availability and Disaster Recovery for file systems.

We implement the solution with Debian 8, but it should work also on Ubuntu.

Prerequisites

Before we start, here are the prerequisites:

At least 2 Debian servers. Debian is installed as a minimal installation (not necessary at all if you know what are you doing on production systems) recommended guide https://www.howtoforge.com/tutorial/debian-8-jessie-minimal-server/ At least 2 linux disks in each server: /dev/sda for the linux installation, /dev/sdb for the DRDB installation.

ATTENTION!!!: During installation, all data on disk /dev/sdb will be destroyed, so don't work on a disk with data inside.

DRBD Installation

In our example, I will use two nodes, wich are:

192.168.152.100 mysql1.local.vm 192.168.152.110 mysql2.local.vm

On all nodes, modify the file /etc/hosts as follows:

127.0.0.1 localhost

192.168.152.100 mysql1.local.vm mysql1

192.168.152.110 mysql2.local.vm mysql2

# The following lines are desirable for IPv6 capable hosts

::1 localhost ip6-localhost ip6-loopback

ff02::1 ip6-allnodes

ff02::2 ip6-allrouters

Then execute the following commands to install DRDB:

apt-get update

apt-get -y upgrade

apt-get installdrbd-utils

Configuration Primary/Secondary - Disaster Recovery

The main configuration file is /etc/drbd.conf wich looks like the following one:

include "drbd.d/global_common.conf";

include "drbd.d/*.res";

By convention, /etc/drbd.d/global_common.conf contains the global andcommon sections of the DRBD configuration, whereas the .res files contain oneresource in each section.

In our example we do a minimalsetup that replicates the data on the two nodes. O n each node do the following modification:

We'll start editing the file /etc/drbd.d/global_common.conf modify the default line from

global {

usage-count yes ;

# minor-count dialog-refresh disable-ip-verification

}

...

net {

protocol C;

# 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

}

...

Now we'll create the configuration file /etc/drbd.d/r0.resfor our resource. Create the file on all nodes and add this inside:

resource r0 {
on mysql1.local.vm {
device /dev/drbd1;
disk /dev/sdb;
address 192.168.152.100:7789;
meta-disk internal;
}
on mysql2.local.vm {
device /dev/drbd1;
disk /dev/sdb;
address 192.168.152.110:7789;
meta-disk internal;
}
}

What we have done until now is the following:

You "opt in" to be included in DRBD’s usage statisticswithusage-count parameter. Resources are configured to use fully synchronous replication with Protocol Cunless explicitly specified otherwise. Our cluster consists of twonodes:mysql1andmysql2. We have a resource arbitrarily named r0 which uses /dev/sdb as the lower-level device, and is configured with internal meta data. The resource uses TCP port 7789 for its network connections, and binds to the IP addresses 192.168.152.100and 192.168.152.110 respectively.

On all nodes initialize the metadata with the following command:

drbdadm create-md r0

You should see something like this:

--== Thank you for participating in the global usage survey ==--

The server's response is:

you are the 2963th user to install this version

initializing activity log

NOT initializing bitmap

Writing meta data...

New drbd meta data block successfully created.

success

Next, we enable the resource and initialize the first replication run, only on first node, it should start replicating:

drbdadm up r0
drbdadm primary --force r0

To check if all is working well you can check the file /proc/drbd on both nodes and you shold see something like this:

Mysql1 [emailprotected]

:# cat /proc/drbd

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

srcversion: 1A9F77B1CA5FF92235C2213

1: cs:SyncSource ro:Primary/Secondary ds:UpToDate/Inconsistent C r-----

ns:54624 nr:0 dw:0 dr:55536 al:0 bm:3 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:5188060

[>....................] sync'ed: 1.1% (5064/5116)Mfinish: 0:17:21 speed: 4,964 (4,964) K/sec Mysql2 [emailprotected]

:# cat /proc/drbd

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

srcversion: 1A9F77B1CA5FF92235C2213

1: cs:SyncTarget ro:Secondary/Primary ds:Inconsistent/UpToDate C r-----

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

[>....................] sync'ed: 0.4% (5100/5116)Mfinish: 0:29:41 speed: 2,916 (2,916) want: 5,160 K/sec

During the build phase you can notice the UpToDate/Inconsistent , it's correct because this is the first sync of data.

After the filsystem is synced this shloud change to UpToDate/UpToDate like in the following log:

[emailprotected]

:/home/sysop# cat /proc/drbd

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

srcversion: 1A9F77B1CA5FF92235C2213

1: cs:Connected ro:Primary/Secondary ds:UpToDate/UpToDate C r-----

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

Now we have a new block device, called/dev/drbd1 that we can format with our preferred filesystem type. For example, if we want to format it in ext4 and mount it on /var/www we can simply do:

[emailprotected]

:/home/sysop# mkfs.ext4 /dev/drbd1

mke2fs 1.42.12 (29-Aug-2014)

Creazione del fil

本文系统(linux)相关术语:linux系统 鸟哥的linux私房菜 linux命令大全 linux操作系统

主题: DebianLinuxUbuntuTIIPv6
分页:12
转载请注明
本文标题:Install and configure DRDB for network filesystem replication on Debian 8
本站链接:http://www.codesec.net/view/481435.html
分享请点击:


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 系统(linux) | 评论(0) | 阅读(36)