LoginSignup
3
0

More than 1 year has passed since last update.

IBM Cloud: Public Gateway/Floating IP利用時のtimeout/KeepAlive構成について

Last updated at Posted at 2022-12-21

はじめに

前回、IBM Cloud: Cloud Service Endpoint(CSE)利用時のtimeout/KeepAlive構成についてという記事を書いたが、じゃあFloating IPやPublic Gatewayを利用している時はどうなのかについても確認しておきたかったため、(良いかどうかはともかく)DBサーバーからのKeepAliveパケットが全く飛んでこなかったDb2 warehouse on Cloudを利用して検証してみた。

結論

idle connection timeout 検証記事
Cloud Service Endpoint(CSE) 発生する(4分)。利用するサービス、使い方によってはKeepAlive構成が必要。 前回記事
Public Gateway 発生する(4分) 。利用するサービス、使い方によってはKeepAlive構成が必要。 本記事
Floating IP 発生しない(少なくとも20分放置しても切れなかった) 本記事

参考記事:Troubleshooting Outgoing Connection Issues with IBM VPC Public and Service Gateways

1. Db2 warehouse on CloudにPublic Gateway経由で接続した場合

[root@syasuda-pgw-tok1-vpc1 dsdriver]# export LANG=C
[root@syasuda-pgw-tok1-vpc1 dsdriver]# source db2profile
[root@syasuda-pgw-tok1-vpc1 dsdriver]# clpplus -nw bluadmin/xxxxxxxxxxxxxxxxxxxxxxxxxxxxx@dashdb2
CLPPlus: Version 1.6
Copyright (c) 2009, 2011, IBM CORPORATION.  All rights reserved.


Database Connection Information :
---------------------------------
Hostname = xxxx-xxxxxxx.ap-north.db2w.cloud.ibm.com
Database server = DB2/LINUXX8664  SQL110570
SQL authorization ID = bluadmin
Local database alias = DASHDB2
Port = 50001

ssコマンドにて、-oオプションを付けるとtimer情報(keepaliveの情報)が確認できる。OS設定値では、net.ipv4.tcp_keepalive_time=7200(120分)なので、クライアントがTCP コネクション開始から KeepAliveの送信を開始するまで、120分もかかる。

[root@syasuda-pgw-tok1-vpc1 ~]# ss -no 'dport == :50001'
Netid  State      Recv-Q Send-Q                                                                       Local Address:Port                                                                                      Peer Address:Port
tcp    ESTAB      0      0                                                                       [::ffff:10.0.0.44]:47848                                                                          [::ffff:128.168.xx.xxx]:50001               timer:(keepalive,120min,0)

DBサーバー側からもCSE利用時の時と同様に、Keepalive パケットは届かないし、クライアントからも(最初の120分は)KeepAliveパケットを送信することはない。

[root@syasuda-pgw-tok1-vpc1 ~]# tcpdump -i any port 50001 -nn
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on any, link-type LINUX_SLL (Linux cooked), capture size 262144 bytes
(何もなし)

この状態で5分放置して、再度SQLを実行してみると、エラーになった。よって、KeepAliveパケットのやりとりがないと、CSEのように4分ほどでコネクションを切断されてしまう。

SQL> select count(*) from sysscat.tables;
ERROR near line 1:
[jcc][t4][2030][11211][4.27.25] A communication error occurred during operations
on the connection's underlying socket, socket input stream,
or socket output stream.  Error location: Reply.fill() - socketInputStream.read
(-1).  Message: Connection reset. ERRORCODE=-4499, SQLSTATE=08001
SQL> select count(*) from sysscat.tables;
DB250201E: No database connection exists, but a database connection is required.

2. Db2 warehouse on CloudにFloating IP経由で接続した場合

[root@new-syasuda-tok1-vpc1 dsdriver]# export LANG=C
[root@new-syasuda-tok1-vpc1 dsdriver]# source db2profile
[root@new-syasuda-tok1-vpc1 dsdriver]# clpplus -nw bluadmin/xxxxxxxxxxxxxxxxxxxxxxxxxxxxx@dashdb2
CLPPlus: Version 1.6
Copyright (c) 2009, 2011, IBM CORPORATION.  All rights reserved.


Database Connection Information :
---------------------------------
Hostname = xxxx-xxxxxxx.ap-north.db2w.cloud.ibm.com
Database server = DB2/LINUXX8664  SQL110570
SQL authorization ID = bluadmin
Local database alias = DASHDB2
Port = 50001

ssコマンドにて、-oオプションを付けるとtimer情報(keepaliveの情報)が確認できる。OS設定値では、net.ipv4.tcp_keepalive_time=7200(120分)なので、クライアントがTCP コネクション開始から KeepAliveの送信を開始するまで、120分もかかる。

[root@new-syasuda-tok1-vpc1 ~]# ss -no 'dport == :50001'
Netid  State      Recv-Q Send-Q                                                                       Local Address:Port                                                                                      Peer Address:Port
tcp    ESTAB      0      0                                                                        [::ffff:10.0.0.4]:40164                                                                          [::ffff:128.168.xx.xxx]:50001               timer:(keepalive,120min,0)

DBサーバー側からもCSE利用時の時と同様に、Keepalive パケットは届かないし、クライアントからも(最初の120分は)KeepAliveパケットを送信することはない。

[root@new-syasuda-tok1-vpc1 ~]# tcpdump -i any port 50001 -nn
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on any, link-type LINUX_SLL (Linux cooked), capture size 262144 bytes
(何もなし)

この状態で20分放置して、再度SQLを実行してみると、ちゃんと結果は返ってきた。よって、(KeepAliveパケットのやり取りがなくても)、CSEのように4分ほどでコネクションを切断されるということはなかった。

SQL> select count(*) from syscat.tables;

                                1
---------------------------------
                             1089
3
0
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
3
0