Cloud Foundry体验

简介:
注册:

http://cloudfoundry.com/ 注册完了等一会会收到一个随机密码
登陆系统后可以创建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 [http://api.cloudfoundry.com]

# vmc login
Successfully logged into [http://api.cloudfoundry.com]

#vmc info
VMware's Cloud Application Platform
For support visit http://support.cloudfoundry.com
Target:   http://api.cloudfoundry.com (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

接着打开http://feisky.cloudfoundry.com/就可以访问刚才发布的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 <appname>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等) 支持多种云计算平台,能提升开发者的生产力,加速软件开发部署。
本文转自feisky博客园博客,原文链接:http://www.cnblogs.com/feisky/archive/2012/03/24/2416004.html,如需转载请自行联系原作者

相关文章
|
7月前
|
人工智能 安全 Linux
开箱即用的使用体验!Alibaba Cloud Linux 的演进之旅
AI时代的到来,对操作系统带来怎样的挑战?
开箱即用的使用体验!Alibaba Cloud Linux 的演进之旅
|
10天前
|
Java Nacos Sentinel
Spring Cloud Alibaba:一站式微服务解决方案
Spring Cloud Alibaba(简称SCA) 是一个基于 Spring Cloud 构建的开源微服务框架,专为解决分布式系统中的服务治理、配置管理、服务发现、消息总线等问题而设计。
121 13
Spring Cloud Alibaba:一站式微服务解决方案
|
Go 网络架构
Cloud Foundry 2. 核心概念
Cloud Foundry 2. 核心概念
Cloud Foundry 2. 核心概念
|
消息中间件 Kubernetes Java
Spring Cloud Alibaba 生态发展和近期规划 | 学习笔记
快速学习 Spring Cloud Alibaba 生态发展和近期规划
Spring Cloud Alibaba 生态发展和近期规划 | 学习笔记
|
Java 数据库 微服务
10.3k?这才是企业级的 Spring Cloud Alibaba 微服务开发平台,真心牛 x! 下
10.3k?这才是企业级的 Spring Cloud Alibaba 微服务开发平台,真心牛 x! 下
|
消息中间件 监控 NoSQL
10.3k?这才是企业级的 Spring Cloud Alibaba 微服务开发平台,真心牛 x! 上
10.3k?这才是企业级的 Spring Cloud Alibaba 微服务开发平台,真心牛 x! 上
|
Shell API Go
Cloud Foundry 1. 快速入门
Cloud Foundry 1. 快速入门
Cloud Foundry 1. 快速入门
|
消息中间件 Kubernetes Java
Spring Cloud Alibaba 生态发展和近期规划
Spring Cloud Alibaba 的诞生得益于过往数十年处理淘系电商高并发大流量业务所积累的技术经验,阿里巴巴内部沉淀了一套包括限流降级、分布式配置、注册中心、分布式消息、分布式事务等完整的微服务解决方案,比如 Sentinel、RocketMQ 等。 2015 年 6 月, Spring Cloud 第一个正式版本发布后,得益于 SpringBoot 奠定的用户群体基础,再加上 Spring Cloud 本身较为完善的解决方案能力和简单易上手的特点,迅速成为微服务技术圈热点。
Spring Cloud Alibaba 生态发展和近期规划
|
Ubuntu 物联网 Docker