本文在介紹關(guān)于CloudFoundry in 1 Box的基礎(chǔ)上,重點(diǎn)探討了Lattice的使用具體步驟,步驟簡(jiǎn)單易上手操作,文章內(nèi)容步步緊湊,希望大家根據(jù)這篇文章可以有所收獲。
創(chuàng)新互聯(lián)長(zhǎng)期為近千家客戶提供的網(wǎng)站建設(shè)服務(wù),團(tuán)隊(duì)從業(yè)經(jīng)驗(yàn)10年,關(guān)注不同地域、不同群體,并針對(duì)不同對(duì)象提供差異化的產(chǎn)品和服務(wù);打造開放共贏平臺(tái),與合作伙伴共同營(yíng)造健康的互聯(lián)網(wǎng)生態(tài)環(huán)境。為周寧企業(yè)提供專業(yè)的成都做網(wǎng)站、成都網(wǎng)站建設(shè)、成都外貿(mào)網(wǎng)站建設(shè),周寧網(wǎng)站改版等技術(shù)服務(wù)。擁有十多年豐富建站經(jīng)驗(yàn)和眾多成功案例,為您定制開發(fā)。1. Lattice簡(jiǎn)介
Lattice是一個(gè)很有意思的項(xiàng)目,設(shè)計(jì)目標(biāo)是為Cloud Foundry的開發(fā)人員提供一個(gè)最小的App運(yùn)行時(shí)環(huán)境,所以它只選擇了Cloud Foundry中與App運(yùn)行相關(guān)的組件,從而組成了一個(gè)最簡(jiǎn)化的開發(fā)測(cè)試Cloud Foundry App的環(huán)境。
如上圖所示,Lattice僅包含如下組件
Router:負(fù)責(zé)訪問(wèn)App請(qǐng)求的routing
Diego:Cloud Foundry App的運(yùn)行時(shí)環(huán)境
Blob store: App staging的存儲(chǔ)空間
loggregator:log服務(wù)器,供app開發(fā)者查看app運(yùn)行時(shí)日志
下面我們就來(lái)一步一步搭建一個(gè)Lattice環(huán)境
2. 環(huán)境準(zhǔn)備
筆者采用的事Cent OS 7.2作為宿主機(jī)的操作系統(tǒng),VirtualBox為虛擬機(jī)平臺(tái)
2.1 安裝以來(lái)的軟件包
# 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環(huán)境
筆者使用rbenv來(lái)安裝和管理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驗(yàn)證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時(shí)需要linux kernel的源代碼,設(shè)置KERN_DIR環(huán)境變量指示kernel源代碼路徑 # export KERN_DIR=/usr/src/kernels/<your kernel dir> # rpm -Uvh VirtualBox-5.0-5.0.16_105871_el7-1.x86_64.rpm驗(yàn)證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-<version>.zip3.3 啟動(dòng)Lattice
# cd <lattice>/vagrant # vagrant up --provider=virtualbox3.4 查看PCF-dev component
# cd <lattice>/vagrant # vagrant ssh ##登陸pcf-dev虛擬機(jī) # 登陸之后的pcf-dev虛擬機(jī) $ sudo -i # monit summary root@agent-id-pcfdev-0:~# monit summary The Monit daemon 5.2.4 uptime: 17m Process 'auctioneer' running Process 'receptor' running Process 'bbs' running Process 'converger' running Process 'file_server' running Process 'route_emitter' running Process 'ssh_proxy' running Process 'rep' running Process 'rootfses' running Process 'garden' running File 'haproxy_config' accessible Process 'haproxy' running Process 'router_configurer' running Process 'tcp_emitter' running Process 'routing-api' running Process 'consul_agent' running Process 'doppler' running Process 'gorouter' running Process 'loggregator_trafficcontroller' running Process 'metron_agent' running Process 'nats' running Process 'route_registrar' running Process 'etcd' running System 'system_lattice-colocated-0' running啟動(dòng)后的Lattice虛擬機(jī)配置了兩塊網(wǎng)卡,一塊用來(lái)連接CloudFoundry網(wǎng)絡(luò),使用10.0.2.15/24;一塊用來(lái)和宿主機(jī)通信,使用IP 192.168.11.11. Lattice默認(rèn)的域名為local.lattice.cf
如果設(shè)有http/https proxy,需要執(zhí)行如下步驟
至此,Lattice環(huán)境準(zhǔn)備完畢。
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默認(rèn)的域名為local.lattice.cf, *.local.lattice.cf會(huì)被解析到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
因?yàn)閘attice環(huán)境僅包含運(yùn)行Cloud Foundry App的最小環(huán)境,不包含任何buildpack,所以使用Lattice運(yùn)行Cloud Foundry App需要兩個(gè)步驟
build Cloud Foundry droplet,在這個(gè)步驟中,需要顯示指定buildpack,以ruby app為例
2. 啟動(dòng)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使用和部署的詳細(xì)內(nèi)容,具體使用情況還需要大家自己動(dòng)手實(shí)驗(yàn)使用過(guò)才能領(lǐng)會(huì)。如果想了解更多相關(guān)內(nèi)容,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。
文章名稱:CloudFoundryin1Box之Lattice使用介紹-創(chuàng)新互聯(lián)
本文來(lái)源:http://www.rwnh.cn/article42/dcdchc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供外貿(mào)建站、虛擬主機(jī)、網(wǎng)站設(shè)計(jì)公司、服務(wù)器托管、App設(shè)計(jì)、網(wǎng)站營(yíng)銷
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容