欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Centos6 使用yum安装memcached

程序员文章站 2024-03-25 17:16:58
...

yum 搜索 memcached相关安装包

[aaa@qq.com ~]# yum search memcached
=========================================== N/S Matched: memcached ===========================================
libmemcached.i686 : Client library and command line tools for memcached server
libmemcached.x86_64 : Client library and command line tools for memcached server
libmemcached-devel.i686 : Header files and development libraries for libmemcached
libmemcached-devel.x86_64 : Header files and development libraries for libmemcached
libmemcached-last-libs.x86_64 : libmemcached libraries
libmemcached-opt-libs.x86_64 : libmemcached libraries
memcached-devel.i686 : Files needed for development using memcached protocol
memcached-devel.x86_64 : Files needed for development using memcached protocol
perl-Cache-Memcached.noarch : Perl client for memcached
memcached.x86_64 : High Performance, Distributed Memory Object Cache

使用yum安装memcached

[aaa@qq.com ~]# yum install -y memcached
Installed:
  memcached.x86_64 0:1.4.4-5.el6                                                                              

Dependency Installed:
  libevent.x86_64 0:1.4.13-4.el6                                                                              

Complete!
[aaa@qq.com ~]# 

启动memcached服务

# 查看memcached的当前状态
[aaa@qq.com ~]# service memcached status
memcached is stopped
[aaa@qq.com ~]# 
# 启动memcached的服务
[aaa@qq.com ~]# service memcached start
Starting memcached:                                        [  OK  ]
[aaa@qq.com ~]# 
[aaa@qq.com ~]# service memcached status
memcached (pid  2782) is running...
[aaa@qq.com ~]# 
# 查看memcached相关启动参数
[aaa@qq.com ~]# ps -ef | grep memcached
495        2782      1  0 15:32 ?        00:00:00 memcached -d -p 11211 -u memcached -m 64 -c 1024 -P /var/run/memcached/memcached.pid
root       2803   2620  0 15:33 pts/0    00:00:00 grep memcached
[aaa@qq.com ~]# 

查看memcached版本

[aaa@qq.com sysconfig]# memcached -h
memcached 1.4.4
...
[aaa@qq.com sysconfig]# 

配置加入linux服务

[aaa@qq.com ~]# chkconfig --level 2345 memcached on

配置memcached启动参数

[aaa@qq.com ~]# vim /etc/sysconfig/memcached 

PORT="11211"
USER="memcached"
MAXCONN="1024"
CACHESIZE="64"
OPTIONS=""
  • PORT,服务启动端口。
  • USER,服务启动用户。
  • MAXCONN,服务配置支持最大连接数。
  • CACHESIZE,服务支持的最大内存,以M为单位。

配置修改了之后,重启memcached服务即可生效。

使用memcached-tool检测memcached服务

[aaa@qq.com ~]# memcached-tool 127.0.0.1:11211 stats
#127.0.0.1:11211   Field       Value
         accepting_conns           1
               auth_cmds           0
             auth_errors           0
                   bytes           0
              bytes_read           7
           bytes_written           0
              cas_badval           0
                cas_hits           0
              cas_misses           0
               cmd_flush           0
                 cmd_get           0
                 cmd_set           0
             conn_yields           0
   connection_structures          11
        curr_connections          10
              curr_items           0
               decr_hits           0
             decr_misses           0
             delete_hits           0
           delete_misses           0
               evictions           0
                get_hits           0
              get_misses           0
               incr_hits           0
             incr_misses           0
          limit_maxbytes    67108864
     listen_disabled_num           0
                     pid        2782
            pointer_size          64
           rusage_system    0.033994
             rusage_user    0.000000
                 threads           4
                    time  1557215298
       total_connections          11
             total_items           0
                  uptime         924
                 version       1.4.4
[aaa@qq.com ~]# 
Centos6 使用yum安装memcached