タイム・ゾーンの管理

コンソールおよびAPIの「タイム・ゾーン」フィールドでは、UTC (デフォルト)以外のタイム・ゾーンを使用してDB Systemリソースを起動できます。

データベース・システムの作成時に指定したタイム・ゾーンは、ホストおよびOracle Grid Infrastructure (システムにGrid Infrastructureがある場合)に適用され、データベース・ログ・ファイルのタイム・ゾーンを制御します。データベース自体のタイム・ゾーンは影響を受けません。ただし、データベースのタイム・ゾーンはtimestampデータ型にのみ影響します。データベース・タイムゾーンは手動で変更できますが、データベース間でデータを転送するときにデータ変換を回避し、パフォーマンスを向上させるために、UTC (デフォルト)のままにすることをお薦めします。この構成は、特に、分散データベース、レプリケーションおよびインポートの操作で重要です。

UTCのタイム・ゾーンを使用することをお薦めしますが、データベース・クライアントとアプリケーション・ホストに共通のタイム・ゾーンを設定すると、データベース管理者の管理およびトラブルシューティングを簡素化できます。

ノート:

タイム・ゾーンは、主に表示目的またはユーザー入力の処理に使用されます。タイム・ゾーンを変更しても、システム・クロックの時間は変更されません。

タイム・ゾーンのオプション

コンソールを使用しているかAPIを使用しているかに関係なく、選択可能なタイム・ゾーン・オプションは指定のリージョン・フォーマット(例: America/Los_Angeles)で表示されます。コンソールでは、UTC、ブラウザで検出されたタイム・ゾーン(ブラウザでタイム・ゾーン検出がサポートされている場合)、または別のタイム・ゾーンを選択できます。

別のタイム・ゾーン(「別のタイム・ゾーンの選択」オプション)を指定するには、最初に「リージョンまたは国」フィールドで値を選択して、「タイム・ゾーン」フィールドのリストで、選択可能なタイム・ゾーンのリストを絞り込みます。「America/Los_Angeles」の例では、Americaがリージョン、Los_Angelesがタイム・ゾーンです。この2つのフィールドに表示されるオプションは、Java.util.TimeZoneクラスとLinuxオペレーティング・システムの両方でサポートされているタイム・ゾーンとほぼ相関しています。探しているタイム・ゾーンが表示されない場合は、「リージョンまたは国」フィールドで「その他」を選択してみてください。

ヒント :

APIを使用している場合、サポートされているタイム・ゾーンのリストを表示するには、コンソールでタイム・ゾーン・オプションを調べることができます。DBシステム・シェイプを選択した後に拡張オプションを表示すると、「DBシステムの作成」ページにこれらのオプションが表示されます。

現在のタイム・ゾーンの表示

タイム・ゾーン情報を表示するには、次のステップを実行します。

  1. グリッド・ユーザーとしてホストにログオンします。

    次に例を示します:
    [opc@rc ~]$ sudo su - grid
  2. 次のコマンドを使用して、タイム・ゾーンを表示します。
    timedatectl
    次に例を示します:
    [grid@rc ~]$ timedatectl 
            Local time: Thu 2023-03-16 08:00:25 UTC 
        Universal time: Thu 2023-03-16 08:00:25 UTC 
              RTC time: Thu 2023-03-16 08:00:21 
             Time zone: UTC (UTC, +0000) 
           NTP enabled: yes 
      NTP synchronized: no 
       RTC in local TZ: no 
            DST active: n/a

    システムは現在UTCタイム・ゾーンであることに注意してください。

  3. データベースにログオンします。

    次に例を示します:
    [grid@rc ~]$ sqlplus / as sysdba 
    
    SQL*Plus: Release 21.0.0.0.0 - Production on Thu Mar 16 08:00:33 2023 
    Version 21.9.0.0.0 
    
    Copyright (c) 1982, 2022, Oracle.  All rights reserved. 
    
    Connected to:
    Oracle Database 21c Enterprise Edition Release 21.0.0.0.0 -Production 
    Version 21.9.0.0.0
  4. 次のコマンドを使用して、現在のデータベース時間を表示できます。
    sysdate
    次に例を示します:
    SQL> select to_char(sysdate,'DD-MON-YYYY HH24:MI:SS') from dual; 
    
    TO_CHAR(SYSDATE,'DD-
    --------------------
    16-MAR-2023 08:00:40
  5. 終了します。

DBシステムのタイム・ゾーンの変更

次のステップを実行して、DBシステムのタイム・ゾーンを設定します。

  1. rootユーザーとしてホストにログオンします。

    次に例を示します:
    [opc@rc ~]$ sudo su -
  2. 次のコマンドを使用して、設定する正しいタイム・ゾーン(TZ)値を特定します。たとえば、米国東部タイム・ゾーン(EST/EDT)の正しいTZ値を識別する場合は、tzselectコマンドを使用し、Americas/United States/Easternを選択できます。
    tzselect
    次に例を示します:
    [root@rc ~]# tzselect 
    Please identify a location so that time zone rules can be set correctly. 
    Please select a continent or ocean. 
     1) Africa 
     2) Americas 
     3) Antarctica 
     4) Arctic Ocean 
     5) Asia 
     6) Atlantic Ocean 
     7) Australia 
     8) Europe 
     9) Indian Ocean 
    10) Pacific Ocean 
    11) none - I want to specify the time zone using the Posix TZ format. 
    #? 2 
    Please select a country. 
     1) Anguilla              19) Dominican Republic    37) Peru 
     2) Antigua & Barbuda     20) Ecuador               38) Puerto Rico 
     3) Argentina             21) El Salvador           39) St Barthelemy 
     4) Aruba                 22) French Guiana         40) St Kitts & Nevis 
     5) Bahamas               23) Greenland             41) St Lucia 
     6) Barbados              24) Grenada               42) St Maarten (Dutch) 
     7) Belize                25) Guadeloupe            43) St Martin (French) 
     8) Bolivia               26) Guatemala             44) St Pierre & Miquelon 
     9) Brazil                27) Guyana                45) St Vincent 
    10) Canada                28) Haiti                 46) Suriname 
    11) Caribbean NL          29) Honduras              47) Trinidad & Tobago 
    12) Cayman Islands        30) Jamaica               48) Turks & Caicos Is 
    13) Chile                 31) Martinique            49) United States 
    14) Colombia              32) Mexico                50) Uruguay 
    15) Costa Rica            33) Montserrat            51) Venezuela 
    16) Cuba                  34) Nicaragua             52) Virgin Islands (UK) 
    17) Curaçao               35) Panama                53) Virgin Islands (US) 
    18) Dominica              36) Paraguay 
    #? 49 
    Please select one of the following time zone regions.
     1) Eastern (most areas)              16) Central - ND (Morton rural) 
     2) Eastern - MI (most areas)         17) Central - ND (Mercer) 
     3) Eastern - KY (Louisville area)    18) Mountain (most areas) 
     4) Eastern - KY (Wayne)              19) Mountain - ID (south); OR (east) 
     5) Eastern - IN (most areas)         20) MST - Arizona (except Navajo) 
     6) Eastern - IN (Da, Du, K, Mn)      21) Pacific 
     7) Eastern - IN (Pulaski)            22) Alaska (most areas) 
     8) Eastern - IN (Crawford)           23) Alaska - Juneau area 
     9) Eastern - IN (Pike)               24) Alaska - Sitka area 
    10) Eastern - IN (Switzerland)        25) Alaska - Annette Island 
    11) Central (most areas)              26) Alaska - Yakutat 
    12) Central - IN (Perry)              27) Alaska (west) 
    13) Central - IN (Starke)             28) Aleutian Islands 
    14) Central - MI (Wisconsin border)   29) Hawaii 
    15) Central - ND (Oliver) 
    #? 1 
    The following information has been given:
            United States 
            Eastern (most areas) 
    Therefore TZ='America/New_York' will be used. 
        Local time is now:    Thu Mar 16 04:01:39 EDT 2023. 
    Universal Time is now:    Thu Mar 16 08:01:39 UTC 2023. 
    Is the above information OK? 
    1) Yes 
    2) No 
    #? 1 
    You can make this change permanent for yourself by appending the line 
            TZ='America/New_York'; export TZ 
    to the file '.profile' in your home directory; then log out and log in again. 
    Here is that TZ value again, this time on standard output so that you 
    can use the /bin/tzselect command in shell scripts: 
            America/New_York
    [root@rc ~]#

    tzselectコマンドで、EDTタイム・ゾーンのTZ値をAmerica/New_Yorkとして識別しました。

  3. 次のコマンドを更新して、新しいタイム・ゾーンを設定します。
    timedatectl set-timezone <new_time_zone>
    次に例を示します:
    [root@rc ~]# timedatectl set-timezone America/New_York
  4. 次のコマンドを使用して、タイム・ゾーンが更新されたかどうかを確認します。
    timedatectl
    次に例を示します:
    [root@rc ~]# timedatectl 
             Local time: Thu 2023-03-16 04:02:15 EDT 
         Universal time: Thu 2023-03-16 08:02:15 UTC 
               RTC time: Thu 2023-03-16 08:02:10 
              Time zone: America/New_York (EDT, -0400) 
            NTP enabled: yes 
       NTP synchronized: no 
        RTC in local TZ: no 
             DST active: yes 
        Last DST change: DST began at 
                         Sun 2023-03-12 01:59:59 EST 
                         Sun 2023-03-12 03:00:00 EDT 
        Next DST change: DST ends (the clock jumps one hour backwards) at 
                         Sun 2023-11-05 01:59:59 EDT 
                         Sun 2023-11-05 01:00:00 EST

    システムが現在America/New_York (EDT)タイム・ゾーンになっていることを確認します。

  5. 終了します。

Grid Infrastructureを使用するDBシステムでのホストのタイム・ゾーンの変更

Oracle Grid Infrastructureのタイム・ゾーンによって、データベース・ログ・ファイルのタイム・ゾーンが決まります。

ストレージ管理にグリッド・インフラストラクチャを使用するDBシステムのホストのタイム・ゾーン情報を更新するには、次のステップを実行します。

ノート:

  • ステップ1から10は、RACクラスタ内のすべてのノードで実行する必要があります。
  • ステップ11から15は、RACクラスタ内の任意のノードで実行できます。
  • この手順は、ストレージ管理にGrid InfrastructureではなくLogical Volume Managerを使用する、高速プロビジョニングされたDBシステムには適用されません。
  1. gridユーザーとしてホストにログオンします。

    次に例を示します:
    [opc@rc ~]$ sudo su - grid
  2. 次のコマンドを使用して、設定する正しいタイム・ゾーン(TZ)値を特定します。たとえば、米国太平洋タイム・ゾーン(PST/PDT)の正しいTZ値を識別する場合は、tzselectコマンドを使用し、Americas/United States/Pacificを選択できます。
    tzselect
    次に例を示します:
    [grid@rc ~]$ tzselect 
    Please identify a location so that time zone rules can be set correctly. 
    Please select a continent or ocean. 
     1) Africa 
     2) Americas 
     3) Antarctica 
     4) Arctic Ocean 
     5) Asia 
     6) Atlantic Ocean 
     7) Australia 
     8) Europe 
     9) Indian Ocean 
    10) Pacific Ocean 
    11) none - I want to specify the time zone using the Posix TZ format. 
    #? 2 
    Please select a country. 
     1) Anguilla              19) Dominican Republic    37) Peru 
     2) Antigua & Barbuda     20) Ecuador               38) Puerto Rico 
     3) Argentina             21) El Salvador           39) St Barthelemy 
     4) Aruba                 22) French Guiana         40) St Kitts & Nevis 
     5) Bahamas               23) Greenland             41) St Lucia 
     6) Barbados              24) Grenada               42) St Maarten (Dutch) 
     7) Belize                25) Guadeloupe            43) St Martin (French) 
     8) Bolivia               26) Guatemala             44) St Pierre & Miquelon 
     9) Brazil                27) Guyana                45) St Vincent 
    10) Canada                28) Haiti                 46) Suriname 
    11) Caribbean NL          29) Honduras              47) Trinidad & Tobago 
    12) Cayman Islands        30) Jamaica               48) Turks & Caicos Is 
    13) Chile                 31) Martinique            49) United States 
    14) Colombia              32) Mexico                50) Uruguay 
    15) Costa Rica            33) Montserrat            51) Venezuela 
    16) Cuba                  34) Nicaragua             52) Virgin Islands (UK) 
    17) Curaçao               35) Panama                53) Virgin Islands (US) 
    18) Dominica              36) Paraguay 
    #? 49 
    Please select one of the following time zone regions. 
     1) Eastern (most areas)              16) Central - ND (Morton rural) 
     2) Eastern - MI (most areas)         17) Central - ND (Mercer) 
     3) Eastern - KY (Louisville area)    18) Mountain (most areas) 
     4) Eastern - KY (Wayne)              19) Mountain - ID (south); OR (east) 
     5) Eastern - IN (most areas)         20) MST - Arizona (except Navajo) 
     6) Eastern - IN (Da, Du, K, Mn)      21) Pacific 
     7) Eastern - IN (Pulaski)            22) Alaska (most areas) 
     8) Eastern - IN (Crawford)           23) Alaska - Juneau area 
     9) Eastern - IN (Pike)               24) Alaska - Sitka area 
    10) Eastern - IN (Switzerland)        25) Alaska - Annette Island 
    11) Central (most areas)              26) Alaska - Yakutat 
    12) Central - IN (Perry)              27) Alaska (west) 
    13) Central - IN (Starke)             28) Aleutian Islands 
    14) Central - MI (Wisconsin border)   29) Hawaii 
    15) Central - ND (Oliver) 
    #? 21 
    The following information has been given: 
            United States 
            Pacific 
    Therefore TZ='America/Los_Angeles' will be used. 
        Local time is now:    Thu Mar 16 01:08:57 PDT 2023. 
    Universal Time is now:    Thu Mar 16 08:08:57 UTC 2023. 
    Is the above information OK? 
    1) Yes 
    2) No 
    #? 1 
    You can make this change permanent for yourself by appending the line 
            TZ='America/Los_Angeles'; export TZ 
    to the file '.profile' in your home directory; then log out and log in again. 
    Here is that TZ value again, this time on standard output so that you 
    can use the /bin/tzselect command in shell scripts: 
            America/Los_Angeles 
    [grid@rc ~]$

    tzselectコマンドで、PDTタイム・ゾーンのTZ値をAmerica/Los_Angelesとして識別しました。

  3. 次のコマンドを実行して、ホスト名を取得します。
    hostname
    次に例を示します:
    [grid@rc ~]$ hostname 
    rc
  4. 次のコマンドを実行して、データベース名を取得します。
    srvctl config database -v
    次に例を示します:
    [grid@rc ~]$ srvctl config database -v 
    SMDB0316_iad1cx    /u01/app/oracle/product/21.0.0.0/dbhome_1    21.0.0.0.0
  5. gridユーザーとしてログアウトし、rootユーザーとしてサインインします。

    次に例を示します:
    [grid@rc ~]$ exit 
    logout 
    [opc@rc ~]$ sudo su -
  6. 次のディレクトリに移動します。
    cd $GRID_HOME/crs/install
    次に例を示します:
    [root@rc ~]# cd /u01/app/21.0.0.0/grid/crs/install/
  7. 次のファイルのTZの内容を編集します。編集後、ファイルを保存して閉じます。
    vim s_crsconfig_<hostname>_env.txt
    次に例を示します:
    [root@rc install]# vim s_crsconfig_rc_env.txt
  8. ファイルのTZエントリが更新されているかどうかを確認します。
    cat s_crsconfig_<hostname>_env.txt
    次に例を示します:
    [root@rc install]# cat s_crsconfig_rc_env.txt 
    ######################################################################### 
    #This file can be used to set values for the NLS_LANG and TZ environment 
    #variables and to set resource limits for Oracle Clusterware and 
    #Database processes. 
    #1. The NLS_LANG environment variable determines the language and 
    #   characterset used for messages. For example, a new value can be 
    #   configured by setting NLS_LANG=JAPANESE_JAPAN.UTF8 
    #2. The Time zone setting can be changed by setting the TZ entry to 
    #   the appropriate time zone name. For example, TZ=America/New_York 
    #3. Resource limits for stack size, open files and number of processes 
    #   can be specified by modifying the appropriate entries. 
    # 
    #Do not modify this file except as documented above or under the 
    #direction of Oracle Support Services. 
    ######################################################################### 
    TZ=America/Los_Angeles 
    NLS_LANG=AMERICAN_AMERICA.AL32UTF8 
    CRS_LIMIT_STACK=2048 
    CRS_LIMIT_OPENFILE=65536 
    CRS_LIMIT_NPROC=65536 
    TNS_ADMIN= 
    [root@rc install]#
  9. 次のコマンドを使用して、新しいタイムゾーンを設定します。
    timedatectl set-timezone <new_time_zone>
    次に例を示します:
    [root@rc install]# timedatectl set-timezone America/Los_Angeles

    ノート:

    • ステップ1から9は、RACクラスタ内のすべてのノードで実行する必要があります。
    • ステップ10から15は、RACクラスタ内の任意のノードで実行できます。
  10. 次のディレクトリに移動します。
    cd $GRID_HOME/bin
    次に例を示します:
    [root@rc install]# cd /u01/app/21.0.0.0/grid/bin/
  11. 次のコマンドを使用して、データベース・レベルのTZ値を目的のタイム・ゾーンに変更します。
    srvctl setenv database -d <database_name> -t "TZ=<new_time_zone>"
    次に例を示します:
    [root@rc bin]# ./srvctl setenv database -d SMDB0316_iad1cx -t "TZ=America/Los_Angeles"
  12. 次のコマンドを使用して、設定されたTZ値を確認します。
    srvctl getenv database -d <database_name>
    次に例を示します:
    [root@rc bin]# ./srvctl getenv database -d SMDB0316_iad1cx 
    SMDB0316_iad1cx: 
    TZ=America/Los_Angeles
  13. すべてのコンピュート・ノードでCRSスタックを停止します。
    crsctl stop cluster
    次に例を示します:
    [root@rc bin]# ./crsctl stop cluster 
    CRS-2673: Attempting to stop 'ora.crsd' on 'rc' 
    . 
    . 
    . 
    CRS-2673: Attempting to stop 'ora.cssd' on 'rc' 
    CRS-2677: Stop of 'ora.cssd' on 'rc' succeeded 
    [root@rc bin]#
  14. すべてのコンピュート・ノードでCRSスタックを起動します。
    crsctl start cluster
    次に例を示します:
    [root@rc bin]# ./crsctl start cluster 
    CRS-2672: Attempting to start 'ora.cssdmonitor' on 'rc' 
    . 
    . 
    . 
    CRS-2672: Attempting to start 'ora.crsd' on 'rc' 
    CRS-2676: Start of 'ora.crsd' on 'rc' succeeded 
    [root@rcbin]#
  15. 次のコマンドを使用して、タイム・ゾーンが更新されたかどうかを確認します。
    timedatectl
    次に例を示します:
    [root@rc bin]# timedatectl 
             Local time: Thu 2023-03-16 01:19:15 PDT 
         Universal time: Thu 2023-03-16 08:19:15 UTC 
               RTC time: Thu 2023-03-16 08:19:10 
              Time zone: America/Los_Angeles (PDT, -0700) 
            NTP enabled: yes 
       NTP synchronized: no 
        RTC in local TZ: no 
             DST active: yes 
        Last DST change: DST began at 
                         Sun 2023-03-12 01:59:59 PST 
                         Sun 2023-03-12 03:00:00 PDT 
        Next DST change: DST ends (the clock jumps one hour backwards) at 
                         Sun 2023-11-05 01:59:59 PDT 
                         Sun 2023-11-05 01:00:00 PST

    システムが現在America/Los_Angeles (PDT)タイム・ゾーンになっていることを確認します。