Hot Standby Based on HeartBeat in Ubuntu

Source: Internet
Author: User
1. step 1.1 prepare the experiment environment and install two dual Nic hosts with Ubuntu10.10 on VMwareWorkStation. The host hardware configuration is as follows: 1.1 :. 1. When configuring a host, note that NetworkAdapter is in the "Bridged" mode, NetworkAdapter2 is in the Custom mode (Custom), and is connected to VMNET2, 1.2:

1.  Procedure 

1.1Prepare the lab environment

InVMware WorkStationInstall the following two operating systems:Ubuntu 10.10The host hardware configuration is shown in figure1.1:

Figure1.1Host Configuration

Note thatNetwork AdapterFor the "bridge" mode(Bridged),Network Adapter2For custom Mode(Custom), ConnectedVMNET2Upper,1.2:

Figure1.2 Network Adapter2Set

Logical topology:

Ubuntu1

Eth0Corresponding Internet NicIp 192.168.0.128 255.255.255.0 192.168.0.1

Eth1 NicCorresponding intranetIp 192.168.1.2255.255.255.0 192.168.1.1

Ubuntu2

Eth0Corresponding Internet NicIp 192.168.0.130 255.255.255.0 192.168.0.1

Eth1Corresponding intranetIp 192.168.1.3255.255.255.0 192.168.1.1

Cluster

Virtual ClusterIp192.168.0.129

The cluster IP address cannot conflict with the LAN (including the local machine) IP address, and cannot be configured anywhere except the/etc/ha. d/haresources File

 

1.2HeartBeatConfiguration

HeartBeatOfThe installation command is

# Apt-get install heartbeat

After installation/Usr/share/doc/heartbeatDirectoryHa. cf,Haresources,AuthkeysPut the three files/Etc/ha. dDirectory.

We recommend that you installApache2

# Apt-get install apache2

1.2.1AuthkeysFile Configuration

Modify the configuration file as follows:

Auth 3

3 md5 Hello! #WhereHello!As the key

This configuration file is very simple.AuthSelect a value. Each value corresponds to an algorithm.Data Verification between nodes and slave nodes

The permission for this configuration file must be0600.

# Chmod 0600 authkeys

1.2.2Ha. cfFile Configuration

Modify the configuration file as follows:

# Log File Location

Logfile /Var/log/ha-log

#UseEth1OfUdpBroadcast is used to send heartbeat information

Bcast eth1

#After the master node is restarted successfully, wait until the slave NodeDownThen retrieve the resource

Auto_failback off

#How long does it take to determine the node death? The default value is30Seconds

Deadtime 10

#Node name. The order is not important, but the name must be consistentUname-NConsistent

Node ubuntu1

Node ubuntu2

Modify the Host Name/Etc/hostnameFile and restart

1.2.3 haresourcesFile Configuration

This file is used to configureIPAnd use cluster services

#Configuration method 1 (HAWhen the service startsIPAutomatically configured on the master node)

Ubuntu1 192.168.0.129/24/eth0

#Configuration method 2ApacheServices and clustersIpAddress binding)

Ubuntu1 192.168.0.129/24/eth0 apache2

WhereUbuntu1Is the host name, you can useUname-NView;192.168.0.129 indicates the cluster ip address and 24 indicates the mask.

In this tutorial, the configuration method is as follows:Apache2Bind the service to the cluster.

1.2.4Other optional configurations

HeartbeatThere are some other configuration items in the three configuration files,Please refer to the official documentation.

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.