中文字幕一区二区人妻电影,亚洲av无码一区二区乱子伦as ,亚洲精品无码永久在线观看,亚洲成aⅴ人片久青草影院按摩,亚洲黑人巨大videos

教程:使用OpenShift獲取夾點(diǎn)

發(fā)布于:2021-01-19 09:08:49

0

186

0

java linux openshift php ruby 教程

本文將引導(dǎo)您完成使用OpenShift在云中設(shè)置一臺、兩臺、三臺新機(jī)器所需的簡單步驟,最多可設(shè)置五臺新機(jī)器。您將部署您的應(yīng)用程序以進(jìn)行開發(fā)、測試或在幾分鐘內(nèi)向全世界展示它們。別再胡鬧了。

我們首先概述什么是OpenShift,它來自哪里,以及如何在工作站上設(shè)置客戶端工具。然后,您將了解應(yīng)用于OpenShift的客戶機(jī)工具。幾分鐘后,您就可以開始專注于應(yīng)用程序開發(fā),并在OpenShift中部署測試。完成后,你將丟棄你的測試機(jī),繼續(xù)前進(jìn)。在這之后,你將完全有能力在你選擇的時候,在你需要它的地方,并且在一個時刻通知你的時候,提升到OpenShift云中。這就是開發(fā)應(yīng)該是什么樣的,沒有堆棧干擾的開發(fā)。

現(xiàn)在IT界對云計(jì)算有大量的炒作。已經(jīng)劃分出來的各個領(lǐng)域都不乏縮寫詞,比如IaaS、PaaS和SaaS。OpenShift是Red Hat的平臺即服務(wù)(PaaS),它為您提供了運(yùn)行應(yīng)用程序的平臺。作為一名開發(fā)人員,您需要查看將應(yīng)用程序作為所提供服務(wù)放置的環(huán)境。您不想為服務(wù)如何由一組組件構(gòu)成、如何配置或在何處運(yùn)行而煩惱。您只需要利用他們提供的服務(wù)來部署、開發(fā)、測試和運(yùn)行您的應(yīng)用程序。在這個基本級別上,OpenShift為Java應(yīng)用程序提供了一個平臺。

首先讓我們快速了解一下OpenShift的來源。它起源于一家名為Makara的公司,總部位于加州紅木市,提供解決方案,使企業(yè)能夠在私有云或公共云上部署、管理、監(jiān)控和擴(kuò)展其應(yīng)用程序。Red Hat于2010年11月收購了Makara,次年他們將Red Hat technologies合并到一個名為OpenShift的新項(xiàng)目中。

就在最近,OpenShift團(tuán)隊(duì)宣布了他們的開源項(xiàng)目OpenShift Origin的發(fā)布,使得整個代碼庫可以在線使用。您甚至可以使用他們提供的liveCD來體驗(yàn)一下,但這超出了本文的范圍。對于Java開發(fā)人員來說,這種技術(shù)的融合之所以有趣,是因?yàn)镽ed Hat在OpenShift中包含了基于JBoss AS 7的下一代應(yīng)用程序平臺。這為您的所有開發(fā)需求帶來了一個閃電般快速的應(yīng)用程序平臺。

OpenShift

OpenShift網(wǎng)站聲明,“OpenShift是一個免費(fèi)的、基于云的應(yīng)用程序平臺,用于Java、Perl、PHP、Python和Ruby應(yīng)用程序。你的開發(fā)環(huán)境也是你的部署環(huán)境,這非常簡單:而且你在云中?!边@激起了人們的興趣,所以讓我們試試看我們是否可以將我們的web應(yīng)用程序提升到云中。為此,我們有一個jBPM遷移web應(yīng)用程序,我們將在本練習(xí)的其余部分使用它作為運(yùn)行示例。

OpenShift的入門在網(wǎng)站上有很好的文檔記錄,可以作為一個快速入門,一旦你注冊了一個redhatcloud(rhcloud)帳戶,就可以使用它。這個快速入門為我們提供了使我們的應(yīng)用程序聯(lián)機(jī)所需的四個步驟,并從安裝必要的客戶機(jī)工具開始。這是為Red Hat Enterprise Linux(RHEL)、Fedora Linux、通用Linux發(fā)行版、Mac OS X和Windows概述的。對于RHEL和Fedora來說,它是一個簡單的軟件包安裝,其余的是一個基于Ruby的gem安裝,我們將留給讀者應(yīng)用到他們的系統(tǒng)中。

一旦安裝了客戶端工具,就會有幾種基于rhc- <command>形式的命令。有可用的在線界面,但是大多數(shù)開發(fā)人員更喜歡命令行客戶端工具提供的控件,因此我們將使用它們。以下是對可用內(nèi)容的概述,并簡要介紹了每種內(nèi)容。

  • rhc create domain–用于將注冊的rhcloud用戶綁定到rhcloud中的域。每個注冊的rhcloud用戶最多可以有一個域。

  • rhc create app–用于為給定的rhcloud用戶、給定的開發(fā)環(huán)境(Java、Ruby、Python、Perl、PHP)和給定的rhcloud域創(chuàng)建應(yīng)用程序。您最多可以為給定域創(chuàng)建五個應(yīng)用程序。這將為您的rhcloud實(shí)例生成完整的URI,根據(jù)所選環(huán)境設(shè)置rhcloud實(shí)例,默認(rèn)情況下,將為所選開發(fā)環(huán)境創(chuàng)建本地git項(xiàng)目。

  • rhc-snapshot–用于創(chuàng)建給定rhcloud實(shí)例的本地備份。

  • rhc-ctl-app–用于控制給定rhcloud應(yīng)用程序。您可以在這里添加數(shù)據(jù)庫、檢查實(shí)例的狀態(tài)、啟動、停止等。

  • rhc tail files–用于連接到rhcloud應(yīng)用程序日志文件并將其轉(zhuǎn)儲到命令shell。

  • rhc user info–用于查看給定的rhcloud用戶,定義的域和創(chuàng)建的應(yīng)用程序。

  • rhc chk–用于對安裝程序運(yùn)行簡單的配置檢查。

創(chuàng)建您的網(wǎng)域

為了開始使用我們的演示應(yīng)用程序,我們需要做一些簡單的事情來獲得一個OpenShift實(shí)例設(shè)置,以托管我們的Java應(yīng)用程序,從一個域開始。

# We need to create the domain for OpenShift to start setting up # our URL with the client tooling using # rhc-create-domain -n domainname -l rhlogin # $ rhc-create-domain –help
Usage: /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 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 key found at /home/[homedir]/.ssh/libra_id_rsa. Reusing…
Contacting https://openshift.redhat.com
Creation successful
You may now create an application. Please make note of your local config file in /home/[homedir]/.openshift which has been created and populated for you.

創(chuàng)建應(yīng)用程序

接下來我們要創(chuàng)建我們的應(yīng)用程序,這意味著我們要告訴OpenShift我們需要哪個堆棧。這是通過rhc創(chuàng)建應(yīng)用程序客戶端工具完成的。

# 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 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) (require) -l|–rhlogin rhlogin Red Hat login (RHN or OpenShift login) (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/jbpmmigration
Found a bug? Post to the forum and we’ll get right on it.
IRC: #openshift on freenode
Forums: https://www.redhat.com/openshift/forums
Attempting to create remote application space: jbpmmigration Contacting https://openshift.redhat.com API version: 1.1.1 Broker version: 1.1.1
RESULT: Successfully created application: jbpmmigration
Checking ~/.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/

要對應(yīng)用程序進(jìn)行更改,請?zhí)峤籮bpmmigration/。然后運(yùn)行“git push”更新OpenShift空間。

如果我們查看我給定的repo路徑,就會發(fā)現(xiàn)git projects/jbpmmigration git存儲庫。請注意,如果決定更改域名,則必須調(diào)整git repository配置文件以反映遠(yuǎn)程存儲庫的位置,請參見上面帶有“ssh:……”的行。此外,該頁面已處于活動狀態(tài)http://jbpmmigration-ishereon.rhcloud.com/. 這只是一個啟動屏幕,讓您開始,所以現(xiàn)在我們繼續(xù)部署我們現(xiàn)有的jBPM遷移項(xiàng)目。

首先讓我們看看git項(xiàng)目中提供的README,它提供了一些關(guān)于存儲庫布局的見解。

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目錄。你只需輸入你的戰(zhàn)爭文件,刪除pom.xml文件文件在項(xiàng)目的根目錄中,它們將被自動部署。如果要部署分解的WAR文件,只需添加一個名為“.dodeploy”的文件,如自述文件中所述。對于實(shí)際的項(xiàng)目開發(fā),我們希望通過普通的src目錄結(jié)構(gòu)推動我們的代碼,這也可以通過使用提供的pom.xml文件文件。提供的自述文件提供了啟動所需的所有詳細(xì)信息。

我們的演示應(yīng)用程序jbpmmigration還附帶了一個自述文件,該文件提供了將項(xiàng)目內(nèi)容添加到新git存儲庫的說明,因此我們將運(yùn)行這些命令將文件拉入本地項(xiàng)目。

# placing our application into our Openshift 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

如您所見,我們現(xiàn)在已經(jīng)將內(nèi)容推送到我們創(chuàng)建的rhcloud實(shí)例,它部署了內(nèi)容并啟動了我們的實(shí)例?,F(xiàn)在我們應(yīng)該可以在網(wǎng)上找到我們的申請http://jbpmmigration-in.rhcloud.com/jbpmmigrationu upload-0.2。

最后一步是您完成了對這個應(yīng)用程序的工作,并希望將它釋放出來以供新的應(yīng)用程序使用。然后可以使用rhc snapshot>;client工具進(jìn)行備份,然后使用rhc ctl app client工具刪除實(shí)例。

# 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

結(jié)論

如您所見,在應(yīng)用程序開發(fā)中使用五個免費(fèi)實(shí)例非常容易。

這就完成了我們的OpenShift項(xiàng)目之旅,我們?yōu)槟峁┝艘粋€機(jī)會,等待您和您的應(yīng)用程序一瞥。創(chuàng)建您的域、定義您的應(yīng)用程序需求并將您的項(xiàng)目導(dǎo)入所提供的git項(xiàng)目是輕而易舉的事。將更改推送到新實(shí)例之后,您就可以在云中測試應(yīng)用程序開發(fā)了。這是真的。這很簡單?,F(xiàn)在,走出去,把你的代碼提高到云端宣傳之上。