In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how to install and configure drbd in CentOS6.5. It is very detailed and has a certain reference value. Friends who are interested must read it!
I. Overview of drbd
Distributed Replicated Block Device (DRBD) is a software-based, shared, replicated storage solution that mirrors block devices (hard disks, partitions, logical volumes, etc.) between servers.
DRBD works in the kernel, similar to a driver module. DRBD works between the buffer cache of the file system and the disk scheduler, sends it to another host through tcp/ip to the other host's tcp/ip and finally sends it to the other party's drbd, and then stores it on the local corresponding disk by the other's drbd, which is similar to a network RAID-1 function.
Using the DRBD function in HA can be used instead of using a shared array. The data of the local (primary node) and the remote host (standby node) can be synchronized when confirmed. When the local system fails, a copy of the same data is retained on the remote host and can continue to be used.
The architecture of DRBD is as follows
Underlying device support
DRBD needs to be built on top of the underlying device and then build a block device. To the user, a DRBD device is like a physical disk on which a file system can be created. The underlying devices supported by DRBD have the following classes:
1. A disk, or a partition of a disk
2. A soft raid device
3. A logical volume of LVM
4. A volume of EVMS (Enterprise Volume Management System, Enterprise Volume Management system)
5. Any other block equipment.
DRBD replication mode
Protocol A:
Asynchronous replication protocol. Once the local disk write has been completed and the packet is in the send queue, the write is considered complete. When a node fails, data loss may occur because the data written to the remote node may still be in the sending queue. Although the data on the failover node is consistent, it is not updated in a timely manner. This is usually used for geographically separate nodes.
Protocol B:
Memory synchronous (semi-synchronous) replication protocol. Once the local disk write has been completed and the replication packet reaches the peer node, the write on the primary node is considered complete. Data loss may occur when both participating nodes fail at the same time, because the data in transit may not be committed to disk.
Protocol C:
Synchronous replication protocol. A write is considered complete only if the disk of the local and remote node has confirmed that the write operation is complete. There is no data loss, so this is a popular mode for a cluster node, but I / O throughput depends on network bandwidth.
Protocol C is generally used, but the choice of C protocol will affect the traffic and thus the network delay. For the sake of data reliability, we should carefully choose which protocol to use in the production environment.
II. Installation of drbd
1. Preparatory work
1) there are two test nodes in this configuration, node1.comratings.com and node2.comratings.com, the IP addresses of which are 10.0.0.16 and 10.0.0.17 respectively, and the parsing is written under the corresponding / etc/hosts.
2) A partition of the same size is provided as a drbd device on both node1 and node2 nodes; here, the partition is / dev/sda5 on both nodes, with a size of 512m
3) the system is the platform of CentOS 6.5 and x8634.
2. Introduction of software package
Drbd consists of two parts: the kernel module and the user space management tool. 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.
At present, there are three main drbd versions of CentOS 5: 8.0,8.2,8.3. The corresponding rpm packages are named drbd, drbd82 and drbd83, and the corresponding kernel modules are named kmod-drbd, kmod-drbd82 and kmod-drbd83 respectively. The version suitable for CentOS 6 is 8.4, and the corresponding rpm packages are drbd and drbd-kmdl, but in practice, two points should be kept in mind: the version of drbd and drbd-kmdl should correspond to the version of drbd-kmdl, and the version of drbd-kmdl should correspond to the content version of the current system. The function and configuration of each version are slightly different; the platform used in our experiment is x86x64 and the system is CentOS 6.4.Therefore, we need to install kernel modules and management tools at the same time. We choose the latest version 8.4 here (drbd-8.4.3-33.el6.x86_64.rpm and drbd-kmdl-2.6.32-431.el6-8.4.3-33.el6.x86_64.rpm). The download address is ftp://rpmfind.net/linux/atrpms/. Please download as needed.
In actual use, you need to download the version of the software package that meets your needs according to your system platform. The download address of each version is not provided here.
3. Software package installation
After the download is completed, you can install it directly:
# rpm-ivh drbd-8.4.3-33.el6.x86_64.rpm drbd-kmdl-2.6.32-431.el6-8.4.3-33.el6.x86_64.rpm
3. Configure drbd
1. Introduction of 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.
Here is an example of my configuration:
# cat / etc/drbd.d/global-common.conf
Global {usage-count no; # minor-count dialog-refresh disable-ip-verification} common {protocol C; handlers {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 15-c 16k"; # after-resync-target / usr/lib/drbd/unsnapshot-resync-target-lvm.sh;} startup {# wfc-timeout 120; # degr-wfc-timeout 120 } disk {on-io-error detach; # fencing resource-only;} net {cram-hmac-alg "sha1"; shared-secret "mydrbd";} syncer {rate 1000M;}}
2. Define a resource / etc/drbd.d/web.res, which is as follows:
Resource web {on node1.comratings.com {device / dev/drbd0; disk / dev/sda5; address 10.0.0.16 dev/sda5; address 7789; meta-disk internal;} on node2.comratings.com {device / dev/drbd0; disk / dev/sda5; address 10.0.0.17 meta-disk internal;}}
Note: the above configuration must be the same on both nodes
IV. Drbd startup and viewing
1. Initialize resources
Execute on Node1 and Node2 respectively:
# drbdadm create-md web
2. Start the service
Execute on Node1 and Node2 respectively:
# service drbd start
3. Check the startup status
# cat / proc/drbdversion: 8.3.8 (api:88/proto:86-94) GIT-hash: d78846e52224fd00562f7c225bcc25b2d422321d build by mockbuild@builder10.centos.org, 2010-06-04 08:04:16 0: cs:Connected ro:Secondary/Secondary ds:Inconsistent/Inconsistent Murray-ns:0 nr:0 dw:0 dr:0 al:0 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:b oos:505964
You can also use the drbd-overview command to see:
# drbd-overview 0:web Connected Secondary/Secondary Inconsistent/Inconsistent CRUMUMI-
You can see from the above information that both nodes are in the Secondary state at this time. So, next we need to set one of the nodes to Primary. Execute the following command on the node that you want to set to Primary:
# drbdadm primary-force resource
Note: you can also set the primary node on the node you want to set to Primary using the following command:
# drbdadm-overwrite-data-of-peer primary web
Then check the status again, and you can see that the data synchronization process has begun:
# drbd-overview 0:web SyncSource Primary/Secondary UpToDate/Inconsistent Murmuri-[= >.] Sync'ed: 66.2% (172140C505964) K delay_probe: 35
Check the status again after the data synchronization is completed, and you can find that the node has a real-time status, and the node has primary and secondary status:
# drbd-overview 0:web Connected Primary/Secondary UpToDate/UpToDate CRUMUMI-
4. Create a file system
The mount of the file system can only be done on the Primary node, so the drbd device can be formatted only after the primary node is set:
# mke2fs-j-L DRBD / dev/drbd0# mkdir / mnt/drbd # mount / dev/drbd0 / mnt/drbd
5. Switch between Primary and Secondary nodes
For the drbd service of the master Primary/Secondary model, only one node can be Primary at some point. Therefore, to switch the roles of the two nodes, the original Primary node can only be set to Primary after the original Secondary node is set to Primary:
Node1:
# cp-r / etc/drbd.* / mnt/drbd# umount / mnt/drbd# drbdadm secondary web
View status:
# drbd-overview 0:web Connected Secondary/Secondary UpToDate/UpToDate CRUMUMI-
Node2:
# drbdadm primary web# drbd-overview 0:web Connected Primary/Secondary UpToDate/UpToDate Murray-# mkdir / mnt/drbd# mount / dev/drbd0 / mnt/drbd
Use the following command to see if the file that was previously copied to this device on the primary node exists:
# ls / mnt/drbd above are all the contents of the article "how to install and configure drbd in CentOS6.5". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.