LoginSignup
6
2

Power Systems Virtual ServerからICOSにファイルをアップロードする

Last updated at Posted at 2021-06-20

2023/8/16追記

Virtual Private Endpoint(VPE)を使ってPowerVSからICOSへのアクセスが可能になっています。ユーザー自身でproxy serverを構築・運用するより安価で容易と思われますので、こちらもご検討ください。
https://qiita.com/y_tama/items/1cb84b59553aa48fe805

概要

Power Systems Virtual Server(Power VS)からIBM Cloud Object Storage(ICOS)にファイルを転送しました。

ICOSは、高い可用性と安価なディスク単価で、バックアップなど、大容量ファイルを長期に保管する用途に向いています。
Power VSからもICOSを使うユースケースは少なくないと思います。

ICOSにはパブリックエンドポイントもありますが、本番利用では、おそらくプライベートエンドポイントの利用が検討されると思います。
Power VSのネットワークからは、直接はICOSのプライベートエンドポイントに行けない(ルーティングされない)ため、x86側に立てた仮想サーバーをReverse Proxyとして経由してICOSに行く構成としています。

image.png

下記もご参照ください。図の"Customer Premise"が、今回のPower VSに相当します。
https://cloud.ibm.com/docs/direct-link?topic=direct-link-using-ibm-cloud-direct-link-to-connect-to-ibm-cloud-object-storage
image.png

x86とPower VSの間のDirect Link

下記の項番2の手順で構成します。
https://qiita.com/y_tama/items/eb8d6e3d54197a569e25

Reverse Proxyの基盤として、今回はClassicよりネットワークの速いVPC環境の仮想サーバーを選びました。
Direct LinkのVirtual connectionとして、VPCに接続すれば、VPCとPower VSの間でBGPによる経路交換が行われ、疎通します。

image.png

必要に応じ、OSで、相手のセグメントに対し、静的経路を設定します。

AIXに、x86セグメント(10.0.0.0/8)へのルーティング設定
# netstat -rn
Routing tables
Destination        Gateway           Flags   Refs     Use  If   Exp  Groups

Route tree for Protocol Family 2 (Internet):
default            192.168.188.169   UG        5    315732 en0      -      -   
10/8               192.168.150.1     UGS       0   3998501 en1      -      -   
127/8              127.0.0.1         U         4     38647 lo0      -      -   
192.168.150.0      192.168.150.195   UHSb      0         0 en1      -      -   =>
192.168.150/24     192.168.150.195   U         2         2 en1      -      -   
192.168.150.195    127.0.0.1         UGHS      0         0 lo0      -      -   
VPCからPowerVS(192.168.150.0/24)への通信はD/G設定に包含されているので、変更不要
# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         10.244.64.1     0.0.0.0         UG    0      0        0 eth0
0.0.0.0         10.244.64.1     0.0.0.0         UG    100    0        0 eth0
10.244.64.0     0.0.0.0         255.255.255.0   U     100    0        0 eth0
#

ICOS準備

今回は、jp-tok, Smart Tierを選びました。HMACを有効にしてWriterの権限でcredentialを作ります。
後ほど、AIX上のs3cmdの構成時にaccess_key_idとsecret_access_keyを使います。

image.png

bucket20210619aという名前でbucketを作りました。
image.png

x86仮想サーバーでReverse Proxy(nginx)を動かす

Power VSがあるのはTOK04なので、VPCとして一番近いTokyo 2(jp-tok-2)に仮想サーバーを立てます。
https://cloud.ibm.com/docs/power-iaas?topic=power-iaas-creating-power-virtual-server#creating-service
image.png

2コア4GBのVSIを使いました。
image.png

VPC VSI@jp-tok-2からPower VS@TOK04へのpingは、0.5ms未満でした。ちなみにTOK02やTOK05のVSIからPower VSまでは、1.5msくらいでした。(※保証値ではありません)

VSI@jp-tok-2からPowerVS@TOK04へのping
[root@tamavsi04tok ]# ping 192.168.150.195
PING 192.168.150.195 (192.168.150.195) 56(84) bytes of data.
64 bytes from 192.168.150.195: icmp_seq=1 ttl=249 time=0.423 ms
64 bytes from 192.168.150.195: icmp_seq=2 ttl=249 time=0.371 ms
64 bytes from 192.168.150.195: icmp_seq=3 ttl=249 time=0.438 ms
64 bytes from 192.168.150.195: icmp_seq=4 ttl=249 time=0.401 ms

ICOSへの通信はhttps(port 443)を使いますので、VSIのSecurity Groupsの設定で、PowerのセグメントからVSIへのport 443のインバウンドを許可します。

image.png

/etc/nginx/nginx.confの http { } の中に下記を追加します。
proxy_passは、下記URLに記載のある、ICOSのDirect Endpointを指定します。
https://cloud.ibm.com/docs/cloud-object-storage?topic=cloud-object-storage-endpoints

nginx.confに下記を追加
    server {
        client_max_body_size 100M;
        listen       443 ssl http2;
        listen       [::]:443 ssl http2;
        server_name  10.244.64.6;
        root         /usr/share/nginx/html;

        ssl_certificate "/etc/ssl/certs/NGINX-selfsigned.crt";
        ssl_certificate_key "/etc/ssl/NGINX-selfsigned.key";
        ssl_session_cache shared:SSL:1m;
        ssl_session_timeout  10m;
        ssl_ciphers HIGH:!aNULL:!MD5;
        ssl_prefer_server_ciphers on;

        location / {
                proxy_set_header Host $server_name;
                proxy_pass https://s3.direct.jp-tok.cloud-object-storage.appdomain.cloud ;
        }

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        error_page 404 /404.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    }

自己署名証明書を作成します。パラメータはデフォルトで進めましたが、必要に応じて変更ください。

# openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/NGINX-selfsigned.key -out /etc/ssl/certs/NGINX-selfsigned.crt
Generating a RSA private key
......................................................................+++++
...........+++++
writing new private key to '/etc/ssl/NGINX-selfsigned.key'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [XX]:jp
State or Province Name (full name) []:
Locality Name (eg, city) [Default City]:
Organization Name (eg, company) [Default Company Ltd]:
Organizational Unit Name (eg, section) []:
Common Name (eg, your name or your server's hostname) []:
Email Address []:
# 
# service nginx start

AIXにs3cmdを導入

今回はs3cmdを使いましたが、AIXからICOSを操作する方法は他にもあります。
参考:https://qiita.com/khayama/items/5bd9101c32f2d3381291

AIX Toolbox for Linux Applicationsをインストール

# curl -G -o yum.sh http://ftp.software.ibm.com/aix/freeSoftware/aixtoolbox/ezinstall/ppc/yum.sh
# ./yum.sh
# yum update

RPM Package Manager (RPM) をインストール

# curl -G -o rpm.rte ftp://public.dhe.ibm.com/aix/freeSoftware/aixtoolbox/INSTALLP/ppc/rpm.rte
# installp -qaXgd rpm.rte rpm.rte

s3cmd + その前提モジュールを導入

# yum install python-dateutil
# curl -G -o file-libs-5.32-1.aix5.1.ppc.rpm http://www.oss4aix.org/download/RPMS/file/file-libs-5.32-1.aix5.1.ppc.rpm  
# curl -G -o file-5.32-1.aix5.1.ppc.rpm  http://www.oss4aix.org/download/RPMS/file/file-5.32-1.aix5.1.ppc.rpm 
# curl -G -o python-magic-5.32-1.aix5.1.ppc.rpm  http://www.oss4aix.org/download/RPMS/file/python-magic-5.32-1.aix5.1.ppc.rpm
# curl -G -o s3cmd-1.6.1-1.aix5.1.noarch.rpm  http://www.oss4aix.org/download/RPMS/s3cmd/s3cmd-1.6.1-1.aix5.1.noarch.rpm
# rpm -i file-libs-5.32-1.aix5.1.ppc.rpm 
# rpm -i file-5.32-1.aix5.1.ppc.rpm  
# rpm -i python-magic-5.32-1.aix5.1.ppc.rpm
# rpm -i s3cmd-1.6.1-1.aix5.1.noarch.rpm
# export PATH=/opt/freeware/bin:$PATH 

s3cmd設定

ホームディレクトリの下に .s3cfg ファイルを作成します。
伏字にしている箇所に、ICOSのaccess_key_idとsecret_access_keyの値を設定します。

# cat .s3cfg
access_key = 65xxxxxxxxxxxxxxxxxxxxxxxxx0
check_ssl_certificate = False
check_ssl_hostname = False
encrypt = False
gpg_command = None
host_base = 10.244.64.6
secret_key = 12xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx84
use_https = True
host_bucket = %(bucket).10.244.64.6
# 

ここまでの設定で、AIXからx86のnginx経由でICOSに疎通するはずです。

# s3cmd ls
2021-06-19 00:26  s3://bucket20210619a
# 

アップロードの動作確認

1GBのサイズのtempfileという名前のファイルを用意してアップロードします。15MBごとに分割されて送られました。

# ls -la /data/tempfile
-rw-r--r--    1 root     system   1073741824 Jun 19 02:03 /data/tempfile
# s3cmd put /data/tempfile s3://bucket20210619a/tempfile
upload: '/data/tempfile' -> 's3://bucket20210619a/tempfile'  [part 1 of 69, 15MB] [1 of 1]
 15728640 of 15728640   100% in    0s    25.88 MB/s  done
upload: '/data/tempfile' -> 's3://bucket20210619a/tempfile'  [part 2 of 69, 15MB] [1 of 1]
 15728640 of 15728640   100% in    0s    26.25 MB/s  done
upload: '/data/tempfile' -> 's3://bucket20210619a/tempfile'  [part 3 of 69, 15MB] [1 of 1]
 15728640 of 15728640   100% in    0s    29.45 MB/s  done

・
・
・

upload: '/data/tempfile' -> 's3://bucket20210619a/tempfile'  [part 67 of 69, 15MB] [1 of 1]
 15728640 of 15728640   100% in    0s    26.50 MB/s  done
upload: '/data/tempfile' -> 's3://bucket20210619a/tempfile'  [part 68 of 69, 15MB] [1 of 1]
 15728640 of 15728640   100% in    0s    26.32 MB/s  done
upload: '/data/tempfile' -> 's3://bucket20210619a/tempfile'  [part 69 of 69, 4MB] [1 of 1]
 4194304 of 4194304   100% in    0s    15.82 MB/s  done
# 

ICOS上では元の1GBのファイルとしてアップされています。

image.png

tempfileをコピーしてアップロード対象ファイルを複数用意し、複数のs3cmdコマンドを並行して発行すると、1.6 Gbpsくらいの転送速度が出ました。下記はVSI上のdstatの出力ですが、Reverse Proxyとして、recvもsendも200MB/s以上出ている事が分かります。(※保証値ではありません)

[root@tamavsi04tok ~]# dstat
You did not select any stats, using -cdngy by default.
----total-cpu-usage---- -dsk/total- -net/total- ---paging-- ---system--
usr sys idl wai hiq siq| read  writ| recv  send|  in   out | int   csw 
  0   0 100   0   0   0|  26k 3392B|   0     0 |   0     0 |1024   718 
  0   0 100   0   0   0|   0     0 | 132B  158B|   0     0 |  36    32 
  0   0 100   0   0   0|   0     0 |  66B  830B|   0     0 |   8    12 
  0   0 100   0   0   0|   0     0 |  66B  350B|   0     0 |  17    29 
  0   0 100   0   0   0|   0     0 |  66B  350B|   0     0 |  28    53 
  0   0 100   0   0   0|   0     0 |  66B  350B|   0     0 |  45    79 
  0   0 100   0   0   0|   0     0 |  66B  350B|   0     0 |  29    53 
  0   0 100   0   0   0|   0     0 |  66B  350B|   0     0 |  27    51 
  0   0 100   0   0   0|   0     0 |  66B  350B|   0     0 |  29    51 
  0   0 100   0   0   0|   0  8192B|  66B  350B|   0     0 |  39    76 
----total-cpu-usage---- -dsk/total- -net/total- ---paging-- ---system--
usr sys idl wai hiq siq| read  writ| recv  send|  in   out | int   csw 
  0   0 100   0   0   0|   0     0 |  66B  350B|   0     0 |  32    57 
  0   0 100   0   0   0|   0     0 |7655B 4898B|   0     0 | 126   118 
  1   1  98   0   0   0|   0     0 |  66M   31M|   0     0 |8827  7679 
  2   4  94   0   0   0|   0     0 | 153M  159M|   0     0 |  26k   16k
  2   6  91   0   0   1|   0     0 | 204M  168M|   0     0 |  34k   24k
  3   6  91   0   0   1|   0     0 | 182M  217M|   0     0 |  25k   12k
  3   6  90   0   0   1|   0     0 | 235M  205M|   0     0 |  35k   17k
  2   6  91   0   0   0|   0     0 | 209M  216M|   0     0 |  30k   17k
  2   5  93   0   0   0|   0     0 | 171M  200M|   0     0 |  28k   14k
  2   5  92   0   0   1|   0     0 | 208M  152M|   0     0 |  27k   15k
  2   6  92   0   0   0|   0     0 | 211M  197M|   0     0 |  30k   16k
  3   6  91   0   0   1|   0     0 | 216M  222M|   0     0 |  32k   19k
  3   6  90   0   0   1|   0     0 | 227M  217M|   0     0 |  35k   17k
  3   6  91   0   0   1|   0     0 | 199M  211M|   0     0 |  32k   18k
  2   6  91   0   0   1|   0  8192B| 221M  211M|   0     0 |  33k   19k
  3   6  91   0   0   1|   0     0 | 221M  203M|   0     0 |  33k   20k
  2   5  91   0   0   1|   0     0 | 201M  216M|   0     0 |  31k   19k
  2   6  91   0   0   1|   0     0 | 212M  209M|   0     0 |  34k   21k
  3   6  90   0   0   2|   0    97k| 225M  206M|   0     0 |  32k   20k
  3   6  91   0   0   1|   0     0 | 221M  214M|   0     0 |  34k   22k
  3   5  91   0   0   1|   0     0 | 210M  212M|   0     0 |  32k   20k
  2   5  92   0   0   1|   0     0 | 199M  200M|   0     0 |  32k   20k
  2   5  92   0   0   1|   0     0 | 216M  185M|   0     0 |  34k   20k
  3   6  89   0   0   1|   0     0 | 222M  239M|   0     0 |  30k   17k
  2   5  92   0   0   1|   0     0 | 203M  206M|   0     0 |  34k   19k
  2   6  91   0   0   1|   0     0 | 217M  214M|   0     0 |  33k   18k
  3   6  91   0   0   1|   0     0 | 222M  201M|   0     0 |  35k   22k
  3   6  91   0   0   1|   0     0 | 203M  235M|   0     0 |  34k   20k
  2   6  91   0   0   1|   0     0 | 218M  198M|   0     0 |  34k   22k
  2   5  91   0   0   1|   0     0 | 221M  196M|   0     0 |  34k   23k
  2   6  90   0   0   2|   0     0 | 217M  214M|   0     0 |  31k   16k
  3   5  90   0   0   2|   0     0 | 216M  210M|   0     0 |  29k   15k
  2   5  92   0   0   1|   0     0 | 194M  197M|   0     0 |  32k   19k
  3   6  89   0   0   2|   0     0 | 220M  245M|   0     0 |  31k   16k
  3   5  90   0   0   2|   0   212k| 214M  180M|   0     0 |  31k   20k
  3   5  91   0   0   2|   0     0 | 203M  224M|   0     0 |  31k   19k
  2   5  90   0   0   2|   0     0 | 221M  198M|   0     0 |  31k   19k
  3   5  90   0   0   2|   0     0 | 226M  200M|   0     0 |  33k   21k
----total-cpu-usage---- -dsk/total- -net/total- ---paging-- ---system--
usr sys idl wai hiq siq| read  writ| recv  send|  in   out | int   csw 
  3   5  90   0   0   2|   0     0 | 211M  226M|   0     0 |  30k   15k
  3   6  89   0   0   2|   0     0 | 215M  211M|   0     0 |  31k   19k
  3   5  90   0   0   2|   0     0 | 215M  201M|   0     0 |  32k   19k
  3   6  89   0   0   2|   0     0 | 213M  227M|   0     0 |  32k   16k
  3   6  90   0   0   2|   0     0 | 207M  219M|   0     0 |  31k   17k
  3   5  91   0   0   2|   0     0 | 207M  183M|   0     0 |  29k   17k
  3   6  89   0   0   2|   0     0 | 237M  213M|   0     0 |  33k   20k
  3   5  90   0   0   2|   0     0 | 212M  215M|   0     0 |  30k   18k
  2   5  91   0   0   2|   0     0 | 191M  207M|   0     0 |  28k   18k
  3   6  90   0   0   2|   0     0 | 226M  200M|   0     0 |  32k   21k
  3   6  90   0   0   2|   0    42k| 217M  211M|   0     0 |  31k   17k
  3   6  90   0   0   2|   0  3072B| 206M  223M|   0     0 |  30k   18k
  3   6  90   0   0   2|   0     0 | 222M  204M|   0     0 |  32k   20k
  3   5  91   0   0   2|   0     0 | 206M  195M|   0     0 |  28k   14k
  1   3  95   0   0   1|   0     0 | 100M  151M|   0     0 |  16k 7742 
  0   1  99   0   0   0|   0     0 |  31M   33M|   0     0 |3876  2784 
  0   0 100   0   0   0|   0     0 |4229k 4148k|   0     0 | 660   468 
  0   0 100   0   0   0|   0     0 |  66B   66B|   0     0 |  44    77 
  0   0 100   0   0   0|   0     0 |  66B  350B|   0     0 |  39    63 
  0   0 100   0   0   0|   0     0 |  66B  350B|   0     0 |  27    51 
  0   0 100   0   0   0|   0     0 |  66B  350B|   0     0 |  28    55 
  0   0 100   0   0   0|   0     0 |  66B  350B|   0     0 |  37    69 

以上です。

6
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
2