2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Db2 Developer Community Edition で、タイムゾーンを変更する

Posted at

MacBookに、Db2 Developer Community Editionを導入しました。

導入は
Db2 Developer Community Editionを "数クリック" で 導入してみた (1)
Db2 Developer Community Editionを "数クリック" で 導入してみた (2)
を参照ください。

Db2 Developer Community Editionは Dockerイメージで提供され、デフォルトのタイムゾーンは UTC です。 日本のタイムゾーンにしたほうが何かと便利なので、MacBookでタイムゾーンを変更してみた一例です。

ターミナルから Rootで Dockerコンテナーにはいります

docker ps
docker exec -it <container id> bash
※ container idは、db2server の コンテナidです

コマンド実行例 $ **docker ps** CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 70cfbb5563c9 dsm:v2.1.4_1 "/opt/start_dsm.sh" 2 hours ago Up 2 hours 0.0.0.0:11080-11082->11080-11082/tcp dsm efbc666a9f5d db2server:v11.1.2fp2_1 "/var/db2_setup/li..." 2 hours ago Up 2 hours 22/tcp, 0.0.0.0:50000->50000/tcp db2server $ **docker exec -it efbc666a9f5d bash**

タイムゾーンのパッケージを導入します

apt-get install tzdata

コマンド実行例 root@db2server_0043cd:/# **apt-get install tzdata** Reading package lists... Done Building dependency tree Reading state information... Done The following NEW packages will be installed: tzdata *・・・・途中省略・・・・* Current default time zone: 'Etc/UTC' *<===現在のタイムゾーン設定はUTC* Local time is now: Fri Jun 30 14:29:36 UTC 2017. Universal Time is now: Fri Jun 30 14:29:36 UTC 2017. Run 'dpkg-reconfigure tzdata' if you wish to change it. root@db2server_0043cd:/# date Fri Jun 30 14:30:10 UTC 2017

タイムゾーンを設定します

dpkg-reconfigure tzdata

コマンド実行例 root@db2server_0043cd:/# **dpkg-reconfigure tzdata** debconf: unable to initialize frontend: Dialog debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 76.) debconf: falling back to frontend: Readlin Configuring tzdata Please select the geographic area in which you live. Subsequent configuration questions will narrow this down by presenting a list of cities, representing the time zones in which they are located. 1. Africa 3. Antarctica 5. Arctic 7. Atlantic 9. Indian 11. SystemV 13. Etc 2. America 4. Australia 6. Asia 8. Europe 10. Pacific 12. US Geographic area: **6** *<=== 6.Asiaを選択* Please select the city or region corresponding to your time zone. 1. Aden 16. Brunei 31. Hong_Kong 46. Kuala_Lumpur 61. Pyongyang 76. Tel_Aviv 2. Almaty 17. Chita 32. Hovd 47. Kuching 62. Qatar 77. Thimphu 3. Amman 18. Choibalsan 33. Irkutsk 48. Kuwait 63. Qyzylorda 78. Tokyo 4. Anadyr 19. Chongqing 34. Istanbul 49. Macau 64. Rangoon 79. Tomsk *・・・・途中省略・・・・* 15. Bishkek 30. Ho_Chi_Minh 45. Krasnoyarsk 60. Pontianak 75. Tehran Time zone: **78** *<===78.Tokyoを選択* Current default time zone: 'Asia/Tokyo' *<===タイムゾーン設定は日本時間になった* Local time is now: Fri Jun 30 23:30:46 JST 2017. Universal Time is now: Fri Jun 30 14:30:46 UTC 2017.

Db2への反映

データベースへ接続しなおせば反映されるようです。

コマンド実行例 db2inst1@db2server_0043cd:~$ **db2 values CURRENT_TIMESTAMP** 1 \------------------------- 2017-06-30-14.30.52.320074 *<==タイムゾーンはまだ変更されていない* 1 record(s) selected. db2inst1@db2server_0043cd:~$ **db2 terminate** *<==データベースに再接続* DB20000I The TERMINATE command completed successfully. db2inst1@db2server_0043cd:~$ **db2 connect to sample** Database Connection Information Database server = DB2/LINUXX8664 11.1.2.2 SQL authorization ID = DB2INST1 Local database alias = SAMPLE db2inst1@db2server_0043cd:~$ **db2 values CURRENT_TIMESTAMP** 1 \-------------------------- 2017-06-30-23.32.03.069300 *<==日本時間になった* 1 record(s) selected.

以上で日本時間になり、気分的にも楽になりました!

2
1
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
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?