目录
[(1)数据存储方式:Slab Allocation](#(1)数据存储方式:Slab Allocation)
[(2)数据过期方式:LRU、Laxzy Expiration](#(2)数据过期方式:LRU、Laxzy Expiration)
[3.Memcached 缓存机制](#3.Memcached 缓存机制)
[4.Memcached 分布式](#4.Memcached 分布式)
[5.Memcached 路由算法](#5.Memcached 路由算法)
[(1)求余数 hash 算法](#(1)求余数 hash 算法)
[(2)一致性 hash 算法](#(2)一致性 hash 算法)
2:安装libevent-2.1.8-stable.tar.gz
5:在103主机安装gcc*,httpd,mariadb,mariadb-server,php,php-devel,php-mysql
[7:安装 libmemcached-1.0.18.tar.gz](#7:安装 libmemcached-1.0.18.tar.gz)
[8:安装 memcached-2.2.0.tgz](#8:安装 memcached-2.2.0.tgz)
[三,Memcached 实现主主复制和高可用的方式](#三,Memcached 实现主主复制和高可用的方式)
[4:安装 libevent-2.1.8-stable.tar.gz](#4:安装 libevent-2.1.8-stable.tar.gz)
[5:安装 memcached-1.2.8-repcached-2.2.tar.gz](#5:安装 memcached-1.2.8-repcached-2.2.tar.gz)
[12 :修改103客户端连接mamcached的ip](#12 :修改103客户端连接mamcached的ip)
一:Memcached
1:Memcached的概述
- 一套开源的高性能的分布式内存对象缓存系统
- 所有的数据都存储在内存中
- 支持任意存储类型的数据
- 提高网站的访问速度
2:数据存储方式与数据过期方式
(1)数据存储方式:Slab Allocation
按组分配内存,每次先分配一个Slab,相当于一个大小为1m的页然后在1M的空间里根据数据划分大小相同的Chunk
(2)数据过期方式:LRU、Laxzy Expiration
LRU 和 Laxzy Expiration 是数据过期的两种方式。
LUR 是指追加的数据空间不足时,会根据LRU的情况淘汰最近最少使用的记录。Laxzy Expiration 即惰性过期,是指使用 get 时查看记录时间,从而检查记录是否已经过期。
3.Memcached 缓存机制
缓存是常驻在内存的数据,能够快速进行读取,而Memcached 就是这样一款非常出色的缓存软件。当程序写入缓存数据请求时,Memcached 的API接口将 Key 输入路由算法模块并路由到集群中的一台服务器,之后由API接口与服务器进行通信,完成一次分布式缓存写入,如图 所示。
4.Memcached 分布式
Memcached 分布式部署主要依赖于Memcached的客户来端实现,多个Memcached 服务器是独立的。分布式数据如何存储是由路由算法所决定。当数据到达客户端程序库,客户端的算法就依据路由算法来决定保存的Memcached 服务器。读取数据时,客户端依据使用保存数据时相同的路由算法选中和存储数据时相同的服务器来读取数据,如图所示。
5.Memcached 路由算法
(1)求余数 hash 算法
求余数 hash 算法先用 key 做 hash 运算得到一个整数,再去做 hash 算法,根据余数进行路由,这种算法适合大多数据需求。但是不适合用在动态变化的环境中,比如有大量机器添加或者删除,这样会导致大量的对象存储位置失效。
(2)一致性 hash 算法
一致性 hash 算法适合在动态变化的环境中使用。原理是按照 hash 算法把对应的 key 通过一定的 hash 算法处理后映射形成一个首尾相接闭合循环,然后通过使用与对象存储一样的hash算法将机器也映射到环中,顺时针方向计算将所有对象存储到离自己最近的机器中,如图所示。
案例一
二,单memcached节点缓存系统
1:设置各节点的主机名:192.168.10.101
bash
[root@localhost ~]# hostnamectl set-hostname Memcache1
[root@localhost ~]# bash
主机:192.168.10.103
bash
[root@localhost ~]# hostnamectl set-hostname Memcached-API
[root@localhost ~]# bash
2:安装libevent-2.1.8-stable.tar.gz
[root@memcache1 ~]# ll
总用量 1008
-rw-------. 1 root root 1603 5月 28 01:57 anaconda-ks.cfg
-rw-r--r--. 1 root root 1026485 8月 19 2019 libevent-2.1.8-stable.tar.gz
[root@memcache1 ~]# tar -zxvf libevent-2.1.8-stable.tar.gz
[root@memcache1 ~]# yum -y install gcc*
[root@memcache1 ~]# cd libevent-2.1.8-stable
[root@memcache1 libevent-2.1.8-stable]# ./configure --prefix=/usr/local/libevent
[root@memcache1 libevent-2.1.8-stable]# make && make install
3:安装memcached-1.5.1.tar.gz
[root@memcache1 ~]# ll
总用量 1420
-rw-------. 1 root root 1603 5月 28 01:57 anaconda-ks.cfg
drwxr-xr-x. 10 1000 1000 8192 8月 15 20:18 libevent-2.1.8-stable
-rw-r--r--. 1 root root 1026485 8月 19 2019 libevent-2.1.8-stable.tar.gz
-rw-r--r--. 1 root root 407282 8月 19 2019 memcached-1.5.1.tar.gz
[root@memcache1 ~]# tar -zxvf memcached-1.5.1.tar.gz
[root@memcache1 ~]# cd memcached-1.5.1
[root@memcache1 memcached-1.5.1]# ./configure --prefix=/usr/local/memcached
--with-libevent=/usr/local/libevent/
[root@memcache1 memcached-1.5.1]# make && make install
4:设置Memcached服务脚本
root@memcache1 ~]# vim memcached_service.sh
#!/bin/bash
CMD="/usr/local/memcached/bin/memcached"
start(){
$CMD -d -m 128 -u root
}
stop(){
killall memcached;
}
ACTION=$1
case $ACTION in
'start')
start;;
'stop')
stop;;
'restart')
stop
sleep 2
start;;
*)
echo 'Usage:{start|stop|restart}'
esac
[root@memcache1 ~]# chmod +x memcached_service.sh
[root@memcache1 ~]# ./memcached_service.sh start
[root@memcache1 ~]# netstat -anpt | grep memcached
tcp 0 0 0.0.0.0:11211 0.0.0.0:* LISTEN 10144/memcached
tcp6 0 0 :::11211 :::* LISTEN 10144/memcached
[root@memcache1 ~]#
5:在103主机安装gcc*,httpd,mariadb,mariadb-server,php,php-devel,php-mysql
[root@memcached-api ~]# yum -y install gcc*
[root@memcached-api ~]# rm -rf /etc/yum.repos.d/*
[root@memcached-api ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 2523 100 2523 0 0 444 0 0:00:05 0:00:05 --:--:-- 606
[root@memcached-api ~]# curl -o /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-7.repo
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 664 100 664 0 0 3058 0 --:--:-- --:--:-- --:--:-- 3059
[root@memcached-api ~]# yum clean all
已加载插件:fastestmirror
正在清理软件源: base epel extras updates
Cleaning up list of fastest mirrors
Other repos take up 39 M of disk space (use --verbose for details)
[root@memcached-api ~]# yum -y install httpd mariadb mariadb-server php php-devel php-mysql
6:测试服务是否正常
[root@memcached-api ~]# systemctl start mariadb
[root@memcached-api ~]# mysqladmin -uroot password 'pwd123'
[root@memcached-api ~]# systemctl start httpd
[root@memcached-api ~]# systemctl stop firewalld
[root@memcached-api ~]# setenforce 0
[root@memcached-api ~]# cd /var/www/html/
[root@memcached-api html]# vim test1.php
<?php
phpinfo()
?>
用浏览器访问看看是否能够访问到
7:安装 libmemcached-1.0.18.tar.gz
[root@memcached-api ~]# ll
总用量 1024
-rw-------. 1 root root 1603 5月 28 01:57 anaconda-ks.cfg
drwxr-xr-x. 24 800 800 4096 8月 15 20:59 libmemcached-1.0.18
-rw-r--r--. 1 root root 1039649 8月 24 2018 libmemcached-1.0.18.tar.gz
[root@memcached-api ~]# tar -zxvf libmemcached-1.0.18.tar.gz
[root@memcached-api ~]# cd libmemcached-1.0.18
[root@memcached-api libmemcached-1.0.18]# ./configure --prefix=/usr/local/libmemcached
--with-memcached=/usr/local/memcached
[root@memcached-api libmemcached-1.0.18]# make && make install
8:安装 memcached-2.2.0.tgz
bash
[root@memcached-api ~]# ll
总用量 1096
-rw-------. 1 root root 1603 5月 28 01:57 anaconda-ks.cfg
drwxr-xr-x. 24 800 800 4096 8月 15 20:59 libmemcached-1.0.18
-rw-r--r--. 1 root root 1039649 8月 24 2018 libmemcached-1.0.18.tar.gz
-rw-r--r--. 1 root root 70449 8月 19 2019 memcached-2.2.0.tgz
[root@memcached-api ~]# tar -zxvf memcached-2.2.0.tgz
[root@memcached-api ~]# cd memcached-2.2.0
[root@memcached-api memcached-2.2.0]# ll
总用量 268
-rw-r--r--. 1 501 games 5720 4月 1 2014 ChangeLog
-rw-r--r--. 1 501 games 14595 4月 1 2014 config.m4
-rw-r--r--. 1 501 games 532 4月 1 2014 config.w32
-rw-r--r--. 1 501 games 59 4月 1 2014 CREDITS
drwxr-xr-x. 2 root root 53 8月 15 21:02 fastlz
-rw-r--r--. 1 501 games 2297 4月 1 2014 g_fmt.c
-rw-r--r--. 1 501 games 1181 4月 1 2014 g_fmt.h
-rw-r--r--. 1 501 games 3218 4月 1 2014 LICENSE
-rw-r--r--. 1 501 games 5770 4月 1 2014 memcached-api.php
-rw-r--r--. 1 501 games 4067 4月 1 2014 memcached.ini
-rw-r--r--. 1 501 games 1649 4月 1 2014 php_libmemcached_compat.c
-rw-r--r--. 1 501 games 2330 4月 1 2014 php_libmemcached_compat.h
-rw-r--r--. 1 501 games 138353 4月 1 2014 php_memcached.c
-rw-r--r--. 1 501 games 1810 4月 1 2014 php_memcached.h
-rw-r--r--. 1 501 games 5269 4月 1 2014 php_memcached_private.h
-rw-r--r--. 1 501 games 24437 4月 1 2014 php_memcached_server.c
-rw-r--r--. 1 501 games 1471 4月 1 2014 php_memcached_server.h
-rw-r--r--. 1 501 games 12543 4月 1 2014 php_memcached_session.c
-rw-r--r--. 1 501 games 1407 4月 1 2014 php_memcached_session.h
-rw-r--r--. 1 501 games 730 4月 1 2014 README.markdown
drwxr-xr-x. 2 root root 4096 8月 15 21:02 tests
[root@memcached-api memcached-2.2.0]# php
php php-cgi php-config phpize
[root@memcached-api memcached-2.2.0]# phpize
Configuring for:
PHP Api Version: 20100412
Zend Module Api No: 20100525
Zend Extension Api No: 220100525
[root@memcached-api memcached-2.2.0]# ls
acinclude.m4 config.sub install-sh php_libmemcached_compat.c php_memcached_session.h
aclocal.m4 configure LICENSE php_libmemcached_compat.h README.markdown
autom4te.cache configure.in ltmain.sh php_memcached.c run-tests.php
build config.w32 Makefile.global php_memcached.h tests
ChangeLog CREDITS memcached-api.php php_memcached_private.h
config.guess fastlz memcached.ini php_memcached_server.c
config.h.in g_fmt.c missing php_memcached_server.h
config.m4 g_fmt.h mkinstalldirs php_memcached_session.c
[root@memcached-api memcached-2.2.0]# yum -y install zlib zlib-devel
[root@memcached-api memcached-2.2.0]# ./configure
--with-php-config=/usr/bin/php-config
--with-libmemcached-dir=/usr/local/libmemcached/
--disable-memcached-sasl
--with-zlib-dir
[root@memcached-api memcached-2.2.0]# make
[root@memcached-api memcached-2.2.0]# make install
Installing shared extensions: /usr/lib64/php/modules/
9:添加模块
10:查看模块是否存在
bash
[root@memcached-api memcached-2.2.0]# systemctl restart httpd
11:测试
php
[root@memcached-api memcached-2.2.0]# cd /var/www/html/
[root@memcached-api html]# vim test2.php
<?php
$memcache = new Memcached();
$memcache->addServer('192.168.10.101', 11211);
$memcache->set('key', 'Memcache test successful!', 0, 60);
$result = $memcache->get('key');
unset($memcache);
echo $result;
?>
12:连接Memcached
bash
[root@memcache1 ~]# yum -y install telnet
[root@memcache1 ~]# telnet 127.0.0.1 11211
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
get key
VALUE key 3932160 25
Memcache test successful! //刚刚浏览器访问的那句话
END
13:Memcached命令
|-----------------|----------------------------------------|-------------------------------------------|
| 命令 | 描述 | 实例 |
| set | 添加或更新一个键值对。如果键已存在,则更新其值;如果不存在,则添加新键值对。 | set mykey 0 0 5hello |
| add | 仅当键不存在时添加新键值对。如果键已存在,则操作失败。 | add newkey 0 0 5world |
| replace | 仅当键已存在时替换其值。如果键不存在,则操作失败。 | replace mykey 0 0 6hello2 |
| get | 检索一个或多个键的值。如果键存在,则返回其值;如果不存在,则不返回任何内容。 | get mykey |
| delete | 删除一个键值对。如果键存在,则删除;如果不存在,则操作失败。 | delete mykey |
| incr | 对一个数值键的值进行自增操作。仅当键存在且其值为整数时有效。 | incr counter(假设counter键已存在且值为1,执行后变为2) |
| decr | 对一个数值键的值进行自减操作。同样,仅当键存在且其值为整数时有效。 | decr counter(假设counter键已存在且值为2,执行后变为1) |
| stats | 显示Memcached服务器的状态信息,如命中率、连接数、内存使用等。 | stats |
| stats reset | 重置Memcached服务器的统计信息。 | stats reset |
| stats slabs | 显示各个slab(内存分配区域)的详细信息,包括chunk大小、使用情况等。 | stats slabs |
| stats items | 显示各个slab中item的数目和最老item的年龄。 | stats items |
| stats cachedump | 显示指定slab中的部分或全部键值对列表。 | stats cachedump 1 100(显示slab 1中的前100个键值对) |
| flush_all | 删除Memcached中的所有键值对。可以配置是否立即生效或延迟一段时间。 | flush_all或flush_all 120(延迟120秒删除) |
| version | 显示Memcached服务器的版本信息。 | version |
| quit | 退出Memcached的telnet会话(如果通过telnet连接)。 | quit |
三,Memcached 实现主主复制和高可用的方式
1:设置各节点的主机名:192.168.10.101
bash
[root@localhost ~]# hostnamectl set-hostname Memcache1
[root@localhost ~]# bash
主机:192.168.10.102
bash
[root@localhost ~]# hostnamectl set-hostname Memcache2
[root@localhost ~]# bash
注意101和102配置一样可以一起做
2:关闭防火墙
bash
[root@memcache1 ~]# systemctl stop firewalld
[root@memcache1 ~]# setenforce 0
3:安装开发环境
bash
[root@memcache1 ~]# yum -y install gcc*
4:安装 libevent-2.1.8-stable.tar.gz
bash
[root@memcache1 ~]# tar -zxvf libevent-2.1.8-stable.tar.gz
[root@memcache1 ~]# cd libevent-2.1.8-stable
[root@memcache1 libevent-2.1.8-stable]# ./configure --prefix=/usr/local/libevent
[root@memcache1 libevent-2.1.8-stable]# make && make install
5:安装 memcached-1.2.8-repcached-2.2.tar.gz
bash
[root@memcache1 ~]# tar -zxvf memcached-1.2.8-repcached-2.2.tar.gz
[root@memcache1 ~]# cd memcached-1.2.8-repcached-2.2
[root@memcache1 memcached-1.2.8-repcached-2.2]# ./configure --prefix=/usr/local/memcached_replication
--enable-replication
--with-libevent=/usr/local/libevent/
[root@memcache1 memcached-1.2.8-repcached-2.2]# vim memcached.c
[root@memcache1 memcached-1.2.8-repcached-2.2]# make && make install
注意先修改memcached.c再make
6:做个函数链接
bash
[root@memcache1 memcached-1.2.8-repcached-2.2]# ln -s /usr/local/libevent/lib/libevent-2.1.so.6 /usr/lib64
注意下面101和102不在同步
7:在101启动memcached并连接102
bash
[root@memcache1 memcached-1.2.8-repcached-2.2]# /usr/local/memcached_replication/bin/memcached -d -u root -m 128 -x 192.168.10.102
[root@memcache1 memcached-1.2.8-repcached-2.2]# netstat -anpt | grep memcached
tcp 0 0 0.0.0.0:11211 0.0.0.0:* LISTEN 10112/memcached
tcp 0 0 192.168.10.101:51294 192.168.10.102:11212 ESTABLISHED 10112/memcached
tcp6 0 0 :::11211 :::* LISTEN 10112/memcached
8:在102启动memcached并连接101
bash
[root@memcache2 memcached-1.2.8-repcached-2.2]# /usr/local/memcached_replication/bin/memcached -d -u root -m 128 -x 192.168.10.101
[root@memcache2 memcached-1.2.8-repcached-2.2]# netstat -anpt | grep memcached
tcp 0 0 0.0.0.0:11211 0.0.0.0:* LISTEN 10225/memcached
tcp 0 0 192.168.10.102:60506 192.168.10.101:11212 ESTABLISHED 10225/memcached
tcp6 0 0 :::11211 :::* LISTEN 10225/memcached
9:测试102和101是否同步
bash
[root@memcache1 memcached-1.2.8-repcached-2.2]# yum -y install telnet
[root@memcache1 memcached-1.2.8-repcached-2.2]# telnet 192.168.10.101 11211
Trying 192.168.10.101...
Connected to 192.168.10.101.
Escape character is '^]'.
set username 0 0 8
zhangsan
STORED
get username
VALUE username 0 8
zhangsan
END
quit
Connection closed by foreign host.
[root@memcache1 memcached-1.2.8-repcached-2.2]# telnet 192.168.10.102 11211
Trying 192.168.10.102...
Connected to 192.168.10.102.
Escape character is '^]'.
get username
VALUE username 0 8
zhangsan
END
10:下载keepalived并修改配置
101
bash
[root@memcache1 ~]# yum -y install keepalived
! 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_01
vrrp_skip_check_adv_addr
# vrrp_strict
vrrp_garp_interval 0
vrrp_gna_interval 0
}
vrrp_script check_down {
script "/etc/keepalived/memcached.sh"
interval 1
}
vrrp_instance VI_1 {
state BACKUP
nopreempt
interface ens33
virtual_router_id 51
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.10.240
}
track_script {
check_down
}
}
[root@memcache1 ~]# cd /etc/keepalived/
[root@memcache1 keepalived]# vim memcached.sh
#!/bin/bash
#!/bin/bash
#
if [ $(ps -C memcached --no-header | wc -l) -eq 0 ]; then
systemctl stop keepalived
fi
[root@memcache1 keepalived]# systemctl stop NetworkManager
[root@memcache1 keepalived]# systemctl start keepalived
102
bash
[root@memcache1 ~]# yum -y install keepalived
! 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_02
vrrp_skip_check_adv_addr
# vrrp_strict
vrrp_garp_interval 0
vrrp_gna_interval 0
}
vrrp_script check_down {
script "/etc/keepalived/memcached.sh"
interval 1
}
vrrp_instance VI_1 {
state BACKUP
interface ens33
virtual_router_id 51
priority 90
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.10.240
}
track_script {
check_down
}
}
[root@memcache1 ~]# cd /etc/keepalived/
[root@memcache1 keepalived]# vim memcached.sh
#!/bin/bash
#!/bin/bash
#
if [ $(ps -C memcached --no-header | wc -l) -eq 0 ]; then
systemctl stop keepalived
fi
[root@memcache1 keepalived]# systemctl stop NetworkManager
[root@memcache1 keepalived]# systemctl start keepalived
11:查看是否配置成功
bash
[root@memcache1 keepalived]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:90:61:c1 brd ff:ff:ff:ff:ff:ff
inet 192.168.10.101/24 brd 192.168.10.255 scope global ens33
valid_lft forever preferred_lft forever
inet 192.168.10.240/32 scope global ens33
valid_lft forever preferred_lft forever
inet6 fe80::2f4c:60b5:64be:bc1f/64 scope link noprefixroute
valid_lft forever preferred_lft forever
[root@memcache1 keepalived]# ip a
12 :修改103客户端连接mamcached的ip
bash
[root@memcached-api ~]# cd /var/www/html/
[root@memcached-api html]# vim test2.php
[root@memcached-api html]#
<?php
$memcache = new Memcached();
$memcache->addServer('192.168.10.240', 11211);
$memcache->set('key', 'Memcache test successful!', 0, 60);
$result = $memcache->get('key');
unset($memcache);
echo $result;
?>
13:测试故障切换
101
bash
[root@memcache1 keepalived]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:90:61:c1 brd ff:ff:ff:ff:ff:ff
inet 192.168.10.101/24 brd 192.168.10.255 scope global ens33
valid_lft forever preferred_lft forever
inet 192.168.10.240/32 scope global ens33
valid_lft forever preferred_lft forever
inet6 fe80::2f4c:60b5:64be:bc1f/64 scope link noprefixroute
valid_lft forever preferred_lft forever
[root@memcache1 keepalived]# pkill memcached
[root@memcache1 keepalived]# netstat -anpt | grep memcached
[root@memcache1 keepalived]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:90:61:c1 brd ff:ff:ff:ff:ff:ff
inet 192.168.10.101/24 brd 192.168.10.255 scope global ens33
valid_lft forever preferred_lft forever
inet6 fe80::2f4c:60b5:64be:bc1f/64 scope link noprefixroute
valid_lft forever preferred_lft forever
[root@memcache1 keepalived]#
102
[root@memcache2 keepalived]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:8f:4c:a4 brd ff:ff:ff:ff:ff:ff
inet 192.168.10.102/24 brd 192.168.10.255 scope global ens33
valid_lft forever preferred_lft forever
inet 192.168.10.240/32 scope global ens33
valid_lft forever preferred_lft forever
inet6 fe80::2f4c:60b5:64be:bc1f/64 scope link tentative noprefixroute dadfailed
valid_lft forever preferred_lft forever
inet6 fe80::9525:f940:b201:bb12/64 scope link noprefixroute
valid_lft forever preferred_lft forever
[root@memcache2 keepalived]# netstat -anpt | grep memcached
tcp 0 0 0.0.0.0:11211 0.0.0.0:* LISTEN 10225/memcached
tcp 0 0 192.168.10.102:60506 192.168.10.101:11212 ESTABLISHED 10225/memcached
tcp6 0 0 :::11211 :::* LISTEN 10225/memcached 10225/memcached
[root@memcache2 keepalived]#