码迷,mamicode.com
首页 > 系统相关 > 详细

memcached安装

时间:2015-04-02 13:23:34      阅读:229      评论:0      收藏:0      [点我收藏+]

标签:

系统环境:

[root@DBSERVER ~]# uname -a
Linux DBSERVER 2.6.18-274.el5 #1 SMP Fri Jul 8 17:36:59 EDT 2011 x86_64 x86_64 x86_64 GNU/Linux
[root@DBSERVER ~]# cat /etc/redhat-release 
Red Hat Enterprise Linux Server release 5.7 (Tikanga)

所需软件:

libevent-2.0.22-stable.tar.gz

memcached-1.4.22.tar.gz 

安装环境:

1、简历所需目录:

[root@DBSERVER ~]# mkdir -p /usr/local/webserver
[root@DBSERVER ~]# mkdir -p /usr/local/webserver/memcached
[root@DBSERVER ~]# chmod 775 -R /usr/local/webserver

2、升级所需的库:

yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers patch autoconf213.noarch unzip gzip libtool-ltdl libtool-ltdl-devel libaio

3、编辑编译时使用的动态链接库的路径

#将/etc/ld.so.conf列出的路径下的库文件 缓存到/etc/ld.so.cache 以供使用

#修改ld.so.conf增加新的库路径后,需要运行一下/sbin/ldconfig

#在任何目录下运行都可以

[root@DBSERVER ~]# cat /etc/ld.so.conf
include ld.so.conf.d/*.conf
/usr/lib
/usr/local/lib
/usr/lib64
[root@DBSERVER ~]# /sbin/ldconfig  ##使之生效

 

4、安装依赖环境:

[root@DBSERVER ~]# tar -xf libevent-2.0.22-stable.tar.gz 
[root@DBSERVER ~]# cd libevent-2.0.22-stable
[root@DBSERVER libevent-2.0.22-stable]# ./configure
[root@DBSERVER libevent-2.0.22-stable]# make && make install

5、安装memcached:

[root@DBSERVER ~]# tar -xf memcached-1.4.22.tar.gz 
[root@DBSERVER ~]# cd memcached-1.4.22
[root@DBSERVER memcached-1.4.22]# ls
aclocal.m4  compile       daemon.c    items.h         memcached_dtrace.d  protocol_binary.h  slabs.h         timedrun.c
assoc.c     config.guess  depcomp     jenkins_hash.c  memcached.h         README.md          solaris_priv.c  trace.h
assoc.h     config.h.in   doc         jenkins_hash.h  memcached.spec      sasl_defs.c        stats.c         util.c
AUTHORS     config.sub    hash.c      m4              missing             sasl_defs.h        stats.h         util.h
cache.c     configure     hash.h      Makefile.am     murmur3_hash.c      scripts            t               version.m4
cache.h     configure.ac  install-sh  Makefile.in     murmur3_hash.h      sizes.c            testapp.c
ChangeLog   COPYING       items.c     memcached.c     NEWS                slabs.c            thread.c
[root@DBSERVER memcached-1.4.22]# ./configure --prefix=/usr/local/webserver/memcached/ --with-libevent=/usr/local
[root@DBSERVER memcached-1.4.22]# make && make install

6、启动memcached:

[root@DBSERVER bin]# ps aux|grep memcached
root     12075  0.0  0.0  61200   756 pts/1    R+   19:32   0:00 grep memcached
[root@DBSERVER bin]# ./memcached -d -m 256 -u root -p 11211
[root@DBSERVER bin]# netstat -tpnl|grep memcached                 
tcp        0      0 0.0.0.0:11211               0.0.0.0:*                   LISTEN      12078/memcached     
[root@DBSERVER bin]# ps aux|grep memcached                        
root     12078  0.0  0.1  64788  1056 ?        Ssl  19:33   0:00 ./memcached -d -m 256 -u root -p 11211
root     12095  0.0  0.0  61200   756 pts/1    R+   19:33   0:00 grep memcached
指定保存进程文件启动:

 [root@DBSERVER bin]# ./memcached -d -m 256 -u root -p 11211 -P /tmp/memcached.pic
 [root@DBSERVER bin]# cat /tmp/memcached.pic
 12117

连接memcached,并且使用:
[root@DBSERVER bin]# telnet localhost 11211 Trying 172.31.213.231... Connected to localhost.localdomain (172.31.213.231). Escape character is ^]. set Uid 0 0 5 12345 STORED get Uid VALUE Uid 0 5 12345 END gets Uid VALUE Uid 0 5 1 12345 END

常用命令:

启动/结束
memcached -d -m 10 -u root -l 192.168.0.122 -p 11200 -c 256 -P /tmp/memcached.pid
-d 选项是启动一个守护进程, 
-m 是分配给Memcache使用的内存数量,单位是MB,这里是10MB
-u 是运行Memcache的用户,这里是root
-l 是监听的服务器IP地址,如果有多个地址的话,这里指定了服务器的IP地址192.168.0.122 
-p 是设置Memcache监听的端口,这里设置了12000,最好是1024以上的端口
-c 选项是最大运行的并发连接数,默认是1024,这里设置了256,按照你服务器的负载量来设定
-P 是设置保存Memcache的pid文件
kill `cat /tmp/memcached.pid`

echo stats | nc 192.168.1.123 11200
watch "echo stats | nc 192.168.1.123 11200" (实时状态)

[root@DBSERVER bin]# echo stats | nc 172.31.213.231 11211
STAT pid 12078
STAT uptime 225
STAT time 1427888213
STAT version 1.4.22
STAT libevent 2.0.22-stable
STAT pointer_size 64
STAT rusage_user 0.001999
STAT rusage_system 0.001999
STAT curr_connections 5
STAT total_connections 7
STAT connection_structures 6
STAT reserved_fds 20
STAT cmd_get 2
STAT cmd_set 1
STAT cmd_flush 0
STAT cmd_touch 0
STAT get_hits 2
STAT get_misses 0
STAT delete_misses 0
STAT delete_hits 0
STAT incr_misses 0
STAT incr_hits 0
STAT decr_misses 0
STAT decr_hits 0
STAT cas_misses 0
STAT cas_hits 0
STAT cas_badval 0
STAT touch_hits 0
STAT touch_misses 0
STAT auth_cmds 0
STAT auth_errors 0
STAT bytes_read 53
STAT bytes_written 64
STAT limit_maxbytes 268435456
STAT accepting_conns 1
STAT listen_disabled_num 0
STAT threads 4
STAT conn_yields 0
STAT hash_power_level 16
STAT hash_bytes 524288
STAT hash_is_expanding 0
STAT malloc_fails 0
STAT bytes 73
STAT curr_items 1
STAT total_items 1
STAT expired_unfetched 0
STAT evicted_unfetched 0
STAT evictions 0
STAT reclaimed 0
STAT crawler_reclaimed 0
STAT lrutail_reflocked 0
END

 

memcached安装

标签:

原文地址:http://www.cnblogs.com/cheerong/p/4386520.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!