CentOS安装memcached

来源:互联网 发布:淘宝客服有提成吗 编辑:程序博客网 时间:2024/06/16 13:15

1.安装前必须先安装依赖gcc 及 libevent

yum install libevent//若没有libvevent包,则选择下载解压的方式安装wget http://cloud.github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gztar zxvf libevent-2.0.21-stable.tar.gzcd libevent-2.0.21-stable./configure --prefix=/usr/local/libeventmakemake install

2.安装完成之后再安装memcached

wget http://www.memcached.org/files/memcached-1.5.0.tar.gztar -zxvf memcached-1.5.0.tar.gzcd /usr/memcached/memcached-1.5.0/./configure --with-libevent=/usr/makemake install// 关于memcache启动的一些参数说明: // memcached命令参数解释: // -p <num>          监听的端口 // -l <ip_addr>      连接的IP地址, 默认是本机 // -d start          启动memcached 服务 // -d restart        重起memcached 服务 // -d stop|shutdown  关闭正在运行的memcached 服务 // -d install        安装memcached 服务 // -d uninstall      卸载memcached 服务 // -u <username>    以<username>的身份运行 (仅在以root运行的时候有效) // -m <num>          最大内存使用,单位MB。默认64MB // -M                内存耗尽时返回错误,而不是删除项 // -c <num>          最大同时连接数,默认是1024 // -f <factor>      块大小增长因子,默认是1.25 // -n <bytes>        最小分配空间,key+value+flags默认是48 // -h                显示帮助 // 然后执行命令启动memcached // #/usr/local/bin/memcached -d -m 1024 -u root -p 11211 -P /tmp/memcached.pid //启动./memcached -d -m 1024 -u root -p 11211 -P /tmp/memcached.pid

3.测试memcached

  • 可以使用telnet,来测试memcache的连接状态,
  • 如果没有安装telnet服务,可以执行

    yum install telnet-server

  • 安装服务

    yum install telnet

安装命令
然后编辑vi /etc/xinetd.d/telnet 文件,激活telnet,默认是禁用的

# default: on# description: The telnet server serves telnet sessions; it uses \#       unencrypted username/password pairs for authentication.service telnet{        flags           = REUSE        socket_type     = stream        wait            = no        user            = root        server          = /usr/sbin/in.telnetd        log_on_failure  += USERID        disable         = yes #默认为no,需要改为yes}
  • 然后重启服务

    service xinetd restart

  • 执行以下命令查看memcached连接信息

telnet 127.0.0.1 11211// Trying 127.0.0.1...// Connected to 127.0.0.1.// Escape character is '^]'.// stats //输入

输入stats,会输出memcache的一些连接信息,包括PID
如果需要退出,则执行quit命令即可

参考文章:http://www.linuxidc.com/Linux/2016-03/129532.htm

原创粉丝点击