通过OpenShift超越云技术
本文將逐步引導您使用OpenShift在云中設置一臺,兩臺,三臺而不是五臺新計算機所需要的簡單步驟。 您將部署應用程序以進行開發,測試或在數分鐘之內將它們全面展示給全世界。 沒有更多的混亂。
我們首先概述什么是OpenShift,它來自何處以及如何在工作站上獲得客戶端工具設置。 然后,您將瀏覽客戶端工具,因為它適用于OpenShift的入門級(稱為Express)。 幾分鐘后,您便會回到專注于應用程序開發的位置,并進行部署以在OpenShift Express中對其進行測試。 完成后,您將只丟棄測試機器并繼續前進。 掌握了這一點之后,就該使用OpenShift Flex將其提升到一個新的水平了。 這稍微開放了您的選項,因此您可以對可能需要更多火力的復雜應用程序和部署執行更多操作。 此后,您將完全有能力在需要的時候立即進入您選擇的OpenShift Cloud。 這就是開發應該的樣子,沒有堆棧干擾的開發。
介紹
現在,IT世界中有關云的大量宣傳。 對于IaaS,PaaS和SaaS之類的各個領域,不乏首字母縮寫詞。 OpenShift是Red Hat的平臺即服務(PaaS),它為您提供了運行應用程序的平臺。 對于作為開發人員的您來說,您希望查看將應用程序作為僅提供的服務放置的環境。 您無需理會該服務如何由一組組件構成,如何配置或在何處運行。 您只想利用他們提供的這項服務來部署,開發,測試和運行您的應用程序。 在此基本級別上,OpenShift為您的Java應用程序提供了一個平臺。
首先,讓我們快速看一下OpenShift的來源。 它始于一家位于加利福尼亞州紅木城的名為Makara的公司,該公司提供的解決方案使組織能夠在私有或公共云上部署,管理,監視和擴展其應用程序。 紅帽在2010年11月收購了Makara,第二年他們將紅帽技術合并到一個名為OpenShift [1]的新項目中。 他們啟動了第一個項目,該項目最初提供兩個級別的服務[2],即稱為Express的共享托管解決方案和稱為Flex的專用托管解決方案。 對于Java開發人員來說,這種技術融合的有趣之處在于,Red Hat在OpenShift [3]中包含了基于JBoss AS 7的下一代應用程序平臺。 這為您的所有開發需求提供了一個閃電般快速的應用程序平臺。
OpenShift Express
OpenShift網站指出:“ Express是一個免費的基于云的應用程序平臺,適用于Java,Perl,PHP,Python和Ruby應用程序。 它非常簡單-您的開發環境也是您的部署環境: git push ,“您就在云中?!?這使人們的興趣達到頂峰,因此可以嘗試一下,看看是否可以將我們的Web應用程序提升到云端。 為此,我們有jBPM遷移Web應用程序[4],在本練習的其余部分中,我們將使用它作為運行示例。
Express入門在網站上有很好的記錄,可以作為快速入門[5],一旦您注冊了Red Hat Cloud(rhcloud)帳戶,即可開始使用。 快速入門為我們提供了使我們的應用程序聯機所需的四個步驟,并從安裝必需的客戶端工具開始。 這是針對Red Hat Enterprise Linux(RHEL),Fedora Linux,通用Linux發行版,Mac OS X和Windows概述的。 對于RHEL和Fedora,這是一個簡單的軟件包安裝,其余的是基于Ruby的gem安裝,我們將留給讀者將其應用于她的系統。
一旦安裝了客戶端工具,就會有幾個基于rhc- <command>形式的命令。 有可用的在線界面,但是大多數開發人員更喜歡命令行客戶端工具提供的控件,因此我們將使用它們。 以下是對可用內容的概述,并簡要介紹了每個可用內容:
- rhc-create-domain –用于將注冊的rhcloud用戶綁定到rhcloud中的域。 每個注冊的rhcloud用戶最多可以有一個域。
- rhc-create-app –用于為給定的rhcloud用戶,給定的開發環境(Java,Ruby,Python,Perl,PHP)和給定的rhcloud域創建應用程序。 對于給定的域,您最多可以創建五個應用程序。 這將為您的rhcloud實例生成完整的URI,根據您選擇的環境設置您的rhcloud實例,默認情況下將為您選擇的開發環境創建本地git項目。
- rhc-snapshot –用于創建給定rhcloud實例的本地備份。
- rhc-ctl-app –用于控制給定的rhcloud應用程序。 您可以在此處添加數據庫,檢查實例的狀態,啟動,停止等。
- rhc-tail-files –用于連接到rhcloud應用程序日志文件并將其轉儲到命令外殼中。
- rhc-user-info –用于查看給定的rhcloud用戶,定義的域和創建的應用程序。
- rhc-chk –用于對安裝程序進行簡單的配置檢查。
建立您的網域
要開始使用演示應用程序,我們需要做一些簡單的事情,以從域開始獲取用于托管Java應用程序的Express實例設置。
# We need to create the domain for Express to start setting up # We need to create the domain for Express to start setting up # our URL with the client tooling using # rhc-create-domain -n domainname -l rhlogin # $ rhc-create-domain --helpUsage: /usr/bin/rhc-create-domain Bind a registered rhcloud user to a domain in rhcloud.NOTE: to change ssh key, please alter your ~/.ssh/libra_id_rsa and~/.ssh/libra_id_rsa.pub key, then re-run with --alter-n|--namespace namespace Namespace for your application(s) (alphanumeric - max 16 chars) (required)-l|--rhlogin rhlogin Red Hat login (RHN or OpenShift login with OpenShift Express access) (required)-p|--password password RHLogin password (optional, will prompt)-a|--alter Alter namespace (will change urls) and/or ssh key-d|--debug Print Debug info-h|--help Show Usage info# So we setup one for our Java application. Note that we already have # setup my ssh keys for OpenShift, if you have not yet done that, # then it will walk you through it. # $ rhc-create-domain -n inthe -l [rhcloud-user] -p [mypassword]OpenShift Express key found at /home/[homedir]/.ssh/libra_id_rsa. Reusing... Contacting https://openshift.redhat.com Creation successfulYou may now create an application. Please make note of your local config file in /home/[homedir]/.openshift/express.conf which has been created and populated for you.創建你的應用
接下來,我們要創建應用程序,這意味著我們要告訴OpenShift Express我們需要哪個堆棧。 這是通過rhc-create-app客戶端工具完成的。
# Let's take a look at the options available before we setup a Java # instance for our application. # $ rhc-create-app --help Contacting https://openshift.redhat.com to obtain list of cartridges...(please excuse the delay)Usage: /usr/bin/rhc-create-app Create an OpenShift Express app.-a|--app application Application name (alphanumeric - max 16 chars) (required)-t|--type type Type of app to create (perl-5.10, jbossas-7.0, wsgi-3.2, rack-1.1, php-5.3) (required)-l|--rhlogin rhlogin Red Hat login (RHN or OpenShift login with OpenShift Express access) (Default: xxxxxxxxx)-p|--password password RHLogin password (optional, will prompt)-r|--repo path Git Repo path (defaults to ./$app_name)-n|--nogit Only create remote space, don't pull it locally-d|--debug Print Debug info-h|--help Show Usage info# It seems we can choose between several but we want the jboss-as7.0 # stack (called a cartridge). Provide a user, password and location # for the git repo to be created called 'jbpmmigration', see the # documentation for the defaults. Let's watch the magic happen! # $ rhc-create-app -a jbpmmigration -t jbossas-7.0 -l [rhcloud-user] -p [mypassword] -r /home/[homedir]/git-projects/jbpmmigrationFound a bug? Post to the forum and we'll get right on it.IRC: #openshift on freenodeForums: https://www.redhat.com/openshift/forumsAttempting to create remote application space: jbpmmigration Contacting https://openshift.redhat.com API version: 1.1.1 Broker version: 1.1.1RESULT: Successfully created application: jbpmmigrationChecking ~/.ssh/config Contacting https://openshift.redhat.com Found rhcloud.com in ~/.ssh/config... No need to adjust Now your new domain name is being propagated worldwide (this might take a minute)... Pulling new repo down Warning: Permanently added 'jbpmmigration-inthe.rhcloud.com,50.17.167.44' (RSA) to the list of known hosts. Confirming application jbpmmigration is available Attempt # 1 Success! Your application is now published here: http://jbpmmigration-inthe.rhcloud.com/ The remote repository is located here: ssh://1806d6b78bb844d49378874f222f4403@jbpmmigration-inthe.rhcloud.com/~/git/jbpmmigration.git/ To make changes to your application, commit to jbpmmigration/. Then run 'git push' to update your OpenShift Express space .如果我們看一下我給定的回購路徑,我們會找到一個git-projects / jbpmmigration git存儲庫。 請注意,如果您決定更改域名,則必須調整git repository配置文件以反映遠程存儲庫的位置,請參見“ ssh:…..”行上方。 該頁面也已經位于 http://jbpmmigration-ishereon.rhcloud.com/ 。 這只是一個入門的初始屏幕,因此現在我們繼續部署現有的jBPM Migration項目。
首先,讓我們看一下git項目中提供的自述文件,該文件對存儲庫布局提供了一些見解。
Repo layout =========== deployments/ - location for built wars (Details below) src/ - maven src structure pom.xml - maven build file .openshift/ - location for openshift specific files .openshift/config/ - location for configuration files such as standalone.xml (used to modify jboss config such as datasources) ../data - For persistent data (also in env var OPENSHIFT_DATA_DIR) .openshift/action_hooks/build - Script that gets run every push, just prior to starting your app對于本文,我們將僅檢查部署和src目錄。 您只需放入WAR文件,在項目根目錄中刪除pom.xml文件,它們就會被自動部署。 如果要部署爆炸的WAR文件,則只需添加README文件中概述的名為“ .dodeploy”的文件即可。 對于實際的項目開發,我們希望通過常規的src目錄結構推送代碼,也可以通過使用提供的pom.xml文件來實現。 提供的自述文件提供了入門所需的所有詳細信息。
我們的演示應用程序jbpmmigration還帶有一個README文件,該文件提供了將項目內容添加到我們的新git存儲庫中的說明,因此我們將運行這些命令將文件拉入我們的本地項目中。
# placing our application into our express git repo. # $ cd jbpmmigration $ git remote add upstream -m master git://github.com/eschabell/openshift-jbpmmigration.git $ git pull -s recursive -X theirs upstream master # now we need to push the content. # $ git push origin[jbpmmigration maven build log output removed] ... remote: [INFO] ------------------------------------------------------------------------ remote: [INFO] BUILD SUCCESS remote: [INFO] ------------------------------------------------------------------------ remote: [INFO] Total time: 3.114s remote: [INFO] Finished at: Mon Nov 14 10:26:57 EST 2011 remote: [INFO] Final Memory: 5M/141M remote: [INFO] ------------------------------------------------------------------------ remote: ~/git/jbpmmigration.git remote: Running .openshift/action_hooks/build remote: Running .openshift/action_hooks/deploy remote: Starting application... remote: Done remote: Running .openshift/action_hooks/post_deploy To ssh://1806d6b78bb844d49378874f222f4403@jbpmmigration-inthe.rhcloud.com/~/git/jbpmmigration.git/ 410a1c9..7ea0003 master -> master如您所見,我們現在將內容推送到我們創建的rhcloud實例,它部署了內容并啟動了我們的實例。 現在,我們應該可以在http://jbpmmigration-ishereon.rhcloud.com/jbpmmigration_upload-0.4/上在線找到我們的應用程序。
然后,最后一步是您已經完成了該應用程序的工作,并希望將其釋放給新的應用程序。 然后,您可以使用rhc-snapshot客戶端工具進行備份,然后使用rhc-ctl-app客戶端工具刪除實例。
# Ready to get rid of our application now. # $ rhc-ctl-app -a jbpmmigration -l eschabell -c destroy Password: ********Contacting https://openshift.redhat.com !!!! WARNING !!!! WARNING !!!! WARNING !!!! You are about to destroy the jbpmmigration application. This is NOT reversible, all remote data for this application will be removed. Do you want to destroy this application (y/n): y Contacting https://openshift.redhat.com API version: 1.1.1 Broker version: 1.1.1 RESULT: Successfully destroyed application: jbpmmigration如您所見,開始進行應用程序開發時必須使用的五個免費實例非常容易。 您可能會注意到存在限制,無法使用特定的集成監視工具,自動縮放功能缺失,并且對配置的控制受到限制。 對于那些需要更多訪問權限和功能的用戶,請看一下使用OpenShift Flex [6]進行的下一步。
這就完成了我們對OpenShift Express項目的游覽,在其中我們為您提供了等待您和您的應用程序的可能性的一瞥。 創建您的域,定義您的應用程序需求并將您的項目導入提供的git項目非常容易。 將更改推送到新的Express實例后,您將關閉并在云中測試應用程序開發。 這是真的。 這很容易。 現在走到那里,將您的代碼提升到云炒作之上。
相關鏈接:
參考:我們的JCG合作伙伴 Eric D. Schabell在中間件,Linux,軟件,自行車和其他新聞…博客上發表了OpenShift , 超越Cloud的炒作 。
翻譯自: https://www.javacodegeeks.com/2012/06/rise-above-cloud-hype-with-openshift.html
總結
以上是生活随笔為你收集整理的通过OpenShift超越云技术的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 优派8q平板电脑(优派平板电脑官网)
- 下一篇: 电脑玩cs局域网(电脑玩cs局域网游戏)