PACEMAKER+COROSYNC+DRBD implementing an automatic failover cluster

Source: Internet
Author: User
Tags echo b sha1

1, two cenots7.0 server, I was built with a KVM virtual machine.

2, parse the hosts file with each other

3, turn off iptables and selinux,ssh open

4, configure Yum source, install PACEMAKER,COROSYNC,DRBD

5, configure DRBD, select Procoto C, copy mode, verify results

6, configuration Corosync, CRM-based management VIP,FSSYSTEM,DRBD block device

7, verify the result, can fail automatic switch.



1,drbdaa eth0 9.111.222.59 eth1 192.168.100.59

DRBDBB eth0 9.111.222.60 eth1 192.168.100.60


2, two node execution

Systemctl Stop Firewalld

Systemctl Disable FIREWALLD


Vim/etc/selinux/config

Change enforing to Disabled

Reboot make it effective


3. Two node execution

Yum Clean All

Yum Makecache

4. Install DRBD

Here is yum install, compile and install easy error, need two nodes to execute

RPM --import https://www. Elrepo. Org/RPM-GPG-KEY-elrepo. Org Install yum source

Yum Install http://www. Elrepo. Org/elrepo-release-7. 0-2. El7. Elrepo. Noarch. Rpm

Yum Install drbd84-utils kmod-drbd84 installation DRBD

5, Mount hard disk, KVM and virtual,vmwarestation virtual machine mount method, like two node partitions, like a drive letter, I'm here for 8G,SDA.

6,fdisk-l to see if the disk device is loaded, partition the disk device

Fdisk/dev/sda

M

P

N

Enter

Enter

W


7,DRBD Port is 7789, the production environment is generally configured iptables rules, the experimental environment is closed iptables can

8,DRBD configuration file is divided into modular, drbd.conf is the main configuration file, the other module configuration file under/etc/drbd.d/

9,[[email protected] ~]# vim/etc/drbd.d/global_common.conf

Global {
Usage-count No;
# Minor-count Dialog-refresh disable-ip-verification
# Cmd-timeout-short 5; Cmd-timeout-medium 121; Cmd-timeout-long 600;
}

Common {
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---c 16k";
#after-resync-target/usr/lib/drbd/unsnapshot-resync-target-lvm.sh;
}

startup {
# wfc-timeout Degr-wfc-timeout outdated-wfc-timeout WAIT-AFTER-SB
#wfc-timeout 30;
#degr-wfc-timeout 30;
}

Options {
# Cpu-mask On-no-data-accessible
}

Disk {
On-io-error detach; Synchronization error is done by separating

Fencing resource-only;
}

NET {
Protocol C; Copy mode
Cram-hmac-alg "SHA1"; Set the encryption algorithm SHA1
Shared-secret "MYDRBD"; Set encryption key
}

Syncer {
Rate 1000M; Transfer rate
}
}

Increase Resources
Vim/etc/drbd.d/r0.res

Resource R0 {
On DRBDAA {
device/dev/drbd0;
DISK/DEV/SDA1;
Address 192.168.100.59:7789;
Meta-disk internal;
}
On DRBDBB {
device/dev/drbd0;
DISK/DEV/SDA1;
Address 192.168.100.60:7789;
Meta-disk internal;
}
}

Synchronizing configuration files to DRBDBB

Scp-r/etc/drbd.d/* [Email protected]:/etc/drbd.d/

Initializing resources

[Email protected] ~]# Drbdadm CREATE-MD r0
Writing Meta Data ...
Initializing activity log
Not initializing bitmap
New DRBD Meta data block successfully created.


[Email protected] ~]# drbdadm CREATE-MD web
Writing Meta Data ...
Initializing activity log
Not initializing bitmap
New DRBD Meta data block successfully created.


Drbdaa and DRBDBB start the DRBD service

Systemctl Start DRBD

Check the startup status
DRBDAA:
[Email protected] ~]# CAT/PROC/DRBD
version:8.4.2 (api:1/proto:86-101)
git-hash:7ad5f850d711223713d6dcadc3dd48860321070c build by [email protected], 2012-09-06 08:16:10
0:cs:connected ro:secondary/secondary ds:inconsistent/inconsistent C r-----
ns:0 nr:0 dw:0 dr:0 al:0 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:20970844

DRBDBB:
[Email protected] ~]# CAT/PROC/DRBD
version:8.4.2 (api:1/proto:86-101)
git-hash:7ad5f850d711223713d6dcadc3dd48860321070c build by [email protected], 2012-09-06 08:16:10
0:cs:connected ro:secondary/secondary ds:inconsistent/inconsistent C r-----
ns:0 nr:0 dw:0 dr:0 al:0 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:20970844

(8). command to see
DRBDAA:
[Email protected] ~]# Drbd-overview
0:web/0 Connected secondary/secondary inconsistent/inconsistent C r-----

DRBDBB:
[Email protected] ~]# Drbd-overview
0:web/0 Connected secondary/secondary inconsistent/inconsistent C r-----

As can be seen from the above information, two nodes are in the secondary state at this time. Then, we need to set one of the nodes to primary. Execute the following command on the node that you want to set as primary: Drbdsetup/dev/drbd0 Primary–o, or you can set the master node on the node that you want to set to primary by using the following command: Drbdadm---- Overwrite-data-of-peer Primary R0

(9). Set Drbdaa as the primary node

[Email protected]~]# drbdadm primary -Force R0

[Email protected] ~]# Drbd-overview #drbdAA为主节点
0:web/0 syncsource primary/secondary uptodate/inconsistent C r---N-
[A]. ..... ......... Sync ' ed:5.1% (19440/20476) M
Note: You can see that you are synchronizing data for a period of time
[Email protected] ~]# Drbd-overview #node2为从节点
0:web/0 synctarget secondary/primary inconsistent/uptodate C r-----
[==>........] Sync ' ed:17.0% (17016/20476) M
After the synchronization is complete, check
[Email protected] ~]# Drbd-overview
0:web/0 Connected primary/secondary uptodate/uptodate C r-----
[Email protected] ~]# Drbd-overview
0:web/0 Connected secondary/primary uptodate/uptodate C r-----

Format and Mount

[Email protected] ~]# mkfs.ext4/dev/drbd0

[[email protected] ~]#Mount /dev/drbd0 /mnt

[Email protected] ~]#Mount| grep /dev/drbd0

Toggle Primary and Secondary nodes
Note: For the DRBD service of the main primary/secondary model, only one node can be primary at a time, therefore, to switch the roles of two nodes, the original primary node can only be set to secondary earlier. Before the original secondary node is set to primary.
DRBDAA:
[Email protected] ~]# umount/mnt/
[Email protected] ~]# Drbdadm secondary r0

View status Drbdaa

[Email protected] ~]# Drbd-overview
0:web/0 Connected secondary/secondary uptodate/uptodate C r-----
Node2:
[Email protected] ~]# Drbdadm Primary web

View status DRBDBB

[Email protected] ~]# Drbd-overview
0:web/0 Connected primary/secondary uptodate/uptodate C r-----
[Email protected] ~]# mount/dev/drbd0/mnt/

Use the following command to see if the file that was previously copied to this device on the primary node exists

[Email protected] ~]# ll/mnt/
Total dosage 20
-rw-r--r--1 root root 884 August 13:50 Inittab
drwx------2 root root 16384 August 13:49 lost+found

13. DRBD Dual Main Mode configuration example
The first time you set a node to become the primary node in DRBD 8.4

[Email protected] ~]# Drbdadm primary--force R0
Example of configuring a resource dual Master model:
Resource R0 {
NET {
Protocol C;
Allow-two-primaries Yes;
}
startup {
Become-primary-on both;
}
Disk {
Fencing Resource-and-stonith;
}
Handlers {
# Make sure the other node is confirmed
# dead after this!
Outdate-peer "/sbin/kill-other-node.sh";
}
On DRBDAA {
device/dev/drbd0;
DISK/DEV/SDA1;
Address 192.168.100.59:7789;
Meta-disk internal;
}
On DRBDBB {
device/dev/drbd0;
DISK/DEV/SDA1;
Address 192.168.100.60:7789;
Meta-disk internal;
}
}

Not to be continued

This article is from "Rain" blog, be sure to keep this source http://gushiren.blog.51cto.com/3392832/1687548

PACEMAKER+COROSYNC+DRBD implementing an automatic failover cluster

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.