This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
簡介
雲端服務是目前常見對於網路服務應用運作模式的稱謂,大多數的使用者很難清楚的定義何謂雲端?在美國國家
標準與技術研究院(NIST)對於雲端運算提出了一份明確的定義 [http://www.nist.gov/itl/cloud/index.cfm], 雲端運算是一種網路應用的運作模式,其需求能夠方便存取網路上所提供的電腦資源,其包含5種特徵、4種建置模式、3項服務,比較常見的有3種服務模式 (SaaS)軟體即服務、(PaaS)平台即服務、(IaaS)基礎設施即服務以及4種建置方式 Public cloud(公共雲), Private cloud(私有雲), Community cloud(社區雲), Hybrid cloud(混合雲),另外有五種特徵可以評估該服務是不是雲端服務的重要項目,分別是(1)On-demand self-service(需要時自助的取得)(2)Broad network access(可以透過標準網路取得)(3)Resource pooling(資源可以動態配置)(4)Rapid elasticity,(快速且有彈性)(5)Measured Service(用多少付多少)。
Red Hat(紅帽)提出新的平台即服務(PaaS)、及架構及服務(IaaS)的解決方案 OpenShift,讓使用者可以專心於軟體的應用而不是基礎設施的建設。OpenShift的基礎來源於Red Hat於2010年11月收購的科技公司Makara technology。目前OpenShift 提供三種不同的部屬應用程序,開發人員可以快速的透過此服務建立開發平台,而無須架設任何伺服器。OpenShift Express 提供用來開發 PHP、Ruby、Python 和 Java 等軟體的應用程式環境,另外有 OpenShift FLEX 和 OpenShit Power 等服務,OpenShift FLEX 預計供部署、監控、預備用和自動擴充與縮減的應用系統,而 OpenShift Power 是部署自己所建置的 Linux,目前 FLEX 和 Power 服務目前是還在開發中,只有 OpenShift FLEX 有開放免費使用,OpenShift Flex 提用試用,而 OpenShift Power 還在開發中。
* 同這網址的內容 https://openshift.redhat.com/app/getting_started/express[https://openshift.redhat.com/app/getting_started/express] ,因為這系統仍然不斷的在開發中,你可以透過IRC: #openshift on Freenode [http://webchat.freenode.net/] 直接反映問題。
Thank you for requesting access to OpenShift Express!To get started, click on this link:https://openshift.redhat.com/app/getting_started/express We'd love to hear your feedback, please join us on IRC and our forums.ThanksThe Red Hat OpenShift TeamIRC: #openshift on Freenode
[jangmt@localhost ~]$ rhc-create-domain -n jangmt -l [email protected]: rhcloud的密碼Generating Openshift Express ssh key to /home/jangmt/.ssh/libra_id_rsaGenerating public/private rsa key pair.Created directory '/home/jangmt/.ssh'.Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/jangmt/.ssh/libra_id_rsa.Your public key has been saved in /home/jangmt/.ssh/libra_id_rsa.pub.The key fingerprint is:18:25:39:79:b5:88:87:9c:56:ab:35:6e:da:3b:4e:8b [email protected] key's randomart image is:+--[ RSA 2048]----+| .oo.. || .+B.o . || Bo* . || . B . || o S || + || . o || o.o || E.+. |+-----------------+Contacting https://openshift.redhat.comAdding rhlogin to /home/jangmt/.openshift/express.confCreation successful
You may now create an application. Please make note of your local config filein /home/jangmt/.openshift/express.conf which has been created and populated for you.
Checking ~/.ssh/configContacting https://openshift.redhat.comFound rhcloud.com in ~/.ssh/config... No need to adjustNow your new domain name is being populated worldwide (this might take a minute)...Pulling new repo downWarning: Permanently added the RSA host key for IP address '50.17.172.80' to the list of known hosts.remote: Counting objects: 23, done.remote: Compressing objects: 100% (20/20), done.remote: Total 23 (delta 6), reused 0 (delta 0)Receiving objects: 100% (23/23), done.Resolving deltas: 100% (6/6), done.Confirming application myphp is available
# 修改程式碼,加入 <?php phpinfo(); ?> 這段做為測試[jangmt@localhost php]$ vim index.php <html><title>OpenShift!</title><body><h1>Welcome to OpenShift</h1><p>Place your application here</p><p>In order to commit to your new project, go to your projects git repo(created with the create_http command). Make your changes, then run:</p>
<pre>git commit -a -m 'Some commit message'git push</pre><p>Then reload this page</p><?php phpinfo(); ?></body></html>
* 加上 commit 資訊並 git push
# git commit -a 將所有修改過得檔案都 commit, 但是新增的檔案 還是得要先 add 才可以(git add -A 新增所有變更的檔案)# -m 'message' 指的是在這個 commit 加上說明的內容[jangmt@localhost php]$ git commit -a -m 'add phpinfo() in index.php'[master a7aaf2b] add phpinfo() in index.php1 files changed, 1 insertions(+), 0 deletions(-)
# git-push 更新遠端的檔案物件資訊[jangmt@localhost php]$ git pushCounting objects: 7, done.Compressing objects: 100% (4/4), done.Writing objects: 100% (4/4), 399 bytes, done.Total 4 (delta 2), reused 0 (delta 0)remote: tar: README: time stamp 2011-05-31 07:51:47 is 28761.007922033 s in the futureremote: tar: libs/README: time stamp 2011-05-31 07:51:47 is 28761.00683967 s in the futureremote: tar: libs: time stamp 2011-05-31 07:51:47 is 28761.006520158 s in the futureremote: tar: misc/README: time stamp 2011-05-31 07:51:47 is 28761.006146669 s in the futureremote: tar: misc: time stamp 2011-05-31 07:51:47 is 28761.005907377 s in the futureremote: tar: php/health_check.php: time stamp 2011-05-31 07:51:47 is 28761.005505289 s in the futureremote: tar: php/index.php: time stamp 2011-05-31 07:51:47 is 28761.005190215 s in the futureremote: tar: php: time stamp 2011-05-31 07:51:47 is 28761.004967428 s in the futureTo ssh://[email protected]/~/git/myphp.git/
...skip...# 上傳[jangmt@localhost php]$ git push...skip...remote: tar: php: time stamp 2011-05-31 08:00:29 is 28702.719547983 s in the futureTo ssh://[email protected]/~/git/myphp.git/
[jangmt@localhost ~]$ rhc-ctl-app -c destroy -a myphp -l [email protected]: Contacting https://openshift.redhat.com!!!! WARNING !!!! WARNING !!!! WARNING !!!!You are about to destroy the myphp application.
This is NOT reversable, all remote data for this application will be removed.Do you want to destroy this application (y/n): yContacting https://openshift.redhat.com
RESULT:Successfully destroyed application: myphp
* 當你 destory 應用程式只會移除雲端的資料,本地端的目錄還是一樣存在不會有任何的異動。
建立wsgi應用程式
* Python網頁開發的標準: WSGI,(Python Web Server Gateway Interface,縮寫為WSGI)是為Python語言定義的Web伺服器和Web應用程序或框架之間的一種簡單而通用的介面。
Checking ~/.ssh/configContacting https://openshift.redhat.comFound rhcloud.com in ~/.ssh/config... No need to adjustNow your new domain name is being populated worldwide (this might take a minute)...Pulling new repo downWarning: Permanently added 'mywsgi-jangmt.rhcloud.com,50.17.156.80' (RSA) to the list of known hosts.remote: Counting objects: 30, done.remote: Compressing objects: 100% (25/25), done.remote: Total 30 (delta 9), reused 0 (delta 0)Receiving objects: 100% (30/30), done.Resolving deltas: 100% (9/9), done.Confirming application mywsgi is available
# git上傳[jangmt@localhost mywsgi]$ git pushCounting objects: 7, done.Compressing objects: 100% (3/3), done.Writing objects: 100% (4/4), 422 bytes, done.Total 4 (delta 1), reused 0 (delta 0)remote: tar: README: time stamp 2011-05-31 08:47:47 is 28763.774683407 s in the futureremote: tar: data/SAFETOREMOVE.txt: time stamp 2011-05-31 08:47:47 is 28763.773869298 s in the futureremote: tar: data: time stamp 2011-05-31 08:47:47 is 28763.773712804 s in the futureremote: tar: libs/SAFETOREMOVE.txt: time stamp 2011-05-31 08:47:47 is 28763.773307896 s in the futureremote: tar: libs: time stamp 2011-05-31 08:47:47 is 28763.773183541 s in the futureremote: tar: wsgi/application: time stamp 2011-05-31 08:47:47 is 28763.772759805 s in the futureremote: tar: wsgi: time stamp 2011-05-31 08:47:47 is 28763.772630393 s in the futureTo ssh://[email protected]/~/git/mywsgi.git/
* The NIST Definition of Cloud Computing(Draft),NIST Peter Mell;Yimothy Grance ,http://csrc.nist.gov/publications/drafts/800-145/Draft-SP-800-145_cloud-definition.pdf[http://csrc.nist.gov/publications/drafts/800-145/Draft-SP-800-145_cloud-definition.pdf]