Configuring keepalived for httpd High availability

Source: Internet
Author: User

First, Environment Description

Installation Environment:

TD width= "valign=" Top "rowspan=" 2 "colspan=" 1 ">192.168.1.3
hostname

host address

Cluster service

virtual address

keepalived-master

192.168.1.1

main node

httpd

Keepalived-backup

192.168.1.2

Backup ( backup node )

HTTPD


Official address:http://www.keepalived.org/

First, Software Deployment

installing keepalived software in keepalived-master and keepalived-backup , respectively

Yum Install Openssl-devel-y

Tar zxvf keepalived-1.2.20.tar.gz

./configure--sysconf=/etc--with-kernel-dir=/usr/src/kernels/2.6.32-431.el6.x86_64

Make && make install

Ln-s/usr/local/sbin/keepalived/sbin/

Chkconfig--add keepalived

Chkconfig--level keepalived on

Second, Creating a configuration file

Keepalived-master configuration file:

Vim/etc/keepalived/keepalived.conf

! Configuration File for Keepalived

Global_defs {

Notification_email {

[Email protected]

[Email protected]

[Email protected]

}

Notification_email_from [email protected]

Smtp_server 192.168.200.1

Smtp_connect_timeout 30

router_id Lvs_devel

}

Vrrp_script CHECK_HTTPD {

Script "killall-0 httpd"

Interval 2

}

Vrrp_instance ha_1 {

State MASTER

Interface eth0

VIRTUAL_ROUTER_ID 80

Priority 100

Advert_int 2

Authentication {

Auth_type PASS

Auth_pass QWEASDZXC

}

Notify_master "/etc/keepalived/master.sh"

Notify_backup "/etc/keepalived/backup.sh"

Notify_fault "/etc/keepalived/fault.sh"

Track_script {

Check_httpd

}

virtual_ipaddress {

192.168.1.3/24 Dev eth0

}

}

Where the contents of the master.sh file are:

#!/bin/bash

Logfile=/var/log/keepalived-mysql-state.log

echo "[Master]" >> $LOGFILE

Date >> $LOGFILE

Where the contents of the backup.sh file are:


#!/bin/bash

Logfile=/var/log/keepalived-mysql-state.log

echo "[Backup]" >> $LOGFILE

Date >> $LOGFILE

Where the contents of the fault.sh file are:

#!/bin/bash

Logfile=/var/log/keepalived-mysql-state.log

echo "[Fault]" >> $LOGFILE

Date >> $LOGFILE

Keepalived-backup configuration file:

The keepalived.conf configuration file on the keepalived-backup node is essentially the same as the Keepalived-master node, There are two places that need to be modified:

Change "stateMASTER" to "StateBACKUP".

Change The priority to a smaller value, which is changed to "priority."

Third, Start the service

Start the keepalived service on keepalived-master and keepalived-backup nodes respectively

Chkconfig--level httpd on

/ETC/INIT.D/HTTPD start

/etc/init.d/keepalived start

Four, log to view boot information

Tail-f/var/log/keepalived-mysql-state.log

Tail-f/var/log/messages

Command view:IP Add

Five, Analog Failover

Stop the HTTPD service on the keepalived-master node and discover the 192.168.1.3 IP correctly transferred to the keepalived-backup node.

Error:

[[email protected] ~]#/etc/init.d/keepalived start

Starting keepalived:/bin/bash:keepalived:command not found

[ failed ]

Solve:

Ln-s/usr/local/sbin/keepalived/usr/sbin/


This article is from the "Gao Chuan" blog, please be sure to keep this source http://luchuangao.blog.51cto.com/11311715/1760477

Configuring keepalived for httpd High availability

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.