之前写过一个Guide for Cloud Foundry New Teamer。不过似乎已经有些过时,那会实验室主要是针对的CF v1进行的研究,现在已经全面进入V2时代了。所以更新一下关于CloudFoundry运维的一些内容。如果有时间也可再回头看看V1的那个帖子,希望能有所帮助。

部署

关于部署,目前使用的工具一般有两种,BOSH和cf_nise_installer。BOSH适用于集群安装,cf_nise_installer适用于单节点安装。下面主要以cf_nise_installer的安装方法为主描述部署的运维流程。

cf_nise_installer实际上就是一大堆shell脚本建立起来的项目,对shell脚本熟悉的人打开上面的链接就可以看到整个部署的流程。

第一步就是安装运行环境。

通过cf_nise_installer中的这段install.sh脚本的代码我们可以看到它的安装流程如下:

./scripts/install_ruby.sh
source ~/.profile
./scripts/clone_nise_bosh.sh
./scripts/clone_cf_release.sh
./scripts/install_environemnt.sh
./scripts/install_cf_release.sh
  • 安装ruby:cf_nise_installer使用的是rbenv这个ruby安装工具。同样比较有名的ruby安装工具还有rvm,这两个工具任选一个即可,如果是使用某个固定的ruby版本的话,建议使用源码安装。
  • 下载nise_bosh项目:实际上cf_nise_installer是基于nise_bosh的一个脚本,真正执行安装的就是nise_bosh这个项目。nise_bosh是一个基于bosh的项目,把bosh关于IaaS层的内容去除,保留了虚拟机上组建安装的内容。所以使用nisebosh无需IaaS层的API支持,只需要虚拟机即可安装
  • 制作cf_release:cf_release是cf源码经过编译后的内容。从github上clone下来的cf_release,checkout到指定版本git使用简易入门,然后执行git submodule update --init --recursive把子模块submodule下载下来,再执行bosh create release命令,就可以得到一个完整的cf_release,当然,这里面又是漫长的下载。实验室已经制作了几个常用的cf_release版本,在内网可以下载。
  • 安装环境,这里执行的其实就是nise_bosh/bin/init这个脚本,打开就可以看到下载了很多基础的运行时环境,以及监控使用的monit工具。
  • 安装cf组件。到这里就是真正的安装cf组件了。安装的命令很短,东西都在配置文件里面了。可以打开manifests/template查看一下。默认的域名都设置成了192.168.10.10.xip.io,执行generate_deploy_manifest.sh脚本可以更改域名和密码,不过需要在环境变量中导入export NISE_DOMAIN=[你的域名]export NISE_PASSWORD=[你的密码]

关于域名 架设本地域名解析服务器,如bind9之类的,然后在/etc/resolv.conf下面的nameserver加上本地域名解析服务器IP即可。在域名解析服务器上加上一条域名对应组件机器的IP就可以顺利用域名访问集群了。

关于一次正常的连接 [用户访问域名]->[域名解析服务器解析出IP]->[Haproxy组件收到请求转发]->[Gorouter接到请求]->[DEA/CC最终处理]

集群使用

安装CF命令行工具

下载并安装cf_clidpkg -i ***.deb。新版cf命令行的命令有比较大的变化,可以使用cf --help看一下。

制作离线java_buildpack

cloudfoundry从V168以后,就不在cf-release里面放入buildpack了,也就是云应用的运行时环境。每次应用上传都要去pivotal的网站上下buildpack,速度比较慢,所以就涉及到了制作离线的buildpack。官方的java_buildpack就提供了制作离线包的功能。Clone下来以后执行如下步骤就制作成功了一个zip包。

bundle install
bundle exec rake package OFFLINE=true
...
Creating build/java-buildpack-offline-cfd6b17.zip

然后使用cf命令上传离线的buildpack,参数的意思可以从help中查看。

root@cf-one:~/java-buildpack# cf create-buildpack test_pack ./build/java-buildpack-offline-abe37f7.zip 0
Creating buildpack test_pack...
OK
Uploading buildpack test_pack...
OK root@cf-one:~/java-buildpack# cf buildpacks
Getting buildpacks... buildpack position enabled locked filename
java_buildpack 2 true false java-buildpack-v2.1.2.zip
ruby_buildpack 3 true false buildpack_ruby_v46-245-g2fc4ad8.zip
nodejs_buildpack 4 true false buildpack_nodejs_v8-177-g2b0a5cf.zip
test_pack 1 true false java-buildpack-offline-abe37f7.zip

使用CF-CLI命令行上传应用

如果用户名密码都是默认的话,使用流程基本如下:

target

root@cf-one:~/yd/cf_nise_installer# cf api --skip-ssl-validation api.test4.sel
Setting api endpoint to api.test4.sel...
OK
API endpoint: https://api.test4.sel (API version: 2.2.0)
Not logged in. Use 'cf login' to log in.

login

root@cf-one:~/yd/cf_nise_installer# cf login
API endpoint: https://api.test4.sel
Email> admin
Password>
Authenticating...
OK
Targeted org DevBox
Select a space (or press enter to skip):
Space> API endpoint: https://api.test4.sel (API version: 2.2.0)
User: admin
Org: DevBox
Space: No space targeted, use 'cf target -s SPACE'

org

root@cf-one:~/yd/cf_nise_installer# cf create-org sun
Creating org sun as admin...
OK
TIP: Use 'cf target -o sun' to target new org
root@cf-one:~/yd/cf_nise_installer# cf target -o sun
API endpoint: https://api.test4.sel (API version: 2.2.0)
User: admin
Org: sun
Space: No space targeted, use 'cf target -s SPACE'

space

root@cf-one:~/yd/cf_nise_installer# cf create-space test
Creating space test in org sun as admin...
OK
Assigning role SpaceManager to user admin in org sun / space test as admin...
OK
Assigning role SpaceDeveloper to user admin in org sun / space test as admin...
OK TIP: Use 'cf target -o sun -s test' to target new space
root@cf-one:~/yd/cf_nise_installer# cf create-space test
Creating space test in org sun as admin...
OK
Assigning role SpaceManager to user admin in org sun / space test as admin...
OK
Assigning role SpaceDeveloper to user admin in org sun / space test as admin...
OK
TIP: Use 'cf target -o sun -s test' to target new space root@cf-one:~/yd/cf_nise_installer# cf target -o sun -s test
API endpoint: https://api.test4.sel (API version: 2.2.0)
User: admin
Org: sun
Space: test

Push APP

root@cf-one:~# cf push test -p helloworldWeb.war -b test_pack
Creating app test in org sun / space test as admin...
OK Creating route test.test4.sel...
OK Binding test.test4.sel to test...
OK Uploading test...
Uploading app files from: helloworldWeb.war
Uploading 2.6K, 10 files
OK Starting app test in org sun / space test as admin...
OK
-----> Downloaded app package (4.0K)
-----> Java Buildpack Version: abe37f7 (offline) | https://github.com/cloudfoundry/java-buildpack.git#abe37f7
-----> Downloading Open Jdk JRE 1.7.0_60 from http://download.run.pivotal.io/openjdk/lucid/x86_64/openjdk-1.7.0_60.tar.gz (found in cache)
Expanding Open Jdk JRE to .java-buildpack/open_jdk_jre (2.1s)
-----> Downloading Tomcat Instance 7.0.54 from http://download.run.pivotal.io/tomcat/tomcat-7.0.54.tar.gz (found in cache)
Expanding Tomcat to .java-buildpack/tomcat (0.1s)
-----> Downloading Tomcat Lifecycle Support 2.1.0_RELEASE from http://download.run.pivotal.io/tomcat-lifecycle-support/tomcat-lifecycle-support-2.1.0_RELEASE.jar (found in cache)
-----> Downloading Tomcat Logging Support 2.1.0_RELEASE from http://download.run.pivotal.io/tomcat-logging-support/tomcat-logging-support-2.1.0_RELEASE.jar (found in cache)
-----> Uploading droplet (38M) 0 of 1 instances running, 1 starting
1 of 1 instances running App started Showing health and status for app test in org sun / space test as admin...
OK requested state: started
instances: 1/1
usage: 1G x 1 instances
urls: test.test4.sel state since cpu memory disk
#0 running 2014-06-19 08:10:08 AM 0.0% 170.5M of 1G 96M of 1G root@cf-one:~# curl test.test4.sel
<html>
<body>
<h2>Hello World!</h2>
</body>
</html>

至此,就成功上传了一个应用了。

查看应用状态

root@cf-one:~# cf apps
Getting apps in org sun / space test as admin...
OK name requested state instances memory disk urls
test started 1/1 1G 1G test.test4.sel

重启一个应用

oot@cf-one:~# cf restart test
Stopping app test in org sun / space test as admin...
OK
Starting app test in org sun / space test as admin...
OK
0 of 1 instances running, 1 starting
0 of 1 instances running, 1 starting
1 of 1 instances running
App started Showing health and status for app test in org sun / space test as admin...
OK
requested state: started
instances: 1/1
usage: 1G x 1 instances
urls: test.test4.sel state since cpu memory disk
#0 running 2014-06-19 08:19:38 AM 0.0% 170M of 1G 96M of 1G

集群维护

目前集群的维护都是使用的monit工具进行简单的组件监控。更多的维护还需要查看组件的日志。组件日志一般在/var/vcap/sys/log

查看集群组件状态

root@cf-one:~# monit summary
The program 'monit' is currently not installed. You can install it by typing:
apt-get install monit
You will have to enable the component called 'universe'
root@cf-one:~# /var/vcap/bosh/bin/monit summary
The Monit daemon 5.2.4 uptime: 44m Process 'nats' running
Process 'nats_stream_forwarder' running
Process 'cloud_controller_ng' running
Process 'cloud_controller_worker_local_1' running
Process 'cloud_controller_worker_local_2' running
Process 'nginx_ccng' running
Process 'cloud_controller_worker_1' running
Process 'cloud_controller_clock' running
Process 'uaa' running
Process 'uaa_cf-registrar' running
Process 'haproxy' running
Process 'gorouter' running
Process 'warden' running
Process 'dea_next' running
Process 'dir_server' running
Process 'dea_logging_agent' running
Process 'loggregator' running
Process 'loggregator_trafficcontroller' running
Process 'etcd' running
Process 'hm9000_listener' running
Process 'hm9000_fetcher' running
Process 'hm9000_analyzer' running
Process 'hm9000_sender' running
Process 'hm9000_metrics_server' running
Process 'hm9000_api_server' running
Process 'hm9000_evacuator' running
Process 'hm9000_shredder' running
Process 'postgres' running
System 'system_cf-one' running

重启某个组件

root@cf-one:~# monit restart postgres

重启所有组件

root@cf-one:~# monit restart all

Cloud Foundry v2 部署及入门运维的更多相关文章

  1. 部署MySQL自动化运维工具inception+archer

    ***************************************************************************部署MySQL自动化运维工具inception+a ...

  2. 往ABAP gateway system上和Cloud Foundry上部署HTML5应用

    ABAP Gateway system 在我的公众号文章里有详细介绍:SAP Fiori应用的三种部署方式 用WebIDE部署 用Eclipse Team provider部署 执行report /U ...

  3. 如何高效地远程部署?自动化运维利器 Fabric 教程

    关于 Python 自动化的话题,在上一篇文章中,我介绍了 Invoke 库,它是 Fabric 的最重要组件之一.Fabric 也是一个被广泛应用的自动化工具库,是不得不提的自动化运维利器,所以,本 ...

  4. 基于Cloud Foundry平台部署nodejs项目上线

    Cloud Foundry(以下简称CF),CF是Vmware公司的PaaS服务平台,Paas(Platform as a Service,平台即服务), 是为开发者提供一个应用运行的平台,有了这人平 ...

  5. 在centOS 7 上部署ansible自动化运维环境(01)

    环境:         3台centos 7        mycat : 10.0.0.2 mariadb1: 10.0.0.3 mariadb2: 10.0.0.4        为了实验方便 f ...

  6. k8s部署03-----常用运维命令

    kubectl常用命令 kubectl get nodes #查看集群中有多少个node kubectl describe node <node_name> #查看某个node的详细信息 ...

  7. Docker集群管理工具 - Kubernetes 部署记录 (运维小结)

    一.  Kubernetes 介绍 Kubernetes是一个全新的基于容器技术的分布式架构领先方案, 它是Google在2014年6月开源的一个容器集群管理系统,使用Go语言开发,Kubernete ...

  8. 阿里云运维部署工具AppDeploy详细教程

    AppDeploy是一个通过SSH实现的命令行工具,可完成应用部署和远程运维管理.当前工具实现为两个版本:普通版(伪代码描述语言)和Python版.Python版使用Python语法规则,可实现您的各 ...

  9. linux运维、架构之路-Kubernetes集群部署

    一.kubernetes介绍        Kubernetes简称K8s,它是一个全新的基于容器技术的分布式架构领先方案.Kubernetes(k8s)是Google开源的容器集群管理系统(谷歌内部 ...

随机推荐

  1. Nginx反向代理时tomcat日志获取真实IP

    对于nginx+tomcat这种架构,如果后端tomcat配置保持默认,那么tomcat的访问日志里,记录的就是前端nginx的IP地址,而不是真实的访问IP.因此,需要对nginx.tomcat做如 ...

  2. 收藏点webservice接口

    商业和贸易: 1.股票行情数据 WEB 服务(支持香港.深圳.上海基金.债券和股票:支持多股票同时查询) Endpoint: http://webservice.webxml.com.cn/WebSe ...

  3. 初级JS

    唐太宗  李世民  杀了大哥 和弟弟  登上的皇位    一个人当皇帝 排他性是指一种物品具有可以阻止其他人使用该物品的特性. 排他性思想: 在程序中但凡是遇到只让自己怎么样,不让别人怎么样的效果,都 ...

  4. 魅族手机USB调试无法打开、log无法打印

    MEIZU 在打开usb调试允许时,总提示:because an app is oobscuring a premision request, Setting can't verify your re ...

  5. War3编辑器

    [War3编辑器] 1.英雄在商店买东西叫“任意单位 出售物品”,英雄卖东西给商店叫“抵押物品”. 2.触发器中的一级窗口包含: 1)设置事件窗口. 2)设置条件窗口. 3)设置动作窗口. 3.二级设 ...

  6. C#之代码优化

    1.if和swith: 区别:1.if语句会执行多次判断,增加CPU的消耗,效率较低:switch只判断一次,效率较高 2.if表示的是一个范围,switch表示一个点 2.for和foreach f ...

  7. EHR ORA--1187由于验主频雘失败而无法从文件读取 ORA-01110数据文件temp01.dbf

    alter tablespace TEMP add tempfile '/data/oracle/oradata/orcl/temp02.dbf' size 100m autoextend on; a ...

  8. 搭建jsp渗透测试环境

    java运行环境下载地址:http://www.oracle.com/technetwork/java/javase/downloads/jre8-downloads-2133155.html fir ...

  9. 算法之LOWB三人组之选择排序

    选择排序 思想是在一个列表中每次循环一遍,拿到最小值,接着再从剩下的无序区中继续拿最小值,如此循环,直到结束. 时间复杂度为O(n^2) # 最简单的一个选择排序,循环一个列表,拿到最小值,添加到一个 ...

  10. 两种创建Observable的方法(转)

    转自:http://blog.csdn.net/nicolelili1/article/details/52038211 Observable.create() create()方法使开发者有能力从头 ...