wget http://softlayer-dal.dl.sourceforge.net/project/repcached/repcached/2.2.1-1.2.8/repcached-2.2.1-1.2.8.patch.gz
gzip -cd ../repcached-2.2.1-1.2.8.patch.gz | patch -p1
./configure --enable-replication
make && make install 方式二:整合版本安装
1. 安装libevent:
cd /tmp
wget http://downloads.sourceforge.net/levent/libevent-2.0.22-stable.tar.gz
tar zxvf libevent-2.0.22-stable.tar.gz
cd libevent-2.0.22-stable
./configure --prefix=/usr/local/lib
make && make install 2. 将libevent的库文件添加到动态库中:
vi /etc/ld.so.conf
在最后添加如下行:
/usr/local/lib //此处为要添加的libevent库目录
重新加载动态lib库
memcached 1.2.8
repcached 2.2.1
-p TCP port number to listen on (default: 11211)
-U UDP port number to listen on (default: 11211, 0 is off)
-s unix socket path to listen on (disables network support)
-a access mask for unix socket, in octal (default 0700)
-l interface to listen on, default is INDRR_ANY
-d run as a daemon
-r maximize core file limit
-u assume identity of (only when run as root)
-m max memory to use for items in megabytes, default is 64 MB
-M return error on memory exhausted (rather than removing items)
-c max simultaneous connections, default is 1024
-k lock down all paged memory. Note that there is a
limit on how much memory you may lock. Trying to
allocate more than that would fail, so be sure you
set the limit correctly for the user you started
the daemon with (not for -u user;
under sh this is done with 'ulimit -S -l NUM_KB').
-v verbose (print errors/warnings while in event loop)
-vv very verbose (also print client commands/reponses)
-h print this help and exit
-i print memcached and libevent license
-P save PID in , only used with -d option
-f chunk size growth factor, default 1.25
-n minimum space allocated for key+value+flags, default 48
-R Maximum number of requests per event
limits the number of requests process for a given con nection
to prevent starvation. default 20
-b Set the backlog queue limit (default 1024)
-x hostname or IP address of peer repcached
-X TCP port number for replication. (default: 11212)
修改memcached目录所有者:
cd ..
chown -R memcached.memcached memcached 配置主从复制
在Master创建数据:
[root@test01 bin]# telnet 192.168.11.51 11211Trying 192.168.11.51...
Connected to 192.168.11.51.
Escape character is '^]'.
get key1
END
set key1 0 0 2
aa
STORED
quit
Connection closed by foreign host. 在Slave获取数据:
[root@test02 bin]# telnet 192.168.11.52 11211Trying 192.168.11.52...
Connected to 192.168.11.52.
Escape character is '^]'.
get key1
END
get key1
VALUE key1 0 2
aa
END
quit
Connection closed by foreign host. 在Slave创建数据:
[root@test02 bin]# telnet 192.168.11.52 11211Trying 192.168.11.52...
Connected to 192.168.11.52.
Escape character is '^]'.
get key2
END
set key2 0 0 3
b
STORED
get key2
VALUE key2 0 3
b
END
quit
Connection closed by foreign host. 在Master获取数据:
[root@test01 bin]# telnet 192.168.11.51 11211Trying 192.168.11.51...
Connected to 192.168.11.51.
Escape character is '^]'.
get key2
VALUE key2 0 3
b
END
quit
Connection closed by foreign host. Memcached高可用