Memcached主从同步备份负载配置
2016-04-06 23:20
531 查看
http://blog.csdn.net/liufeng93/article/details/40614985
猫爪实习,带我的师兄让我寻找Memcached主从热备份的解决方案。一番折腾,blog找了一大堆,终于磕磕绊绊搞定了。很多blog写的不全,magent安装出错而无法进行Memcached代理,所以想自己整理一番,以备后用。
操作系统:Ubuntu 64位
所需软件:libevent-1.4.9-stable.tar.gz、memcached-1.2.8.tar.gz、memcached-1.2.8-repcached-2.2.tar.gz、magent-0.5.tar.gz
安装过程:
1、提升至root权限,在tmp目录下新建memcached文件夹,将上述4个压缩包复制到文件夹下
cd /tmp
mkdir memcached
2、安装libevent
tar zxvf libevent-1.4.9-stable.tar.gz
cd libevent-1.4.9-stable
./configure --prefix=/usr
make
make install
cd ..
3、安装memcached
tar zxvf memcached-1.2.8.tar.gz
cd memcached-1.2.8
./configure –with-libevent=/usr
make
make install
cd ..
4、安装memcached-repcached
tar zxvf memcached-1.2.8-repcached-2.2.tar.gz
cd memcached-1.2.8-repcached-2.2
./configure –enable-replication
make
make install
cd ..
5、安装magent
mkdir magent
cp magent-0.5.tar.gz magent
cd magent
tar zxvf magent-0.5.tar.gz
vi ketama.h
在开头加入
#ifndef SSIZE_MAX
# define SSIZE_MAX 32767
#endif
vim Makefile
CFLAGS = -Wall -O2 -g 改为 CFLAGS = -lrt -Wall -O2 -g
mkdir /usr/lib64
cp /usr/lib/libevent.a /usr/lib64
ln -s /usr/lib64/libm.so /usr/lib64/libm.a
/sbin/ldconfig
sed -i "s#LIBS = -levent#LIBS = -levent -lm#g" Makefile
make
cp magent /usr/bin/magent
cd ..
测试流程:
1、开启代理,代理端口是12000,设置127.0.0.1:11211为主服务器,127.0.0.1:11212为从服务器
magent -u root -p 12000 -s 127.0.0.1:11211 -b 127.0.0.1:11212
2、启动两个memcached进程,在11111端口进行同步
./memcached -u root -d -l 127.0.0.1 -p 11211 -x 127.0.0.1 -X 11111
./memcached -u root -d -l 127.0.0.1 -p 11212 -x 127.0.0.1 -X 11111
3、从代理服务器写入数据,然后查看两个memcached进程内是否存在数据
4、关掉主服务器,从代理和从服务器查看是否能够查询到结果
5、重新启动在11211端口监听的memcached进程,查询其上是否存在数据
至此,完毕。
猫爪实习,带我的师兄让我寻找Memcached主从热备份的解决方案。一番折腾,blog找了一大堆,终于磕磕绊绊搞定了。很多blog写的不全,magent安装出错而无法进行Memcached代理,所以想自己整理一番,以备后用。
操作系统:Ubuntu 64位
所需软件:libevent-1.4.9-stable.tar.gz、memcached-1.2.8.tar.gz、memcached-1.2.8-repcached-2.2.tar.gz、magent-0.5.tar.gz
安装过程:
1、提升至root权限,在tmp目录下新建memcached文件夹,将上述4个压缩包复制到文件夹下
cd /tmp
mkdir memcached
2、安装libevent
tar zxvf libevent-1.4.9-stable.tar.gz
cd libevent-1.4.9-stable
./configure --prefix=/usr
make
make install
cd ..
3、安装memcached
tar zxvf memcached-1.2.8.tar.gz
cd memcached-1.2.8
./configure –with-libevent=/usr
make
make install
cd ..
4、安装memcached-repcached
tar zxvf memcached-1.2.8-repcached-2.2.tar.gz
cd memcached-1.2.8-repcached-2.2
./configure –enable-replication
make
make install
cd ..
5、安装magent
mkdir magent
cp magent-0.5.tar.gz magent
cd magent
tar zxvf magent-0.5.tar.gz
vi ketama.h
在开头加入
#ifndef SSIZE_MAX
# define SSIZE_MAX 32767
#endif
vim Makefile
CFLAGS = -Wall -O2 -g 改为 CFLAGS = -lrt -Wall -O2 -g
mkdir /usr/lib64
cp /usr/lib/libevent.a /usr/lib64
ln -s /usr/lib64/libm.so /usr/lib64/libm.a
/sbin/ldconfig
sed -i "s#LIBS = -levent#LIBS = -levent -lm#g" Makefile
make
cp magent /usr/bin/magent
cd ..
测试流程:
1、开启代理,代理端口是12000,设置127.0.0.1:11211为主服务器,127.0.0.1:11212为从服务器
magent -u root -p 12000 -s 127.0.0.1:11211 -b 127.0.0.1:11212
2、启动两个memcached进程,在11111端口进行同步
./memcached -u root -d -l 127.0.0.1 -p 11211 -x 127.0.0.1 -X 11111
./memcached -u root -d -l 127.0.0.1 -p 11212 -x 127.0.0.1 -X 11111
3、从代理服务器写入数据,然后查看两个memcached进程内是否存在数据
4、关掉主服务器,从代理和从服务器查看是否能够查询到结果
5、重新启动在11211端口监听的memcached进程,查询其上是否存在数据
至此,完毕。
相关文章推荐
- 转载:分布式Session共享:tomcat+memcached实现session共享
- 采用Memcached实现分布式Session
- 采用Memcached实现分布式Session
- Memcached安装与配置
- Memcached安装与配置
- centos安装memcached服务
- 面试题之Memcached与Redis的区别
- .NET下实现分布式缓存系统Memcached
- Nginx+Memcached+Tomcat集群配置实践(Sticky Session)
- 第三方缓存软件:Redis 和 Memcached
- memcache 未授权访问漏洞
- 使用Memcached提高.NET应用程序的性能
- php7 install memcache extension
- php7 install memcached extension
- PHP操作Memcache基本函数
- Linux下PHP安装Memcache扩展
- PHP使用Memcache来存储session
- Linux下Memcache安装
- memcache的介绍与操作
- Memcache 和 Radis 比较