网站建设公司价格差别18种最有效线下推广的方式
网站建设公司价格差别,18种最有效线下推广的方式,重庆首页工程设计咨询有限责任公司,电子商城网站制作数据库1.基础简介1.1Keepalived简介1.2 VRRP协议原理VRRP 是一种网络协议#xff0c;允许多台路由器共享一个虚拟IP地址#xff0c;实现路由器的高可用工作模式#xff1a;Master#xff08;主设备#xff09;#xff1a;实际持有虚拟IP#xff0c;处理所有发往该IP的请求Back…1.基础简介1.1Keepalived简介1.2 VRRP协议原理VRRP 是一种网络协议允许多台路由器共享一个虚拟IP地址实现路由器的高可用工作模式Master主设备实际持有虚拟IP处理所有发往该IP的请求Backup备用设备监控Master状态当Master故障时接管VIP虚拟路由器由一组路由器组成的逻辑实体对外表现为一个具有固定IP的路由器2.安装keepalived[rootKA1 ~]# dnf install keepalived.x86_64 -y[rootKA2 ~]# dnf install keepalived.x86_64 -y3.配置虚拟路由KA1为master#[rootKA1 ~]# vim /etc/keepalived/keepalived.confglobal_defs { notification_email { timinglee_zln163.com } notification_email_from timinglee_zln163.com smtp_server 127.0.0.1 smtp_connect_timeout 30 router_id KA1 vrrp_skip_check_adv_addr #vrrp_strict vrrp_garp_interval 1 vrrp_gna_interval 1 vrrp_mcast_group4 224.0.0.44 } vrrp_instance WEB_VIP { state MASTER interface eth0 virtual_router_id 51 priority 100 advert_int 1 authentication { auth_type PASS auth_pass 1111 } virtual_ipaddress { 172.25.254.100/24 dev eth0 label eth0:0 } }#[rootKA1 ~]# systemctl enable --now keepalived.serviceCreated symlink /etc/systemd/system/multi-user.target.wants/keepalived.service → /usr/lib/systemd/system/keepalived.service.#KA2同上4.验证[rootKA1 ~]# tcpdump -i eth0 -nn host 224.0.0.4411:38:46.183386 IP 172.25.254.50 224.0.0.44: VRRPv2, Advertisement, vrid 51, prio 100, authtype simple, intvl 1s, length 2011:38:47.184051 IP 172.25.254.50 224.0.0.44: VRRPv2, Advertisement, vrid 51, prio 100, authtype simple, intvl 1s, length 2011:38:48.184610 IP 172.25.254.50 224.0.0.44: VRRPv2, Advertisement, vrid 51, prio 100, authtype simple, intvl 1s, length 2011:38:49.185084 IP 172.25.254.50 224.0.0.44: VRRPv2, Advertisement, vrid 51, prio 100, authtype simple, intvl 1s, length 205.日志分离默认情况下。keepalived的日志会被保存在/var/log/messages文件中这个文件中除了含有keepalived的日志外还有其他服务的日志信息这样不利于对于keepalived的日志进行查看[rootKA1 ~]# vim /etc/sysconfig/keepalivedKEEPALIVED_OPTIONS-D -S 6[rootKA1 ~]# systemctl restart keepalived.service[rootKA1 ~]# vim /etc/rsyslog.conflocal6.* /var/log/keepalived.log[rootKA1 ~]# systemctl restart rsyslog.service#测试[rootKA1 log]# ls -l /var/log/keepalived.logls: 无法访问 keepalived.log: 没有那个文件或目录[rootKA1 log]# ls keepalived.logkeepalived.log6.keepalivd业务vip迁移警告6.1.邮件告警环境构建#安装邮件软件[rootKA1 ~]# dnf install s-nail postfix -y[rootKA2 ~]# dnf install s-nail postfix -y#启动邮件代理[rootKA1 ~]# systemctl start postfix.service[rootKA2 ~]# systemctl start postfix.service#设定sendmail可以通过公网邮箱发送邮件下面方式人选其一#在Linux主机中配置mailrcKA1KA2[rootKA1KA2 ~]# vim /etc/mail.rcset smtpsmtp.163.comset smtp-authloginset smtp-auth-usertiminglee_zln163.comset smtp-auth-passwordTGfdKaJT7EBset fromtiminglee_zln163.comset ssl-verifyignore#测试邮件[rootKA1 mail]# echo hello | mailx -s test 1122334455qq.com[rootKA1 mail]# mailq #查看邮件队列Mail queue is empty[rootKA1 mail]# mail #查看是否又退信s-nail version v14.9.22. Type ? for help/var/spool/mail/root: 1 message▸ 1 Mail Delivery Subsys 2026-01-28 16:26 69/2210 Returned mail: see transcript for details q 退出#查看对应邮箱是否有邮件收到6.2.设定keepalived告警脚本[rootKA1 ~]# mkdir -p /etc/keepalived/scripts[rootKA2 ~]# mkdir -p /etc/keepalived/scripts#编写告警脚本[rootKA12 ~]# vim /etc/keepalived/scripts/waring.sh#!/bin/bashmail_dest594233887qq.commail_send(){mail_subj$HOSTNAME to be $1 vip 转移mail_messdate %F\ %T: vrrp 转移,$HOSTNAME 变为 $1echo $mail_mess | mail -s $mail_subj $mail_dest}case $1 inmaster)mail_send master;;backup)mail_send backup;;fault)mail_send fault;;*)exit 1;;esac[rootKA12 ~]# chmod x /etc/keepalived/scripts/waring.sh[rootKA1 ~]# /etc/keepalived/scripts/waring.sh master#对应邮箱中会出现邮件6.3.配置keepalived告警#在KA1和KA2中设定配置文件! Configuration File for keepalivedglobal_defs {notification_email {timinglee_zln163.com}notification_email_from timinglee_zln163.comsmtp_server 127.0.0.1smtp_connect_timeout 30router_id KA1vrrp_skip_check_adv_addr#vrrp_strictvrrp_garp_interval 1vrrp_gna_interval 1vrrp_mcast_group4 224.0.0.44enable_script_securityscript_user root}vrrp_instance WEB_VIP {state MASTERinterface eth0virtual_router_id 51priority 100advert_int 1# unicast_src_ip 172.25.254.50# unicast_peer {# 172.25.254.60# }authentication {auth_type PASSauth_pass 1111}virtual_ipaddress {172.25.254.100/24 dev eth0 label eth0:0}notify_master /etc/keepalived/scripts/waring.sh masternotify_backup /etc/keepalived/scripts/waring.sh backupnotify_fault /etc/keepalived/scripts/waring.sh fault}[rootKA12 ~]# systemctl restart keepalived.service#测试[rootKA1 ~]# systemctl stop keepalived.service #停止服务后查看邮件[rootKA1 ~]# systemctl start keepalived.service #开启服务后查看邮件7.KeepAlived长链接优化7.1.设定长链接时间[rootNginx ~]# vim /usr/local/nginx/conf/nginx.confkeepalive_timeout 5;[rootNginx ~]# nginx -s reload#测试[rootNginx ~]# dnf install telnet -y[rootNginx ~]# telnet www.timinglee.org 80Trying 172.25.254.100...Connected to www.timinglee.org.Escape character is ^].GET / HTTP/1.1 Host: www.timinglee.org HTTP/1.1 200 OKServer: nginx/1.28.1Date: Sat, 31 Jan 2026 08:27:02 GMTContent-Type: text/htmlContent-Length: 10Last-Modified: Thu, 29 Jan 2026 09:02:15 GMTConnection: keep-aliveETag: 697b2217-aAccept-Ranges: bytestiminglee 显示的页面出现后根据设定的长链接时间会等待超过时间后会自动退出Connection closed by foreign host.7.2.设定长链接次数[rootNginx ~]# vim /usr/local/nginx/conf/nginx.confkeepalive_requests 3;[rootNginx ~]# nginx -s reload#测试[rootNginx ~]# telnet www.timinglee.org 80Trying 172.25.254.100...Connected to www.timinglee.org.Escape character is ^].GET / HTTP/1.1Host: www.timinglee.orgHTTP/1.1 200 OK #第一次Server: nginx/1.28.1Date: Sat, 31 Jan 2026 08:32:14 GMTContent-Type: text/htmlContent-Length: 10Last-Modified: Thu, 29 Jan 2026 09:02:15 GMTConnection: keep-aliveKeep-Alive: timeout100ETag: 697b2217-aAccept-Ranges: bytestimingleeGET / HTTP/1.1Host: www.timinglee.orgHTTP/1.1 200 OK #第二次Server: nginx/1.28.1Date: Sat, 31 Jan 2026 08:32:24 GMTContent-Type: text/htmlContent-Length: 10Last-Modified: Thu, 29 Jan 2026 09:02:15 GMTConnection: keep-aliveKeep-Alive: timeout100ETag: 697b2217-aAccept-Ranges: bytestimingleeGET / HTTP/1.1Host: www.timinglee.orgHTTP/1.1 200 OK #第三次Server: nginx/1.28.1Date: Sat, 31 Jan 2026 08:32:35 GMTContent-Type: text/htmlContent-Length: 10Last-Modified: Thu, 29 Jan 2026 09:02:15 GMTConnection: closeETag: 697b2217-aAccept-Ranges: bytestimingleeConnection closed by foreign host.