凤儿 发表于 2015-2-4 08:17:15

memcached 数据存储

1、memcached简介、安装自行google

2、memcached监控与数据导出

   在memcached源码目录下的scripts目录中一个perl语言的的脚本,可用于对memcache进行一些日常查询与监控
   用法如下:

1
2
3
4
5
6
7
8
9
10
11
12
#./memcached-tool
Usage: memcached-tool <host[:port]>
       memcached-tool 10.0.0.5:11211 display    # shows slabs
       memcached-tool 10.0.0.5:11211            # same.(default is display)
       memcached-tool 10.0.0.5:11211 stats      # shows general stats
       memcached-tool 10.0.0.5:11211 dump       # dumps keys and values
       memcached-tool 10.0.0.5:11211 move 7 9   # takes 1MB slab from class #7
                                                # to class #9.
You can only move slabs around once memory is totally allocated, and only
once the target class is full.(So you can't move from #6 to #9 and #7
to #9 at the same itme, since you'd have to wait for #9 to fill from
the first reassigned page)




    2.1memcache状态查询

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#./memcached-tool 192.168.10.1:11211 stats
#192.168.10.1:11211 Field       Value
         accepting_conns         1
                   bytes         0
            bytes_read          20
         bytes_written         5
               cmd_flush         0
               cmd_get         0
               cmd_set         0
   connection_structures         3
      curr_connections         2
            curr_items         0
               evictions         0
                get_hits         0
            get_misses         0
          limit_maxbytes    67108864
   listen_disabled_num         0
                     pid       18088
            pointer_size          32
         rusage_system    0.000999
             rusage_user    0.000000
               threads         2
                  time1422969575
       total_connections         4
             total_items         0
                  uptime       25344
               version       1.2.8




    是不是so eay


    2.2导出memcache内在中的key与value值,命令如下:


1
# ./memcached-tool 192.168.10.1:11211 dump >./memcachekeys




    是不是很简单,当时我心情也和你一样;不过别高兴太早,经过大量数据测试,发现导出的key与内在的key数量不同,要少很多;后来经过大量google得之,memcached自身有缓冲区大小限制,最大2M。这个问题至今没有得到解决,如有大神或路过的兄弟有此问题解决方法,请mail之waitingtome@gmail.com。
       2.3   memcached数据导入


1
#nc 192.168.10.1 11211 <./memcachekeys




    right! key-value导入如此简单
页: [1]
查看完整版本: memcached 数据存储