CentOS7 两台做vip飘逸,实现虚拟ip的跳转

两台机器

首先下载ipvsadm 和 keepalived

  1. yum -y install ipvsadm keepalived

  vim /etc/keepalived/keepalived.conf

  1. ! Configuration File for keepalived
  2.  
  3. global_defs {
  4. notification_email {
  5. acassen@firewall.loc
  6. failover@firewall.loc
  7. sysadmin@firewall.loc
  8. }
  9. notification_email_from Alexandre.Cassen@firewall.loc
  10. smtp_server 192.168.200.1
  11. smtp_connect_timeout 30
  12. router_id LVS_DEVEL
  13. vrrp_skip_check_adv_addr
  14. vrrp_strict
  15. vrrp_garp_interval 0
  16. vrrp_gna_interval 0
  17. }
  18.  
  19. vrrp_instance VI_1 {
  20. state MASTER #配置主 、 从 master backup
  21. interface ens33 #查看自己主机真实ip
  22. virtual_router_id 51
  23. priority 100 #优先级
  24. advert_int 1
  25. authentication {
  26. auth_type PASS
  27. auth_pass 1111
  28. }
  29. virtual_ipaddress {
  30. 192.168.189.181 #填写自己的虚拟ip
  31. }
  32. }
  33.  
  34. virtual_server 192.168.189.181 80 { #虚拟ip
  35. delay_loop 6
  36. lb_algo rr
  37. lb_kind DR #DR模式
  38. net_mask 255.255.255.0 #网关
  39. protocol TCP
  40.  
  41. real_server 192.168.189.137 80 { #真实地址ip1
  42. weight 1
  43. TCP_CHECK {
  44. connect_port 80 # 端口
  45. connect_timeout 3
  46. nb_get_retry 3
  47. delay_before_retry 3
  48. }
  49. }
  50. real_server 192.168.189.138 80 { #真实地址ip2
  51. weight 1
  52. TCP_CHECK {
  53. connect_port 80
  54. connect_timeout 3
  55. nb_get_retry 3
  56. delay_before_retry 3
  57. }
  58. }
  59. }  

这一步完成即可看到vip的飘逸

下一步查看ipvsadm是否存在虚拟ip  (vip 和 ip)

  1. ipvsadm -a -t 192.168.189.181:80 -r 192.168.189.137:80 -g
  2. ipvsadm -a -t 192.168.189.181:80 -r 192.168.189.138:80 -g
  3. ipvsadm -Ln

  

CentOS7配置VIP的更多相关文章

  1. Centos7 配置网络步奏详解

    Centos7 配置网络步奏详解 编辑网卡配置文件 vi /etc/sysconfig/network-script/ifcfg-ens01 备注:这里的ens01不是所有系统都叫这个,有的可能叫其他 ...

  2. centos7配置开启无线网卡,重启防火墙

    centos7配置无线网卡: 在虚拟机为nat的网络连接下(就是默认的那个),centos7默认网卡未激活. 可以设置 文件 /etc/sysconfig/network-scripts/ifcfg- ...

  3. 配置VIP地址

    10.10.10.7  mysql主 redis从 10.10.10.8  mysql从 redis主 现游戏架构如上,游戏后端数据库配置集群.场景描述:若是一台服务器宕机之后,及时切换数据库保持业务 ...

  4. Centos7配置JAVA_HOME

    Centos7配置JAVA_HOME http://blog.csdn.net/zzpzheng/article/details/73613838 在Centos7上,通过yum install ja ...

  5. Centos7配置NFS

    centos7配置nfs yum -y install nfs-utils rpcbind 设置服务开机启动: systemctl enable rpcbind systemctl enable nf ...

  6. keepalived主备节点都配置vip,vip切换异常案例分析

    原文地址:http://blog.51cto.com/13599730/2161622 参考地址:https://blog.csdn.net/qq_14940627/article/details/7 ...

  7. Centos7 配置ssh连接

    Centos7 配置ssh连接 1.检查是否安装openssh-server:#yum list installed | grep openssh-server 安装openssh-server:#y ...

  8. CentOS7 配置静态 ip

    1. 为 CentOS7 配置静态 ip 1.1 修改文件/etc/sysconfig/network-scripts/ifcfg-ens33 sudo vi /etc/sysconfig/netwo ...

  9. virtualbox 最小化安装centos7 配置双网卡(nat和桥接)记录----已经过期

    该文章已经过期   请参考另一篇文章:virtualbox 安装centos7 配置桥接网卡,实现主机和虚拟机互通,虚拟机可以访问外网,解决无法上网问题   先说明一下为什么要配置双网卡? 配置nat ...

随机推荐

  1. 微信小程序路径表达式解析规则

    小程序 setData 方法支持路径表达式来设置属性,例如 setData({"x.y.z": 1}). 微信官方没有公布路径表达式的语法规则及解析规则,本文所描述的路径表达式解析 ...

  2. CSP2019: Lost and Found

    再不更就成鸽子了= = Day -INF to Day 0 不记得发生了什么 Day 1 今年HN用网上提交的方式收题?再也不怕因为交代码太晚增加省队名额了 开考看了一眼T1好像是模拟题,特地注意了\ ...

  3. 创建一个dotnetcore的SPA模板项目

    MPA和SPA 对比 dotnet new --install Microsoft.AspNetCore.SpaTemplates::* 我这边用的是vue dotnet new vue dotnet ...

  4. java 基础 四种权限修饰符

    /** * Java有四种权限修饰符: * public > protected > (default) > private * 同一个类 YES YES YES YES * 同一个 ...

  5. RabbitMQ学习之RPC(6)

    在第二个教程中,我们了解到如何在多个worker中使用Work Queues分发费时的任务. 但是,如果我们需要在远程运行一个函数并且等待结果该怎么办呢?这个时候,我们需要另外一个模式了.这种模式通常 ...

  6. person类与其子类在使用中的内存情况(含java的改写和c#的屏蔽)

    JAVA 普通person类及调用代码: public class Person { public String xm; public int nl; public void setme(String ...

  7. POST请求转换为PUT或者Delete请求、处理post请求乱码的过滤器、Get请求乱码

    在web.xml中配置 <!--配置HiddenHttpMethodFilter : 将所有的POST请求转换为PUT或者Delete请求 --><filter> <fi ...

  8. SpringBoot中执行定时任务

    一:在SpringBoot中使用定时任务相当的简单.首先,我们在启动类中加入@EnableScheduling来开启定时任务. @SpringBootApplication @EnableSchedu ...

  9. golang之数据转换

    golang按位取反符号和异或符号都是^. fmt.Printf("0x%X\n", 0xFF^0x55) var a uint8 = 0x55 fmt.Printf(" ...

  10. 第十二周LINUX学习笔记

    zabbix zabbix-server: 监听的端口10051 zabbix-agent: 10050 Zabbix: Item, Key(键) ethercard.traffic[eth0] ac ...