CloudFoundryin1Box之Lattice使用介绍-创新互联
本文在介绍关于CloudFoundry in 1 Box的基础上,重点探讨了Lattice的使用具体步骤,步骤简单易上手操作,文章内容步步紧凑,希望大家根据这篇文章可以有所收获。
创新互联长期为近千家客户提供的网站建设服务,团队从业经验10年,关注不同地域、不同群体,并针对不同对象提供差异化的产品和服务;打造开放共赢平台,与合作伙伴共同营造健康的互联网生态环境。为周宁企业提供专业的成都做网站、成都网站建设、成都外贸网站建设,周宁网站改版等技术服务。拥有十多年丰富建站经验和众多成功案例,为您定制开发。1. Lattice简介
Lattice是一个很有意思的项目,设计目标是为Cloud Foundry的开发人员提供一个最小的App运行时环境,所以它只选择了Cloud Foundry中与App运行相关的组件,从而组成了一个最简化的开发测试Cloud Foundry App的环境。
如上图所示,Lattice仅包含如下组件
Router:负责访问App请求的routing
Diego:Cloud Foundry App的运行时环境
Blob store: App staging的存储空间
loggregator:log服务器,供app开发者查看app运行时日志
下面我们就来一步一步搭建一个Lattice环境
2. 环境准备
笔者采用的事Cent OS 7.2作为宿主机的操作系统,VirtualBox为虚拟机平台
2.1 安装以来的软件包
# rpm -Uvh http://mirror.pnl.gov/epel/7/x86_64/e/epel-release-7-5.noarch.rpm # yum install -y vim git screen kernel* libX11 qt SDL SDL-devel libxml2-devel \ libvpx libpng libXt libXmu libxslt libxslt-devel openssl \ openssl-devel libXcursor libXinerama qt qt-devel wget gcc unzip ntpdate net-tools2.2 安装Ruby环境
笔者使用rbenv来安装和管理ruby
# git clone git://github.com/sstephenson/rbenv.git $HOME/.rbenv # git clone https://github.com/sstephenson/ruby-build.git $HOME/.rbenv/plugins/ruby-build # echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile # echo 'eval "$(rbenv init -)"' >> ~/.bash_profile # source ~/.bash_profile # rbenv install 2.3.0 # rbenv global 2.1.3 # gem install bundle # gem install nokogiri — --use-system-libraries2.3安装Vagrant
# wget https://releases.hashicorp.com/vagrant/1.8.1/vagrant_1.8.1_x86_64.rpm # rpm -Uvh vagrant_1.8.1_x86_64.rpm验证vagrant
# vagrant --version Vagrant 1.8.12.4 安装VirtualBox
# wget http://download.virtualbox.org/virtualbox/5.0.16/VirtualBox-5.0-5.0.16_105871_el7-1.x86_64.rpm # #安装virtualbox时需要linux kernel的源代码,设置KERN_DIR环境变量指示kernel源代码路径 # export KERN_DIR=/usr/src/kernels/验证virtualbox是否安装成功
# VBoxManage --version 5.0.16r1058713. 部署Lattice
3.1 从github上下载最新的lattice release
# wget https://github.com/cloudfoundry-incubator/lattice-release/releases/latest3.2 解压Lattice
# gunzip lattice-bundle-3.3 启动Lattice
# cd3.4 查看PCF-dev component
# cd启动后的Lattice虚拟机配置了两块网卡,一块用来连接CloudFoundry网络,使用10.0.2.15/24;一块用来和宿主机通信,使用IP 192.168.11.11. Lattice默认的域名为local.lattice.cf
如果设有http/https proxy,需要执行如下步骤
至此,Lattice环境准备完毕。
4. 部署app到Lattice
4.1 安装Lattice CLI
# curl -O http://receptor.local.lattice.cf/v1/sync/linux/ltc # chmod +x ltc4.2 Lattice target
Lattice默认的域名为local.lattice.cf, *.local.lattice.cf会被解析到192.168.11.11
# ping xyz.local.lattice.cf PING xyz.local.pcfdev.io (192.168.11.11) 56(84) bytes of data. 64 bytes from 192.168.11.11: icmp_seq=1 ttl=64 time=0.818 ms 64 bytes from 192.168.11.11: icmp_seq=2 ttl=64 time=1.45 ms 64 bytes from 192.168.11.11: icmp_seq=3 ttl=64 time=1.33 ms 64 bytes from 192.168.11.11: icmp_seq=4 ttl=64 time=1.69 ms 64 bytes from 192.168.11.11: icmp_seq=5 ttl=64 time=1.25 ms ^C --- xyz.local.pcfdev.io ping statistics --- 5 packets transmitted, 5 received, 0% packet loss, time 4006ms rtt min/avg/max/mdev = 0.818/1.311/1.696/0.292 ms# lattice target local.pcfdev.io API location set.4.3 部署App
因为lattice环境仅包含运行Cloud Foundry App的最小环境,不包含任何buildpack,所以使用Lattice运行Cloud Foundry App需要两个步骤
build Cloud Foundry droplet,在这个步骤中,需要显示指定buildpack,以ruby app为例
2. 启动droplet
# ltc launch-droplet helloruby helloruby No port specified. Defaulting to 8080. Creating App: helloruby .04/20 22:37:00.15 [APP|0] Creating container .04/20 22:37:01.77 [APP|0] Successfully created container ..............04/20 22:37:16.10 [HEALTH|0] healthcheck failed 04/20 22:37:16.14 [HEALTH|0] Exit status 1 04/20 22:37:16.56 [SSH|0] {"timestamp":"1461163036.562246799","source":"sshd","message":"sshd.started","log_level":1,"data":{}} 04/20 22:37:16.81 [HEALTH|0] healthcheck failed 04/20 22:37:16.83 [HEALTH|0] Exit status 1 .04/20 22:37:17.54 [HEALTH|0] healthcheck failed 04/20 22:37:17.57 [HEALTH|0] Exit status 1 .04/20 22:37:18.04 [APP|0] I, [2016-04-20T14:37:18.041860 #10] INFO -- : Refreshing Gem list 04/20 22:37:18.26 [APP|0] I, [2016-04-20T14:37:18.253960 #10] INFO -- : listening on addr=0.0.0.0:8080 fd=9 04/20 22:37:18.27 [APP|0] I, [2016-04-20T14:37:18.266758 #10] INFO -- : master process ready 04/20 22:37:18.27 [HEALTH|0] healthcheck passed 04/20 22:37:18.31 [APP|0] I, [2016-04-20T14:37:18.280764 #43] INFO -- : worker=0 ready 04/20 22:37:18.32 [APP|0] I, [2016-04-20T14:37:18.284959 #49] INFO -- : worker=2 ready 04/20 22:37:18.33 [APP|0] I, [2016-04-20T14:37:18.305195 #46] INFO -- : worker=1 ready 04/20 22:37:18.35 [HEALTH|0] Exit status 0 helloruby is now running. App is reachable at: http://helloruby.local.lattice.cf http://helloruby-8080.local.lattice.cf上文描述的就是Lattice使用和部署的详细内容,具体使用情况还需要大家自己动手实验使用过才能领会。如果想了解更多相关内容,欢迎关注创新互联行业资讯频道!
另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
分享文章:CloudFoundryin1Box之Lattice使用介绍-创新互联
文章分享:http://cdiso.cn/article/dcdchc.html