千家信息网

Unix环境下简单的部署memchache

发表于:2024-09-26 作者:千家信息网编辑
千家信息网最后更新 2024年09月26日,在很多大型网站或者是资讯类站点下往往都会有海量的查询,那么为了减小数据库的压力就出现了缓存系统,现在比较流行的缓存系统有很多,如memcache、Xcache等等,在这里就简单的说说开源的memcac
千家信息网最后更新 2024年09月26日Unix环境下简单的部署memchache

在很多大型网站或者是资讯类站点下往往都会有海量的查询,那么为了减小数据库的压力就出现了缓存系统,现在比较流行的缓存系统有很多,如memcache、Xcache等等,在这里就简单的说说开源的memcache的简单部署和使用。

memcache的使用要依赖于libevent网络库,所以在安装memcache之前必需要先安装libevent网络库然后再安装memcache,这里在二者的官网上都有稳定版的二进制包下载。libevent官网:http://libevent.org/,memcache官网:http://memcached.org/

[root@localhost src]# tar -zxvf libevent-2.1.8-stable.tar.gz[root@localhost src]# tar -zxvf memcached-1.4.34.tar.gz[root@localhost src]# cd libevent-2.1.8-stable[root@localhost libevent-2.1.8-stable]# ./configure --prefix=/usr/local/libevent[root@localhost libevent-2.1.8-stable]# make && make install[root@localhost libevent-2.1.8-stable]# cd ../memcached-1.4.34[root@localhost memcached-1.4.34]# ./configure --prefix=/usr/local/memchached --with-libevent=/usr/local/libevent[root@localhost memcached-1.4.34]# make && make install#实际到这一步基本安装就完毕了,但是最好还是要配置下相应环境[root@localhost memcached-1.4.34]# cd /usr/local/[root@localhost local]# ln -sv /usr/local/libevent/include/* /usr/include/#添加lib和include[root@localhost local]# ln -sv /usr/local/memchached/include/* /usr/include/[root@localhost local]# cd /etc/ld.so.conf.d/[root@localhost ld.so.conf.d]# vim libevent.conf/usr/local/libevent/lib[root@localhost ld.so.conf.d]# ldconfig[root@localhost ld.so.conf.d]# cd /etc/profile.d/#添加bin文件的环境路径[root@localhost profile.d]# vim libevent.shexport PATH=$PATH:/usr/local/libevent/bin[root@localhost profile.d]# source libevent.sh[root@localhost profile.d]# vim memcache.shexport PATH=$PATH:/usr/local/memchached/bin[root@localhost 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
0