当前位置:网站首页>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
}
边栏推荐
- 【八大排序②】选择排序(选择排序,堆排序)
- How do Lenovo computers connect Bluetooth headsets?
- 【微信授权登录】uniapp开发小程序,实现获取微信授权登录功能
- [bottom pop-up selector] uniapp picker component - scroll selector popped up at the bottom
- 2023款雷克萨斯ES产品公布,这回进步很有感
- Export default the exported object cannot be deconstructed, and module Differences between exports
- How to type spaces in latex
- King combat power query renamed toolbox applet source code - with traffic main incentive advertisement
- The new version of graphic network PDF will be released soon
- [conference resources] the Third International Conference on Automation Science and Engineering in 2022 (jcase 2022)
猜你喜欢
【会议资源】2022年第三届自动化科学与工程国际会议(JCASE 2022)
【八大排序②】选择排序(选择排序,堆排序)
Intelligent operation and maintenance practice: banking business process and single transaction tracking
Comprehensive usage and case questions of sub query of SQL data analysis [patient sorting]
Weather forecast applet source code weather wechat applet source code
Evolution of Himalayan self-developed gateway architecture
AIX存储管理之逻辑卷的创建及属性的查看和修改
To meet the needs of consumers in technological upgrading, Angel water purifier's competitive way of "value war"
【八大排序①】插入排序(直接插入排序、希尔排序)
Leetcode skimming: stack and queue 01 (realizing queue with stack)
随机推荐
Node -- egg implements the interface of uploading files
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?
PHP reads ini or env type configuration
JS——图片转base码 、base转File对象
An intern's journey to cnosdb
Example explanation: move graph explorer to jupyterlab
Take the enclave Park as a sample to see how Yuhua and Shaoshan play the song of Chang Zhu Tan integrated development
2022 safety officer-b certificate examination practice questions simulated examination platform operation
JS -- image to base code, base to file object
【CTF】bjdctf_ 2020_ babystack2
测试员8年工资变动,令网友羡慕不已:你一个月顶我一年工资
Is the securities account given by qiniu business school safe? Where can I open an account
[opencv450] hog+svm and hog+cascade for pedestrian detection
Kyushu cloud and Intel jointly released the smart campus private cloud framework, enabling new infrastructure for education
Xinniuniu blind box wechat applet source code_ Support flow realization, with complete material pictures
测试人进阶技能:单元测试报告应用指南
[eight sorts ④] merge sort, sort not based on comparison (count sort, cardinal sort, bucket sort)
Halcon knowledge: an attempt of 3D reconstruction
ThreadLocal内存泄漏是什么,怎么解决
2022 low voltage electrician examination questions and answers