当前位置:网站首页>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
}
边栏推荐
- [wechat authorized login] the small program developed by uniapp realizes the function of obtaining wechat authorized login
- Creating logical volumes and viewing and modifying attributes for AIX storage management
- Gaussdb (for MySQL):partial result cache, which accelerates the operator by caching intermediate results
- Summary of Aix storage management
- Schrodinger's Japanese learning applet source code
- [eight sorts ④] merge sort, sort not based on comparison (count sort, cardinal sort, bucket sort)
- Halcon knowledge: an attempt of 3D reconstruction
- How can entrepreneurial teams implement agile testing to improve quality and efficiency? Voice network developer entrepreneurship lecture Vol.03
- 创业团队如何落地敏捷测试,提升质量效能?丨声网开发者创业讲堂 Vol.03
- SSO single sign on implementation.
猜你喜欢
![[eight sorts ④] merge sort, sort not based on comparison (count sort, cardinal sort, bucket sort)](/img/0d/22f3f65ab9422383df9a55d0724d59.jpg)
[eight sorts ④] merge sort, sort not based on comparison (count sort, cardinal sort, bucket sort)

使用 ES 实现疫情地图或者外卖点餐功能(含代码及数据)

Practical calculation of the whole process of operational amplifier hysteresis comparator

Basis of deep learning neural network

Leetcode skimming: stack and queue 06 (top k high-frequency elements)

Leetcode skimming: stack and queue 03 (valid parentheses)

Halcon knowledge: an attempt of 3D reconstruction

【会议资源】2022年第三届自动化科学与工程国际会议(JCASE 2022)

To meet the needs of consumers in technological upgrading, Angel water purifier's competitive way of "value war"

Example explanation: move graph explorer to jupyterlab
随机推荐
How to improve data quality
测试人进阶技能:单元测试报告应用指南
Accelerator systems initiative is an independent non-profit organization
PLC Analog input analog conversion FB s_ ITR (Mitsubishi FX3U)
【会议资源】2022年第三届自动化科学与工程国际会议(JCASE 2022)
excel查找与引用函数
Qt5.12.9 migration tutorial based on Quanzhi H3
Random avatar encyclopedia, multi category wechat applet source code with history_ Support traffic master
JS common library CDN recommendation
[wechat authorized login] the small program developed by uniapp realizes the function of obtaining wechat authorized login
Leetcode skimming: stack and queue 06 (top k high-frequency elements)
JMeter做接口测试,如何提取登录Cookie
[eight sorting ③] quick sorting (dynamic graph deduction Hoare method, digging method, front and back pointer method)
RFID makes the inventory of fixed assets faster and more accurate
B tree and b+tree of MySQL
Leetcode question brushing: stack and queue 07 (maximum value of sliding window)
Talents come from afar, and Wangcheng district has consolidated the intellectual base of "strengthening the provincial capital"
2022 low voltage electrician examination questions and answers
449-原码、补码、反码
cookie、session、tooken