aburrido 发表于 2013-1-28 09:35:34

TokyoTyrant 搭建 session 服务器

纯记录 
 
#安装 Tokyo Cabinetwget http://1978th.net/tokyocabinet/tokyocabinet-1.4.47.tar.gztar zxvf tokyocabinet-1.4.47.tar.gzcd tokyocabinet-1.4.47./configure --enable-off64#32位系统需要 --enable-off64,以让它支持大于2GB的文件makemake installcd ..#安装 luawget http://www.lua.org/ftp/lua-5.1.4.tar.gztar zxvf lua-5.1.4.tar.gzcd lua-5.1.4#要根据系统而定,直接make它会有提示make linuxmake installln -s /usr/local/bin/lua /usr/bin/luacd ..#安装Tokyo Cabinet 的 lua 扩展wget http://1978th.net/tokyocabinet/luapkg/tokyocabinet-lua-1.10.tar.gztar zxvf tokyocabinet-lua-1.10.tar.gzcd tkoyocabinet-lua-1.10./configuremakemake installcd ..#安装 Tokyo Tyrantwget http://1978th.net/tokyotyrant/tokyotyrant-1.1.41.tar.gztar zxvf tokyotyrant-1.1.41.tar.gzcd tokyotyrant-1.1.41./configure --enable-lua --with-luamakemake installcd ../mkdir -p /session/#还需要一个 expire.lua 文件,这个文件用于定时将过期的 session 清理。代码如下:cat > /session/expire.lua << "EOF" function expire()local args = {}local cdate = string.format("%d", _time())table.insert(args, "addcond\0ts\0NUMLE\0" .. cdate)table.insert(args, "out")local res = _misc("search", args)if not res then_log("expiration was failed", 2)endendEOFulimit -SHn 51200ttserver -host 127.0.0.1 -port 11222 -ext /session/expire.lua -extpc expire 5.0 -thnum 8 -dmn -pid /session/session.pid -log /session/session.log -le -ulog /session/ -ulim 128m -sid 1 -rts /session/session.rts '/session/session.tct#idx=key:lex#idx=ts:dec#dfunit=8'#安装pecl tokyo_tyrantwget http://pecl.php.net/get/tokyo_tyranttar zxvf tokyo_tyrantcd tokyo_tyrant-*/usr/local/php/bin/phpize./configure --with-php-config=/usr/local/php/bin/php-config make && make installecho 'extension="/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613//tokyo_tyrant.so"' >> /usr/local/php/lib/php.inicd ../
页: [1]
查看完整版本: TokyoTyrant 搭建 session 服务器