關於部署,目前使用的工具通常有兩種,BOSH和cf_nise_installer。BOSH適用於集羣安裝,cf_nise_installer適用於單節點安裝。下面主要以cf_nise_installer的安裝方法爲主描述部署的運維流程。html
cf_nise_installer實際上就是一大堆shell腳本創建起來的項目,對shell腳本熟悉的人打開上面的連接就能夠看到整個部署的流程。java
第一步就是安裝運行環境。node
經過cf_nise_installer中的這段install.sh腳本的代碼咱們能夠看到它的安裝流程以下:nginx
./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
git submodule update --init --recursive
把子模塊submodule下載下來,再執行bosh create release
命令,就能夠獲得一個完整的cf_release,固然,這裏面又是漫長的下載。實驗室已經制做了幾個經常使用的cf_release版本,在內網能夠下載。192.168.10.10.xip.io
,執行 generate_deploy_manifest.sh腳本能夠更改域名和密碼,不過須要在環境變量中導入export NISE_DOMAIN=[你的域名]
export NISE_PASSWORD=[你的密碼]
關於域名 架設本地域名解析服務器,如bind9之類的,而後在/etc/resolv.conf下面的nameserver加上本地域名解析服務器IP便可。在域名解析服務器上加上一條域名對應組件機器的IP就能夠順利用域名訪問集羣了。git
關於一次正常的鏈接 [用戶訪問域名]->[域名解析服務器解析出IP]->[Haproxy組件收到請求轉發]->[Gorouter接到請求]->[DEA/CC最終處理]github
下載並安裝cf_clidpkg -i ***.deb
。新版cf命令行的命令有比較大的變化,可使用cf --help
看一下。shell
cloudfoundry從V168之後,就不在cf-release裏面放入buildpack了,也就是雲應用的運行時環境。每次應用上傳都要去pivotal的網站上下buildpack,速度比較慢,因此就涉及到了製做離線的buildpack。官方的java_buildpack就提供了製做離線包的功能。Clone下來之後執行以下步驟就製做成功了一個zip包。api
bundle install bundle exec rake package OFFLINE=true ... Creating build/java-buildpack-offline-cfd6b17.zip
而後使用cf命令上傳離線的buildpack,參數的意思能夠從help中查看。tomcat
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
若是用戶名密碼都是默認的話,使用流程基本以下:ruby
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