Centos6 使用yum安装memcached

2019-05-30 21:46:47 浏览数 (1)

yum 搜索 memcached相关安装包

代码语言:javascript复制
[root@centos6 ~]# 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

代码语言:javascript复制
[root@centos6 ~]# 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!
[root@centos6 ~]# 

启动memcached服务

代码语言:javascript复制
# 查看memcached的当前状态
[root@centos6 ~]# service memcached status
memcached is stopped
[root@centos6 ~]# 
# 启动memcached的服务
[root@centos6 ~]# service memcached start
Starting memcached:                                        [  OK  ]
[root@centos6 ~]# 
[root@centos6 ~]# service memcached status
memcached (pid  2782) is running...
[root@centos6 ~]# 
# 查看memcached相关启动参数
[root@centos6 ~]# 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
[root@centos6 ~]# 

查看memcached版本

代码语言:javascript复制
[root@centos6 sysconfig]# memcached -h
memcached 1.4.4
...
[root@centos6 sysconfig]# 

配置加入linux服务

代码语言:javascript复制
[root@centos6 ~]# chkconfig --level 2345 memcached on

配置memcached启动参数

代码语言:javascript复制
[root@centos6 ~]# vim /etc/sysconfig/memcached 

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

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

使用memcached-tool检测memcached服务

代码语言:javascript复制
[root@centos6 ~]# 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
[root@centos6 ~]# 

0 人点赞