memcached下载地址:http://repcached.sourceforge.net/ #yum install gcc libevent libevent-devel #cd /usr/local/src/ #wget https://sourceforge.net/projects/repcached/files/repcached/2.2.1-1.2.8/memcached-1.2.8-repcached-2.2.1.tar.gz #tar xvf memcached-1.2.8-repcached-2.2.1.tar.gz #cd memcached-1.2.8-repcached-2.2.1 #./configure --prefix=/usr/local/repcached --enable-replication
#make make all-recursive make[1]: Entering directory `/usr/local/src/memcached-1.2.8-repcached-2.2.1‘ Making all in doc make[2]: Entering directory `/usr/local/src/memcached-1.2.8-repcached-2.2.1/doc‘ make[2]: Nothing to be done for `all‘. make[2]: Leaving directory `/usr/local/src/memcached-1.2.8-repcached-2.2.1/doc‘ make[2]: Entering directory `/usr/local/src/memcached-1.2.8-repcached-2.2.1‘ gcc -DHAVE_CONFIG_H -I. -DNDEBUG -g -O2 -MT memcached-memcached.o -MD -MP -MF .deps/memcached-memcached.Tpo -c -o memcached-memcached.o `test -f ‘memcached.c‘ || echo ‘./‘`memcached.c memcached.c: In function ‘add_iov’: memcached.c:697:30: error: ‘IOV_MAX’ undeclared (first use in this function) if (m->msg_iovlen == IOV_MAX || ^ memcached.c:697:30: note: each undeclared identifier is reported only once for each function it appears in make[2]: *** [memcached-memcached.o] Error 1 make[2]: Leaving directory `/usr/local/src/memcached-1.2.8-repcached-2.2.1‘ make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/usr/local/src/memcached-1.2.8-repcached-2.2.1‘ make: *** [all] Error 2 解决方法: [root@centos7 memcached-1.2.8-repcached-2.2.1]#vim memcached.c #ifndef IOV_MAX #if defined(__FreeBSD__) || defined(__APPLE__) # define IOV_MAX 1024 #endif #endif 改为如下内容: /* FreeBSD 4.x doesn‘t have IOV_MAX exposed. */ #ifndef IOV_MAX # define IOV_MAX 1024 #endif
# make && make install
#/usr/local/repcached/bin/memcached -h memcached 1.2.8 repcached 2.2.1 -p <num> TCP port number to listen on (default: 11211) -U <num> UDP port number to listen on (default: 11211, 0 is off) -s <file> unix socket path to listen on (disables network support) -a <mask> access mask for unix socket, in octal (default 0700) -l <ip_addr> interface to listen on, default is INDRR_ANY -d run as a daemon -r maximize core file limit -u <username> assume identity of <username> (only when run as root) -m <num> max memory to use for items in megabytes, default is 64 MB -M return error on memory exhausted (rather than removing items) -c <num> 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 <username> 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 <file> save PID in <file>, only used with -d option -f <factor> chunk size growth factor, default 1.25 -n <bytes> 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 <ip_addr> hostname or IP address of peer repcached -X <num:num> TCP port number for replication. <listen:connect> (default: 11212)
#/usr/local/repcached/bin/memcached -d -m 2048 -p 11211 -u root -c 65536 -x 172.18.141.24 -X 18000 #ss -tnl State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 128 *:11211 *:* LISTEN 0 128 *:22 *:* LISTEN 0 100 127.0.0.1:25 *:* LISTEN 0 128 :::11211 :::*
#/usr/local/repcached/bin/memcached -d -m 2048 -p 11211 -u root -c 65536 -x 172.18.142.3 -X 18000 #ss -tnl State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 128 *:11211 *:* LISTEN 0 128 *:22 *:* LISTEN 0 100 127.0.0.1:25 *:* LISTEN 0 128 :::11211 :::*
# telnet 172.18.141.24 11211 Trying 172.18.141.24... Connected to 172.18.141.24. Escape character is ‘^]‘. set name 0 0 4 jack STORED get name VALUE name 0 4 jack END quit Connection closed by foreign host. # telnet 172.18.142.3 11211 Trying 172.18.142.3... Connected to 172.18.142.3. Escape character is ‘^]‘. get name VALUE name 0 4 jack END quit Connection closed by foreign host.
转自
memcached 双主复制_weixin_34040079的博客-CSDN博客 https://blog.csdn.net/weixin_34040079/article/details/91605661
原文:https://www.cnblogs.com/paul8339/p/12145091.html