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


2008年11月26日星期三

读书:高效能人士的七个习惯(1)

以前读书不多,这种商业性质(不知道把它归为什么书了)的书更少,从来没有完全读完过一本。从今天开始,试着读完吧。
首先记录一下七个习惯吧:
1:积极主动
2:以终为始
3:要事第一
4:双赢思维
5:知彼解己
6:统合宗效
7:不断更新
我觉得要解释一下的有 2:以终为始 , 望文生义的话感觉是一件事快做完了才能当作开始? 看了书后才明白 ,一件事物都要经过两次得创造,一次是脑海里的酝酿,再有就是实质得创造,这里指 要以计划,使命宣言等前期的创造为开始。觉得这点是非常正确的,说话说万事开头难,首先就是要有一个好的开始,这当然离不开前期的计划等工作。
第二个要解释的是 6:统合宗效 ,用一个简单的算式表达就是:1+1>2 , 这是指在团体合作时的处理问题,矛盾,等方式上的一种选择处理方法的原则。
7:不断更新 ,不断更新自己的各方面,包括 生理,社会,情感,心智以及性灵。
还有一个这七个习惯的关系图,以后有时间做了再贴上来吧。

自己庆祝一下

今天开始写写博文,之前都是只喜欢随便看看别人的东西,而自己从不动手。这周开始准备静下心来看看书,记录一下自己的感受,也许只是些笔记吧。不管怎样希望有好的开始,更要有坚持下来的决心。