天天看点

memcached高可用

memcached-1.2.8-repcached-2.2.tar.gz

tar zxvf memcached-1.2.8-repcached-2.2.tar.gz

cd memcached-1.2.8-repcached-2.2

./configure --prefix=/usr/local/repcached

--with-libevent=/usr/local/libevent/ --enable-replication

--program-transform-name=s/memcached/repcached

make

报错

[root@master memcached-1.2.8-repcached-2.2.1]# vim

memcached.c找到下面这行

/* FreeBSD 4.x doesn‘t have IOV_MAX exposed. */

#ifndef IOV_MAX

#if defined(__FreeBSD__) || defined(__APPLE__)

# define IOV_MAX 1024

#endif

修改为

# define IOV_MAX 1024问题解决

make install

增加

ln -s /usr/local/libevent/lib/libevent-1.4.so.2

/usr/lib64/libevent-1.4.so.2

以其它用户运行

./repcached -d -p 11211 –v-d

 ./repcached -p 11212 -x localhost -v -d

修改端口 

./repcached -p 11311 -d -v -X 11312

./repcached -p 11313 -x 127.0.0.1 -v

-d -X 11312

./repcached -h

memcached 1.2.8

repcached 2.2

-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>

TCP port number for replication (default: 11212)

继续阅读