Chinaunix首页 | 论坛 | 博客
  • 博客访问: 876927
  • 博文数量: 372
  • 博客积分: 10063
  • 博客等级: 中将
  • 技术积分: 4220
  • 用 户 组: 普通用户
  • 注册时间: 2012-02-24 11:36
文章分类

全部博文(372)

文章存档

2012年(372)

分类: 虚拟化

2012-04-12 18:43:20

注册:

注册完了等一会会收到一个随机密码
登陆系统后可以创建Micro Cloud Foundry,接着可以下载一个可以用VMWare打开的镜像。下面的操作不需要下载这个镜像。

安装vmc:

Installing Ruby and RubyGems:
    sudo apt-get install ruby-full rubygems
    sudo gem install rubygems-update
    sudo /var/lib/gems/1.8/bin/update_rubygems 
Installing vmc:
    sudo gem install vmc

Specify the Cloud Foundry target

# vmc target api.cloudfoundry.com
Successfully targeted to []

# vmc login
Successfully logged into []

#vmc info
VMware's Cloud Application Platform
For support visit
Target:   (v0.999)
Client:   v0.3.15
User:     <##############>
Usage:    Memory   (0B of 2.0G total)
          Services (0 of 16 total)
          Apps     (0 of 20 total)
          

A simple Ruby Hello World application using Sintatra

Install Sinatra Web framework
# gem install sinatra
# mkdir -p /usr/bob/sample-apps/hello
# cd /usr/bob/sample-apps/hello/
# vim hello.rb
require 'sinatra'
get '/' do
        "Hello from Cloud Foundry"
end

Push hello to cloudfoundry:
# vmc push
Would you like to deploy from the current directory? [Yn]: y
Application Name: feisky
Application Deployed URL [feisky.cloudfoundry.com]: 
Detected a Sinatra Application, is this correct? [Yn]: 
Memory Reservation (64M, 128M, 256M, 512M, 1G, 2G) [128M]: 
Creating Application: OK
Would you like to bind any services to 'feisky'? [yN]: 
Uploading Application:
  Checking for available resources: OK
  Packing application: OK
  Uploading (0K): OK   
Push Status: OK
Staging Application: OK
Starting Application: OK

接着打开就可以访问刚才发布的app

可以通过下面的命令查看已有的apps:
# vmc apps

+-------------+----+---------+-------------------------+----------+
| Application | #  | Health  | URLS                    | Services |
+-------------+----+---------+-------------------------+----------+
| feisky      | 1  | RUNNING | feisky.cloudfoundry.com |          |
+-------------+----+---------+-------------------------+----------+

更新已有的app:
# vmc update feisky

Logging

root@localhost:~# vmc files feisky logs (当前有哪些log文件)
stderr.log                                185B
stdout.log                                217B

root@localhost:~# vmc files feisky logs/stdout.log (读log文件的内容)
== Sinatra/1.2.1 has taken the stage on 54337 for production with backup from Thin
>> Thin web server (v1.2.11 codename Bat-Shit Crazy)
>> Maximum connections set to 1024
>> Listening on 0.0.0.0:54337, CTRL+C to stop

If you suspect that your application has crashed recently, run vmc crashes which will provide you with more information:

prompt$ vmc crashes hotels

Use vmc crashlogs to get more detailed information about the crash:

prompt$ vmc crashlogs hotels
Managing the Application Lifecycle:
# vmc restart feisky
Stopping Application: OK
Staging Application: OK
Starting Application: OK
# vmc start feisky
# vmc stop feisky
# vmc rename old-name new-name
# vmc delete feisky
Avoiding Downtime When Updating The Deployment Bits
 vmc push feisky-new
 vmc map feisky-new feisky.cloudfoundry.com
 # vmc apps
+-------------+----+---------+------------------------------------------------------+----------+
| Application | #  | Health  | URLS                                                 | Services |
+-------------+----+---------+------------------------------------------------------+----------+
| feisky      | 1  | RUNNING | feisky.cloudfoundry.com                              |          |
| feisky-new  | 1  | RUNNING | feisky-new.cloudfoundry.com, feisky.cloudfoundry.com |          |
+-------------+----+---------+------------------------------------------------------+----------+
此时,访问feisky.cloudfoundry.com,有的时候会访问到老版本,有的时候会访问到新版本
Disassociate the old application from its original deployment URL:
# vmc unmap feisky feisky.cloudfoundry.com
Disassociate the new application from its new deployment URL:
# vmc unmap feisky-new feisky-new.cloudfoundry.com
Delete old application:
# vmc delete feisky
Monitering
# vmc stats feisky-new (当前的资源占用情况)

+----------+-------------+----------------+--------------+---------------+
| Instance | CPU (Cores) | Memory (limit) | Disk (limit) | Uptime        |
+----------+-------------+----------------+--------------+---------------+
| 0        | 0.0% (4)    | 17.2M (128M)   | 44.0K (2G)   | 0d:0h:12m:20s |
+----------+-------------+----------------+--------------+---------------+

# vmc mem feisky-new 512
Updating Memory Reservation to 512M: OK
Stopping Application: OK
Staging Application: OK                                                         
Starting Application: OK                                                        

# vmc stats feisky-new  (改变应用的内存上限)

+----------+-------------+----------------+--------------+-------------+
| Instance | CPU (Cores) | Memory (limit) | Disk (limit) | Uptime      |
+----------+-------------+----------------+--------------+-------------+
| 0        | 3.9% (4)    | 17.0M (512M)   | 40.0K (2G)   | 0d:0h:0m:5s |
+----------+-------------+----------------+--------------+-------------+

#  vmc instances feisky-new 4 (将应用的实例数改为4)
Scaling Application instances up to 4: OK

# vmc stats feisky-new  

+----------+-------------+----------------+--------------+--------------+
| Instance | CPU (Cores) | Memory (limit) | Disk (limit) | Uptime       |
+----------+-------------+----------------+--------------+--------------+
| 0        | 0.1% (4)    | 17.0M (512M)   | 40.0K (2G)   | 0d:0h:1m:21s |
| 1        | 2.7% (4)    | 17.0M (512M)   | 40.0K (2G)   | 0d:0h:0m:6s  |
| 2        | 3.6% (4)    | 17.0M (512M)   | 40.0K (2G)   | 0d:0h:0m:6s  |
| 3        | 3.4% (4)    | 17.0M (512M)   | 40.0K (2G)   | 0d:0h:0m:6s  |
+----------+-------------+----------------+--------------+--------------+
总结:
Cloud Foundry是VMware用Ruby实现的业界首个开源PaaS平台,支持多种语言(Ruby、Java、Javascript、Python、 PHP等)以及开发框架(Rails、Sinatra、Spring、NodeJS等),能集成各种后端serivce(Mysql、MongoDB、 Redis等) 支持多种云计算平台,能提升开发者的生产力,加速软件开发部署。
阅读(972) | 评论(3) | 转发(0) |
给主人留下些什么吧!~~

最乖啦啦2012-04-15 21:29:06

呵呵,这个东东现在我还用不上啊`

泥亚鳅2012-04-14 12:54:00

恩恩  这个的确有点意思。

鸪灵2012-04-13 23:42:23

看上去不错的样子,什么时候我也去看看。。。