1、下载, memcached需要先安装libevent
memcached的下载地址:http://danga.com/memcached/download.bml
libevent的下载地址 :http://www.monkey.org/~provos/libevent/
2、安装libevent
检查是否安装成功:
如果有:
libevent-1.4.so.2
libevent-1.4.so.2.0.0
libevent.a
libevent.la
libevent.so
这几个文件存在,说明安装成功。
3、安装memcached
检查是否安装成功:
如果memcached 和memcached-debug这2个文件存在,说明安装成功
4、执行
如果出现:
memcached 1.2.5
-p <num> TCP port number to listen on (default: 11211)
-U <num> UDP port number to listen on (default: 0, 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
-b run a managed instanced (mnemonic: buckets)
-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
说明安装成功,并且路径配置正确。
有可能会出现:
memcached: error while loading shared libraries: libevent-1.4.so.2: cannot open shared object file: No such file or directory
说明没有找到文件:libevent-1.4.so.2
解决办法:
将libevent-1.4.so.2拷贝到任何一个列出的lib下或者软链接就可以了。
或者 修改.profile文件。加入:
启动服务:
参数说明:
-d选项是启动一个守护进程
-m是分配给Memcache使用的内存数量,单位是MB,我这里是10MB
-u是运行Memcache的用户,我这里是root
-l是监听的服务器IP地址
-p是设置Memcache监听的端口,最好是1024以上的端口
-c选项是最大运行的并发连接数,默认是1024,按照你服务器的负载量来设定
-P是设置保存Memcache的pid文件
停止服务:
用# ps -e 查看进程,# kill pid memcached的进程号。
memcached的下载地址:http://danga.com/memcached/download.bml
libevent的下载地址 :http://www.monkey.org/~provos/libevent/
2、安装libevent
- # tar xvf libevent-1.4.4-stable.tar.gz
- # cd libevent-1.4.4-stable
- # ./configure --prefix= /opt/cuix/3rdParty/libevent-1.4.4
- # make
- # make install
# tar xvf libevent-1.4.4-stable.tar.gz
# cd libevent-1.4.4-stable
# ./configure --prefix= /opt/cuix/3rdParty/libevent-1.4.4
# make
# make install
检查是否安装成功:
- #cd /opt/cuix/3rdParty/libevent-1.4.4/lib
#cd /opt/cuix/3rdParty/libevent-1.4.4/lib
如果有:
libevent-1.4.so.2
libevent-1.4.so.2.0.0
libevent.a
libevent.la
libevent.so
这几个文件存在,说明安装成功。
3、安装memcached
- # tar xvf memcached-1.2.5.tar.gz
- # cd memcached-1.2.5
- # ./configure --with-libevent=/opt/cuix/3rdParty/libevent-1.4.4
- --prefix=/opt/cuix/3rdParty/memcached-1.2.5
- # make
- # make install
# tar xvf memcached-1.2.5.tar.gz
# cd memcached-1.2.5
# ./configure --with-libevent=/opt/cuix/3rdParty/libevent-1.4.4
--prefix=/opt/cuix/3rdParty/memcached-1.2.5
# make
# make install
检查是否安装成功:
- # cd 3rdParty/memcached-1.2.5/bin
# cd 3rdParty/memcached-1.2.5/bin
如果memcached 和memcached-debug这2个文件存在,说明安装成功
4、执行
- # cd /opt/cuix/3rdParty/memcached-1.2.5/bin
- # ./memcached -h
# cd /opt/cuix/3rdParty/memcached-1.2.5/bin
# ./memcached -h
如果出现:
引用
memcached 1.2.5
-p <num> TCP port number to listen on (default: 11211)
-U <num> UDP port number to listen on (default: 0, 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
-b run a managed instanced (mnemonic: buckets)
-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
说明安装成功,并且路径配置正确。
有可能会出现:
引用
memcached: error while loading shared libraries: libevent-1.4.so.2: cannot open shared object file: No such file or directory
说明没有找到文件:libevent-1.4.so.2
解决办法:
将libevent-1.4.so.2拷贝到任何一个列出的lib下或者软链接就可以了。
或者 修改.profile文件。加入:
- export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib:/opt/cuix/3rdParty/libevent-1.4.4/lib
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib:/opt/cuix/3rdParty/libevent-1.4.4/lib
启动服务:
- ./memcached -d -m 10 -u cuix -l 10.3.2.36 -p 18887 -c 256 -P /tmp/memcached.pid
./memcached -d -m 10 -u cuix -l 10.3.2.36 -p 18887 -c 256 -P /tmp/memcached.pid
参数说明:
-d选项是启动一个守护进程
-m是分配给Memcache使用的内存数量,单位是MB,我这里是10MB
-u是运行Memcache的用户,我这里是root
-l是监听的服务器IP地址
-p是设置Memcache监听的端口,最好是1024以上的端口
-c选项是最大运行的并发连接数,默认是1024,按照你服务器的负载量来设定
-P是设置保存Memcache的pid文件
停止服务:
用# ps -e 查看进程,# kill pid memcached的进程号。