memcache 主从配置
Rehat 6.0 server 版本配置memcahed 主从关系据说: memcached配置主从关系,必须得用repcached 版本或repcached插件 !
下载地址: http://sourceforge.net/projects/repcached/files/repcached/
下载memcache 2.21-1.2.8-replication2.2.1.tar.gz 带插件的版本
安装此版本的memcached 必须有libevent支持
下载libevent-1.4.10-stable.tar.gz 切勿最新版本(可能会有replicarion-service错误!)
下载地址:https://github.com/downloads/libevent/libevent/libevent-1.4.10-stable.tar.gz
安装 libevent:
# tar -zxvf libevent-1.4.10-stable.tar.gz
# cd libevent-1.4.10-stable
# ./configure --prefix=/usr/local/libevent
# make && make install
# cp /usr/local/libevent/lib/libevent-1.4.so.2 /usr/lib/
PS:必须把 libevent-1.4.so.2 复制到/usr/lib 目录下 否则安装memcached会报错!
安装 memcached
# tar -xzfv memcached-1.2.8.tar.gz -C /usr/local/
# cd /usr/local
# mv memcached-1.2.8 memcached
# cd memcached
# ./configure --prefix=/usr/local/memcached --with-libevent=/usr/local/libevent --enable-replication
# make && make install
按同样的方式安装到例外一台机器上.
启动memcached:
在172.19.121.125上执行
# ./memcached -d -m 256 -x 172.19.121.162 -u root -p 11211 -v
# replication: connect (peer=172.19.121.162:11212)
replication: marugoto copying
在172.19.121.162上执行
# ./memcached -d -m 256 -x 172.19.121.125 -u root -p 11211 -v
# replication: connect (peer=172.19.121.125:11212)
replication: marugoto copying
测试:
# telnet 172.19.121.162 11211
Trying 172.19.121.162...
Connected to 172.19.121.162.
Escape character is '^]'.
set usetid 0 0 6
123456
STORED
get usetid
VALUE usetid 0 6
123456
END
查看172.19.121.125 上的memcached
# telnet 172.19.121.125 11211
Trying 172.19.121.125...
Connected to 172.19.121.125.
Escape character is '^]'.
get usetid
VALUE usetid 0 6
123456
END
至此memcached 主从配置完成。
若telnet 命令不可用,可使用yum命令安装: yum telnet install
yum配置参考: http://xjward.iteye.com/blog/1837074
memcacahed安装 参考:http://www.mohancheema.net/howtos/install-memcached-with-repcached-built-in-server-side-replication
页:
[1]