Memcached的安装

1.安装libevent
libevent是一个事件触发的网络库,适用于windows、linux、bsd等多种平台,内部使用
select、epoll、kqueue等系统调用管理事件机制。memcached也是libevent
based,而且libevent在使用上可以做到跨平台,而且根据libevent官方网站上公布的数据统计,似乎也有着非凡的性能。
The
libevent API provides a mechanism to execute a callback function when a
specific event occurs on a file descriptor or after a timeout has been
reached. Furthermore, libevent also support callbacks due to signals or
regular timeouts.
libevent is meant to replace the event loop found
in event driven network servers. An application just needs to call
event_dispatch() and then add or remove events dynamically without
having to change the event loop.
安装Memcached前需要先安装libevent,下载地址:http://libevent.org/
[root@localhost home]# tar zxvf libevent-2.0.21-stable.tar.gz
[root@localhost home]# cd libevent-2.0.21-stable
[root@localhost libevent-2.0.21-stable]# ./configure
[root@localhost libevent-2.0.21-stable]#make && make install

2.安装Memcached
下载地址:http://memcached.org/
[root@bogon home]# tar zxvf memcached-1.4.15.tar.gz
[root@bogon home]# cd memcached-1.4.15
[root@bogon memcached-1.4.15]# ./configure
[root@bogon memcached-1.4.15]# make && make install
安装完成后,Memcached的默认安装目录是/usr/local/bin/memcached

3.启动Memcached
[root@bogon run]# /usr/local/bin/memcached -m 32m -p 11211 -d -u root -P /var/run/memcached.pid -c 256
启动时可能出现如下错误:
[root@bogon run]# /usr/local/bin/memcached -m 32m -p 11211 -d -u root -P /var/run/memcached.pid -c 256
/usr/local/bin/memcached:
error while loading shared libraries: libevent-2.0.so.5: cannot open
shared object file: No such file or directory
提示找不到libevent-2.0.so.5文件,解决办法是把/usr/local/lib
加入到/etc/ld.so.conf中,/etc/ld.so.conf里保存的是想要读入高速缓存当中的动态函数库所在的目录,过程如下:
[root@bogon run]# echo "/usr/local/lib">>/etc/ld.so.conf
[root@bogon run]# ldconfig    #利用ldconfig这个可执行文件将/etc/ld.so.conf的数据读入到高速缓存中,
[root@bogon script]# ldconfig -p|grep libevent-2.0.so.5    #ldconfig -p 查看libevent-2.0.so.5库已经被读入到高速缓存中了。
libevent-2.0.so.5 (libc6) => /usr/local/lib/libevent-2.0.so.5
启动过程参数说明:

-p:使用TCP端口。默认是11211.
-m:最大内存的大小。默认是64M。
-vv:以very vrebose模式启动,将调试信息和错误输出到控制台。
-d:做为守护进程在后台运行。
-c:最大运行的并发连接数,默认是1024,按照服务器的负载量来设定。
-P :设置保存Memcached的pid文件。
-l:监听的服务器IP地址,如果有多个地址。
-u:运行Memcached的用户,默认不能由root用户启动,所以当前用户为root时需要利用-u参数来指定。
通过/usr/local/bin/memcached -h命令可以显示所有可选项:
[root@bogon run]# /usr/local/bin/memcached -h
memcached 1.4.15
-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 <addr>    interface to listen on (default: INADDR_ANY, all addresses)
            <addr> may be specified as host:port. If you don't specify
            a port number, the value you specified with -p or -U is
            used. You may specify multiple addresses separated by comma
            or by using -l multiple times
-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: 64 MB)
-M            return error on memory exhausted (rather than removing items)
-c <num>      max simultaneous connections (default: 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)
-vvv          extremely verbose (also print internal state transitions)
-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.
-D <char>    Use <char> as the delimiter between key prefixes and IDs.
            This is used for per-prefix stats reporting. The default is
            ":" (colon). If this option is specified, stats collection
            is turned on automatically; if not, then it may be turned on
            by sending the "stats detail on" command to the server.
-t <num>      number of threads to use (default: 4)
-R            Maximum number of requests per event, limits the number of
            requests process for a given connection to prevent
            starvation (default: 20)
-C            Disable use of CAS
-b            Set the backlog queue limit (default: 1024)
-B            Binding protocol - one of ascii, binary, or auto (default)
-I            Override the size of each slab page. Adjusts max item size
            (default: 1mb, min: 1k, max: 128m)
-o            Comma separated list of extended or experimental options
            - (EXPERIMENTAL) maxconns_fast: immediately close new
              connections if over maxconns limit
            - hashpower: An integer multiplier for how large the hash
              table should be. Can be grown at runtime if not big enough.
              Set this based on "STAT hash_power_level" before a
              restart.

4.关闭Memcached

关闭Memcached的命令如下:
[root@bogon script]# kill `cat /var/run/memcached.pid`  #注意是返单引号。

5.安装Memcache的PHP扩展

下载地址:http://pecl.php.net/package/memcache 我下载的是memcache-2.2.7.tgz稳定版
[root@bogon home]# tar zxvf memcache-2.2.7.tgz
[root@bogon home]# cd memcache-2.2.7
执行phpize扩展安装程序,假设phpzie的路径为/usr/local/php/bin/phpize,具体的路径得根据自己的环境修改。
/usr/local/php/bin/phpize

Memcached的安装和应用的更多相关文章

  1. Memcached的安装(Linux)、操作、命令

    最近在整理有关分布式缓存的服务器,做了一下老牌nosql服务器memcached的学习总结.文中所述的所有安装均是在联网的情况下进行的. 序: 什么是memcached: Free & ope ...

  2. Memcached总结二:Memcached环境安装设置以及连接memcache服务器

    1 在Ubuntu上安装Memcached 要在Ubuntu上安装Memcached,打开终端,然后输入以下命令: $sudo apt-get update $sudo apt-get install ...

  3. PHP与memcache和memcached以及安装使用

    老规则,在作者寒冰讲之前我们要来明确memcache与memcached这两个东西到底是什么? 说法一: 两个不同版本的php的memcached的客户端 new memcache是pecl扩展库版本 ...

  4. memcached的安装和linux下memcached服务自启动的配置

    关于memcached在windows和linux环境的安装,以及在Linux系统系memcached服务自启动的配置,可以参考我在csdn上下的博客, windows和linux环境下memcach ...

  5. Memcached服务安装

    安装Memcached服务 memcache分为服务端和客户端程序 服务端程序用来支持存储k-v值,程序名称memcached 客户端与服务端通信,进行存取值(常用的如php的memcache扩展,m ...

  6. memcached的安装以及php两个扩展软件安装(memcache、memcached)

    百度云安装包:http://pan.baidu.com/s/1pKZeDwn  k3ap 1.安装memcached Memcached是基于libevent的事件处理,所以它的安装依赖libeven ...

  7. Memcached的安装与使用

    这一段折腾了下Memcached,有所收获吧,记录一下. 1.什么是Memcached memcached是一种缓存技术, 他可以把你的数据放入内存,从而通过内存访问提速,因为内存最快的, memca ...

  8. Memcached下载安装、NET对Memcached进行CRUD操作(2)

    Memcached概念.作用.运行原理.特性.不足简单梳理(1) Memcached下载安装.NET对Memcached进行CRUD操作(2) Memcached存Session数据.访问安全性.使用 ...

  9. memcached/memcache安装

    memcached安装 查找memcached:        yum  search  memcached安装 memcached             yum  -y install memca ...

  10. linux-CentOS6.4安装Memcached+memcached扩展+安装memcache扩展+Memcache+mecached同步SESSION的几种方法

    一.编译环境的准备 yum install gcc  yum install gcc-c++ libstdc++-devel  yum install zlib-devel 二.源代码包准备 wget ...

随机推荐

  1. hdoj2159【二位费用背包】

    题意: 略: 推荐看一下那个背包九讲,第五讲非常清晰啊. 原文: 算法 费用加了一维,只需状态也加一维即可.设f[i][v][u]表示前i件物品付出两种代价分别为v和u时可获得的最大价值.状态转移方程 ...

  2. hdoj1176【DP】

    DP基础吧.A掉还是挺爽的.就是考虑在两端只能是从前一秒的内部一米或原来的点来进行,但是在5秒以内可到达点是逐渐外扩的,并不是[0,10],所以就特殊考虑了一下.后面两端是0和10,中间的点可以从上一 ...

  3. Gist使用经验

    注:本文只是分享Gist使用经验,不讨论类似软件或服务的优劣,对于技术或软件不要有傲慢与偏见 一.Gist是什么 关于Gist的详细介绍,请阅读官方文档About gists,下面只简略介绍我所用到的 ...

  4. (九)SpringBoot整合redis框架

    二:添加Redis依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactI ...

  5. Ubuntu解决中文乱码

    gsettings set org.gnome.gedit.preferences.encodings candidate-encodings "['GB18030', 'UTF-8', ' ...

  6. iOS 上传的图片在HTML上显示时,图片方向信息(EXIF Orientation)异常

    将iPhone 6s拍摄的照片上传到服务器之后, 在Web网页上看到图片被逆时针旋转了90度, 这让我很惆怅呐! 出现这个问题其实是因为上传的图片为.jpg格式,.jpg文件含有EXIF信息, 其中E ...

  7. 【数据结构(C语言版)系列四】 串

    串类型的定义 串(或字符串)是由零个或多个字符组成的有限序列,一般记为 s = 'a1a2...an',s为串名.子串在主串中的位置以子串的第一个字符在主串中的位置来表示. 串和表示和实现——定长顺序 ...

  8. Ilya And The Tree CodeForces - 842C

    ((半个)智商题,主要难度在于实现) 题意:有一棵n个结点组成的树,其根是编号为1的结点.对于每一个结点,生成从根结点走到这个结点的路径(包括自身),选择路径上的一个点或者不选择任何点,使得其它点的最 ...

  9. C. Jon Snow and his Favourite Number DP + 注意数值大小

    http://codeforces.com/contest/768/problem/C 这题的数值大小只有1000,那么可以联想到,用数值做数组的下标,就是类似于计数排序那样子.. 这样就可以枚举k次 ...

  10. Apache Kylin的架构特性

    不多说,直接上干货! http://kylin.apache.org/cn/ 可扩展的超快OLAP引擎,提供标准SQL查询接口 支持单机或集群部署,为减少在Hadoop上百亿规模数据查询延迟而设计: ...