Modifying a configuration file
Vi/etc/keepalived/keepalived.conf
! Configuration File forKeepalivedglobal_defs {notification_email {616043155@qq. com #设置报警邮件地址, you can set multiple, 1 per line, [email protected] #需开启邮件报警及本机的Sendmail服务. } #notification_email_from616043155@qq. com #smtp_server smtp.qq.com #设置SMTP server address; #smtp_connect_timeout -router_id Lvs_devel} ####### #VRRP instance####### #vrrp_instance vi_1 {State MASTER #指定Keepalived的角 The master is the host server, backup is the standby server interface eth0 virtual_router_idWuyi#虚拟路由的id号, generally not more than 255 of the priority -#定义优先级, the higher the number, the higher the priority, the primary Dr must be larger than the standby Dr. Advert_int1Authentication {Auth_type Pass #设置验证类型, mainly have pass and ah two kinds of auth_pass Passwd #设置验证密码} virtual_ipad Dress {10.10.0.116#设置主DR的虚拟IP地址 (Virtual IP), multi-set, but must be 1} per line
keepalived CodeNote:
When Keepalived is started, the VIP is not visible through ifconfig, but can be seen through the IP a command
When Master is down, BACKUP is upgraded to master, and these vrrp_instance state transitions can be recorded in/var/log/message
Copy the configuration file to the backup server and modify the initial status to priority
vrrp_instance vi_1 {State BACKUP // initialization status interface eth0 #定义优先级, must be 1 lower than Master's priority Authentication { Auth_type PASS auth_pass Passwd } virtual_ipaddress { 10.10 . 0.116 }}
keepalived Backup CodeStart the service
Service keepalived Restart
Check the keepalived log file
Stop or shut down the keepalived service, tail-f/var/log/message check log condition in master server