memcache的好处我就不多废话了,在此我值讲它的安装与使用。
一,memcached和libevent的安装
1.分别把memcached和libevent下载回来,放到 /nad 目录下:
# cd /nad
# wget http://www.danga.com/memcached/dist/memcached-1.2.6.tar.gz
# wget http://www.monkey.org/~provos/libevent-1.4.8-stable.tar.gz
2.先安装libevent:
# cd /nad
# tar zxvf libevent-1.4.8-stable.tar.gz
# cd libevent-1.4.8-stable.tar.gz
# ./configure --prefix=/usr
# make
# make install
测试libevent是否安装成功:
#ls -al /usr/lib | grep libevent
lrwxrwxrwx 1 root root 21 Oct 9 18:21 libevent-1.4.so.2 -> libevent-1.4.so.2.1.2
-rwxr-xr-x 1 root root 222847 Oct 9 18:21 libevent-1.4.so.2.1.2
-rw-r--r-- 1 root root 295754 Oct 9 18:21 libevent.a
-rwxr-xr-x 1 root root 825 Oct 9 18:21 libevent.la
lrwxrwxrwx 1 root root 21 Oct 9 18:21 libevent.so -> libevent-1.4.so.2.1.2
lrwxrwxrwx 1 root root 26 Oct 9 18:21 libevent_core-1.4.so.2 -> libevent_core-1.4.so.2.1.2
-rwxr-xr-x 1 root root 87635 Oct 9 18:21 libevent_core-1.4.so.2.1.2
-rw-r--r-- 1 root root 121744 Oct 9 18:21 libevent_core.a
-rwxr-xr-x 1 root root 860 Oct 9 18:21 libevent_core.la
lrwxrwxrwx 1 root root 26 Oct 9 18:21 libevent_core.so -> libevent_core-1.4.so.2.1.2
lrwxrwxrwx 1 root root 27 Oct 9 18:21 libevent_extra-1.4.so.2 -> libevent_extra-1.4.so.2.1.2
-rwxr-xr-x 1 root root 175803 Oct 9 18:21 libevent_extra-1.4.so.2.1.2
-rw-r--r-- 1 root root 227258 Oct 9 18:21 libevent_extra.a
-rwxr-xr-x 1 root root 867 Oct 9 18:21 libevent_extra.la
lrwxrwxrwx 1 root root 27 Oct 9 18:21 libevent_extra.so -> libevent_extra-1.4.so.2.1.2
3,安装memcached
# cd /nad
# tar zxvf memcached-1.2.6.tar.gz
# cd memcached-1.2.6
# ./configure --with-libevent=/usr
# make
# make install
测试memcached是否安装成功:
# ls -al /usr/local/bin/mem*
-rwxr-xr-x 1 root root 100065 Oct 9 18:27 /usr/local/bin/memcached
-rwxr-xr-x 1 root root 107259 Oct 9 18:27 /usr/local/bin/memcached-debug
4,启动
# cd /nad/memcached-1.2.6
# nohup ./memcached –d –m 500 -u root -l 192.168.0.20 -p 11212 -vv >/nad/memcachedLogs/memcached_1.log &
slab class 1: chunk size 88 perslab 11915
slab class 2: chunk size 112 perslab 9362
slab class 3: chunk size 144 perslab 7281
slab class 4: chunk size 184 perslab 5698
slab class 5: chunk size 232 perslab 4519
slab class 6: chunk size 296 perslab 3542
slab class 7: chunk size 376 perslab 2788
slab class 8: chunk size 472 perslab 2221
slab class 9: chunk size 592 perslab 1771
slab class 10: chunk size 744 perslab 1409
slab class 11: chunk size 936 perslab 1120
slab class 12: chunk size 1176 perslab 891
slab class 13: chunk size 1472 perslab 712
slab class 14: chunk size 1840 perslab 569
slab class 15: chunk size 2304 perslab 455
slab class 16: chunk size 2880 perslab 364
slab class 17: chunk size 3600 perslab 291
slab class 18: chunk size 4504 perslab 232
slab class 19: chunk size 5632 perslab 186
slab class 20: chunk size 7040 perslab 148
slab class 21: chunk size 8800 perslab 119
slab class 22: chunk size 11000 perslab 95
slab class 23: chunk size 13752 perslab 76
slab class 24: chunk size 17192 perslab 60
slab class 25: chunk size 21496 perslab 48
slab class 26: chunk size 26872 perslab 39
slab class 27: chunk size 33592 perslab 31
slab class 28: chunk size 41992 perslab 24
slab class 29: chunk size 52496 perslab 19
slab class 30: chunk size 65624 perslab 15
slab class 31: chunk size 82032 perslab 12
slab class 32: chunk size 102544 perslab 10
slab class 33: chunk size 128184 perslab 8
slab class 34: chunk size 160232 perslab 6
slab class 35: chunk size 200296 perslab 5
slab class 36: chunk size 250376 perslab 4
slab class 37: chunk size 312976 perslab 3
slab class 38: chunk size 391224 perslab 2
slab class 39: chunk size 489032 perslab 2
<6 server listening
<7 send buffer was 110592, now 268435456
<7 server listening (udp)
这样memcache就能使用了。
你在linux命令行上输入
# netstat -lnp
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 192.168.0.20:11211 0.0.0.0:* LISTEN 28311/memcached
就表示memcache已经安装并启动成功。
memcached –d –m 500 -u root -l 192.168.0.20 -p 11212 -c 256 -vv >>/nad/memcachedLogs/memcached_2.log
命令的参数说明
-d选项是启动一个守护进程,
-m是分配给Memcache使用的内存数量,单位是MB,我这里是10MB,
-u是运行Memcache的用户,我这里是root,
-l是监听的服务器IP地址,如果有多个地址的话,我这里指定了服务器的IP地址192.168.0.20
-p是设置Memcache监听的端口,我这里设置了11212,最好是1024以上的端口,
-c选项是最大运行的并发连接数,默认是1024,我这里设置了256,按照你服务器的负载量来设定,
-P是设置保存Memcache的pid文件
posted on 2008-10-10 11:28
分享爱的空间 阅读(345)
评论(0) 编辑 收藏