Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Introduction and installation Test of DRBD + heartbeat

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Http://freeloda.blog.51cto.com/2033581/1275384

Upgrade the kernel:

Http://88fly.blog.163.com/blog/static/1226803902013111345347479/

Common mistakes

Http://blog.csdn.net/t1anyuan/article/details/52143789

Heartbeat

Http://www.iyunv.com/thread-39963-1-1.html

Http://czmmiao.iteye.com/blog/1174010

Http://www.linuxidc.com/Linux/2014-04/99503.htm

Http://oldboy.blog.51cto.com/2561410/515345

Http://oldboy.blog.51cto.com/2561410/1240412

Outline

I. Preface

What is DRBD?

III. Main functions of DRBD

Fourth, the working principle of DRBD

5. DRBD and HA clusters

VI. DRBD replication mode

7. DRBD configuration tool

VIII. DRBD configuration file

IX. DRBD resources

10. Underlying devices supported by DRBD

11. DRBD configuration steps

Detailed explanation of installation and configuration of DRBD

XIII. DRBD dual main mode configuration example

I. Preface

In this blog post, we mainly explain DRBD, and say something beside the point here. In fact, the best way to learn any Linux knowledge is to read the official documents, which is the characteristic of Linux and the embodiment of the open source spirit. It not only provides software, but also learning materials. Here, the official document of DRBD, http://www.drbd.org/users-guide/, talks about DRBD in great detail, but it is all in English. It is a bit good to learn Linux. Even if there are many bloggers affected by the spirit of open source, will also do very private things, there are no buddies to translate our documents, this is the translation version for everyone to refer to http://blog.csdn.net/liuyunfengheda/article/details/6460814, I am here to talk about the important knowledge points of DRBD, bloggers who have time can seriously study the official documents.

What is DRBD?

To put it simply, DRBD (Distributed Replicated Block Device) is made up of kernel modules and related scripts to build high-availability clusters. It is realized by mirroring the whole device through the network. You can think of it as a kind of network RAID1.

III. Main functions of DRBD

To briefly talk about the main functions of DRBD, DRBD is responsible for receiving data, writing it to a local disk, and then sending the same data over the network to another host, which then stores the data on its own disk.

Fourth, the working principle of DRBD

Each device (drbd provides more than one device) has a state, which may be a 'master' state or a 'slave' state. On the primary node, the application should be able to run and access the drbd device (/ dev/drbd*). Each write is sent to the local disk device and the slave node device. The slave node can only simply write data to its disk device. Reading data is usually done locally. If the master node fails, the heartbeat (heartbeat or corosync) will transition the slave node to the master state and start the application on it. (if you use it with a non-journaling FS, you need to run fsck.) If the failed node returns to work, it becomes the new slave node and must keep its content synchronized with that of the master node. Of course, these operations will not interfere with the background service.

5. DRBD and HA clusters

Most of the current high availability clusters (such as Hewlett-Packard, IBM, Dell) use shared memory, so the memory is connected to multiple nodes (this can be done with a shared SCSI bus or fibre Channel). DRBD can also be used as a shared device, but it doesn't require any unusual hardware. It runs in the IP network, and the IP network is much more economical than the dedicated storage network in terms of price. Currently, DRBD allows read and write access to only one node at a time, which is sufficient for a typical failover high availability cluster. The current version will support both nodes for read and write access at the same time. This is useful, for example, for GFS. Compatibility DRBD can run on IDE, SCSI partitions, and entire drives, but not on circuit module devices. If you insist on doing so, a deadlock will occur. DRBD also cannot run on loopback network devices. (because it also causes deadlocks: all requests are consumed by the sending device, and the sending process is blocked in sock_sendmsg (). Sometimes, the receiving thread is extracting data blocks from the network and trying to put it in the cache, but the system fetches some data blocks from the cache to disk. This often happens in the context of the receiver because all requests are already occupied by the receiver block.

VI. DRBD replication mode

Protocol A: asynchronous replication protocol. It is returned immediately after the local write is successful, and the data is placed in the sending buffer and may be lost.

Protocol B: memory synchronous (semi-synchronous) replication protocol. The local write is successful and the data is sent to the other party and returned immediately. If both computers lose power, the data may be lost.

Protocol C: synchronous replication protocol. Return after the local and the other party write a successful confirmation. If both computers lose power or the disk is damaged at the same time, data may be lost.

Protocol C is generally used, but the choice of C protocol will affect the traffic, thus affecting the network delay. For the sake of data reliability, we still use C protocol in production environment.

7. DRBD configuration tool

Drbdadm: advanced management tool, manage / etc/drbd.conf, send instructions to drbdsetup and drbdmeta.

Drbdsetup: configure the DRBD module loaded into kernel, which is rarely used directly.

Drbdmeta: manage META data structures, which are rarely used directly at ordinary times.

VIII. DRBD configuration file

The main configuration file of DRBD is / etc/drbd.conf;. For ease of management, these configuration files are usually divided into multiple parts and saved to the / etc/drbd.d directory. Only the "include" directive is used in the main configuration file to integrate these configuration file fragments. Typically, the configuration files in the / etc/drbd.d directory are global_common.conf and all files that end in .res. Global segment and common segment are mainly defined in global_common.conf, and each .res file is used to define a resource.

The global segment can only appear once in the configuration file, and if all configuration information is saved to the same configuration file without being separated into multiple files, the global segment must be at the beginning of the configuration file. Currently, the only parameters that can be defined in the global section are minor-count, dialog-refresh, disable-ip-verification and usage-count.

The common section is used to define the parameters that are inherited by default for each resource, and the parameters that can be used in the resource definition can be defined in the common section. In practical application, the common segment is not necessary, but it is recommended that the parameters shared by multiple resources be defined as the parameters in the common segment to reduce the complexity of the configuration file.

The resource section is used to define drbd resources, each of which is usually defined in a separate file that ends with .res in the / etc/drbd.d directory. Resources must be named when they are defined, and the name can be made up of non-blank ASCII characters. The definition of each resource segment must include at least two host subsegments to define the node to which the resource is associated, and other parameters can be inherited from the default of the common segment or drbd without definition.

IX. DRBD resources

Resource name: can be any ACSII code character except white space characters

DRBD device: the device file of this DRBD device on both nodes; typically / dev/drbdN, with the main device number 147,

Disk configuration: storage devices provided by each node on both nodes

Nerwork configuration: the network attribute used by both parties when synchronizing data

Case study:

1234567891011121314resource web {# Resource name "web" on node1.magedu.com {# setup node cluster1 device / dev/drbd0; # indicates the label name of drbd disk / dev/sda5; # indicates the device address 172.16.100.11 meta-disk internal; 7789 as drbd; # specifies ip and port number meta-disk internal; # network communication attributes, specifies drbd metadata in native} on node2.magedu.com {device / dev/drbd0; disk / dev/sda5 Address 172.16.100.12 address 7789; meta-disk internal;}}

10. Underlying devices supported by DRBD

DRBD needs to be built on top of the underlying device and then build a block device. To the user, an DRBD device, like a physical disk, can create a file system within the business context. The underlying devices supported by DRBD have the following classes:

A disk, or a partition of a disk.

A soft raid device.

A logical volume for LVM.

A volume of EVMS (Enterprise Volume Management System, Enterprise Volume Management system).

Any other block device.

11. DRBD configuration steps

Install drbd

Configuration resource files (define data names, disks, node information, synchronization restrictions, etc.)

Add drbd to the system service chkconfig-add drbd

Initialize resource group drbdadm create-md resource_name

Start the service service drbd start

Set up the primary host and synchronize the data

Partitioning, formatting / dev/drbd*

One node is mounted

View statu

Detailed explanation of installation and configuration of DRBD

1. Experimental topology

two。 Experimental environment

(1)。 Operating system

CentOS 6.4 X86_64

(2)。 Software environment

Kmod-drbd84-8.4.2-1.el6_3.elrepo.x86_64

Drbd84-utils-8.4.2-1.el6.elrepo.x86_64

(3)。 Install the epel source

Node1:

12345678 [root@node1 src] # wget http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm[root@node1 src] # rpm-ivh epel-release-6-8.noarch.rpmwarning: epel-release-6-8.noarch.rpm: Header V3 RSA/SHA256Signature, key ID 0608b895: NOKEYPreparing... # [100%] 1:epel-release # [root@node1 src] # rpm--import / etc/pki/rpm-gpg / RPM-GPG-KEY-EPEL-6 [root@node1 ~] # rpm-ivh http://elrepo.org/elrepo-release-6-5.el6.elrepo.noarch.rpm[root@node1 ~] # yum list

Node2:

12345678 [root@node2 src] # wget http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm[root@node2 src] # rpm-ivh epel-release-6-8.noarch.rpmwarning: epel-release-6-8.noarch.rpm: Header V3 RSA/SHA256Signature, key ID 0608b895: NOKEYPreparing... # [100%] 1:epel-release # [root@node2 src] # rpm--import / etc/pki/rpm-gpg / RPM-GPG-KEY-EPEL-6 [root@node2 ~] # rpm-ivh http://elrepo.org/elrepo-release-6-5.el6.elrepo.noarch.rpm[root@node2 ~] # yum list

3. Install DRBD

Description: drbd consists of two parts: kernel module and user space management tools. Among them, the drbd kernel module code has been integrated into the Linux kernel version after 2.6.33, so if your kernel version is higher than this version, you only need to install management tools; otherwise, you need to install both kernel module and management tools software packages, and the version numbers of both must be kept corresponding. The kernel version of CentOS 6.4 is 2.6.32-358.el6.x86_64, so it is also mentioned to install kernel modules.

Node1:

1 [root@node1 ~] # yum-y install drbd84 kmod-drbd84

Node2:

1 [root@node2 ~] # yum-y install drbd84 kmod-drbd84

4. Configure DRBD

(1)。 Check the configuration file

12345 [root@node1] # ll / etc/drbd.conf/etc/drbd.d/-rw-r--r-- 1 root root 133 September 6 2012 / etc/drbd.conf/etc/drbd.d/: Total consumption 4-rw-r--r-- 1 root root 1650 September 6 2012 global_common.conf

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report