Rails部署环境:各就位,预备,跑
August 24th, 2007
有人评论了RubyWorks Production Stack。“Damn those ThoughtWorks people are smart!” 这话听着很振奋。不过第二天,他又爱上了FiveRuns的RM-Manage。“With built in notification it’s definitely a winner”
毫无疑问,FiveRuns的RM-Install是一个好东西。完整的Rails stack,丰富的附加功能,使用简便。但试用以后却加深了我对RubyWorks的信心。因为:
- 我们的stack是在现有标准(apt和yum)基础上搭建起来的,这就意味着用户能够以他们习惯的方式安装和(更重要的)升级所有软件;一个以自定义格式包装的工具包将不得不提供自己的更新升级方式,甚至根本就无法升级。
- 我们的stack是逐步组合出来的,这就意味着我们提供的始终是对绝大多数用户最有价值的东西,并且给用户选择的机会;一个大包大揽的工具包很可能包含一些看上去很酷、但很多用户并不需要的庞大的组件(例如ImageMagick)。
- 我们的stack是开源的,这就意味着我们能够得到整个社区的反馈和贡献;一个闭源工具包的开发者需要花费更多的工夫才能弄清系统管理员们的工作方式和习惯。
归根结底,我的信心来自于对Unix传统的信心:开放的、遵循标准的、组合协作的软件,应该好过封闭的、自立山头的、大包大揽的软件。谁能在这场Rails stack的赛跑中最终获胜,走着看吧。
RubyWorks Production Stack: Version 1.0 Is Coming
July 27th, 2007
RubyWorks production stack is a collection of open-source software required to host a RubyOnRails application on a Linux server.
To set up a production Rails server, you point a package manager to RubyWorks package repository, run one command, and few minutes later you have a skeleton Rails application served by a cluster of Mongrel servers, load-balanced by HAProxy, monitored by monit and controlled by runit.
Version 0.0.4 is the first release candidate on the way to version 1.0. The core stack has stabilized, and changes from 0.0.3 are all peripheral:
- Officially supported x86_64 packages on Red Hat Enterprise Linux and CentOS.
- Pre-compiled Ruby gems added to the package repositories: rubygem-libxml-ruby, rubygem-hpricot, rubygem-ferret, rubygem-ruby-debug, rubygem-rmagick. All these packages are optional (not automatically installed with ‘rubyworks’ main package, but available from the same RPM/DEB repositories).
- Added log rotation script /etc/cron.daily/rubyworks.logrotate.daily.
- BUGFIX: Corrected the value of clitimeout in haproxy.conf (changed from 150 seconds to 15 seconds).
- Added documentation for individual components in the stack.
Documentation: http://rubyworks.rubyforge.org
Commercial support: http://studios.thoughtworks
Users mailing list: rubyworks-users@rubyforge.org
汇总:一站式的Rails环境
July 5th, 2007
RubyWorks Production Stack: http://rubyworks.rubyforge.org/
RubyWorks production stack is a collection of open-source software required to host a RubyOnRails application on a Linux server. Supported Linux variants include RedHat Enterprise Linux 4 (both i386 and x64 versions), CentOS 4 (both i386 and x64 versions), Debian 4 (Etch) and Ubuntu 7 (Feisty Fawn).
RubyWorks Production Stack的特点是提供了方便的服务管理、强大的服务监控和可靠的多应用服务器负载均衡。此外,以RPM包/DEB包的形式发布,同时支持RedHat和Debian也是我们的一大优势。
deprec: http://www.deprec.org/
Deprec is a collection of automated recipes, written in Ruby, for setting up production ready Ruby on Rails servers. This includes everything from creating admin accounts and setting up your ssh keys to compiling and installing the packages required to get a Rails application running on a freshly installed Ubuntu 6.06.1 LTS server.
平心而论deprec确实做得很不错。基于Capistrano来搭建远端的部署服务器,这个想法很巧妙,也让部署环境和Capistrano的结合更紧密。主要的缺点有两个:(1)要求部署环境安装GCC(build-essential),因为所有的gem都是在本地build native extension的;(2)目前为止只支持Ubuntu。
LinRails: http://linrails.thembid.com/
While developing ThemBid.com using Symfony, our developers used XAMPP to standardize development environments and have something easy to install. When we started using Ruby on Rails, we could not find something similar for Linux so LinRails was started.
从这段简介来看,LinRails认为他们在做一个Rails的开发环境,事实上他们打包的东西也确实更像是一个开发环境。同时,LinRails也只在Ubuntu上测试过。
Rails Machine: http://www.railsmachine.com/
Rails Machine provides software, services and support for commercial Ruby on Rails application deployments. Our primary customers are professional Ruby on Rails developers that need simple and high quality solutions for deploying their applications either in a hosted environment or internal corporate environment.
我印象里Rails Machine是率先引入虚拟化技术(我喜欢这种大词)的stack:之所以叫“machine”,因为他们发布的stack整个是一个Xen虚拟机,里面装着CentOS和Rails服务器所需的一切东西。这就是它的特点(优点+缺点)所在。RailsMachine是商业软件,同时也提供hosting服务。
FiveRuns RM-Install: http://www.fiveruns.com/products/rm/install
RM-Install is a free, multi-platform, full-tested and enterprise-ready Rails stack that enables you to instantly begin developing and deploying your great Rails applications without the worry of installing or maintaining the various integrated software components.
这个产品也不是开源的(尽管是免费的)。不过最困扰的还是:目前压根看不到它是什么样子。FiveRuns最吸引我的是RM-Manage产品,点一下“System Browser”那里的图片,这样奢华的服务管理界面确实值得卖一定价钱。
Engine Yard: http://www.engineyard.com/
We handle deployment and operations, so you can focus on your application and your business. Smoothly scale from 1 user to 1 million.
Engine Yard就完全是shared host了,吸引我注意到它的是一篇“Xen And The Art of Rails Deployment”的演讲稿,以及那华丽的24层架构图。也许他们是不会把自己的deployment stack卖出来的——当然更不用说开源出来了。
RubyWorks迈出第二步:Production Stack on Ubuntu
June 19th, 2007
RubyWorks Production Stack今天发布0.0.2版本。
虽然只是千分位上的进展,不过也可以说是比前一个版本进步了一倍——事实也差不多正是这样:除了Redhat/CentOS以外,我们现在开始支持Debian 4 Etch和Ubuntu 7.04 Feisty Fawn。此外我们还用runit替换了monit来负责管理所有的服务器进程,从而避免了由于非正常退出而留下PID文件、导致服务无法启动的问题。monit仍然可以提供监控服务器进程的功能。
我们还全面重写了文档。Alexey和我,两个“外国人”写出的文档,文采就不敢说了,但愿对用户有所帮助就行。
下一步我们将支持x64架构的服务器,进一步加强安全性和可管理性,以及增加对Capistrano的支持。下一次的发布——如果一切顺利的话——应该在“敏捷中国”技术大会之前出来。
系统监控工具:monit和runit的比较
June 4th, 2007
关于Rails的部署:Rails部署艺术
monit作为监控工具有一个缺点:monit会以daemon模式来启动mongrel进程(以及,可能还有,haproxy进程),也就是说每个 mongrel需要自己管理PID文件。问题出现在mongrel被意外杀掉的情况:此时PID文件仍然存在,因此monit没办法再用“mongrel start -d”的命令来启动mongrel。你必须自己想办法清理这些“僵尸PID”文件。
而runit就比较好:它管理的进程都是自己的子进程,这些子进程以阻塞模式运行,所以也没有PID文件。唯一需要注意的是,haproxy缺省是daemon模式,你需要使用“haproxy -db”把haproxy启动在阻塞模式下。
所以,用runit来监控mongrel(和haproxy)进程,monit只是看着这些进程有没有异常状况;如果出现异常状况,monit调用sv来 重启有问题的服务进程。这就是RubyWorks目前采用的系统监控策略。
[转载]RubyWorks入门指南
May 20th, 2007
(抄袭Giive Chen的RubyWorks 0.0.1 Release,感谢Giive的帮助_)
如果你覺得安裝所有的 Ruby on Rails 相關套件,並且將 Production Server系統設定好是一件很麻煩的事情嗎?或許你可以試試看RubyWorks。
RubyWorks 是一個在 Red Hat Enterprise 或是 CentOS 上面的套件組合,他會幫你把所有 Production 環境下面的相關的 Ruby on Rails 套件跟 Server 套件一次安裝完成,並且提供一個馬上可以跑的 defulat config file,也就是說各位公司的技術長們不需要花時間去看那麼多 Production 設定方式,你已經有一個很堪用的 Production Ruby on Rails Server了。
So,你還有理由不玩 Ruby on Rails嗎?
我們看看怎麼安裝 RubyWorks,因為我沒有 Red Hat Enterprise Server,所以我只 Test CentOS。
前置作業
RubyWorks 因為好像還沒進去 yum 資料庫,所以我們還是得必須告訴 yum 哪裡有 RubyWorks 的 Package,如果已經進去yum repo了,就好像不需要這個動作了。
如果你像我一樣,是個不求甚解,只求可以 Work 的人,就這樣打就好了。
wget http://rubyworks.rubyforge.org/public_key.txtsudo rpm—import public_key.txtwget http://rubyworks.rubyforge.org/RubyWorks.repocp RubyWorks.repo /etc/yum.repos.d/
直接用 gem 安裝
yum install rubyworks然後…..裝好了。
Rubyworks 安裝表
RubyWorks 一共會幫你安裝
- ruby
- ruby-devel
- rubygems
- haproxy
- monit
- mongrel
- rubyworks
Rubyworks 詳細位置表
詳細的安裝位置是在
/usr/bin/ruby/:Ruby 所在地/usr/lib/ruby/:Ruby libraries/usr/lib/ruby/1.8/:Ruby standard library/usr/lib/ruby/gems/1.8/gems/:所有安裝的 Ruby gems Package/usr/bin/monit:monit 執行檔/etc/init.d/monit:monit的啟動 script,所有的 server 都會在 monit 啟動的時候,也順便幫你啟動好了(Mongrel,Haproxy)/usr/bin/haproxy:HAProxy 執行檔/usr/bin/mongrel_rails:Mongrel/etc/rails/:configuration files/var/rails/:所有 Deamon 的 .pid files/usr/rails/:Rails app code 所在地。/var/log/monit.log:Monit 的 log/var/log/haproxy.log:HAProxy log/usr/rails/log/:Mongrels and Rails 的 log
Rails部署:反向代理优于FastCGI
May 18th, 2007
RubyWorks采用了基于反向代理和Mongrel的部署方案:HAProxy把请求代理给不同的Mongrel实例。在InfoQ中文站的报道中写道:
“RubyWorks项目领导人Alexey Verkhovsky也认为,只有在对节约内存使用非常重视的情况下(例如虚拟共享主机),FastCGI才有其价值;而在普通的企业应用中,可靠性和可管理性重于节约内存,这也是RubyWorks选择基于反向代理和Mongrel的部署方案的原因。”
在《Agile Web Development with Rails》的第一版中所推荐的部署方案是基于FastCGI的,而第二版则改为推荐基于反向代理的部署方案。James Duncan Davidson在书中写道:
“ 简而言之,FastCGI确实是一枚火箭,但有时会因为各种奇怪的原因而爆炸在发射台上。使用代理让Rails应用直接与HTTP对话,这是整个社群的发展方向。”
即使在DreamHost这样的shared host上,FastCGI也给人们带来了种种困扰,这也是Mongrel(以及相应的,反向代理的部署方案)流行的原因。另一个Rails服务器Swiftiply号称比Mongrel更高性能,不过伸缩性方面都是线性的。
HAProxy -> Mongrel -> Rails
April 24th, 2007
这是一个高性能、高伸缩性的Rails部署方案。有一组性能数据可供参考。
首先接收到HTTP请求的是HAProxy。HAProxy会把请求反向代理给其后的多个Mongrel实例。每个Mongrel实例同一时间只处理一个请求。只要Rails应用本身贯彻无共享架构,就可以直接通过增加服务器和改变HAProxy配置得到线性的性能提升。另外可以用Monit来管理Mongrel实例的开启和关闭,并且在异常状况发生时及时采取措施。这样一来,企业级超复杂所暗含的性能、伸缩性、可管理性等等要求都满足了。
“HAProxy is a free, very fast and reliable solution offering
high availability,
load balancing, and
proxying for TCP and HTTP-based applications.”
“Mongrel is a fast HTTP library and server for Ruby that is intended for hosting
Ruby web applications of any kind using plain HTTP rather than FastCGI or SCGI.”
“monit is a utility for managing and monitoring,
processes, files, directories and devices on a UNIX
system.”
(今天下午和George讨论的主题:我们已经听厌了“企业级”这样的大帽子。我们需要做的是弄明白所谓“企业级”究竟代表什么,然后把解决方案拿出来。基本上——如果真的喜欢“企业级”的话——这就是所谓的“企业级Rails”了。)



