2008年12月23日星期二

scribe 研究- 一种分布式日志系统(facebook)

一张scribe结构图

先转一下,留作后用。

Installing Scribe For Log Collection

Scribe is a newly released log collection tool that dumps log files from various nodes in a cluster to Scribe servers, where the logs are stored for further use. Facebook describes their usage of Scribe by saying, “[Scribe] runs on thousands of machines and reliably delivers tens of billions of messages a day.” It turns out that Scribe is rather difficult to install, so the hope of this post is to help those of you attempting to install Scribe. The first step is to get dependencies installed.

Dependencies
Scribe has many dependencies that must be installed in order for Scribe to be built properly. They are listed here:

  • ruby (ruby and ruby-dev)
  • python (python and python-dev)
  • libevent (libevent and libevent-dev)
  • boost v1.36
  • Thrift
  • fb303 (included in Thrift in contrib/fb303)

The order in which these are installed is important. First, you must install libevent, then libevent-dev, then boost, then Thrift, and finally fb303. I installed libevent and libevent-dev from RPMs, whereas boost, Thrift, and fb303 were installed from source. I was unable to get Scribe, Thrift, and fb303 to locate the boost libraries and includes correctly with the default boost install directories, so I installed boost in /usr/local/boost, /usr/local/boost/bin, /usr/local/boost/lib, and /usr/local/boost/include. Run ‘./configure –help’ when configuring boost to see how to specify these options.

When configuring Thrift and fb303, you must specify your location of boost with the “–with-boost=/path/to/boost/root” option and also set your BOOST_ROOT environment variable.

Finally, you must make sure your LD_LIBRARY_PATH environment variable contains the lib folders that house the Thrift, fb303, boost, and libevent C++ libraries. LD_LIBRARY_PATH follows the same pattern as the PATH variable. That is, directories that contain libraries are separated by colons. If you forget to set your LD_LIBRARY_PATH variable, then you’ll get the following error when running scribed:

scribed: error while loading shared libraries: libboost_system-gcc41-mt-1_36.so.1.36.0: cannot open shared object file: No such file or directory
Install Scribe
Once you’ve successfully installed all dependencies, installing Scribe is easy. Scribe ships with a fairly comprehensive README file, but the instructions involving boost’s configuration are slightly incorrect. I needed to pass the “–with-boost=/usr/local/boost” options while configuring. However, the README file says to use “–with-boost /usr/local/boost”. Here is my full configure statement:
./configure –with-boost=/usr/local/boost –with-boost-system=boost_system-gcc41-mt-1_36 –with-boost-filesystem=boost_filesystem-gcc41-mt-1_36

We installed Scribe from trunk instead of releases/scribe-2.0.

Configure Scribe
Scribe ships with a few good examples in $SCRIBE_ROOT/examples; just take a look at the README in the examples directory, and you should be ready to rock. However, the README doesn’t document that the scribe_ctrl and scribe_cat programs are in the examples directory.

I hope this tutorial was helpful! Send us an email if you have any issues. We’ll make a follow-up post later talking about more in-depth Scribe configurations and benchmarking.

centos 5 安装

2008年12月22日星期一

php gd 库jpeg图片上传失真问题

在用gd 库处理上传图片时,如果图片过大,则需要对其进行压缩,如果上传是jpg图片,用 imagecreate() 函数 则 图片会失真掉色,这就需要使用 imagecreatetruecolor() 了( 本函数不能用于 GIF 文件格式),且imagecopyresampled() 会比 imagecopyresized() 的效果要好。

2008年12月10日星期三

memcache 研究

在php里面就有关于memcache的一些函数, 如
Memcache::add — Add an item to the server
Memcache::addServer — Add a memcached server to connection pool
Memcache::close — Close memcached server connection
Memcache::connect — Open memcached server connection
memcache_debug — Turn debug output on/off
Memcache::decrement — Decrement item's value
Memcache::delete — Delete item from the server
Memcache::flush — Flush all existing items at the server
Memcache::get — Retrieve item from the server
Memcache::getExtendedStats — Get statistics from all servers in pool
Memcache::getServerStatus — Returns server status
Memcache::getStats — Get statistics of the server
Memcache::getVersion — Return version of the server
Memcache::increment — Increment item's value
Memcache::pconnect — Open memcached server persistent connection
Memcache::replace — Replace value of the existing item
Memcache::set — Store data at the server
Memcache::setCompressThreshold — Enable automatic compression of large values
Memcache::setServerParams — Changes server parameters and status at runtime