由于memcached安装时,需要使用libevent类库,所以先安装libevent
libevent下载网址:
http://www.monkey.org/~provos/libevent/
本手册中下载的是 libevent-1.4.8-stable.tar.gz版本安装步骤如下:
1. 解压缩
tar xzfv libevent-1.4.8-stable.tar.gz
2. 进入到 libevent-1.4.8-stable目录
cd libevent-1.4.8-stable
3. 编译,安装
./configure
make
make install
注:默认安装到
/usr/local/lib/目录
接下来,安装memcached
memcached下载网址:
http://www.danga.com/memcached/download.bml
本手册中下载的是 memcached-1.2.6.tar.gz版本
安装步骤如下:
1. 解压缩
tar xzfv memcached-1.2.6.tar.gz
2. 进入到 memcached-1.2.6目录
cd memcached-1.2.6
3. 编译,安装
./configure --prefix=/local/memcached
make
make install
安装完成后,会在 /local/memcached 出现 bin和share目录
进行 bin目录,启动 memcache
方法如下:
./memcached -d -u nobody -m 512 127.0.0.1 -p 11211
此时,会报一个异常
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类库,解决办法如下:
使用LD_DEBUG=help ./memcached -v来确定 加载的类库路径,方法如下:
LD_DEBUG=libs ./memcached -v 2>&1 > /dev/null | less
则系统会显示:
linux:/local/memcached/bin # LD_DEBUG=libs ./memcached -v 2>&1 > /dev/null | less
20421: find library=libevent-1.4.so.2; searching
20421: search cache=/etc/ld.so.cache
20421: search path=/lib/tls/i686/sse2:/lib/tls/i686:/lib/tls/sse2:/lib/tls:/lib/i686/sse2:/lib/i686:/lib/sse2:/lib:/usr/lib/tls/i686
/sse2:/usr/lib/tls/i686:/usr/lib/tls/sse2:/usr/lib/tls:/usr/lib/i686/sse2:/usr/lib/i686:/usr/lib/sse2:/usr/lib (system search path)
20421: trying file=/lib/tls/i686/sse2/libevent-1.4.so.2
20421: trying file=/lib/tls/i686/libevent-1.4.so.2
20421: trying file=/lib/tls/sse2/libevent-1.4.so.2
20421: trying file=/lib/tls/libevent-1.4.so.2
20421: trying file=/lib/i686/sse2/libevent-1.4.so.2
20421: trying file=/lib/i686/libevent-1.4.so.2
20421: trying file=/lib/sse2/libevent-1.4.so.2
20421: trying file=/lib/libevent-1.4.so.2
20421: trying file=/usr/lib/tls/i686/sse2/libevent-1.4.so.2
20421: trying file=/usr/lib/tls/i686/libevent-1.4.so.2
20421: trying file=/usr/lib/tls/sse2/libevent-1.4.so.2
20421: trying file=/usr/lib/tls/libevent-1.4.so.2
20421: trying file=/usr/lib/i686/sse2/libevent-1.4.so.2
20421: trying file=/usr/lib/i686/libevent-1.4.so.2
20421: trying file=/usr/lib/sse2/libevent-1.4.so.2
20421: trying file=/usr/lib/libevent-1.4.so.2
20421:
./memcached: error while loading shared libraries: libevent-1.4.so.2: cannot open shared object file: No such file or directory
我们看到,memcached会到很多地方去找,所以根据其它求,我们只需建一个软链接,指定到我们安装的类库上即可
方法如下:
ln -s /usr/local/lib/libevent-1.4.so.2 /lib/libevent-1.4.so.2
现在可以正常启动memcached了
./memcached -d -u nobody -m 512 127.0.0.1 -p 11211
到这里,看到memcached已经启动,说明安装成功。
memcache启动参数说明:
The options for memcached are:
-l <ip_addr>
Listen on <ip_addr>; default to INDRR_ANY. This is an important option to consider as there is no other way to secure the installation. Binding to an internal or firewalled network interface is suggested.
-d
Run memcached as a daemon.
-u <username>
Assume the identity of <username> (only when run as root).
-m <num>
Use <num> MB memory max to use for object storage; the default is 64 megabytes.
-M
Instead of throwing items from the cache when max memory is reached, throw an error
-c <num>
Use <num> max simultaneous connections; the default is 1024.
-k
Lock down all paged memory. This is a somewhat dangerous option with large caches, so consult the README and memcached homepage for configuration suggestions.
-p <num>
Listen on port <num>, the default is port 11211.
-r
Maximize core file limit
-M
Disable automatic removal of items from the cache when out of memory. Additions will not be possible until adequate space is freed up.
-r
Raise the core file size limit to the maximum allowable.
-h
Show the version of memcached and a summary of options.
-v
Be verbose during the event loop; print out errors and warnings.
-vv
Be even more verbose; same as -v but also print client commands and responses.
-i
Print memcached and libevent licenses.
-P <filename>
Print pidfile to <filename>, only used under -d option.
Good Luck!
Yours Matthew!
posted on 2008-11-12 12:47
x.matthew 阅读(5470)
评论(3) 编辑 收藏 所属分类:
其它