SAP Netweaver AS ABAP Developer Edition をDocker on GCEで動かす

このリポジトリを知ったので、動かしてみました。インフラはGCPの無料クレジット余っていたのでGCEを使いました。

github.com

SAP側インストールメディア取得手続き

こちらにDeveloper Editionの記載があります。SAP StoreからTrial版をダウンロードできるとあります。

https://tools.hana.ondemand.com/#abap

SAP NetWeaver AS ABAP Developer Edition

If you want to try out the tools without having access to an ABAP Server, you can run your own one using the "SAP NetWeaver AS ABAP Developer Editon". You can download the Trial Version of 7.50 SP02 and 7.51 SP02 from the SAP Store.

今回つかったバージョンはこちら。 SAP NetWeaver AS ABAP 7.51 SP02 です。これでABAPがDocker上で動くはず。

f:id:yomon8:20180517222855p:plain

手続きするとダウンロードリンクが記載されたメールが飛んできます。

f:id:yomon8:20180517222852p:plain

以下のようにダウンロードページに飛びます。さすがSAP、開発環境でも巨大な10ファイルが必要・・・

f:id:yomon8:20180517222848p:plain

こちらのページのダウンロードリンクは後で利用します。

GCE仮想マシン立ち上げ

初年度クレジットがまだ残っていたので、今回はGCE使って作業してみます。

どのLinuxでも動くはずなので、Container-Optimized OSとか使ってみたかったのですが、ビルドの処理などで周辺ツールが色々必要で、インストールメディア等もSCPでやりとりできるサイズでもないのでUbuntuにしておきました。

ディスクは中間ファイル含めて150GB近く使うことになりますので、200GB程度用意しておいた方が安心です。

f:id:yomon8:20180518100307p:plain

GCEの初回起動は本当に一瞬で仮想マシン立ち上がります。

f:id:yomon8:20180517222902p:plain

OS環境準備(Dockerインストール)

OS起動したらSSHつなぎます。(今回はdefaultのVPCにしているので最初からSSH開いています)

gcloud compute ssh sapdev --zone asia-northeast1-c

Dockerインストールします。dockerコマンドsudo無しで叩きたいので、ついでにdockerグループに自身を追加します。

$ sudo apt-get update && sudo apt-get install docker.io
$ sudo usermod -aG docker $USER

ログインしなおして、dockerのソケットにアクセスできていることを確認します。

$ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

Ubuntuの場合は元々色々入っていることもあり、SAPのインストールメディアを展開する unrar のみ追加すれば大丈夫でした。

他に必要なのは vim 等のエディタと wgetgit くらいですが、Ubuntuの場合は全て最初から入っています。

$ sudo apt-get install unrar

Systemd版openSUSEビルド

SAP NW Developer EditionのイメージはopenSUSEのものです、Systemdが使われているのですが、Dockerでは普通に起動するとSystemdが立ち上がりません。

Systemdが立ち上がらないとuuiddのサービスが起動できず、SAPのSICKでエラーが出ます。

ということでこちらのイメージをビルドして使います。

github.com

ビルドの手順は以下の通り。

$ git clone https://github.com/openSUSE/docker-containers.git
$ docker build -t opensuse/systemd ./docker-containers/derived_images/systemd/

リポジトリの取得とDockerfile修正

次に前述のsap-nw-abap-dockerリポジトリをクローンしてきます。ここにDockerfileが含まれています。

GitHub - tobiashofmann/sap-nw-abap-docker: SAP NetWeaver ABAP Developer Edition in Docker

ホームディレクトリに移動してリポジトリをクローンします。クローンしたディレクトリに移動しておきます。

$ cd
$ git clone https://github.com/tobiashofmann/sap-nw-abap-docker.git
$ cd ./sap-nw-abap-docker/

先程ビルドしたSystemd版openSUSEで立ち上げるためDockerfileを修正します。

最後のrun.sh も後から自分で叩くのでコメントアウトしておきます。ここでrun.sh動かすと一時的なホスト名を元にSAPがインストールされてしまいます。

$ cd ~/sap-nw-abap-docker/
$ vim Dockerfile

ということでDockerfileの変更点は以下の通り。

$ git diff -U0
diff --git a/Dockerfile b/Dockerfile
index cf09a1d..365ed1e 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1 +1 @@
-FROM opensuse:latest
+FROM opensuse/systemd
@@ -47 +47 @@ EXPOSE 3200
-RUN ./run.sh
+# RUN ./run.sh

SAPメディア配置

メディアのダウンロード

最初のSAPからのメールに記載のあったダウンロードページ。作業ディレクトリを作って、そこにある10ファイルをダウンロードしてきます。

  wget を使って、 part01.rarpart10.rar という名前でダウンロードしてきます。

$ mkdir ~/sap_work
$ cd ~/sap_work

# このようなコマンドを10ファイル分実行
$ wget "http://download.store.sap.com/SCN/14493/sap_netweaver_as_abap_751_sp02_ase_dev_edition_part07.rar?_avtstr=xxxxxxxxxxxxxxxxxx&fileExt=.rar" -O part07.rar

メディアの解凍・配置

sap-nw-abap-dockerリポジトリ内にNW751という名前のメディア格納用のディレクトリを掘ります。

$ cd ~/sap-nw-abap-docker/
$ mkdir NW751

作成したNW751というディレクトリにメディアを解凍します。一つ目のrarファイルをunrarで解凍すると全ファイルが解凍されます。

# この10ファイルを解凍します。
$ ls -lh ~/sap_work/
total 14G
-rw-rw-r-- 1 yomon8 yomon8 1.4G Oct 22  2017 part01.rar
-rw-rw-r-- 1 yomon8 yomon8 1.4G Oct 22  2017 part02.rar
-rw-rw-r-- 1 yomon8 yomon8 1.4G Oct 22  2017 part03.rar
-rw-rw-r-- 1 yomon8 yomon8 1.4G Oct 22  2017 part04.rar
-rw-rw-r-- 1 yomon8 yomon8 1.4G Oct 22  2017 part05.rar
-rw-rw-r-- 1 yomon8 yomon8 1.4G Oct 22  2017 part06.rar
-rw-rw-r-- 1 yomon8 yomon8 1.4G Oct 22  2017 part07.rar
-rw-rw-r-- 1 yomon8 yomon8 1.4G Oct 22  2017 part08.rar
-rw-rw-r-- 1 yomon8 yomon8 1.4G Oct 22  2017 part09.rar
-rw-rw-r-- 1 yomon8 yomon8 1.1G Oct 22  2017 part10.rar

# 作業は先程作ったNW751のディレクトリで行います。
$ cd ./NW751

# このコマンドで10ファイルが解凍される
$ unrar x ~/sap_work/part01.rar

Dockerイメージのビルド

これでやっとDockerイメージをビルドする準備が整いました。

$ cd ~/sap-nw-abap-docker;ls -1
Docker.qcow2.zip
Dockerfile
LICENSE
NW751
README.md

Dockerのビルドします。時間かかるので気長に待ちます。

$ docker build -t nwabap .

〜 省略 〜

Instance Service on host 2e760f470df3 started
-------------------------------------------
starting SAP Instance D00
Startup-Log is written to /home/npladm/startsap_D00.log
-------------------------------------------
/usr/sap/NPL/D00/exe/sapcontrol -prot NI_HTTP -nr 00 -function Start
Instance on host 2e760f470df3 started
Installation of NPL successful

Removing intermediate container 2e760f470df3
 ---> 8d26c0d92dd6
Successfully built 8d26c0d92dd6
Successfully tagged nwabap:latest

作業後のDockerのイメージ確認してみます。開発環境でも大きい。Build、Ship、RunのShipは気軽にはできなさそうですね。

$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
nwabap              latest              f54430ada5d8        3 minutes ago       14.6GB
opensuse/systemd    latest              97a81ab30f97        2 hours ago         162MB
opensuse            latest              35057ab4ef08        3 weeks ago         110MB

コンテナ起動とSAPインストール

これでDockerでSAP Netweaver 7.5 AS ABAP のコンテナを起動する準備は整いました。

以下のコマンドで、まずは、コンテナのコンソールに/bin/bashで入ります。ポート番号は適宜指定してください。

$ docker run -d \
    -p 44300:44300 -p 8000:8000 -p 3200:3200 -p 3300:3300 \
    --privileged  -e 'container=docker' -v /sys/fs/cgroup:/sys/fs/cgroup:ro \
    -h sapnwdev --name nwabap751 \
    -it nwabap:latest
$ docker exec -it nwabap751 /bin/bash
sapnwdev:/tmp/NW751 # 

コンテナに入ったカレントのディレクトリ /tmp/NW751 に置いてある run.sh を実行すると、ログが流れ始めてSAPがインストールされます。

sapnwdev:/tmp/NW751 # ./run.sh
〜〜〜〜
〜省略〜
〜〜〜〜
OK
Instance Service on host sapnwdev started
-------------------------------------------
starting SAP Instance ASCS01
Startup-Log is written to /home/npladm/startsap_ASCS01.log
-------------------------------------------
/usr/sap/NPL/ASCS01/exe/sapcontrol -prot NI_HTTP -nr 01 -function Start
Instance on host sapnwdev started
Starting Startup Agent sapstartsrv
OK
Instance Service on host sapnwdev started
-------------------------------------------
starting SAP Instance D00
Startup-Log is written to /home/npladm/startsap_D00.log
-------------------------------------------
/usr/sap/NPL/D00/exe/sapcontrol -prot NI_HTTP -nr 00 -function Start
Instance on host sapnwdev started
Installation of NPL successful

                       
sapnwdev:/tmp/NW751 # 

npladm ユーザにスイッチして、SAPを起動してみます。

sapnwdev:/tmp/NW751 # su - npladm
sapnwdev:npladm 2> startsap ALL

ホスト側でプロセス見てみると、SAPのNPLインスタンスが起動しているのがわかります。

$ ps -ef | grep sapNPL
ubuntu    4420 30298  0 09:19 ?        00:00:10 dw.sapNPL_D00 pf=/usr/sap/NPL/SYS/profile/NPL_D00_sapnwdev
yomon8   16263  4867  0 09:46 pts/2    00:00:00 grep --color=auto sapNPL
ubuntu   25206 25194  0 08:55 ?        00:00:00 ms.sapNPL_ASCS01 pf=/usr/sap/NPL/SYS/profile/NPL_ASCS01_sapnwdev
ubuntu   25207 25194  0 08:55 ?        00:00:10 en.sapNPL_ASCS01 pf=/usr/sap/NPL/SYS/profile/NPL_ASCS01_sapnwdev
ubuntu   30298 30192  0 08:55 ?        00:00:01 dw.sapNPL_D00 pf=/usr/sap/NPL/SYS/profile/NPL_D00_sapnwdev
ubuntu   30299 30192  0 08:55 ?        00:00:00 ig.sapNPL_D00 -mode=profile pf=/usr/sap/NPL/SYS/profile/NPL_D00_sapnwdev
ubuntu   30308 30298  0 08:55 ?        00:00:12 dw.sapNPL_D00 pf=/usr/sap/NPL/SYS/profile/NPL_D00_sapnwdev
ubuntu   30309 30298  0 08:55 ?        00:00:10 dw.sapNPL_D00 pf=/usr/sap/NPL/SYS/profile/NPL_D00_sapnwdev
ubuntu   30310 30298  0 08:55 ?        00:00:07 dw.sapNPL_D00 pf=/usr/sap/NPL/SYS/profile/NPL_D00_sapnwdev
ubuntu   30311 30298  0 08:55 ?        00:00:06 dw.sapNPL_D00 pf=/usr/sap/NPL/SYS/profile/NPL_D00_sapnwdev
ubuntu   30312 30298  0 08:55 ?        00:00:02 dw.sapNPL_D00 pf=/usr/sap/NPL/SYS/profile/NPL_D00_sapnwdev
ubuntu   30313 30298  3 08:55 ?        00:01:58 dw.sapNPL_D00 pf=/usr/sap/NPL/SYS/profile/NPL_D00_sapnwdev
ubuntu   30315 30298  0 08:55 ?        00:00:02 dw.sapNPL_D00 pf=/usr/sap/NPL/SYS/profile/NPL_D00_sapnwdev
ubuntu   30316 30298  0 08:55 ?        00:00:02 dw.sapNPL_D00 pf=/usr/sap/NPL/SYS/profile/NPL_D00_sapnwdev

GCEにSSHトンネルを掘る

SAPに接続するために、この記事を参考にSSHトンネル掘ります。

VM インスタンスへの安全な接続  |  Compute Engine ドキュメント  |  Google Cloud

私のローカルPCはUbuntuなのでbashですが、Windowsでも似たような手順でいけると思います。

PROJECT=myproject01-123456
HOST=sapdev
ZONE=asia-northeast1-c
gcloud compute ssh ${HOST} --project ${PROJECT} --zone ${ZONE} -- \
    -L 8000:localhost:8000 \
    -L 44300:localhost:44300 \
    -L 3200:localhost:3200 \
    -L 3300:localhost:3300

SAP GUIでログオン

SAP GUI for Javaの設定ですが、以下の通り localhost:3200 に接続します。

conn=/H/localhost/S/3200

     

ログオン画面が表示されました。

   

初期のログオン情報はこちら。

項目
Client 000
User SAP*
Password Appl1ance

     

ログオンできた!

インストール直後の環境をCommit

いつもはDockerfileに全て書いてしまうのですが、今回はそうもいかないので、内容をCommitしておきます。

SAP 停止して。

sapnwdev:/tmp/NW751 # su - npladm
sapnwdev:npladm 9> stopsap ALL

Commit!

docker stop nwabap751
docker commit nwabap751 nwabap751:sapinstalled

そしてこのCommitにも凄い時間かかる・・・

REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
nwabap751           sapinstalled        452b8f96dc7a        5 minutes ago       64.7GB
nwabap              latest              4b27a087921f        3 hours ago         14.6GB
opensuse/systemd    latest              97a81ab30f97        5 hours ago         162MB
opensuse            latest              35057ab4ef08        3 weeks ago         110MB

Commitできました。後はどうにでもなりそうなので、ここまでにしておきます。

所感

大変だった点

  • ファイルが大きく一つ一つの処理にも時間がかかる(SAPあるある)
  • Systemdの件は知っていたはずなのに、最後まで見落としていて、手戻り時間考えて辛かった
  • 作業内容からDockerである良さはかなり少ない気がした

良かった点

  • 小さいは正義のDockerで巨大なイメージを扱う大変さを身を持って知ることができた
  • SAP知らなくてもインストールできるかも
  • こういう検証だとGCEへのSSHトンネルはとても便利
  • 単純に面白かったので、リポジトリの作者に感謝

参考

SAP Developper Edition FAQs

SAP AS ABAP 7.51 Developer Edition: FAQs | SAP Blogs

1391070 - Linux UUID solutions

https://launchpad.support.sap.com/#/notes/1391070

Dockerでそのままではsystemdが立ち上がらないの見落としていて、このノートの現象に引っかかった。最後の最後にエラーが出たので辛かった。