Heartbeat dual-Machine hot backup

Source: Internet
Author: User

Objective: To realize the hot backup of samba, that is, when a machine fails, B machine can be replaced automatically.

Get ready:

A machine (master) ip:192.168.1.67

b Machine (prepared) ip:192.168.1.68

Operation:

A: Modify the/etc/hosts file of machine A and B

Vim/etc/hosts joins 192.168.1.67 Zxw and 192.168.1.68 zxw1

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/59/D0/wKioL1TpkVfxOrq4AAA1KFjGlKs287.jpg "title=" QQ picture 20150222155431.png "alt=" Wkiol1tpkvfxorq4aaa1kfjglks287.jpg "/>


a machine:

II: Installation of Heartbeat and Samba

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/59/D3/wKiom1Tpi0fwFbUoAABItAr2EB0724.jpg "title=" QQ picture 20150222155431.png "alt=" Wkiom1tpi0fwfbuoaabitar2eb0724.jpg "/>

Three: Configure Heartbeat. Copy ha.cf,authkeys,haresources 3 files from the/usr/share/doc/heartbeat-3.0.4/directory to the/etc/ha.d/directory

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/59/D0/wKioL1TpjkXghS2lAAGSh81128k927.jpg "title=" QQ picture 20150222155431.png "alt=" Wkiol1tpjkxghs2laagsh81128k927.jpg "/>

Four: Edit the 3 files just copied under the/etc/ha.d/directory

1:vim Authkeys Remove #auth 3 and #3 MD5 hello! In front of the #. Such as:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/59/D0/wKioL1TpkESANQ6bAABMrkmjIf0781.jpg "title=" QQ picture 20150222155431.png "alt=" Wkiol1tpkesanq6baabmrkmjif0781.jpg "/>

2:vim Haresources joins Zxw 192.168.1.8/24/eth0:0 SMB on the last line

# (ZXW represents the hostname of the Lord, 192.168.1.8 represents a machine with a B-machine communication IP,SMB for the need to do high-availability services)

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/59/D0/wKioL1TplRyjfLbuAABK_BHFFcY453.jpg "title=" QQ picture 20150222162230.png "alt=" Wkiol1tplryjflbuaabk_bhffcy453.jpg "/>

3:vim HA.CF Add the following:

Debugfile/var/log/ha-debug

Logfile/var/log/ha-log

Logfacility local0

KeepAlive 2

Deadtime 30

Warntime 10

Initdead 60

Udpport 694

Ucast eth0 192.168.1.68

Auto_failback on

Node Zxw

Node ZXW1

Ping 192.168.1.1

Respawn Hacluster/usr/lib64/heartbeat/ipfail

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/59/D3/wKiom1TplLGhuAUmAADvgB7mI6E925.jpg "title=" QQ picture 20150222155431.png "alt=" Wkiom1tpllghuaumaadvgb7mi6e925.jpg "/>

V: Open SMB and Heartbeat services

Service SMB Start

Service Heartbeat Start


B machine: Repeat steps two to five.

To prevent the SMBD service on a machine from stopping without automatically switching to B, create a new script on the A to monitor whether SMB is functioning properly.

The 1:vim smb.sh script is as follows:      

#!/bin/bash

#it ' s about to watch SMB ' s status

While:

Do

I= ' PS aux |grep smbd |grep-v "grep smbd" |wc-l '

if [$i = 0];then

Service Heartbeat Stop


Fi

Done

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/59/D0/wKioL1TpmNSTtxkgAAC9PvjncDo845.jpg "title=" QQ picture 20150222155431.png "alt=" Wkiol1tpmnsttxkgaac9pvjncdo845.jpg "/>

2:chmod smb.sh Change permissions for smb.sh

3: Put the smb.sh in the background to run./smb.sh &

4: Put SMB, heartbeat,smb.sh join boot to run, vim/etc/rc.d/rc.local join service heartbeat start, service SMB restart, bash /root/smb.sh &

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/59/D0/wKioL1Tpmenxuo-PAACl5DX7KU4696.jpg "title=" QQ picture 20150222155431.png "alt=" Wkiol1tpmenxuo-paacl5dx7ku4696.jpg "/>


The above can be achieved:

1: When a machine is down, B machine can replace it,

2: When a machine is back to normal, B machine automatically exits as a standby machine.


The build is complete.

This article is from the "night Reading Wit Hope female Ghost" blog, please be sure to keep this source http://more3.blog.51cto.com/9929586/1614977

Heartbeat dual-Machine hot backup

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.