Pivotal Web Serviceのアカウント
を作成する
• 「I Have read and agree to
the Terms of Service for
Pivotal Web Services」に
チェックを入れる。
• 「Next: Claim Your Trial」を
クリック
25
Pivotal Web Serviceのアカウント
を作成する
• CountryにJapanを指定
• Mobile Numberに携帯電
話の番号を入力
• Send me my codeをクリッ
ク
• SMSでverification codeが
送付されます。
26
アプリケーションのデプロイ
42
$ cf push wagby -p wagby-demo.war -f manifest.yml -b java_buildpack
Using manifest file manifest.yml
Creating app wagby in org murajasmine / space development as mura@jasminesoft.co.jp...
OK
Using route wagby.cfapps.io
Binding wagby.cfapps.io to wagby...
OK
Uploading wagby...
Uploading app files from: C:cygwin64tmpunzipped-app159773815
Uploading 16.6M, 13427 files
Done uploading
OK
Starting app wagby in org murajasmine / space development as mura@jasminesoft.co.jp...
Downloading java_buildpack...
Downloaded java_buildpack
Creating container
Successfully created container
Downloading app package...
Downloaded app package (87.2M)
Staging...
-----> Java Buildpack Version: v3.10 (offline) | https://github.com/cloudfoundry/java-
buildpack.git#193d6b7
-----> Downloading Open Jdk JRE 1.8.0_111 from https://java-
buildpack.cloudfoundry.org/openjdk/trusty/x86_64/openjdk-1.8.0_111.tar.gz (found in
cache)
Expanding Open Jdk JRE to .java-buildpack/open_jdk_jre (1.1s)
-----> Downloading Open JDK Like Memory Calculator 2.0.2_RELEASE from https://java-bui
ldpack.cloudfoundry.org/memory-calculator/trusty/x86_64/memory-calculator-2.0.2_REL
EASE.tar.gz (found in cache)
Memory Settings: -Xss349K -Xms681574K -XX:MetaspaceSize=104857K -Xmx681574K -
XX:MaxMetaspaceSize=104857K
-----> Downloading Spring Auto Reconfiguration 1.10.0_RELEASE from https://java-
buildpack.cloudfoundry.org/auto-reconfiguration/auto-reconfiguration-
1.10.0_RELEASE.jar (found in cache)
Modifying /WEB-INF/web.xml for Auto Reconfiguration
-----> Downloading Tomcat Instance 8.0.38 from https://java-
buildpack.cloudfoundry.org/tomcat/tomcat-8.0.38.tar.gz (found in cache)
Expanding Tomcat Instance to .java-buildpack/tomcat (0.1s)
-----> Downloading Tomcat Lifecycle Support 2.5.0_RELEASE from https://java-
buildpack.cloudfoundry.org/tomcat-lifecycle-support/tomcat-lifecycle-support-
2.5.0_RELEASE.jar (found in cache)
-----> Downloading Tomcat Logging Support 2.5.0_RELEASE from https://java-
buildpack.cloudfoundry.org/tomcat-logging-support/tomcat-logging-support-
2.5.0_RELEASE.jar (found in cache)
-----> Downloading Tomcat Access Logging Support 2.5.0_RELEASE from https://java-
buildpack.cloudfoundry.org/tomcat-access-logging-support/tomcat-access-logging-
support-2.5.0_RELEASE.jar (found in cache)
Exit status 0
Staging complete
アプリケーションのデプロイ
43
Uploading droplet, build artifacts cache...
Uploading build artifacts cache...
Uploading droplet...
Uploaded build artifacts cache (108B)
Uploaded droplet (133.5M)
Uploading complete
Destroying container
Successfully destroyed container
0 of 1 instances running, 1 starting
0 of 1 instances running, 1 starting
0 of 1 instances running, 1 starting
0 of 1 instances running, 1 starting
0 of 1 instances running, 1 starting
0 of 1 instances running, 1 starting
0 of 1 instances running, 1 starting
0 of 1 instances running, 1 starting
0 of 1 instances running, 1 starting
1 of 1 instances running
App started
OK
App wagby was started using this command `CALCULATED_MEMORY=$($PWD/.java-build
pack/open_jdk_jre/bin/java-buildpack-memory-calculator-2.0.2_RELEASE -memorySizes=
metaspace:64m..,stack:228k.. -memoryWeights=heap:65,metaspace:10,native:15,stack:10
-memoryInitials=heap:100%,metaspace:100% -stackThreads=300 -totMemory=$MEMORY
_LIMIT) && JAVA_HOME=$PWD/.java-buildpack/open_jdk_jre JAVA_OPTS="-Djava.io.tm
pdir=$TMPDIR -XX:OnOutOfMemoryError=$PWD/.java-buildpack/open_jdk_jre/bin/killjav
a.sh $CALCULATED_MEMORY -Djava.endorsed.dirs=$PWD/.java-buildpack/tomcat/endors
ed -Daccess.logging.enabled=false -Dhttp.port=$PORT" exec $PWD/.java-buildpack/tomca
t/bin/catalina.sh run`
Showing health and status for app wagby in org murajasmine / space development as
mura@jasminesoft.co.jp...
OK
requested state: started
instances: 1/1
usage: 1G x 1 instances
urls: wagby.cfapps.io
last uploaded: Wed Nov 2 10:35:21 UTC 2016
stack: cflinuxfs2
buildpack: java_buildpack
state since cpu memory disk details
#0 running 2016-11-02 07:38:32 PM 150.8% 637M of 1G 307.7M of 1G
アプリケーションを確認(cf apps)
55
$ cf apps
Getting apps in org murajasmine / space development as mura@jasminesoft.co.jp...
OK
name requested state instances memory disk urls
wagby started 1/1 1G 1G wagby.cfapps.io
アプリケーションの詳細を確認(cf app APP_NAME)
56
Showing health and status for app wagby in org murajasmine / space development as mura@jasmin
esoft.co.jp...
OK
requested state: started
instances: 1/1
usage: 1G x 1 instances
urls: wagby.cfapps.io
last uploaded: Fri Nov 4 02:48:32 UTC 2016
stack: cflinuxfs2
buildpack: java_buildpack
state since cpu memory disk details
#0 running 2016-11-04 11:51:28 AM 5.9% 702.7M of 1G 307.7M of 1G
サーバのログ取得(cf logs APP_NAME)
• cf logsコマンドで、コンソールに出力されるメッセー
ジを確認できます。
58
$ cf logs wagby --recent | head
Connected, dumping recent logs for app wagby in org murajasmine / space development as mura@
jasminesoft.co.jp...
2016-11-02T19:33:29.36+0900 [API/1] OUT Created app with guid xxxxxxxx-xxxx-xxxx-xxxx-xxxxx
xxxxxxx2016-11-02T19:33:33.99+0900 [API/5] OUT Updated app with guid xxxxxxxx-xxxx-xxxx-xx
xx-xxxxxxxxxxxx ({"route"=>"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", :verb=>"add", :relation=>"rout
es", :related_guid=>"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"})
2016-11-02T19:35:57.17+0900 [API/3] OUT Updated app with guid xxxxxxxx-xxxx-xxxx-xxxx-
xxxxxxxxxxxx ({"state"=>"STARTED"})
2016-11-02T19:35:57.56+0900 [STG/0] OUT Downloading java_buildpack...
2016-11-02T19:35:57.63+0900 [STG/0] OUT Downloaded java_buildpack
サーバにssh接続(cf ssh APP_NAME)
• cf sshコマンドで、サーバにsshログオンすることが
できます。
59
C:Usersmura>cf ssh wagby
vcap@77bd9cc9-0ee3-4c58-7ba3-61885172c84a:~$ ls
app logs staging_info.yml tmp
vcap@77bd9cc9-0ee3-4c58-7ba3-61885172c84a:~$ ls -l
total 16
drwxr-xr-x 48 vcap root 4096 Nov 2 10:36 app
drwxr-xr-x 2 vcap vcap 4096 Nov 2 10:36 logs
-rw-r--r-- 1 vcap vcap 680 Nov 2 10:36 staging_info.yml
drwxr-xr-x 2 vcap vcap 4096 Nov 2 10:36 tmp
vcap@77bd9cc9-0ee3-4c58-7ba3-61885172c84a:~$
サービス
• Pivotal Web Servicesで提供されているサービスは
下記ページに説明がある。
• https://console.run.pivotal.io/marketplace
66
マーケットプレイス
• cf marketplaceコマンドで作成できるサービスの一覧が表示される。
• cleardbがMySQL、elephantsqlがPostgreSQLを提供しているサービス
• plansはそれぞれデータベースサイズ等の制限。*がついているプランは有料
67
$ cf marketplace
service plans description
...
cleardb spark, boost*, amp*, shock* Highly available MySQL for your
Apps.
...
elephantsql turtle, panda*, hippo*, elephant* PostgreSQL as a Service
...
マーケットプレイス
68
$ cf marketplace -s cleardb
service plan description free or paid
spark Great for getting started and developing your apps free
boost Best for light production or staging your applications paid
amp For apps with moderate data requirements paid
shock Designed for apps where you need real MySQL reliability, power and
throughput paid
サービスの確認(cf services)
• cf servicesコマンドで作成したサービスを確認できる。
70
$ cf services
Getting services in org murajasmine / space development as mura@jasminesoft.co.
jp...
OK
name service plan bound apps last operation
mysql cleardb spark create succeeded