posts - 297,  comments - 1618,  trackbacks - 0
                 轉(zhuǎn)載地址:http://www.cnblogs.com/eoiioe/archive/2008/11/11/1331242.html
                  

          memcachedb是為了持久化而產(chǎn)生的一個分布式 "key-value"存儲系統(tǒng),你可以認(rèn)為是memcached+berkeley DB+sina的一些東西的一個集成,這個東西主要是為了提高持久化對象的訪問效率,而不是一個緩存,他的特點是:

          l         比傳統(tǒng)的RDBMS速度快效率高;

          l         高并發(fā)環(huán)境下訪問安全可靠,效率很不錯;

          l         存儲的數(shù)據(jù)比較小。

          總之:高效、安全的事物機(jī)制、memcached的分布式協(xié)議支持是他的幾大亮點.

          你可以將一些數(shù)據(jù)量不大,讀寫卻很頻繁的數(shù)據(jù)放再這里面,而不用往mysql等數(shù)據(jù)庫里寫,據(jù)說“sohu”的在線用戶是存在這里面的,可見這東西還是挺可靠的。

          在官方文檔里明確指出,只提倡用此數(shù)據(jù)庫保存如下類型的數(shù)據(jù):

          Index, Counter, Flags
          Identity Management(Account, Profile, User config info, Score)
          Messaging
          Personal domain name
          meta data of distributed system
          Other non-relatonal data
          ..

          即,要求訪問數(shù)據(jù)快、數(shù)據(jù)量不大,并且需要持久化到數(shù)據(jù)庫中,卻不需要sql查詢的數(shù)據(jù)。

          下面我們來說應(yīng)用:

          如果你看過了上一篇文章,并且已經(jīng)成功安裝memcachedb的話,那么,現(xiàn)在請啟動你的memcachedb,命令如下:

          memcachedb -p21201 -d -r -u root -f 21201.db -H /data1/demo  -N -P /data1/logs/21201.pid

          參數(shù)說明如下:

          ‘-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

          如果你想要將數(shù)據(jù)保存再特定的目錄可以使用-H 但是你必須首先要創(chuàng)建該目錄,否則數(shù)據(jù)庫將不可啟動。
             
          現(xiàn)在我們來測試下memcachedb是否已經(jīng)啟動了:
             
          輸入  telnet 'your ip'  端口號 (默認(rèn)21201)

          telnet 127.0.0.1 21201
          Trying 127.0.0.1
          Connected to 127.0.0.1.
          Escape character is ’^]’.

              如果可以連接,證明已經(jīng)啟動,現(xiàn)在我們可以來聯(lián)系下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
          posted on 2009-12-24 10:19 阿蜜果 閱讀(1348) 評論(0)  編輯  收藏 所屬分類: Other
          <2009年12月>
          293012345
          6789101112
          13141516171819
          20212223242526
          272829303112
          3456789

                生活將我們磨圓,是為了讓我們滾得更遠(yuǎn)——“圓”來如此。
                我的作品:
                玩轉(zhuǎn)Axure RP  (2015年12月出版)
                

                Power Designer系統(tǒng)分析與建模實戰(zhàn)  (2015年7月出版)
                
               Struts2+Hibernate3+Spring2   (2010年5月出版)
               

          留言簿(263)

          隨筆分類

          隨筆檔案

          文章分類

          相冊

          關(guān)注blog

          積分與排名

          • 積分 - 2297822
          • 排名 - 3

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 缙云县| 兴业县| 光山县| 萨嘎县| 秀山| 右玉县| 高碑店市| 通城县| 颍上县| 剑阁县| 兴国县| 册亨县| 津市市| 哈密市| 从化市| 台中市| 密云县| 洛阳市| 平乐县| 喀喇| 临漳县| 固安县| 福建省| 裕民县| 芮城县| 延安市| 仁布县| 许昌市| 化德县| 乌什县| 巍山| 新蔡县| 本溪市| 抚顺市| 安宁市| 大化| 莲花县| 汕头市| 独山县| 通道| 东乡县|