Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Keepalived+lvs configuration details

2025-03-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

Installation:

Tar-zxvf keepalived-1.2.2.tar.gz

Yum list all | grep "ipvsadm"

Yum-y install kernel-devel openssl-develpopt-devel ipvsadm libnl libnl-devel

Service iptables stop

Setenforce 0

. / configure-- prefix=/--with-kernel-dir=/usr/src/kernels/2.6.32-431.el6.x86_64 & & make&& make install

Add system services:

Chkconfig-after add keepalived is added, you can use service and chkconfig tools to manage keepalived services

Chkconfig keepalived on on levels are 2, 3, 4

Chkconfig-- list keepalived to see if levels 2, 3 and 4 are enabled

Global profile:

Global_defs {

Notification_email {

Acassen@firewall.loc

Failover@firewall.loc

Sysadmin@firewall.loc

}

Notification_email_from Alexandre.Cassen@firewall.loc

Smtp_server 192.168.1.1

Smtp_connect_timeout 30

Router_id LVS_master

}

Vrrp_script check_httpd {

# vrrp_script module is specially used to monitor the service resources in the cluster (HA cluster monitoring). This module is also used with the track_script module, and the track_script module is mainly used to call the vrrp_script module. You can also check ports, shell statements, and scripts. Demonstrate below the appendix

Script "killall-O httpd"

# use killall-O httpd to check the returned status of httpd service. Zero indicates normal operation, while 1 indicates abnormal operation.

Interval 2

# the interval between checks (in seconds).

}

Example of Vrrp configuration (keepalived High availability configuration):

Vrrp_instance VI_1 {

# identity, the identity of the start of the vrrp instance

State MASTER

# define master and slave roles master and backup

Interface eth0

# specify listening Nic

Virtual_router_id51

# Virtual routing identity, which cannot be the same as master / slave.

Priority 100

# priority. The higher the number, the higher the priority. Under the same vrrp-instance, master must have higher priority than backup.

Advert_int 1

# set the time interval for synchronization checks between master and backup (in seconds)

Authentication {

Auth_type PASS

Auth_pass 1111

# set master and backup authentication types (AH, PASS) and password so that the master / slave passwords are the same before you can communicate.

}

Notify_master "/ etc/keep/master.sh"

Notify_backup "/ etc/keep/backup.sh"

Notify_fault "/ etc/keep/fault.sh"

# specifies that the script is executed when keepalived enters the state of master, backup, and fault. Examples of the script are shown in the appendix.

Track_script {

Check_httpd

}

# call the vrrp_script module. Check_httpd is the name followed by the vrrp_script module.

Virtual_ipaddress {

192.168.1.250

# Virtual address, you can set multiple addresses. It adds the address in the form of ip address add.

}

# nopreempt

# No preemption feature, this feature can only be used on nodes whose state status is backup, and this node has higher priority than other nodes

# preempt_delay 300

# preemption delay time in seconds. For example, if there is a jitter in the network, the master node sends the detection packet to the backup node in a timely manner. There is no problem with the actual master node, and there is no need for active / standby switching. The same is true of restarting the service or restarting the system.

}

-vrrp configuration Appendix-

-- vrrp configuration appendix

An example of the notify_master "/ etc/keep/master.sh" script is as follows:

#! / bin/bash

Logfile=/var/log/keep/keep-http-statsu.log

Echo "[MASTER]" > > $logfile

Date > > $logfile

Backup.sh and fault.sh skip.

Port check:

Vrrp_script check_httpd {

Script "

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report