Tokyo Cabinet是日本人开发的一款数据库,它的功能比较简单,只能键值保存,没有检索功能,以hash table、b+tree、fixed-length array保存。
Tokyo Cabinet有如下特点:
- 键值保存数据库
- 数据文件小
- 高性能,插入1百万记录只需0.4秒(250万 rps),查询1百万记录只需0.3秒(300万 rps)
- 高并发,支持多线程,读写支持锁记录
- 使用简单,通过memcached客户端直接使用(需Tyrant)
- 支持64位架构,容量大
- 支持事务
Tokyo Tyrant提供管理Cabinet的接口,支持memcached协议,所以,可以通过memcached客户端连接Cabinet。
Tokyo Tyrant有如下特点:
- 提供使用Cabinet的接口
- 支持通过memcached和http协议连接
- 高并发,查询100万记录17.2秒(5.8万 rps)
- 支持热备份,复制功能,主持主主(可读写)和主从(分写和读)方式
用Cabinet加上Tyrant实现轻量级持久化存储系统,用来分担数据库的压力,实际上和新浪的memcachdb差不多。我的想法是用memcached做缓存,Tyrant持久储存频繁修改或者不需要检索功能的数据。
ok...先安装再说
1.安装Cabinet
要求
- linux 不低于2.4
- gcc 不低于3.1
- zlib 不低于1.2.3
- bzip2 不低于1.0.5
下载:http://tokyocabinet.sourceforge.net/tokyocabinet-1.4.5.tar.gz
引用
tar zxvf tokyocabinet-1.4.5.tar.gz
cd tokyocabinet-1.4.5
./configure
make
make install
cd tokyocabinet-1.4.5
./configure
make
make install
引用
Options of Configure
The following options can be specified with `./configure'.
--enable-debug : build for debugging. Enable debugging symbols, do not perform optimization, and perform static linking.
--enable-devel : build for development. Enable debugging symbols, perform optimization, and perform dynamic linking.
--enable-profile : build for profiling. Enable profiling symbols, perform optimization, and perform dynamic linking.
--enable-static : build by static linking.
--enable-fastest : build for fastest run.
--enable-off64 : build with 64-bit file offset on 32-bit system.
--enable-swab : build for swapping byte-orders.
--enable-uyield : build for detecting race conditions.
--disable-zlib : build without ZLIB compression.
--disable-bzip : build without BZIP2 compression.
--disable-pthread : build without POSIX thread support.
--disable-shared : avoid to build shared libraries.
The following options can be specified with `./configure'.
--enable-debug : build for debugging. Enable debugging symbols, do not perform optimization, and perform static linking.
--enable-devel : build for development. Enable debugging symbols, perform optimization, and perform dynamic linking.
--enable-profile : build for profiling. Enable profiling symbols, perform optimization, and perform dynamic linking.
--enable-static : build by static linking.
--enable-fastest : build for fastest run.
--enable-off64 : build with 64-bit file offset on 32-bit system.
--enable-swab : build for swapping byte-orders.
--enable-uyield : build for detecting race conditions.
--disable-zlib : build without ZLIB compression.
--disable-bzip : build without BZIP2 compression.
--disable-pthread : build without POSIX thread support.
--disable-shared : avoid to build shared libraries.
2.安装Tyrant
下载:http://tokyocabinet.sourceforge.net/tyrantpkg/tokyotyrant-1.1.14.tar.gz
引用
tar zxvf tokyotyrant-1.1.14.tar.gz
cd tokyotyrant-1.1.14
./configure
make
make install
mkdir -p /ttserver/
ttserver -host 192.168.1.254 -port 11311 -thnum 8 -dmn -pid /ttserver/ttserver.pid -log /ttserver/ttserver.log -le -ulog /ttserver/ -ulim 128m -sid 1 -rts /ttserver/ttserver.rts /ttserver/database.tch
cd tokyotyrant-1.1.14
./configure
make
make install
mkdir -p /ttserver/
ttserver -host 192.168.1.254 -port 11311 -thnum 8 -dmn -pid /ttserver/ttserver.pid -log /ttserver/ttserver.log -le -ulog /ttserver/ -ulim 128m -sid 1 -rts /ttserver/ttserver.rts /ttserver/database.tch
失望啊失望啊,用php memcached客户端连接Tyrant有bug( http://willko.iteye.com/blog/332982),Tyrant只提供了Perl和Ruby的客户端
参考资料:
http://tokyocabinet.sourceforge.net/
http://blog.s135.com/post/362.htm