Prerequisites: 1) This configuration has two Test Nodes: node1.a.org and node2.a.org. The IP addresses are 192.168.0.41 and 192.168.0.42, respectively. 2) each node of node1 and node2 provides a shard of the same size as the drbd device. Here, the Shard is/dev/sda5 on both nodes and the size is 2 GB. 3) the system is rhel5.4, x86 Platform. 1. The names and prerequisites of the two VMS after the preparation partition are as follows:
1) This configuration has two Test Nodes, node1.a.org and node2.a.org, with the IP addresses 192.168.0.41 and 192.168.0.42 respectively;
2) each node of node1 and node2 provides a shard of the same size as the drbd device. Here, the shard size is/dev/sda5 on both nodes, and the size is 2 GB;
3) The system is rhel5.4 and x86;
1. Preparations
Shows the two virtual machines after partitioning:
The host names and corresponding IP Address Resolution services of the two nodes can work normally, and the host names of each node must be consistent with the results of the "uname-n" command. Therefore, make sure that the/etc/hosts file on both nodes is the following content:
192.168.0.41 node1.a.org node1
192.168.0.42 node2.a.org node2
To keep the host name as above after the system is restarted, you must execute the following commands on each node:
Node1:
# Sed-I's @ \ (HOSTNAME = \). * @ \ 1node1.a.org @ G'
# Hostname node1.a.org
Node2:
# Sed-I's @ \ (HOSTNAME = \). * @ \ 1node2.a.org @ G'
# Hostname node2.a.org
2. install the software package
Drbd consists of a kernel module and a user space management tool. The drbd kernel module code has been integrated into Versions later than Linux kernel 2.6.33. Therefore, if your kernel version is later than this version, you only need to install the management tool. Otherwise, you need to install both the kernel module and the management tool, and the version numbers must be consistent.
Currently, the drbd versions are mainly 8.0, 8.2, and 8.3. The rpm packages are named drbd, drbd82, and drbd83, respectively, the corresponding kernel modules are named kmod-drbd, kmod-drbd82 and kmod-drbd83 respectively. The functions and configurations of each version are slightly different. The platform used in our www.linuxidc.com experiment is x86 and the system is rhel5.4. Therefore, we need to install the kernel module and management tool at the same time. Here we use the latest version 8.3 (drbd83-8.3.8-1.el5.CentOS.i386.rpm and kmod-drbd83-8.3.8-1.el5.centos.i686.rpm), for: http://mirrors.sohu.com/centos/5.6/extras/ I #/rpms /.
In actual use, you need to download the required software package version based on your system platform.
After the download is complete, install it directly:
- # Yum-y -- nogpgcheck localinstall drbd83-8.3.8-1.el5.centos.i386.rpm kmod-drbd83-8.3.8-1.el5.centos.i686.rpm
3. Configure drbd
The main configuration file of drbd is/etc/drbd. conf; For ease of management, some configuration files are usually divided into multiple parts and saved to/etc/drbd. in the d directory, the main configuration file only uses the "include" command to integrate these configuration file fragments. Generally, the configuration file in the/etc/drbd. d directory is global_common.conf and all files ending with. res. Global_common.conf mainly defines the global and common segments, and each. res file is used to define a resource.
In the configuration file, the global segment can only appear once. If all the configuration information is saved to the same configuration file and not separated into multiple files, the global segment must be at the beginning of the configuration file. Currently, only the minor-count, dialog-refresh, disable-ip-verification, and usage-count parameters can be defined in the global segment.
The common section is used to define parameters inherited by each resource by default. parameters that can be used in the resource definition can be defined in the common section. In practice, the common section is not required, but we recommend that you define parameters for multiple resource sharing as parameters in the common section to reduce the complexity of the configuration file.
The resource segment is used to define drbd resources. Each resource is usually defined in a separate file ending with. res in the/etc/drbd. d directory. When defining a resource, you must name it. The name can contain non-blank ASCII characters. Each resource segment must contain at least two host sub-segments to define the nodes associated with the resource, other parameters can be inherited from the common section or the default drbd without being defined.
1) copy the sample configuration file as the configuration file to be used:
- # Cp/usr/share/doc/drbd83-8.3.8/drbd. conf/etc
2) configuration/etc/drbd. d/global-common.conf
- Global {
- Usage-count yes;
- # Minor-count dialog-refresh disable-ip-verification
- }
- Common {
- Protocol C;
- }
- Startup {
- Wfc-timeout 120;
- Degr-wfc-timeout 120;
- }
- Disk {
- On-io-error detach;
- Fencing resource-only;
- }
- Net {
- Cram-hmac-alg"Sha1";
- Shared-secret"Mydrbdlab";
- }
- Syncer {
- Rate 100 M;
- }
- }
3. Define a resource/etc/drbd. d/web. res. The content is as follows:
Vim/web. res
- Resource web {
- On node1.a.org {
- Device/dev/drbd0;
- Disk/dev/sda5;
- Address 192.168.0.41: 7789;
- Meta-disk internal;
- }
- On node2.a.org {
- Device/dev/drbd0;
- Disk/dev/sda5;
- Address 192.168.0.42: 7789;
- Meta-disk internal;
- }
- } < span> "Code" Class = "Cpp" > // Copy web. res and global-common.conf to node2.a.org <>
- Scp-r/etc/drbd. conf/etc/drbd. d node2:/etc
4. initialize the defined resources on the two nodes and start the service: 1) initialize the resources and run the following commands on Node1 and node2:
- # Drbdadm create-md web
2) start the service and run the following commands on Node1 and node2:
- /Etc/init. d/drbd start
3) view the startup status:
# Cat/proc/drbd