轉載地址:http://www.cnblogs.com/eoiioe/archive/2008/11/11/1331242.html
memcachedb是為了持久化而產生的一個分布式 "key-value"存儲系統,你可以認為是memcached+berkeley DB+sina的一些東西的一個集成,這個東西主要是為了提高持久化對象的訪問效率,而不是一個緩存,他的特點是:
l 比傳統的RDBMS速度快效率高;
l 高并發環境下訪問安全可靠,效率很不錯;
l 存儲的數據比較小。
總之:高效、安全的事物機制、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
posted on 2009-12-24 10:19
阿蜜果 閱讀(1339)
評論(0) 編輯 收藏 所屬分類:
Other