openshift enterprise v2 仮想イメージを使ったクイックスタート...

47
Copyright © 2014 RedHat K.K. - 1 – OpenShift Enterprise v2 仮想イメージを使ったクイックスタート Using OSEv2.2 レッドハット株式会社

Upload: others

Post on 11-Jun-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

  • Copyright © 2014 RedHat K.K. - 1 –  

     OpenShift  Enterprise  v2  

    仮想イメージを使ったクイックスタート    

    ~∼Using  OSEv2.2  ~∼    

                         

    レッドハット株式会社          

  • Copyright © 2014 RedHat K.K. - 2 –  

    Contents  

    1. はじめに ....................................................................................................... 4 1.1. ゴール .............................................................................................................. 4 1.2. 環境 .................................................................................................................. 4 1.3. 使⽤用するソフトウェア ..................................................................................... 4 1.4. 参考⽂文書 ........................................................................................................... 4 1.5. 書体の表記ルール ............................................................................................ 4

    1.5.1. ソースコード ............................................................................................... 4 1.5.2. コマンド ...................................................................................................... 5

    Part 1 概要 .......................................................................................................... 6 2. サーバ環境 ................................................................................................... 7 動作確認 .............................................................................................................. 8

    2.1.1. 仮想 OSの環境 ........................................................................................... 8 2.1.2. OSのログイン ............................................................................................ 8 2.1.3. OpenShiftEnterpriseの管理理コンソールのログイン .................................... 8 2.1.4. OpenShiftEnterpriseのアプリケーションコンソールのログイン .............. 8

    2.2. プロセスの確認 ................................................................................................ 9 2.2.1. 作業環境 ...................................................................................................... 9 2.2.2. PHPアプリケーションの作成 .................................................................... 9 2.2.3. プロセスの確認 ......................................................................................... 10

    Part2 使う ......................................................................................................... 12 3. アプリケーション作成 ............................................................................... 13

    3.1. 利利⽤用するカートリッジ ................................................................................... 13 3.2. ログイン ......................................................................................................... 13 3.3. アプリケーションの作成 ................................................................................ 13

    3.3.1. 作業環境 .................................................................................................... 13 3.3.2. ギアの作成 ................................................................................................ 14 3.3.3. Webアプリケーションのデプロイ ........................................................... 17

    4. アプリケーションの更更新 ............................................................................ 20 4.1. Jenkinsの利利⽤用 .............................................................................................. 20

    4.1.1. 作業環境 .................................................................................................... 20 4.1.2. Jenkinsサーバの作成 ............................................................................... 20 4.1.3. Jenkins Clientの有効化 ............................................................................ 21 『4.1.1作業環境 Jenkinsサーバの作成』で⽣生成されたパスワード ..................... 22

    4.2. アプリケーションの更更新 ................................................................................ 22 4.2.1. 作業環境 .................................................................................................... 23 4.2.2. ディレクトリ構成 ..................................................................................... 23 4.2.3. ソースコードの編集 .................................................................................. 23 4.2.4. GITリポジトリへの反映 ........................................................................... 24 4.2.5. Jenkinsによるビルド ............................................................................... 24

    5. アプリケーション管理理 ............................................................................... 25 5.1. 世代管理理 ......................................................................................................... 25

    5.1.1. 作業環境 .................................................................................................... 25 5.1.2. 保存可能な世代数の設定 ........................................................................... 25 5.1.3. 世代を指定したデプロイ ........................................................................... 25

    5.2. スナップショットの取得とリストア .............................................................. 27

  • Copyright © 2014 RedHat K.K. - 3 –  

    5.2.1. 作業環境 .................................................................................................... 27 5.2.2. 作業ディレクトリの作成 ........................................................................... 27 5.2.3. スナップショットの取得 ........................................................................... 27 5.2.4. リストア .................................................................................................... 27

    Part 3 カスタマイズ ......................................................................................... 29 6. ユーザ管理理 ................................................................................................. 30

    6.1. 準備 ................................................................................................................ 30 6.2. ユーザの追加 .................................................................................................. 30

    6.2.1. 作業環境 .................................................................................................... 30 6.2.2. ユーザ   の追加 ......................................................................................... 30 6.2.3. ユーザの削除 ............................................................................................. 31

    6.3. リソース割り当て .......................................................................................... 31 6.3.1. 利利⽤用可能なギア数の変更更 ........................................................................... 31

    7. カートリッジ管理理 ....................................................................................... 33 7.1. カートリッジのインストール ........................................................................ 33

    7.1.1. 作業環境 .................................................................................................... 33 7.1.2. インストール済みカートリッジの確認 ..................................................... 33 7.1.3. カートリッジの無効化 .............................................................................. 33 7.1.4. カートリッジの有効化 .............................................................................. 33

    8. カスタムカートリッジの利利⽤用 ..................................................................... 35 8.1. URLダウンロードカートリッジの利利⽤用(httpd) .............................................. 35

    8.1.1. 作業環境 .................................................................................................... 35 8.1.2. URLでカートリッジを指定したアプリケーションの作成 ....................... 35 8.1.3. デプロイの確認 ......................................................................................... 36

    8.2. DIYカートリッジの利利⽤用 ................................................................................ 36 8.2.1. アプリケーションの作成 ........................................................................... 36 8.2.2. アプリケーションのデプロイ ................................................................... 37 8.2.3. action_hookの設定 ................................................................................... 37

    9. 付録 ............................................................................................................ 39 9.1. 管理理コマンド⼀一覧 .......................................................................................... 39 9.2. サーバ環境設定 .............................................................................................. 40 9.3. VMのダウンロード ........................................................................................ 40

    9.3.1. Red Hat Customer Portalのアカウント作成 ............................................ 40 9.3.2. OpenShift Enterprise VM イメージのダウンロード .................................. 41

    9.4. VirtualBoxの設定 .......................................................................................... 44 9.4.1. 環境設定 .................................................................................................... 44

    9.5. VMの作成 ...................................................................................................... 45 9.5.1. 仮想マシンの作成 ..................................................................................... 45 9.5.2. 仮想 OSのネットワーク設定 .................................................................... 46

     

  • Copyright © 2014 RedHat K.K. - 4 –  

    1. はじめに  

    1.1. ゴール  

    OpenShift  Enterprise がインストールされた仮想 OS  を利利⽤用して、OpenShift  Enterprise を体験します。    PartⅠでは、仮想 OS に構築された OpenShift   Enterprise の環境を利利⽤用して、OpenShift  Enterprise でどんなことができるかを体験します。  PartⅡでは、アプリケーションのデプロイなど開発者として使⽤用する場合の基本的なオペレーションを体験します。  PartⅢでは、  カートリッジやユーザの管理理といった PaaS 基盤の管理理者としての操作及び、カスタムカートリッジの利利⽤用など、上級の使い⽅方を体験します。  

    1.2. 環境  

    本ハンズオンでは以下の環境を前提とします。  • OS  

    Ø OpenShift  Enterprise  2.2 のインストール済み仮想 OS が動作する環境  • ハードディスク容量量  

    Ø 20GB 以上の空きがあること  • 仮想化ゲスト OS  

    Ø Red  Hat  Enterprise  Linux  6(64bit)    ※OpenShift  の仮想イメージの環境構築は「9付録」を参照してください。  

    1.3. 使⽤用するソフトウェア  

    本クイックスタートで使⽤用する製品は次のものです。  • OpenShift  Enterprise  V2.2  • OpenShift  CLI  Tool  • Web  Browser  • Ruby,  Ruby-‐‑‒Gem  

    1.4. 参考⽂文書  

    • カスタマポータルのマニュアル  Ø https://access.redhat.com/documentation/ja-‐‑‒JP/OpenShift_̲Enterprise/  

    • OpenShift  by  Red  Hat のサイト  Ø https://www.openshift.com/  

    • OpenShift  Origin  Documentation  Home  Ø http://openshift.github.io/documentation/index.html  

    1.5. 書体の表記ルール  1.5.1. ソースコード  ソースコードは⼆二重線の枠で囲んで表記します。ハンズオンラボ中で、編集する箇所は網掛け⽂文字を使⽤用しています。  

  • Copyright © 2014 RedHat K.K. - 5 –  

             Hello  World    

     

    1.5.2. コマンド  コンソールにて利利⽤用するコマンドは、枠で囲んで表記します。⼊入⼒力力箇所は下線付きの太字を使⽤用しています。  

    % ls README.md diy misc

     ルートユーザで実⾏行行するコマンドは、プロンプトが「#」になっています。  

    # cd /root

       

  • Copyright © 2014 RedHat K.K. - 6 –  

    PART  1  概要  

  • Copyright © 2014 RedHat K.K. - 7 –  

    2. サーバ環境  

  • Copyright © 2014 RedHat K.K. - 8 –  

    動作確認  

    2.1.1. 仮想 OS の環境  • OS ユーザ  

    ユーザ   openshift  パスワード   openshift  

    ※root  ユーザで作業をする場合は、openshift ユーザにて sudo  コマンドで実施  • OpenShift アプリケーションユーザ  

    ユーザ   demo  パスワード   openshift  

     

    2.1.2. OS のログイン  • OpenShift ユーザを選択しログインします(パスワードは不不要です)  • ブラウザが起動し、OpenShift ユーザの情報が表⽰示されていることを確認します  

     

    2.1.3. OPENSHIFTENTERPRISE の管理理コンソールのログイン  • http://localhost:8080/admin-‐‑‒console  にアクセスします  

     

    2.1.4. OPENSHIFTENTERPRISE のアプリケーションコンソールのログイン  • Welcome  to  OpenShift のページから「Open  the  Web  Console」のリンクをクリックし

    ます。または、http://vm.openshift.example.com  にアクセスします  

  • Copyright © 2014 RedHat K.K. - 9 –  

     

    2.2. プロセスの確認  2.2.1. 作業環境  実⾏行行環境   localhost  OS ユーザ   openshift  

    ※但し、他の環境及びユーザで実⾏行行する場合は、その箇所に実⾏行行環境及び OS ユーザについて記載しています。  

    2.2.2. PHP アプリケーションの作成  • プロセスを確認するために、php-‐‑‒5.4 カートリッジを利利⽤用してアプリケーションを作成し

    ます  アプリケーションの URL は  http://firstphp-‐‑‒demo.openshift.example.com/  項⽬目   値  アプリケーション名   firstphp  カートリッジ   php-‐‑‒5.4  ユーザ   demo  パスワード   opensihft  ドメイン名   demo  

     作業ディレクトリ>$HOME/git  

    % cd ~/git % rhc create-app firstphp php-5.4 OpenShift Client Tools (RHC) Setup Wizard This wizard will help you upload your SSH keys, set your application namespace, and check that other programs like Git are properly installed. Login to vm.openshift.example.com: demo ←入力 oPassword: ********* ←openshift と入力 . . . <中略> . . . Generate a token now? (yes|no) yes ←入力 Generating an authorization token for this client ... lasts about 1 day Saving configuration to /home/openshift/.openshift/express.conf ... done Checking for git ... found git version 1.7.1 Checking for a domain ... none Applications are grouped into domains - each domain has a unique name (called a namespace) that becomes part of your public application URL. You will not be able to create an application without completing this step. Please enter a namespace (letters and numbers only): demo ←入力

  • Copyright © 2014 RedHat K.K. - 10 –  

    Your domain 'demp' has been successfully created Application Options ------------------- Domain: demo Cartridges: php-5.4 Gear Size: default Scaling: no Creating application 'firstphp' ... done No SSH keys were found. We will generate a pair of keys for you. Created: /home/openshift/.ssh/id_rsa.pub Your public SSH key must be uploaded to the OpenShift server to access code. Upload now? (yes|no) yes ←yes と入力 Since you do not have any keys associated with your OpenShift account, your new key will be uploaded as the 'default' key. Uploading key 'default' ... done Waiting for your DNS name to be available ... done Initialized empty Git repository in /home/openshift/firstphp/.git/ Warning: Permanently added 'firstphp-apps.openshift.example.com,10.0.2.15' (RSA) to the list of known hosts. Your application 'firstphp' is now available. URL: http://firstphp-demo.openshift.example.com/ SSH to: [email protected] Git remote: ssh://[email protected]/~/git/firstphp.git/ Cloned to: /home/openshift/git/firstphp Run 'rhc show-app firstphp' for more details about your app.

    2.2.3. プロセスの確認  • ssh でアプリケーションコンテナにログインしてユーザの id とプロセスを確認します  • プロセスの UID を確認し他のユーザのプロセスが表⽰示されないことを確認します  

    作業ディレクトリ>指定なし  

    % rhc ssh firstphp ←ssh で firstphp アプリケーションの実行コンテナに接続 [firstphp-demo.openshift.example.com 542a6bf7e659c5d2b4000003]¥> id uid=4757(542a6bf7e659c5d2b4000003) gid=4757(542a6bf7e659c5d2b4000003) 所属グループ=4757(542a6bf7e659c5d2b4000003) context=unconfined_u:system_r:openshift_t:s0:c4,c675 [firstphp-apps.openshift.example.com 542a6bf7e659c5d2b4000003]¥> ps -elf F S UID PID PPID C PRI NI ADDR SZ WCHAN STIME TTY TIME CMD 0 S 4757 8937 1 0 80 0 - 62257 poll_s 04:38 ? 00:00:00 /usr/sbin/httpd -C Include / 0 S 4757 8938 1 0 80 0 - 63377 futex_ 04:38 ? 00:00:00 /usr/bin/logshifter -tag php 0 S 4757 8947 8937 0 80 0 - 1018 pipe_w 04:38 ? 00:00:00 tee 0 S 4757 8948 8937 0 80 0 - 1018 pipe_w 04:38 ? 00:00:00 tee 1 S 4757 8953 8937 0 80 0 - 62257 inet_c 04:38 ? 00:00:00 /usr/sbin/httpd -C Include / 5 S 4757 11886 11875 0 80 0 - 27779 poll_s 05:44 ? 00:00:00 sshd: 542a6bf7e659c5d2b40000 0 S 4757 11887 11886 0 80 0 - 27211 wait 05:44 pts/2 00:00:00 /bin/bash --init-file /usr/b

  • Copyright © 2014 RedHat K.K. - 11 –  

    0 R 4757 12140 11887 0 80 0 - 27560 - 05:44 pts/2 00:00:00 ps –elf

     • Node ホストのユーザで、アプリケーションコンテナのプロセスを確認します  

    Ø 「id」コマンドで確認した  uid  で  grep  すると、このコンテナに関連付けられたユーザのプロセスのみが参照できます  

     実⾏行行環境>Node ホスト  OS ユーザ>root  

    # ps -elf|grep 4757 0 S 4757 8937 1 0 80 0 - 62257 poll_s 04:38 ? 00:00:00 /usr/sbin/httpd -C Include /var/lib/openshift/542a6bf7e659c5d2b4000003/php//configuration/etc/conf.d/*.conf -f /var/lib/openshift/542a6bf7e659c5d2b4000003/php//configuration/etc/conf/httpd_nolog.conf -c Include /etc/openshift/cart.conf.d/httpd/*.conf -c Include /etc/openshift/cart.conf.d/httpd/php/*.conf -D FOREGROUND 0 S 4757 8947 8937 0 80 0 - 1018 pipe_w 04:38 ? 00:00:00 tee 0 S 4757 8948 8937 0 80 0 - 1018 pipe_w 04:38 ? 00:00:00 tee 1 S 4757 8953 8937 0 80 0 - 62257 inet_c 04:38 ? 00:00:00 /usr/sbin/httpd -C Include /var/lib/openshift/542a6bf7e659c5d2b4000003/php//configuration/etc/conf.d/*.conf -f /var/lib/openshift/542a6bf7e659c5d2b4000003/php//configuration/etc/conf/httpd_nolog.conf -c Include /etc/openshift/cart.conf.d/httpd/*.conf -c Include /etc/openshift/cart.conf.d/httpd/php/*.conf -D FOREGROUND

     

  • Copyright © 2014 RedHat K.K. - 12 –  

    PART2  使う  

  • Copyright © 2014 RedHat K.K. - 13 –  

    3. アプリケーション作成  

    アプリケーション作成では、OpenShift  Enterprise で⽤用意されているカートリッジを利利⽤用して、JavaEE のアプリケーションを作成します。  また、Jenkins を利利⽤用した CI 環境も有効にします。  

    3.1. 利利⽤用するカートリッジ  

    • JBoss  Enterprise  Application  Platform  6  • Jenkins  Client  • PostgreSQL  • Jenkins  Server    

       

    3.2. ログイン  

    『2.1.4OpenShiftEnterprise のアプリケーションコンソールのログイン』に従い、OpenShiftEnterprise のアプリケーションコンソールにログインします。  

    3.3. アプリケーションの作成  3.3.1. 作業環境  この節では、ブラウザとコマンドラインの両⽅方を利利⽤用します。  実⾏行行環境   localhost  OS ユーザ   openshift  OpenShift ユーザ   demo  OpenShift パスワード   openshift  

     

  • Copyright © 2014 RedHat K.K. - 14 –  

    3.3.2. ギアの作成  Web の UI を使ってアプリケーションを作成していきます。  

    (1) STEP1)  CHOOSE  A  TYPE  OF  APPLICATION  • 画⾯面をスクロールし画⾯面下部の「→Create  your  first  application  now」のリンクをクリ

    ックします  Ø 既にアプリケーションが作成済みの場合は「Add  Application」ボタンをクリックし

    ます  • カートリッジ選択画⾯面で「JBoss  Enterprise  Application  Platform6」カートリッジを選

    択します  

       

    (2) STEP2)  CONFIGURE  THE  APPLICATION  • カートリッジ設定画⾯面で値を設定します  • 「Create  Application」ボタンをクリックしアプリケーションを作成します  

       

    項⽬目名称   設定値  Public  URL   https://jbosseap-‐‑‒demo.openshift.example.com  

  • Copyright © 2014 RedHat K.K. - 15 –  

    Source  Code    Gears   Small  

    ※デフォルト設定では編集不不可  Scalling   No  scalling  

    (3) STEP3)  NEXT  STEPS  • 「Not  now,  Continue」のリンクをクリックし、設定を続けます  

     

    (4) データベースカートリッジの追加  • PostgreSQL9.2 を選択します  • Add  Cartridge  to  jbosseap 画⾯面で「Add  Cartridge」ボタンをクリックします  

  • Copyright © 2014 RedHat K.K. - 16 –  

         

    (5) アプリケーションの確認  • http://jbosseap-‐‑‒demo.openshift.example.com  にアクセスしてJBoss  EAPアプリケー

    ションが作成されたことを確認します  

     

  • Copyright © 2014 RedHat K.K. - 17 –  

    3.3.3. WEBアプリケーションのデプロイ  

    (1) JBOSSEAP アプリケーションのリポジトリ取得  • rhc  apps  コマンドで OpenShift 上の git リポジトリの URL を確認します    作業ディレクトリ>指定なし  

    % rhc apps jbosseap @ http://jbosseap-demo.openshift.example.com/ (uuid: 53da0f7ce659c5be0900000e) ------------------------------------------------------------------------------------ Domain: demo Created: 5:42 AM Gears: 1 (defaults to small) Git URL: ssh://[email protected]/~/git/jbosseap.git/ SSH: [email protected] Deployment: auto (on git push) jbosseap-6 (JBoss Enterprise Application Platform 6) ---------------------------------------------------- Gears: Located with postgresql-9.2 postgresql-9.2 (PostgreSQL 9.2) ------------------------------- Gears: Located with jbosseap-6 Connection URL: postgresql://$OPENSHIFT_POSTGRESQL_DB_HOST:$OPENSHIFT_POSTGRESQL_DB_PORT Database Name: jbosseap Password: vgDArcHvMPZ_ Username: admineev735q You have access to 1 application.

     

    (2) リポジトリのクローン作成  • git  clone  コマンドでリポジトリのクローンを作成します    

    作業ディレクトリ>$HOME/git  

    % cd ~/git/ % rhc git-clone jbosseap

     

    git  コマンドでの clone の⽅方法  git cloneのラッパーコマンド「rhc git-clone」ではなく、gitコマンドで URLを指定して cloneすることも可能です。その場合は、以下のコマンドを実⾏行行してください。 % git clone

    ssh://[email protected]/~/git/jbosseap.gi

    t/

    Initialized empty Git repository in /home/openshift/work/jbosseap/.git/

    remote: Counting objects: 34, done.

    remote: Compressing objects: 100% (23/23), done.

    remote: Total 34 (delta 0), reused 34 (delta 0)

    Receiving objects: 100% (34/34), 29.32 KiB, done.

     

  • Copyright © 2014 RedHat K.K. - 18 –  

    (3) TODO アプリケーションのデプロイ    

    ラボサーバがない場合は、このセクションの最後のコラム「GitHub からのアプリケーションのダウンロード」に従って、todo アプリケーションのダウンロードとリポジトリへのを⾏行行ってください。  

     • todo アプリケーションをダウンロードします  作業ディレクトリ>$HOME/work  

    % mkdir ~/work % cd ~/work % wget http:///ose/todo/master.zip % unzip master.zip

       • ダウンロードした todo アプリケーションを   jbosseap に反映します  作業ディレクトリ>$HOME/git/jbosseap  

    % cd ~/git/jbosseap % cp –R ~/work/todo-jbosseap6-master/* .

     • pom.xml ファイルを確認し、リポジトリが  

    http:///ose/todo/repository  になっていることを確認します  

    http:///ose/todo/repository    • 変更更を反映します  作業ディレクトリ>$HOME/git/jbosseap  

    % cd ~/git/jbosseap % git add . % git commit –m”modify” % git push

     

    GitHub からのアプリケーションのダウンロード  github からダウンロードして利利⽤用する場合は、  • クローンしたリポジトリのディレクトリに移動  • github からアプリケーションをダウンロード  • OpenShift にアプリケーションを push  して、反映します。  %  git  config  user.email  “[email protected]”  %  git  config  user.name  “openshift”  %  git  remote  add  upstream  -‐‑‒m  master  https://github.com/gshipley/todo-‐‑‒javaee6.git  %  git  pull  -‐‑‒s  recursive  -‐‑‒X  theirs  upstream  master  %  git  add  .  %  git  commit  -‐‑‒m"modify"  

  • Copyright © 2014 RedHat K.K. - 19 –  

    %  git  push  

    (4) デプロイの確認  • http://jbosseap-‐‑‒demo.openshift.example.com/index.htmlにアクセスしてTodoアプ

    リケーションがデプロイされたことを確認します      

  • Copyright © 2014 RedHat K.K. - 20 –  

    4. アプリケーションの更更新  

    4.1. JENKINS の利利⽤用  4.1.1. 作業環境  実⾏行行環境   ブラウザ  OpenShift ユーザ   demo  OpenShift パスワード   openshift  

     

    4.1.2. JENKINS サーバの作成  

    (1) STEP1)CHOOSE  A  TYPE  OF  APPLICATION  • アプリケーション⼀一覧画⾯面で「Add  Application」ボタンをクリックします  • カートリッジ選択画⾯面で「Jenkins  Server」を選択します  

    (2) STEP2)CONFIGURE  THE  APPLICATION  • カートリッジ設定画⾯面で値を設定します  • 「Create  Application」ボタンをクリックしアプリケーションを作成します  

    項⽬目名称   設定値  Public  URL   https://jenkins-‐‑‒demo.openshift.example.com  Source  Code   ※⼊入⼒力力しない  Gears   Small  

    ※デフォルト設定では編集不不可  Scalling   No  scalling  

    ※編集不不可  

  • Copyright © 2014 RedHat K.K. - 21 –  

    •  

    (3) STEP3)NEXT  STEPS  • Jenkins  Server のアプリケーションが作成されたことを確認します  • Jenkins の管理理コンソールへログインする際に利利⽤用するユーザ名とパスワードが表

    ⽰示されるので、記録しておきます  

     

    4.1.3. JENKINS  CLIENT の有効化  

    (1) JENKINS  CLIENT を有効にするアプリケーションの選択  • アプリケーション⼀一覧から『3.3 アプリケーションの作成』で作成した「jbosseap」アプ

    リケーションを選択します  • jbosseap アプリケーションの設定画⾯面下部にある「Enable  jenkins」のリンクをクリック

    します  

    (2) JENKINS  CLIENT の有効化  

  • Copyright © 2014 RedHat K.K. - 22 –  

    • 確認画⾯面で「Add  Jenkins」ボタンをクリックし、Jenkins  Client を有効にします  

    •  

    (3) JENKINS の確認  • 作成時に⽣生成された URL にアクセスし、Jenkins  Server にログインします  

    User   admin  Password  

    4.1.4. 『4.1.1 作業環境  実⾏行行環境   ブラウザ  OpenShift ユーザ   demo  OpenShift パスワード   openshift  

     

    JENKINS サーバの作成』で⽣生成されたパスワード  

     

    4.2. アプリケーションの更更新  

  • Copyright © 2014 RedHat K.K. - 23 –  

    『3.3 アプリケーションの作成』で作成した ToDo アプリケーションの UI を変更更し、OpenShiftに反映します。  

    4.2.1. 作業環境  実⾏行行環境   localhost  OS ユーザ   openshift  

     

    4.2.2. ディレクトリ構成  OpenShift 上に作成したアプリケーションは、Maven プロジェクトのディレクトリ構造になっています。    pom.xml Maven のビルド定義ファイル  README.md カートリッジの説明  .git/ GIT の管理理⽤用ディレクトリ  .openshift/ OpenShift の管理理⽤用ディレクトリ  .openshift/config/ カートリッジの設定ディレクトリ  

    JBoss  EAP カートリッジを利利⽤用する場合は、設定ファイルのstandalone.xml と 利利 ⽤用するモジュールを保持する  modules ディレクトリが⽣生成される  

    deployments/ アーカイブ形式のデプロイモジュールを保存するディレクトリ  

    src/main/resources/ Web アプリケーションのリソースファイルを保存するディレクトリ  

    src/main/java/ Java ソースコードを保存するディレクトリ  src/main/webapp/ Web アプリケーションを保存するディレクトリ  

     

    4.2.3. ソースコードの編集  ToDo アプリケーションは Java  Server  Faces を利利⽤用しており、UI のソースコードは次のようになっています。  

    (1) ファイルの編集  • 「src/main/webapp/todo.xhtml」を編集します    作業ディレクトリ>$HOME/git/jbosseap/src/main/webapp    【変更更前】           Start  creating  your  Todos                

    Todo  Application  Running  On  OpenShift  

           

     【変更更後】         Start  creating  your  Todos                

    Todo  Application  

     

  • Copyright © 2014 RedHat K.K. - 24 –  

         

    4.2.4. GIT リポジトリへの反映  

    (1) 編集をローカルリポジトリにコミットします  作業ディレクトリ>$HOME/git/jbosseap/src/main/webapp/  

    % git commit –m”modify title” todo.xhtml [master 80d4c8e] modify 1 files changed, 1 insertions(+), 1 deletions(-)

     

    (2) 編集を OPENSHIFT 上のリポジトリにプッシュします  作業ディレクトリ>$HOME/git/jbosseap/src/main/webapp  

    % git push Counting objects: 11, done. Compressing objects: 100% (5/5), done. Writing objects: 100% (6/6), 434 bytes, done. Total 6 (delta 4), reused 0 (delta 0) remote: Executing Jenkins build. remote: remote: You can track your build at https://jenkins-demo.openshift.example.com/job/jbosseap-build remote: remote: Waiting for build to schedule.............................................Done remote: Waiting for job to complete..........................................................................................Done remote: SUCCESS remote: New build has been deployed. remote: ------------------------- remote: Git Post-Receive Result: success remote: Deployment completed with status: success To ssh://[email protected]/~/git/jbosseap.git/ 782eab2..80d4c8e master -> master

       

    4.2.5. JENKINS によるビルド  • ブラウザで「http://jenkins-‐‑‒demo.openshift.example.com」にアクセスしビルド状況

    を確認します  

  • Copyright © 2014 RedHat K.K. - 25 –  

    5. アプリケーション管理理  

    最初に作成した   firstphp  アプリケーションを利利⽤用して、世代管理理とバックアップとリストアの機能を確認します。  

    5.1. 世代管理理  5.1.1. 作業環境  実⾏行行環境   localhost  OS ユーザ   openshift  

     

    5.1.2. 保存可能な世代数の設定  • 現在の世代数を確認します  

    Ø デフォルトでは  Keep  Deployments  の値は 1  作業ディレクトリ>指定なし  

    % rhc app-configure firstphp firstphp @ http://firstphp-apps.openshift.example.com/ (uuid: 542a6bf7e659c5d2b4000003) ------------------------------------------------------------------------------------ Deployment: auto (on git push) Keep Deployments: 1 Deployment Type: git Deployment Branch: master Your application 'firstphp' is configured as listed above.

     • 世代数を 5に設定します  作業ディレクトリ>指定なし  

    % rhc app-configure -a firstphp --keep-deployments 5 Configuring application 'firstphp' ... done firstphp @ http://firstphp-apps.openshift.example.com/ (uuid: 542a6bf7e659c5d2b4000003) ------------------------------------------------------------------------------------ Deployment: auto (on git push) Keep Deployments: 5 Deployment Type: git Deployment Branch: master Your application 'firstphp' is now configured as listed above. Use 'rhc show-app firstphp --configuration' to check your configuration values any time.

     

    5.1.3. 世代を指定したデプロイ  • index.php を編集します    

    作業ディレクトリ>$HOME/git/firstphp    

  • Copyright © 2014 RedHat K.K. - 26 –  

                                                     Welcome  to  your  PHP  application  on  OpenShift                          Version  2                          

     • リポジトリにコミットします  作業ディレクトリ>$HOME/git/firstphp  

    % git commit –m”version 2” index.php % git push

     • 世代を確認します  作業ディレクトリ>指定なし  

    % rhc deployments firstphp 8:32 AM, deployment b81d5a71 8:34 AM, deployment a22c1dc5

     • ブラウザで  http://firstphp-‐‑‒apps.openshift.example.com/にアクセスしタイトル画⾯面

    が更更新されていることを確認します  

       

    • 最初の世代の ID を指定してロールバックし、再度度ブラウザで確認します  作業ディレクトリ>指定なし  

    % rhc deployments firstphp 8:32 AM, deployment b81d5a71 ←最初の世代 8:34 AM, deployment a22c1dc5 ←version 2 % rhc activate-deployment –a firstphp b81d5a71 ←最初の世代の ID を指定してロールバック

  • Copyright © 2014 RedHat K.K. - 27 –  

    5.2. スナップショットの取得とリストア  

    最初に作成した firstphp アプリケーションを利利⽤用して、スナップショットとリストアを実⾏行行します。    

    5.2.1. 作業環境  実⾏行行環境   localhost  OS ユーザ   openshift  

     

    5.2.2. 作業ディレクトリの作成  スナップショットとリストアを実⾏行行するための作業⽤用に「$HOME/work」ディレクトリを作成します。  • ディレクトリを作成します  作業ディレクトリ>$HOME  

    % cd ~ % mkdir work

     

    5.2.3. スナップショットの取得  • スナップショットを取得します  作業ディレクトリ>$HOME/work  

    % cd ~/work % rhc snapshot save firstphp Pulling down a snapshot of application 'firstphp' to firstphp.tar.gz ... done % ls firstphp.tar.gz

     

    5.2.4. リストア  firstphp アプリケーションを削除し、取得したスナップショットから再構築します    • firstphp アプリケーションを削除します  作業ディレクトリ>指定なし  

    % rhc app delete firstphp This is a non-reversible action! Your application code and data will be permanently deleted if you continue! Are you sure you want to delete the application 'firstphp'? (yes|no): yes ←yes と入力 Deleting application 'firstphp' ... deleted

    • ブラウザから「http://firstphp-‐‑‒demo.openshift.example.com」にアクセスし、Not  Found になることを確認します  

     • アプリケーションを作成し、スナップショットからデプロイします  作業ディレクトリ>$HOME/work  

    % cd ~/work % rhc app create firstphp php-5.4

  • Copyright © 2014 RedHat K.K. - 28 –  

    … <省略> … % rhc snapshot restore firstphp --filepath firstphp.tar.gz Restoring from snapshot firstphp.tar.gz to application 'firstphp' ... done % ls firstphp firstphp.tar.gz

     • ブラウザから「http://firstphp-‐‑‒demo.openshift.example.com」にアクセスし、firstphp

    アプリケーションにアクセスできることを確認します    

    リストアする時のアプリケーション名  リストアする際にアプリケーション名は、別の名称をしてすることが可能です。  上記の例例では、  %  rhc  app  create  newphp  php-‐‑‒5.4  %  rhc  snapshot  restore  newphp  –filepath  firstphp.tar.gz  とすることで、http://newphp-‐‑‒demo.openshift.example.com  にアプリケーションがデプロイされます。      

  • Copyright © 2014 RedHat K.K. - 29 –  

    PART  3  カスタマイズ  

  • Copyright © 2014 RedHat K.K. - 30 –  

    6. ユーザ管理理  

    6.1. 準備  

    管理理コマンドは Broker ホストの root ユーザで実⾏行行します。以降降の作業を進めるにあたり、新しいターミナルを開いて   root  ユーザになります。    • root ユーザへのスイッチします  

    % sudo su - [root@vm ~]# id uid=0(root) gid=0(root) groups=0(root) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023

    6.2. ユーザの追加  

    管理理コマンドを利利⽤用してユーザの追加と削除を実⾏行行します。管理理コマンドは Broker ホストのroot ユーザで実⾏行行します。    

    6.2.1. 作業環境  実⾏行行環境   Broker  OS ユーザ   root  

     

    6.2.2. ユーザ   の追加  • ユーザを作成します  

    ユーザ名   developer  作業ディレクトリ>指定なし  

    # oo-admin-ctl-user -c -l developer User developer: plan: consumed domains: 0 max domains: 10 consumed gears: 0 max gears: 100 max tracked storage per gear: 0 max untracked storage per gear: 0 max teams: 10 viewing all global teams allowed: true gear sizes: small sub accounts allowed: false private SSL certificates allowed: false inherit gear sizes: false HA allowed: true

     • パスワードを設定します  

    ユーザ名   developer  パスワード   openshift  

     

  • Copyright © 2014 RedHat K.K. - 31 –  

    # htpasswd -b /etc/openshift/htpasswd developer openshift # cat /etc/openshift/htpasswd demo:skK/M3AQXVPe. developer:z7ODcimhx09Ec

     • デプロイ済みのアプリケーションを確認します  実⾏行行環境>localhost  OS ユーザ>openshift  作業ディレクトリ>指定なし  

    % rhc apps -l developer -p openshift In order to deploy applications, you must create a domain with 'rhc setup' or 'rhc create-domain'.

     

    6.2.3. ユーザの削除  

    6.3. リソース割り当て  

    実⾏行行環境   Broker  OS ユーザ   root  

     

    6.3.1. 利利⽤用可能なギア数の変更更  • 割り当てられているギア数を確認します  作業ディレクトリ>指定なし  

    # oo-admin-ctl-user -l developer User developer: plan: consumed domains: 1 max domains: 10 consumed gears: 0 max gears: 100 max tracked storage per gear: 0 max untracked storage per gear: 0 max teams: 10 viewing all global teams allowed: true gear sizes: small sub accounts allowed: false private SSL certificates allowed: false inherit gear sizes: false HA allowed: true

     • ギア数を変更更します  作業ディレクトリ>指定なし  

    # oo-admin-ctl-user -l developer --setmaxgears 10 Setting max_gears to 10... Done. User developer: plan: consumed domains: 1 max domains: 10 consumed gears: 0

  • Copyright © 2014 RedHat K.K. - 32 –  

    max gears: 10 max tracked storage per gear: 0 max untracked storage per gear: 0 max teams: 10 viewing all global teams allowed: true gear sizes: small sub accounts allowed: false private SSL certificates allowed: false inherit gear sizes: false HA allowed: true

  • Copyright © 2014 RedHat K.K. - 33 –  

    7. カートリッジ管理理  

    7.1. カートリッジのインストール  7.1.1. 作業環境  実⾏行行環境   Node  OS ユーザ   root  

     

    7.1.2. インストール済みカートリッジの確認  • インストール済みのカートリッジを確認します  作業ディレクトリ>指定なし  

    # oo-admin-ctl-cartridge –c list * cron-1.4 plugin Cron 1.4 2014/06/05 20:07:55 UTC * jenkins-client-1 plugin Jenkins Client 2014/06/05 20:07:55 UTC * mongodb-2.4 service MongoDB 2.4 2014/06/05 20:07:55 UTC * mysql-5.1 service MySQL 5.1 2014/06/05 20:07:55 UTC * mysql-5.5 service MySQL 5.5 2014/06/05 20:07:55 UTC * postgresql-8.4 service PostgreSQL 8.4 2014/06/05 20:07:55 UTC * postgresql-9.2 service PostgreSQL 9.2 2014/06/05 20:07:55 UTC * diy-0.1 web Do-It-Yourself 0.1 2014/06/05 20:07:55 UTC . . .

     

    7.1.3. カートリッジの無効化  • perl5 のカートリッジを無効化します  「oo-‐‑‒admin-‐‑‒ctl-‐‑‒cartridge  –c  list」コマンドを実⾏行行すると、perl-‐‑‒5.10 は以下のように表⽰示されます。現在、perl-‐‑‒5.10 は有効なので先頭に「*」が表⽰示されます。  * perl-5.10 web Perl 5.10 2014/06/05 20:07:55 UTC

         ↑    カートリッジ名    作業ディレクトリ>指定なし  

    # oo-admin-ctl-cartridge –c deactivate -n perl-5.10 perl-5.10 was deactivated.

     • perl-‐‑‒5 カートリッジが無効になったことを確認します  作業ディレクトリ>指定なし  

    # oo-admin-ctl-cartridge –c list |grep perl perl-5.10 web Perl 5.10 2014/06/05 20:07:55 UTC

     ブラウザからは  http://localhost/console/application_̲types  にアクセスし、「Other  types」カテゴリに Perl が表⽰示されていないことが確認できます。  

    7.1.4. カートリッジの有効化  • 先ほど無効化した perl-‐‑‒5.10 カートリッジを有効化します  

  • Copyright © 2014 RedHat K.K. - 34 –  

    「oo-‐‑‒admnin-‐‑‒ctl-‐‑‒cartridge  –c  list」コマンドを実⾏行行すると、perl-‐‑‒5.10 は以下のように表⽰示されます。現在、perl-‐‑‒5.10 は無効なので先頭に「*」が表⽰示されません。     perl-5.10 web Perl 5.10 2014/06/05 20:07:55 UTC        ↑          カートリッジ名  作業ディレクトリ>指定なし  

    # oo-admin-ctl-cartridge –c activate –n perl-5.10 5390ce1be659c55ee100000f # now the active cartridge for perl-5.10

     • カートリッジが有効になったことを確認します  

    作業ディレクトリ>指定なし  

    # oo-admin-ctl-cartridge -c list |grep perl * perl-5.10 web Perl 5.10 2014/06/05 20:07:55 UTC

     ブラウザからは  http://localhost/console/application_̲types  にアクセスし「Other   types」カテゴリに Perl が表⽰示されていることを確認します。  

  • Copyright © 2014 RedHat K.K. - 35 –  

    8. カスタムカートリッジの利利⽤用  

     

    8.1. URL ダウンロードカートリッジの利利⽤用(HTTPD)  

    Node にインストールされていないカートリッジであっても、URL でダウンロード先を指定して利利⽤用します。  この⽅方法を利利⽤用すると、github などで公開されているカートリッジを容易易に利利⽤用することが可能です。  

    8.1.1. 作業環境  実⾏行行環境   localhost  OS ユーザ   openshift  

     

    8.1.2. URL でカートリッジを指定したアプリケーションの作成  • URL でダウンロード可能なカートリッジを利利⽤用して、新しいアプリケーションを作成しま

    す。    

    ハンズオンラボでない場合は、8.1 節の最後のコラム「GitHubで公開されているカートリッジを利利⽤用する場合」に従って、カートリッジの URL を指定してください。  

    作業ディレクトリ>$HOME/git  

    % cd ~/git % rhc create-app httpd http:///ose/httpd/manifest.yml The cartridge 'https://raw.githubusercontent.com/akubicharm/openshift-apache-httpd-cartridge/master/metadata/manifest.yml' will be downloaded and installed Application Options ------------------- Domain: demo Cartridges: https://raw.githubusercontent.com/akubicharm/openshift-apache-httpd-cartridge/master/metadata/manifest.yml Gear Size: default Scaling: no Creating application 'httpd' ... done Waiting for your DNS name to be available ... done Cloning into 'httpd'... The authenticity of host 'httpd-demo.example.com (54.166.119.115)' can't be established. RSA key fingerprint is cf:ee:77:cb:0e:fc:02:d7:72:7e:ae:80:c0:90:88:a7. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 'httpd-komizo.rhcloud.com,54.166.119.115' (RSA) to the list of known hosts. Your application 'httpd' is now available.

  • Copyright © 2014 RedHat K.K. - 36 –  

    URL: http://httpd-demo.example.com/ SSH to: [email protected] Git remote: ssh://[email protected]/~/git/httpd.git/ Cloned to: /home/openshift/git/httpd Run 'rhc show-app httpd' for more details about your app.

         

    8.1.3. デプロイの確認  • ブラウザからでアクセスし「Hello  World!」と表⽰示されることを確認します  

    「http://httpd-‐‑‒demo.openshift.example.com」    

    GitHub で公開している httpd カートリッジを利利⽤用する場合  github で公開している httpd カートリッジを利利⽤用する場合は、アプリケーションを作成する場合は、以下のコマンドを実⾏行行します。  rhc  create-‐‑‒app  httpd  https://raw.githubusercontent.com/akubicharm/openshift-apache-httpd-cartridge/master

    /metadata/manifest.yml  

    8.2. DIY カートリッジの利利⽤用  8.2.1. アプリケーションの作成  • アプリケーションを作成します  作業ディレクトリ>$HOME/git  

    % cd ~/git % rhc create-app diyapp diy Using diy-0.1 (Do-It-Yourself 0.1) for 'diy' Application Options ------------------- Domain: demo Cartridges: diy-0.1 Gear Size: default Scaling: no Creating application 'diyapp' ... done Disclaimer: This is an experimental cartridge that provides a way to try unsupported languages, frameworks, and middleware on OpenShift. Waiting for your DNS name to be available ... done Initialized empty Git repository in /home/openshift/git/diyapp/.git/ Warning: Permanently added 'diyapp-demo.openshift.example.com' (RSA) to the list of known hosts. Your application 'diyapp' is now available. URL: http://diyapp-demo.openshift.example.com/ SSH to: [email protected] Git remote: ssh://[email protected]/~/git/diyapp.git/ Cloned to: /home/openshift/git/diyapp Run 'rhc show-app diyapp' for more details about your app.

     

  • Copyright © 2014 RedHat K.K. - 37 –  

    8.2.2. アプリケーションのデプロイ  • ローカルのリポジトリのファイルを確認します  作業ディレクトリ>$HOME/git/diyapp  

    % cd ~/git/diyapp % ls –al drwxrwxr-x. 8 openshift openshift 4096 10 月 1 07:07 2014 .git drwxrwxr-x. 4 openshift openshift 4096 10 月 1 06:35 2014 .openshift -rw-rw-r--. 1 openshift openshift 169 10 月 1 06:35 2014 README.md drwxrwxr-x. 2 openshift openshift 4096 10 月 1 06:35 2014 diy drwxrwxr-x. 2 openshift openshift 4096 10 月 1 06:35 2014 misc

     • helloworld.c を作成  

    作業ディレクトリ>$HOME/git/diyapp  #include      int  main(int  argc,  char  *argv[])  {           printf("%s\n",  "Hello  World");  }  

     • コンパイル  

    作業ディレクトリ>$HOME/git/diyapp  

    % cc –o hello helloworld.c

     • hello,  helloworld.c  をリポジトリに追加し、コミット  

    作業ディレクトリ>$HOME/git/diyapp  

    % git add hello helloworld.c % git commit –m”first create” . % git push

     

    8.2.3. ACTION_̲HOOK の設定  アプリケーションの起動時に  hello  コマンドが実⾏行行される様に、action  hook を設定します    • action_̲hook ディレクトリへ移動し、start スクリプトを編集  

    作業ディレクトリ>$HOME/git/diyapp/.openshift/action_̲hooks  

    % cd ~/git/diyapp/.openshift/action_hooks % vi start

     • start スクリプトの最後の⾏行行に、1⾏行行追加します。  nohup  $OPENSHIFT_̲DEPLOYMENTS_̲DIR/current/repo/hello  >  ${OPENSHIFT_̲LOG_̲DIR}/hello.log  2>&1  &  

     • start スクリプトをコミット  

    作業ディレクトリ>$HOME/git/diyapp/.openshift/action_̲hooks  

    % git commit –m”modify” start % git push

  • Copyright © 2014 RedHat K.K. - 38 –  

     • アプリケーションの再起動  

    % rhc app restart diyapp

     • hello.log に「Hello  World」が出⼒力力されていることを確認  

    % rhc ssh diyapp Connecting to [email protected] ... . . . <中略> . . . [diyapp-apps.openshift.example.com 542bd8c6e659c5ae180000c3]¥> cat app-root/logs/hello.log Hello World

     

  • Copyright © 2014 RedHat K.K. - 39 –  

    9. 付録  

    9.1. 管理理コマンド⼀一覧  

     

    # コマンド 説明 Broker 管理理コマンド 1 oo-‐‑‒accept-‐‑‒broker Broker ホスト  の状態を確認する 2 oo-‐‑‒accept-‐‑‒systems Node ホストの状態を確認する 3 oo-‐‑‒admin-‐‑‒chk MongoDBに保存されているOpenShift に

    デプロイされたアプリケーションの情報を

    確認する 4 oo-‐‑‒admin-‐‑‒broker-‐‑‒auth /etc/openshift/broker.conf  の  

    AUTH_̲SALT の変更更を反映させる 5 oo-‐‑‒admin-‐‑‒broker-‐‑‒cache Rails アプリケーションのキャッシュをク

    リアする 6 oo-‐‑‒admin-‐‑‒ctl-‐‑‒app 利利⽤用者のアプリケーションの設定を変更更す

    る ex)HAProxy の設定変更更

    7 oo-‐‑‒admin-‐‑‒ctl-‐‑‒authorization 認証トークンを削除する(期限切切れ  or  すべて)

    8 oo-‐‑‒admin-‐‑‒ctl-‐‑‒district District を管理理する 9 oo-‐‑‒admin-‐‑‒ctl-‐‑‒domain OpenShift で公開するアプリケーションの

    ドメインを管理理する 10 oo-‐‑‒admin-‐‑‒ctl-‐‑‒region Region と Region 内の Zone を管理理する 11 oo-‐‑‒admin-‐‑‒ctl-‐‑‒user ユーザの追加・削除、リソース割り当てを

    実⾏行行する 12 oo-‐‑‒admin-‐‑‒move Gear を他のNode ホストへ移動する 13 oo-‐‑‒admin-‐‑‒repair BrokerホストのMongoDBで保持している

    情報と、Gear で保持している情報の不不整合

  • Copyright © 2014 RedHat K.K. - 40 –  

    を修正する 14 oo-‐‑‒admin-‐‑‒upgrade カスタムカートリッジやコミュニティから

    ダウンロードしたカートリッジを更更新する 15 oo-‐‑‒admin-‐‑‒ctl-‐‑‒cartrige カートリッジのインポート、有効化、無効

    化などカートリッジを管理理する 16 oo-‐‑‒register-‐‑‒dns nsupdate コマンドのラッパー。DNS情報

    を更更新する 17   oo-‐‑‒accept-‐‑‒node Node ホストの状態を確認する 18   oo-‐‑‒admin-‐‑‒ctl-‐‑‒gears Node ホスト上のGear を管理理する 19   oo-‐‑‒idler-‐‑‒stats Gear のメトリクス情報を表⽰示する 20   oo-‐‑‒last-‐‑‒access Gear へのWeb経由のアクセスやGit への

    アクセスログを表⽰示する  

    9.2. サーバ環境設定  

    9.3. VM のダウンロード  9.3.1. RED  HAT  CUSTOMER  PORTAL のアカウント作成  RED  HAT  カスタマポータルへのログインアカウントがない場合は、RED  HATログインアカウントを作成してください。  

    (1) カスタマポータルへアクセス  • http://access.redhat.com  にアクセスします  

    (2) ユーザの登録  • 必要な情報を⼊入⼒力力して Red  Hat アカウントを作成します  

  • Copyright © 2014 RedHat K.K. - 41 –  

       

    9.3.2. OPENSHIFT  ENTERPRISE  VM イメージのダウンロード  

    (1) カスタマポータルへアクセス  • http://access.redhat.com  にアクセスします  

    (2) ログイン    • 登録済みの Red  Hat  アカウントでログインし、カスタマポータルのページへ移動しま

  • Copyright © 2014 RedHat K.K. - 42 –  

     

    (3) 無償評価版サブスクリプションの申請  • 「ダウンロード」メニューから「製品のダウンロード」を選択します  • 製品⼀一覧から「OpenShift  Enterprise  by  Red  Hat」を選択します  • 「Request  an  Evaluation」をクリックします  • Try  OpenShift  Enterprise  PaaS  for  Free のページで「Continue」をクリックします  • important  Evaluation  Terms のページで、利利⽤用許諾諾のチェックボックをチェックし

    「Continue」をクリックします  • 申請完了了のページで「EXPLORE  YOUR  EVALUATION」をクリックしダウンロードペー

    ジへ移動します                

  • Copyright © 2014 RedHat K.K. - 43 –    

  • Copyright © 2014 RedHat K.K. - 44 –  

    (4) ダウンロード  • 「ダウンロード」メニューから「製品のダウンロード」を選択します  • 製品⼀一覧から「OpenShift  Enterprise  by  Red  Hat」を選択します  • Red  Hat  OpenShift  Enterprise のダウンロードページで「OSEoD  Virtual  Machine」

    を選択します  • ダウンロードが完了了したら保存ディレクトリに「OSEoD-‐‑‒2.1.1-‐‑‒1.x86_̲64.vmdk」とい

    うファイルが保存されていることを確認します  

     

    9.4. VIRTUALBOX の設定  9.4.1. 環境設定  

    (1) ネットワーク設定  外部と通信するための NAT と、ホスト OS とゲスト OS 間で通信するためにホストオンリーネットワークの設定します。  • Virtual  Box のマネージャ画⾯面の「ファイル」メニューから「環境設定…」を選択します  • 設定ダイアログの左側の⼀一覧から「ネットワーク」を選択します  • 設定ダイアログの右側のネットワーク設定編集領領域で「ホストオンリーネットワーク」

    タブを選択します  • 「ホストオンリーネットワークを追加」ボタン をクリックし「vboxnet0」という名

    称のホストオンリーネットワークの設定を作成します  • 作成された「vboxnet0」をダブルクリックし編集ダイアログを表⽰示します  • アダプタタブで必要事項を⼊入⼒力力します  

    表  1 ホストオンリーネットワークの詳細(アダプター)  

        項⽬目名称   設定値  IPv4 アドレス   192.168.2.9  IPv4 ネットマスク   255.255.255.0  IPv6 アドレス   0  IPv6 ネットマスク⻑⾧長   64    表  2 ホストオンリーネットワークの詳細(DHCP サーバー)  

    項⽬目名称   設定値  サーバを有効化   TRUE(チェックボックスにチェック)  サーバーアドレス   192.168.2.2  

  • Copyright © 2014 RedHat K.K. - 45 –  

    サーバーマスク   255.255.255.0  アドレス下限   192.168.2.9  アドレス上限   192.168.2.254    

     

    9.5. VM の作成  9.5.1. 仮想マシンの作成  • メニューから「新規」ボタンをクリックします  • 「仮想マシンの作成」ダイアログで名前とオペレーティングシステム、メモリーサイズ、

    ハードドライブを設定します  • 「作成」ボタンをクリックし仮想 OS を作成します    設定種別   項⽬目名称   設定値  

    オペレーティングシステム     名前   任意の名称  

    例例)OSEv2     タイプ   Linux     バージョン   Red  Hat(64bit)  メモリーサイズ     メモリーサイズ   2.0GB  ハードドライブ     仮想ハードドライブ   既にある仮想ハードドライブファイルを使⽤用する     ハードドライブ   OSEoD-‐‑‒2.x.x-‐‑‒x.x86-‐‑‒64.vmdk  

    ※ダウンロードした OpenShiftEnterprise の仮想OS イメージ  

     

  • Copyright © 2014 RedHat K.K. - 46 –  

     

    9.5.2. 仮想 OS のネットワーク設定  • 仮想化ゲスト OS ⼀一覧から仮想化ゲスト OS を選択します  • 画⾯面右側の「ネットワーク」をダブルクリックしネットワーク設定ダイアログを表⽰示し

    ます  アダプタ名   項⽬目名称   設定値  アダプター1     ネットワークアダプタを有

    効化  有効  

      割り当て   NAT     名前   ※編集不不可     アダプタータイプ   ※環境に合わせる     MAC アドレス   ⼀一意になる ID を設定。フィールド横

    の ボタンで設定可能。     ケーブル接続   有効  アダプター2  

  • Copyright © 2014 RedHat K.K. - 47 –  

      ネットワークアダプタ有効化  

    有効  

      割り当て   ホストオンリーアダプター     名前   vboxnet0  

    ※『9.4.1 環境設定』で作成したネットワークを指定  

      アダプタータイプ   準仮想化ネットワーク(virtio-‐‑‒net)     プロミスキャスモード   拒否     MAC アドレス   ⼀一意になる ID を設定。フィールド横

    の ボタンで設定可能。     ケーブル接続   有効