• memcachedb


    memcachedb是为了持久化而产生的一个分布式 "key-value"存储系统,你可以认为是memcached+berkeley DB+sina的一些东西的一个集成,这个东西主要是为了提高持久化对象的访问效率,而不是一个缓存,他的特点是:
            比传统的RDBMS速度快效率高
            高并发环境下访问安全可靠,效率很不错
            存储的数据比较小
     
             总之:高效、安全的事物机制、memcached的分布式协议支持
    是他的几大亮点.
     
    你可以将一些数据量不大,读写却很频繁的数据放再这里面,而不用往mysql等数据库里写,据说“sohu”的在线用户是存在这里面的,可见这东西还是挺可靠的。
              在官方文档里明确指出,只提倡用此数据库保存如下类型的数据: 
    Index, Counter, Flags
    Identity Management(Account, Profile, User config info, Score)
    Messaging
    Personal domain name
    meta data of distributed system
    Other non-relatonal data
    .......................
     
    即,要求访问数据快、数据量不大,并且需要持久化到数据库中,却不需要sql查询的数据.
                     
            下面我们来说应用:
    如果你看过了上一片文章,并且已经成功安装memcachedb的话,那么,现在请启动你的memcachedb,命令如下:
    memcachedb -p21201 -d -r -u root -f 21201.db -H /data1/demo  -N -P /data1/logs/21201.pid
    参数说明如下:
     
    ‘-p <num>’ TCP port number to listen on (default: 21201)       tcp侦听端口
       
    ‘-l <ip addr>’ interface to listen on, default is INDRR ANY      这个不要管他

    ‘-d’ run as a daemon    作为隐藏的线程运行

    ‘-r’ maximize core file limit 
    ‘-u <username>’ assume identity of <username> (only when run as root) 用户名

    ‘-c <num>’ max simultaneous connections, default is 1024 
    ‘-b <num>’ max item buffer size in bytes, default is 1KB
    ‘-v’ verbose (print errors/warnings while in event loop)
    ‘-vv’ very verbose (also print client commands/reponses)
    ‘-P <file>’ save PID in <file>, only used with -d option
     
    ‘-m <num>’ in-memmory cache size of BerkeleyDB in megabytes, default
    is 64MB
    ‘-f <file>’ filename of database, default is
    /data1/memcachedb/default.db
    ‘-H <dir>’ env home of database, default is /data1/memcachedb
    ‘-L <num>’ log buffer size in kbytes, default is 32KB
    ‘-C <num>’ do checkpoint every XX seconds, 0 for disable, default is 60s
    ‘-D <num>’ do deadlock detecting every XXX millisecond, 0 for disable,
    default is 100ms
    ‘-N’ enable DB TXN NOSYNC to gain big performance
    improved, default is off
     
    如果你想要将数据保存再特定的目录可以使用-H 但是你必须首先要创建该目录,否则数据库将不可启动
          现在我们来测试下memcachedb是否已经启动了:
    输入  telnet 'your ip'  端口号 (默认21201
    telnet 127.0.0.1 21201
    Trying 127.0.0.1...
    Connected to 127.0.0.1.
    Escape character is ’^]’.
    如果可以连接,证明已经启动,现在我们可以来联系下memcached的命令了,呵呵.
     
    以下是memcachedb支持的命令:
    ‘get’ Retrieval of one or multiple items
    ‘set’ ”Store this data”
    ‘add’ ”Store this data, but only if the server *doesn’t* already
     hold data for this key”
    ‘replace’ ”Store this data, but only if the server *does* already hold
    data for this key”
    ‘delete’ deletes one item based a key
    ‘incr/decr’ Increment or decrement a numeric value. It’s atomic!
    ‘stats’ shows the status of current deamon. ’stats’, ’stats malloc’,
    ’stats maps’
    Steve
     
     
       ‘db checkpoint’ does a checkpoint manuanlly.
    ‘db archive’ removes log files that are no longer needed.
    ‘stats bdb’ shows the status of BerkeleyDB.
    ‘rep ismaster’ shows whether the site is a master.
    ‘rep whoismaster’ shows which site is a master.
    ‘rep set priority’ sets the priority of a site for electing in replication.
    ‘rep set ack policy’ sets ACK policy of the replication.
    ‘rep set ack timeout’ sets ACK timeout value of the replication .
    ‘rep set bulk’ Enable bulk transfer or not in replication.
    ‘rep set request’ sets the minimum and maximum number of missing
    log records that a client waits before requesting
    retransmission.
    ‘stats rep’ shows the status of Replication.
  • 相关阅读:
    转:桩模块 stub 和驱动模块 driver
    音频中PCM的概念
    pthread_exit
    为什么匿名内部类参数必须为final类型
    原创:同步与异步、阻塞与非阻塞
    (转)C语言中长度为0的数组
    编码问题
    查看Android程序使用内存
    C++中class与struct的区别(struct的类型名同时可以作为变量名)
    asn1c
  • 原文地址:https://www.cnblogs.com/java20130722/p/3207046.html
Copyright © 2020-2023  润新知