安装Kyoto Cabinet:
yum install gcc gcc-c++ zlib-devel bzip2-devel
wget http://fallabs.com/kyotocabinet/pkg/kyotocabinet-1.2.76.tar.gz
tar zxvf kyotocabinet-1.2.76.tar.gz
cd kyotocabinet-1.2.76
./configure --prefix=/usr/local/kyotocabinet-1.2.76
make && make install
echo "/usr/local/kyotocabinet-1.2.76/lib/" >> /etc/ld.so.conf.d/kyoto.conf
ldconfig
安装Lua Kyoto Cabinet扩展:
yum install lua-devel
wget http://fallabs.com/kyotocabinet/luapkg/kyotocabinet-lua-1.28.tar.gz
tar zxvf kyotocabinet-lua-1.28.tar.gz
cd kyotocabinet-lua-1.28
./configure --with-kc=/usr/local/kyotocabinet-1.2.76/
make && make install
安装Kyoto Tycoon:
wget http://fallabs.com/kyototycoon/pkg/kyototycoon-0.9.56.tar.gz
tar zxvf kyototycoon-0.9.56.tar.gz
cd kyototycoon-0.9.56
./configure --prefix=/usr/local/kyototycoon-0.9.56 --with-kc=/usr/local/kyotocabinet-1.2.76/ --enable-lua
make && make install
mkdir /etc/ktserver/
cp example/*.lua /etc/ktserver/
echo "/usr/local/kyototycoon-0.9.56/lib/" >> /etc/ld.so.conf.d/kyoto.conf
ldconfig
使用Kyoto Tycoon为前端管理LevelDB,先安装LevelD存储:然后安装Kyoto Tycoon插件支持LevelDB:
cd lab/leveldb/
export CPLUS_INCLUDE_PATH=/usr/local/kyotocabinet-1.2.76/include/
export LIBRARY_PATH=/usr/local/kyotocabinet-1.2.76/lib
make
cp ktplugdblevel.so /usr/local/kyototycoon-0.9.56/lib/
启动:
ktserver -th 4 -scr /etc/ktserver/ktscrex.lua -pldb /usr/local/kyototycoon-0.9.56/lib/ktplugdblevel.so \
/tmp/leveldb/#ktopts=p
使用HTTP协议管理:
curl "http://192.168.1.3:1978/rpc/set?key=japan&value=tokyo"
curl "http://192.168.1.3:1978/rpc/get?key=japan"
curl "http://192.168.1.3:1978/rpc/remove?key=japan"
使用客户端管理:
ktremotemgr set -host 192.168.1.3 -port 1978 key value
ktremotemgr get -host 192.168.1.3 -port 1978 key
ktremotemgr list -host 192.168.1.3 -port 1978 -pv
使用Kyoto Tycoon管理LevelDB兼容于直接使用LevelDB PHP扩展设置的数据库,启动时添加参数:
#ktopts=p
使用Kyoto Tycoon Lua脚本,API:http://fallabs.com/kyototycoon/luadoc/modules/kyototycoon.html
ktremotemgr script -host 192.168.1.3 -port 1978 set key key1 value value1
ktremotemgr script -host 192.168.1.3 -port 1978 get key key1
curl "http://192.168.1.3:1978/rpc/play_script?name=set&_key=key1&_value=value1"
curl "http://192.168.1.3:1978/rpc/play_script?name=get&_key=key1"
标签:none