在很多大型网站或者是资讯类站点下往往都会有海量的查询,那么为了减小数据库的压力就出现了缓存系统,现在比较流行的缓存系统有很多,如memcache、Xcache、redis等等,在这里就简单的说说开源的memcache的简单部署和使用。
memcache的使用要依赖于libevent网络库,所以在安装memcache之前必需要先安装libevent网络库然后再安装memcache,这里在二者的官网上都有稳定版的二进制包下载。libevent官网:http://libevent.org/,memcache官网:http://memcached.org/
[[email protected] src]# wget [[email protected] src]# wget [[email protected] src]# tar -zxvf libevent-2.1.8-stable.tar.gz [[email protected] src]# tar -zxvf memcached-1.4.34.tar.gz [[email protected] src]# cd libevent-2.1.8-stable [[email protected] libevent-2.1.8-stable]# ./configure --prefix=/usr/local/libevent [[email protected] libevent-2.1.8-stable]# make && make install [[email protected] libevent-2.1.8-stable]# cd ../memcached-1.4.34 [[email protected] memcached-1.4.34]# ./configure --prefix=/usr/local/memchached --with-libevent=/usr/local/libevent [[email protected] memcached-1.4.34]# make && make install#实际到这一步基本安装就完毕了,但是最好还是要配置下相应环境 [[email protected] memcached-1.4.34]# cd /usr/local/ [[email protected] local]# ln -sv /usr/local/libevent/include/* /usr/include/#添加lib和include [[email protected] local]# ln -sv /usr/local/memchached/include/* /usr/include/ [[email protected] local]# cd /etc/ld.so.conf.d/ [[email protected] ld.so.conf.d]# vim libevent.conf /usr/local/libevent/lib [[email protected] ld.so.conf.d]# ldconfig [[email protected] ld.so.conf.d]# cd /etc/profile.d/#添加bin文件的环境路径 [[email protected] profile.d]# vim libevent.sh /usr/local/libevent/bin [[email protected] profile.d]# source libevent.sh [[email protected] profile.d]# vim memcache.sh /usr/local/memchached/bin [[email protected] profile.d]# source memcache.sh
如此memcache的服务端部署就完成了,这里就说明下memcache的常用参数选项:
-d:用守护进程启动 -m:以兆字节分配memcache的内存,缺省是64M -u:仅当以root是用户启动时,确定memcache的启动用户 -p:用tcp端口指定memcache的监听端口,缺省是11211 -U:用udp端口指定memcache的监听端口,缺省是11211,0表示关闭 -c:确定memcache的最大并发连接数,缺省是1024 -P:当使用-d的deamon模式时指定pid文件 -s:指定要监听的socket文件,使用该选项为禁用网络支持 -a:当使用套接字监听文件时,用于确定socket文件的文件掩码,缺省是0700 -l:确定memcache的服务器监听ip
时间: 2024-10-13 16:31:39