当前位置:网站首页>Keepalived introduction and installation
Keepalived introduction and installation
2022-07-02 00:51:00 【Zhuge Bo】
keepalived brief introduction
Keepalived Is used to detect the state of the server , If a server goes down , Or work breakdown ,Keepalived Will detect , And remove the faulty server from the system , At the same time, use other servers to replace the work of this server , When the server is working Keepalived Automatically add servers to the server cluster , All this work is done automatically , There is no need for human intervention , All you need to do is fix the failed server . Official website : Keepalived Yes, it is C Programming language routing software . The main objective of the project is to Linux System and based on Linux Our infrastructure provides simple and powerful projects with load balancing and high availability . If we say network failure or itself keepalived After hanging up , Pre configured master slaver1 slaver2…

install keepalived, Configure the load balancing server
Installation configuration yum -y install keepalived
Host configuration vi /etc/keepalived/keepalived.conf
SMTP(Simple Mail Transfer Protocol) Simple Mail Transfer Protocol , It's a set of rules for sending mail from source to destination , It controls the way letters are transferred .
shell Script
vim /usr/local/nginx/conf/nginx.conf
#!/bin/bash
PSNUM=`ps -C nginx --no-header|wc -l`
if [ $PSNUM -eq 0 ];then
/usr/local/nginx/sbin/nginx
if [ `ps -C nginx --no-header|wc -l` -eq 0 ]; then
killall keepalived
fi
fi
Host configuration :
vim /etc/keepalived/check-nginx.sh
1
1
global_defs {
notification_email {
[email protected]
}
notification_email_from [email protected] # Who is the email source address when sending notification email
smtp_server 127.0.0.1
smtp_connect_timeout 30 # Connect smtp Connection timeout
router_id LVS_DEVEL # Machine identification
}
# It's for health check ups , At that time, when the inspection fails, it will vrrp_instance Of priority Reduce the corresponding value .
vrrp_script chk_http_port {
script "/usr/checknginx.sh" # Monitoring script
interval 2 # Monitoring script detection cycle seconds
weight 10 # It means if script in The instruction execution of failed ,
So the corresponding vrrp_instance The priority of will be reduced 10 A little bit
}
vrrp_instance VI_1 {
state MASTER #backup The machine is configured to BACKUP
interface eth0 # Bound network card name
virtual_router_id 51 # Must be with backup The machine configuration is the same
priority 100 # priority , than backup Machine height at least 50
advert_int 1 # Check interval , Default 1 second VRRP The sending cycle of heartbeat packets , Unit is s
authentication {
auth_type PASS # Type of Authorization , Must be with backup identical
auth_pass 1111 # Authorization code , Must be with backup identical
}
virtual_ipaddress {
192.168.23.220 # fictitious ip Address , Must be with backup identical
}
track_script {
chk_http_port
}
}
Standby configuration
global_defs {
notification_email {
[email protected]
}
notification_email_from [email protected]
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id LVS_DEVEL_BAK
}
vrrp_script chk_http_port {
script "/usr/checknginx.sh" # Monitoring script
interval 2 # Monitor script detection cycle
weight -10 # It means if script Instruction execution in failed , So the corresponding vrrp_instance The priority of will be reduced 10 A little bit .
}
vrrp_instance VI_1 {
state BACKUP
interface eth0
virtual_router_id 51
priority 50
advert_int 1
authentication {
auth_type PASS # Type of Authorization , Must be with backup identical
auth_pass 1111 # Authorization code , Must be with backup identical
}
virtual_ipaddress {
192.168.23.220 # fictitious ip Address , Must be with backup identical
}
track_script {
chk_http_port
}
nopreempt # Don't take IP, When keepalived After switching , It can only be configured in BACKUP On ,
# This avoids the overhead of switching back and forth , It also avoids IP System instability caused by switching
}
边栏推荐
- Schrodinger's Japanese learning applet source code
- Take the enclave Park as a sample to see how Yuhua and Shaoshan play the song of Chang Zhu Tan integrated development
- I want to ask, which is the better choice for securities companies? I don't understand. Is it safe to open an account online now?
- How can entrepreneurial teams implement agile testing to improve quality and efficiency? Voice network developer entrepreneurship lecture Vol.03
- Weather forecast applet source code weather wechat applet source code
- Is it safe and reliable to open an account in Caixue school and make new debts?
- Picture puzzle wechat applet source code_ Support multi template production and traffic master
- 2022 safety officer-b certificate examination practice questions simulated examination platform operation
- Tensorflow tensor convolution, input and convolution kernel dimension understanding
- 【八大排序②】选择排序(选择排序,堆排序)
猜你喜欢

【八大排序④】归并排序、不基于比较的排序(计数排序、基数排序、桶排序)

Halcon knowledge: an attempt of 3D reconstruction

EMC circuit protection device for surge and impulse current protection

Leetcode skimming: stack and queue 04 (delete all adjacent duplicates in the string)

Leetcode question brushing: stack and queue 07 (maximum value of sliding window)

Take the enclave Park as a sample to see how Yuhua and Shaoshan play the song of Chang Zhu Tan integrated development

Picture puzzle wechat applet source code_ Support multi template production and traffic master

AIX存储管理之卷组的创建(一)

How to reflect and solve the problem of bird flight? Why are planes afraid of birds?

Leetcode skimming: stack and queue 01 (realizing queue with stack)
随机推荐
Otaku wallpaper Daquan wechat applet source code - with dynamic wallpaper to support a variety of traffic owners
S32Kxxx bootloader之UDS bootloader
Node -- egg creates a local file access interface
@Valid parameter verification does not take effect
Promise and modular programming
[wechat authorized login] the small program developed by uniapp realizes the function of obtaining wechat authorized login
Slf4j print abnormal stack information
Halcon knowledge: an attempt of 3D reconstruction
AIX存储管理之卷组属性的查看和修改(二)
PHP reads ini or env type configuration
Cookie, session, tooken
Using multithreaded callable to query Oracle Database
股票开户哪个证券公司比较安全
【八大排序④】归并排序、不基于比较的排序(计数排序、基数排序、桶排序)
LeetCode 0241.为运算表达式设计优先级 - DFS
Leetcode skimming: stack and queue 01 (realizing queue with stack)
When installing mysql, there are two packages: Perl (data:: dumper) and Perl (JSON)
How to type spaces in latex
cookie、session、tooken
UVM tutorial