LoginSignup
4
0

More than 5 years have passed since last update.

Db2 Developer Community Edition をローカルタイムゾーンで使う

Last updated at Posted at 2017-07-03

少なくとも私の周りでは話題の?!Db2 Developer Community Edition(長い!)

それって何もの?とかどうやってインストールするの?は以下を参考にしてください。

参考
* [DB2DBA] 無料のDB2 Developer Community Editionで個人用検証環境を作ろう
* Db2 Developer Community Editionを "数クリック" で 導入してみた

さっそく遊んでみるとかなりいい感じのGUIが提供されていてこれまでのIBM製品とは違う雰囲気を感じます笑

Kobito.Uwza0n.png

良く見るとデータベースのタイムゾーンはUTCでした。

select current timestamp from sysibm.sysdummy1                         
--------------------------
2017-06-29-04.44.36.023144
/$ date (ホストマシン側)
Thu Jun 29 04:44:36 UTC 2017

日本人なのでローカルタイムゾーンが使いたい。ホストマシンのタイムゾーンとsyncして欲しい!

手順:
* Db2のdockerイメージにtzdataを導入
* 日本のタイムゾーンを選択
* Docker image再起動

やってみた!

1) Dockerイメージを確認します。

Db2は"db2server"
"dsm"はいい感じのGUIを提供しているData Server Managerのイメージです。

$ docker ps
CONTAINER ID        IMAGE                    COMMAND                  CREATED             STATUS              PORTS                                  NAMES
6eafb4a0403d        dsm:v2.1.4_1             "/opt/start_dsm.sh"      25 minutes ago      Up 25 minutes       0.0.0.0:11080-11082->11080-11082/tcp   dsm
6d94f6bc77ce        db2server:v11.1.2fp2_1   "/var/db2_setup/li..."   25 minutes ago      Up 25 minutes       22/tcp, 0.0.0.0:50000->50000/tcp       db2server
2) Db2のほうのDockerイメージ ( 6d94f6bc77ce ) に接続
$ docker exec -ti 6d94f6bc77ce bash
3) tzdata を導入
root@db2server_059ce7:/# 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'
Local time is now:      Mon Jul  3 02:52:37 UTC 2017.
Universal Time is now:  Mon Jul  3 02:52:37 UTC 2017.
Run 'dpkg-reconfigure tzdata' if you wish to change it.
4)tzdataを実行
root@db2server_059ce7:/# 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: Readline
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      4. Australia  7. Atlantic  10. Pacific  13. Etc
  2. America     5. Arctic     8. Europe    11. SystemV
  3. Antarctica  6. Asia       9. Indian    12. US
Geographic area: 6

Please select the city or region corresponding to your time zone.

  1. Aden         19. Chongqing    37. Jerusalem     55. Novokuznetsk   73. Tashkent
  2. Almaty       20. Colombo      38. Kabul         56. Novosibirsk    74. Tbilisi
  3. Amman        21. Damascus     39. Kamchatka     57. Omsk           75. Tehran
  4. Anadyr       22. Dhaka        40. Karachi       58. Oral           76. Tel_Aviv
  5. Aqtau        23. Dili         41. Kashgar       59. Phnom_Penh     77. Thimphu
  6. Aqtobe       24. Dubai        42. Kathmandu     60. Pontianak      78. Tokyo

  中略

  18. Choibalsan  36. Jayapura     54. Nicosia       72. Taipei
Time zone: 78


Current default time zone: 'Asia/Tokyo'
Local time is now:      Mon Jul  3 11:54:23 JST 2017.
Universal Time is now:  Mon Jul  3 02:54:23 UTC 2017.

設定完了!

5) Docker image の再起動

Db2とGUIを提供しているDSMの2つのイメージを再起動

$ docker restart 6d94f6bc77ce
$ docker restart 6eafb4a0403d

データベースとローカルがsyncできました!
Kobito.8wKHD2.png

4
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
4
0