In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
DRBD (DistributedReplicatedBlockDevice) is an open source software that synchronizes and mirrors data directly on remote servers based on block devices. Similar to RAID1 data mirroring, it usually cooperates with HA software such as keepalived and heartbeat to achieve high availability.
DRBD is a block device that can be used in high availability (HA). It is similar to a network RAID-1 function, when you write data to the local file system, the data will also be sent to another host in the network. Recorded in a file system in the same form.
Real-time synchronization is guaranteed between the local (master) and the remote host (backup). If the local system fails, the remote host will retain a copy of the same data and can continue to use it. Using the DRBD function in HA can be used instead of using a shared array. Because the data exists on both the local host and the remote host, when switching, the remote host only needs to use the backup data above it.
I. implementation environment
System version: CentOS 6.5
DRBD version: drbd-8.3.15
Keepalived:keepalived-1.1.15
Master:192.168.10.128
Backup:192.168.10.130
II. Initialize configuration
1) add the following configurations to the 128,130 servers / etc/hosts:
192.168.149.128 node1
192.168.149.130 node2
2) optimize the kernel parameters of the system, and configure the sysctl.conf directly as follows:
Net.ipv4.ip_forward = 0net.ipv4.conf.default.rp_filter = 1net.ipv4.conf.default.accept_source_route = 0kernel.sysrq = 0kernel.core_uses_pid = 1net.ipv4.tcp_syncookies = 1kernel.msgmnb = 65536kernel.msgmax = 65536kernel.shmmax = 68719476736kernel.shmall = 4294967296net.ipv4.tcp_max_tw_buckets = 10000net.ipv4.tcp_sack = 1net.ipv4.tcp_window_scaling = 1net.ipv4.tcp_rmem = 4096 87380 4194304net.ipv4.tcp_wmem = 4096 16384 4194304net.core.wmem_default = 8388608net.core.rmem_default = 8388608net.core.rmem_max = 16777216net.core.wmem_max = 16777216net.core.netdev_max_backlog = 262144net.core.somaxconn = 262144net.ipv4.tcp_max_orphans = 3276800net.ipv4.tcp_max_syn_backlog = 262144net.ipv4.tcp_timestamps = 0net.ipv4.tcp_synack_retries = 1net.ipv4.tcp_syn_retries = 1net.ipv4.tcp_tw_recycle = 1net.ipv4.tcp_tw_reuse = 1net. Ipv4.tcp_mem = 94500000 915000000 927000000net.ipv4.tcp_fin_timeout = 1net.ipv4.tcp_keepalive_time = 30net.ipv4.ip_local_port_range = 1024 65530net.ipv4.icmp_echo_ignore_all = 1
3) one device is added to each of the two servers, which is used for DRBD main device storage. I have / dev/sdb 20g hard disk here.
Execute the following command:
Mkfs.ext3 / dev/sdb; dd if=/dev/zero of=/dev/sdb bs=1M count=1;sync
III. DRBD installation and configuration
Yum installation:
Rpm-Uvh http://www.elrepo.org/elrepo-release-6-6.el6.elrepo.noarch.rpm
Yum-y install drbd83* kmod-drbd83; modprobe drbd
Source code installation method:
Http://oss.linbit.com/drbd/8.4/drbd-8.4.4.tar.gz
. / configure-prefix=/usr/local/drbd-with-km
Make KDIR=/usr/src/kernels/2.6.32-504.el6.x86_64/
Make install
Cp drbd/drbd.ko / lib/modules/ `uname-r` / kernel/lib/
Both Yum mode and source mode need to be executed: modprobe drbd loads the DRBD module.
After the installation is complete and the drbd module is loaded, vi modifies the / etc/drbd.conf configuration file as follows:
Global {usage-count yes;} common {syncer {rate 100M;}} resource r0 {protocol Ctens startup {} disk {on-io-error detach;#size 1G;} net {} on node1 {device / dev/drbd0;disk / dev/sdb;address 192.168.10.128Disk internal;} on node2 {device / dev/drbd0;disk / dev/sdb;address 192.168.10.130
After the configuration modification, execute the following command initialization:
Drbdadm create-md R0; / etc/init.d/drbd restart; / etc/init.d/drbd status
As shown below:
The above steps need to be performed on both servers. After both servers are configured, execute the following command on node2: / etc/init.d/drbd status sees the following message, indicating that both servers are slaves. We need to set node1 to master, and the command is as follows:
Drbdadm-overwrite-data-of-peer primary all
Mkfs.ext4 / dev/drbd0
Mkdir / app; mount / dev/drbd0 / app
Since then, when DRBD is configured, we can write anything to the / app directory. When master goes down or other failures occur, we manually switch to backup without any data loss, which is equivalent to two servers doing network RAID1.
IV. Keepalived configuration
Wget http://www.keepalived.org/software/keepalived-1.1.15.tar.gz; tar-xzvf keepalived-1.1.15.tar.gz; cd keepalived-1.1.15;. / configure; make; make install
DIR=/usr/local/; cp $DIR/etc/rc.d/init.d/keepalived / etc/rc.d/init.d/; cp $DIR/etc/sysconfig/keepalived / etc/sysconfig/
Mkdir-p / etc/keepalived; cp $DIR/sbin/keepalived / usr/sbin/
Both servers install keepalived and configure it. First, configure it on node1 (master). The keepalived.conf content is as follows:
! Configuration File for keepalivedglobal_defs {router_id LVS_DEVEL} vrrp_script check_mysql {script "/ data/sh/check_mysql.sh" interval 5} vrrp_instance VI_1 {state MASTERinterface eth0virtual_router_id 52priority 100advert_int 1authentication {auth_type PASSauth_pass 1111} virtual_ipaddress {192.168.10.100} track_script {check_mysql}}
Then create a check_mysql.sh detection script, as follows:
#! / bin/shA= `ps-C mysqld-- no-header | wc-l`if [$A-eq 0]; then/bin/umount / app/drbdadm secondary r0killall keepalivedfi adds the configuration on node2 (backup). The keepalived.conf content is as follows:! Configuration File for keepalivedglobal_defs {router_id LVS_DEVEL} vrrp_sync_group VI {group {VI_1} notify_master / data/sh/master.shnotify_backup / data/sh/backup.sh} vrrp_instance VI_1 {state BACKUPinterface eth0virtual_router_id 52priority 90advert_int 1authentication {auth_type PASSauth_pass 1111} virtual_ipaddress {192.168.10.100}}
Create a master.sh detection script as follows:
#! / bin/bashdrbdadm primary r0/bin/mount / dev/drbd0 / app//etc/init.d/mysqld start
Create a backup.sh detection script as follows:
#! / bin/bash/etc/init.d/mysqld stop/bin/umount / dev/drbd0drbdadm secondary r0
The steps for the recovery of cerebral fissure are as follows:
Master executes the command:
Drbdadm secondary r0
Drbdadm-discard-my-data connect R0
Drbdadm-overwrite-data-of-peer primary all
Execute the command on Backup:
Drbdadm secondary r0
Drbdadm connect r0
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.