准备工作
- 查看solaris内核 使用 uname -a 命令即可
- 查看gcc版本 使用 gcc -v 命令 (本次测试是 gcc version 3.4.6)
- 下载 libevent:http://www.monkey.org/~provos/libevent/
- 下载 memcached :http://code.google.com/p/memcached/downloads/list
因此此次选择了 libevent-1.4.12-stable.tar.gz 以及 memcached-1.2.8.tar.gz
准备安装
- solaris下安装memcached,需要先编译libevent,而编译libevent,需要配置gcc和make
- 解压 将2个文件上传至服务器 /opt/kpiroot/zhenpei/libevent-1.4.12-stable.tar.gz /opt/kpiroot/zhenpei/memcached-1.2.8.tar.gz
gzip -d libevent-1.4.12-stable.tar.gz
tar xvf libevent-1.4.12-stable.tar
gzip -d memcached-1.2.8.tar.gz
tar xvf memcached-1.2.8.tar
安装libevent
切换至root账号
# cd opt/kpiroot/zhenpei/libevent-1.4.12-stable
# ./configure --prefix= /opt/kpiroot/libevent (准备安装到的地址--自己某个用户下的地址)
# make
# make install
检查是否安装成功:
进入
# cd /opt/kpiroot/libevent/lib
如果有:
libevent-1.4.so.2
libevent-1.4.so.2.0.0
libevent.a
libevent.la
libevent.so
这几个文件存在,说明安装成功
安装 memcached
切换至root账号
# cd memcached-1.4.2
# ./configure --with-libevent=/opt/kpiroot/libevent --prefix=/opt/kpiroot/memcached
# make
# make install
#cd /opt/kpiroot/memcached
#memcached -h
如果报错 如 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 用 find / -name libevent-1.4.so.2
第二步:#LD_DEBUG=libs ./memcached -v
此时会打出很多东西 找到报libevent-1.4.so.2真正指向的地址
第三步:#ln -s /opt/kpiroot/libevent/lib/libevent-1.4.so.2 /usr/lib/libevent-1.4.so.2 (我机器上是这个地址,服务器不同地址可能不同)
第四步:#memcached -h 如还有报错,则重复上述过程 正确时是:
memcached 1.2.8
-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
-L Try to use large memory pages (if available). Increasing
the memory page size could reduce the number of TLB misses
and improve the performance. In order to get large pages
from the OS, memcached will allocate the total item-cache
in one large chunk.
-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)