Configure a high-availability cluster in centos

Source: Internet
Author: User



I. Overview:


System: centos5.0



Cluster software: heartbeat



Node 1ip (
Master
): 192.168.1.105



Node 2ip (
Slave
): 192.168.1.106



Virtual IP: 192.168.1.102


In Node 1
Use on
Uname-n
The result must be
Node01
, In the node
2
Use the same
Uname-n
The result must also be
Node02
.
IP 192.168.1.102
Is a virtual
IP
For
Webserver
.



Ii. download and install the software package and Configuration:


1. The following software packages are required:



Heartbeat-1, 2.1.2


Heartbeat-1, 2.1.2


Heartbeat-stonith-2.1.2


You can also use Yum-y install heartbeat
The attachment is the required software package:



File:



Heartbeat.rar size
: 2627kb
Download
:
Download



2. Configure on each node
Heartbeat
, You must have the following three files:
:



Authkeys,
Ha. cf
,
Haresources
, They exist in
/Etc/ha. d/
Directory.



3. Create the three files mentioned above:



CP/usr/share/doc/heartbeat-2.1.2/authkeys/etc/ha. d/


CP/usr/share/doc/heartbeat-2.1.2/ha. Cf/etc/ha. d/


CP/usr/share/doc/heartbeat-2.1.2/haresources/etc/ha. d/


4. Configuration:



4.1 Edit
Authkeys
File
:



VI/etc/ha. d/authkeys


Add the following line: here we use the second authentication method (shal)



Auth 2


2 sha1 test-ha


Then, change the File Permission to 600.
:



Chmod 600/etc/ha. d/authkeys


4.2 Edit
/Etc/ha. d/ha. cf
File
:



Add the following lines to VI/etc/ha. d/ha. Cf:



Logfile/var/log/ha-Log


Logfacility local0


Keepalive 2


Deadtime 30


Initdead 120


Bcast eth0


Udpport 694


Auto_failback on


Node node01


Node node02


4.3 Edit
/Etc/ha. d/haresources
File:



This file contains the high availability of the service. Here we use httpd;



VI/etc/ha. d/haresources joins the following link:



Node01 172.16.4.82 httpd


4.4.
Node01
On
/Etc/ha. d/
Directory copy to Node
Node02
On
/Etc
Directory.



SCP-r/etc/ha. d/192.168.102.x :/


4.5.
Httpd. conf
Add the following lines to the file:



VI/etc/httpd/CONF/httpd. conf


Listen 192.168.1.102: 80


4.6 set nodes
Node01
On
/Etc/httpd/CONF/httpd. conf
Copy files to nodes
Node02
In the corresponding directory:



SCP/etc/httpd/CONF/httpd. conf 192.168.102.x :/


4.7 create one on the two nodes
Index
File to test:



In node01
On:



Echo "node01 Apache test server">/var/www/html/index.html


In node02
On:



Echo "node02 Apache test server">/var/www/html/index.html


4.8 start on both nodes
Heartbeat:



/Etc/init. d/heartbeat start


4.9.
Node01
Open a browser: Enter

Http: // 192.168.1.102


Press enter and you will see


Node01 Apache test Server


4.10 stop
Node01
On
Heartbeat
Process, and then

In
Enter http: // 192.168.1.102 in the browser
Press enter and you will see
Node02 Apache test server.



Iii. Supplement:


You do not need to create a virtual network interface or configure an IP address.
(
192.168.1.102
) To it, because
Heartbeat
Will help us to complete and start
Httpd server
.

Related Article

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.