搭建memcached 主主复制+keepalived 高可用

本文涉及的产品
传统型负载均衡 CLB,每月750个小时 15LCU
应用型负载均衡 ALB,每月750个小时 15LCU
网络型负载均衡 NLB,每月750个小时 15LCU
简介: 搭建memcached 主主复制+keepalived 高可用

搭建memcached 主主复制+keepalived 高可用

第一台:

yum -y install keepalived

vim /etc/keepalived/keepalived.conf

删除原有数据,添加以下内容:

! Configuration File for keepalived

global_defs {

  notification_email {

    acassen@firewall.loc

    failover@firewall.loc

    sysadmin@firewall.loc

  }

  notification_email_from Alexandre.Cassen@firewall.loc

  smtp_server 192.168.200.1

  smtp_connect_timeout 30

  router_id LVS_DEVEL

}

vrrp_instance VI_1 {

   state MASTER

   interface eth0

   virtual_router_id 51

   priority 100

   advert_int 1

nopreempt

   authentication {

       auth_type PASS

       auth_pass 1111

   }

   virtual_ipaddress {

       192.168.1.100

   }

}

virtual_server 192.168.1.100 11211 {

   delay_loop 6

   lb_algo rr

   lb_kind NAT

   nat_mask 255.255.255.0

   persistence_timeout 50

   protocol TCP

   real_server 192.168.1.10 11211 {

       weight 1

notify_down /root/memcached.sh

       TCP_CHECK {

           connect_timeout 3

           nb_get_retry 3

           delay_before_retry 3

   connect_port 11211

       }

   }

}

echo "/usr/bin/systemctl stop keepalived"> /root/memcached.sh

chmod +x memcached.sh

systemctl start keepalived

ip addr show dev eth0

第二台:

yum -y install keepalived

vim /etc/keepalived/keepalived.conf

删除原有数据,添加以下内容:

! Configuration File for keepalived

global_defs {

  notification_email {

    acassen@firewall.loc

    failover@firewall.loc

    sysadmin@firewall.loc

  }

  notification_email_from Alexandre.Cassen@firewall.loc

  smtp_server 192.168.200.1

  smtp_connect_timeout 30

  router_id LVS_DEVEL

}

vrrp_instance VI_1 {

   state MASTER

   interface eth0

   virtual_router_id 51

   priority 100

   advert_int 1

nopreempt

   authentication {

       auth_type PASS

       auth_pass 1111

   }

   virtual_ipaddress {

       192.168.1.100

   }

}

virtual_server 192.168.1.100 11211 {

   delay_loop 6

   lb_algo rr

   lb_kind NAT

   nat_mask 255.255.255.0

   persistence_timeout 50

   protocol TCP

   real_server 192.168.1.11 11211 {

       weight 1

notify_down /root/memcached.sh

       TCP_CHECK {

           connect_timeout 3

           nb_get_retry 3

           delay_before_retry 3

   connect_port 11211

       }

   }

}

echo "/usr/bin/systemctl stop keepalived"> /root/memcached.sh

chmod +x memcached.sh

systemctl start keepalived

ip addr show dev eth0

验证(断掉有虚拟ip的一台):

killall memcached   #杀死memcached进程

netstat -napt |grep memcached   查询相关进程

相关实践学习
SLB负载均衡实践
本场景通过使用阿里云负载均衡 SLB 以及对负载均衡 SLB 后端服务器 ECS 的权重进行修改,快速解决服务器响应速度慢的问题
负载均衡入门与产品使用指南
负载均衡(Server Load Balancer)是对多台云服务器进行流量分发的负载均衡服务,可以通过流量分发扩展应用系统对外的服务能力,通过消除单点故障提升应用系统的可用性。 本课程主要介绍负载均衡的相关技术以及阿里云负载均衡产品的使用方法。
相关文章
|
5月前
|
Linux Memcache
Linux - 安装memcached
Linux - 安装memcached
104 0
Linux - 安装memcached
|
4月前
|
缓存 Java Spring
SpringBoot配置第三方专业缓存技术Memcached 下载 安装 整合测试 2024年5000字详解
SpringBoot配置第三方专业缓存技术Memcached 下载 安装 整合测试 2024年5000字详解
42 0
|
11月前
|
Docker 容器
Docker下安装memcached
Docker下安装memcached
145 0
|
Shell C语言
脚本用源码来安装 memcached 服务器
脚本用源码来安装 memcached 服务器
50 1
|
Java 程序员
【memcached】下载、安装、、出错一分钟全搞定
【memcached】下载、安装、、出错一分钟全搞定
196 0