Keepalived achieves high Nginx availability

Source: Internet
Author: User
Tags haproxy

Keepalived achieves high Nginx availability

Keepalived achieves high Nginx availability

1. Install keepalived using yum

Yum install keepalived-y

2. modify the configuration file keepalived. conf.

Master server configuration file

Global_defs {
Router_id NodeA
}
Vrrp_script check_run {
Script "/etc/keepalived/check_nginx.sh" # customize the nginx check script
Interval 2
Weight 2
}
Vrrp_instance VI_1 {
State MASTER # set as MASTER server
Interface eth0 # Monitoring Network interface
Virtual_router_id 51 # Master and backup must be the same
Priority 100 # (the master and slave servers have different priorities. The host value is large and the backup server value is small. The larger the value, the higher the priority)
Advert_int 1 # VRRP Multicast broadcast period seconds
Authentication {
Auth_type PASS # VRRP authentication method, Master/backup must be consistent
Auth_pass 1111 # (password)
}
Track_script {
Check_run
}
Virtual_ipaddress {
Virtual IP Address/mask # vrrp ha virtual IP Address
}
}

 

Backup Server Configuration File

 

Global_defs {
Router_id NodeB
}
Vrrp_script check_run {
Script "/etc/keepalived/check_nginx.sh"
Interval 2
Weight 2
}
Vrrp_instance VI_1 {
State BACKUP # set as the master server
Interface eth0 # Monitoring Network interface
Virtual_router_id 51 # Master and backup must be the same
Priority 90 # (the master and slave servers have different priorities. The host value is large and the backup server value is small. The larger the value, the higher the priority)
Advert_int 1 # VRRP Multicast broadcast period seconds
Authentication {
Auth_type PASS # VRRP authentication method, Master/backup must be consistent
Auth_pass 1111 # (password)
}
Track_script {
Check_run
}
Virtual_ipaddress {
Virtual IP Address/mask # vrrp ha virtual IP Address
}
}

3. The master and slave servers start the keepalived and nginx services.

/Etc/init. d/keepalived start
/Etc/init. d/nginx start

Check whether the virtual IP address of the master server exists

Ip addr

Disable the keepalived Service of the master server and test whether the virtual IP address is switched to the backup server.

HAProxy + Keepalived dual-host high availability solution in Linux

Haproxy + Keepalived build Weblogic high-availability server Load balancer Cluster

Keepalived + HAProxy configure high-availability Load Balancing

Haproxy + Keepalived + Apache configuration notes in CentOS 6.3

Haproxy + KeepAlived WEB Cluster on CentOS 6

Haproxy + Keepalived build high-availability Load Balancing

This article permanently updates the link address:

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.