How to change the timezone on ODA lite models

At a customers ODA (the one we have deployed using a json file) we have seen a problem right before going into production. The timezone was set wrong due to a typo mismatch in the json file. CET is the Central European Timezone while ECT is the Ecuador Timezone and in addition to this we have also used UCT.
Redeploying is not funny if you have everything installed you need (including KVMs) on the ODAs, data guard works and the users finished the application tests already.

So we needed to do a change of the timezone without redeploying, and, as the system is placed in Switzerland, to specify the timezone Europe/Zurich is even better than specifying CET (even logically it is the same).
But typo mismatch isn't the only reason to change the timezone like Oracle mentions:
  • Mistaken value during deployment
  • New timezone values or definitions for business reasons
  • Change order to enforce (or disregard) daylight savings values (DST)
  • New usage of timezone dependent functionality including Grid Control, EM Agent or Dbconsole settings
  • Enforce business rules or auditing based on specific time / timezones
  • Reinstallation
At support.oracle.com there is a note regarding "How to change the Timezone in your ODA (Oracle Database Appliance) (Doc ID 1519975.1)", but unfortunately it is only for the ODA HA models.
If you try do to the first steps of the note, you will see, that "onecommand.params" at "/opt/oracle/oak/onecmd" does not exists and you also search unsuccessfully for the "GridInst.pl" command file, which should be located in the same directory.

We recently managed to change the timezone on the ODA lite model by following this approach,which is a mixture of plain Linux and Doc ID 1519975.1:

1.) Connect as root to the system

2.) Check the timezone of the system:

     [root@ODA1 ~]# date
     Tue Feb 20 10:05:49 UTC 2018

3.) Remove the symbolic link localtimezone from the /etc directory

    [root@ODA1 ~]# cd /etc
    [root@ODA1 etc]# rm localtime
    rm: remove symbolic link `localtime'? yes


4.) Create a new symbolic link "localtime" to the right timezone located at /usr/share/zoneinfo/*, in my example it is Europe/Zurich:

   [root@ODA1 etc]# ln -s /usr/share/zoneinfo/Europe/Zurich localtime


5.) Check if the timezone of the system is now correct:

   [root@ODA1 etc]# date
   Tue Feb 20 11:07:54 CET 2018

Now the node itself is running with the correct timezone and we can follow the approach of the Oracle note.

6.) The next step is to set the environment for all databases we do have using srvctl. Therefore you must connect as user "oracle", have set the environment (running oraenv) and change the timezone for the database:

   [oracle@ODA1 ~]$ . oraenv
   ORACLE_SID = [oracle] ? MYDB
   The Oracle base has been set to /u01/app/oracle 

  
   [oracle@ODA1 ~]$ srvctl setenv database -d MYDB_ODA1 -t TZ=Europe/Zurich


7.) Repeat srvctl setenv database for all databases you run on the ODA using the corresponding environment (oraenv). 


8.) Now you have to connect as grid user to the ODA and modify a file. The folder the file is located in is "/u01/app/<yourversion>/grid/crs/install" and the file is named "s_crsconfig_<yourODAhost>_env.txt.
For our environment we did the following:

   [grid@ODA1 ~]$ vi /u01/app/12.1.0.2/grid/crs/install/s_crsconfig_oda1_env.txt

In vi then change the "TZ=<value>" line, e.g. in our environment it was changing
   TZ=ECT
to
   TZ=Europe/Zurich.

You need to write the file with force (!wq) after you have changed the line.

9.) Next step is to restart the Grid Infrastructure, e.g. by rebooting the system.

10.) The last step needed to do is to change the environment for ASM also.
So again connect as grid user to the ODA and execute:

   [grid@ODA1 ~]$ srvctl setenv asm -t TZ=Europe/Zurich
   [grid@ODA1 ~]$ srvctl getenv asm
   asm:
   TZ=Europe/Zurich


That's it folks - you are done!

Edit March 2021:
- First:
On newer ODA versions you can also update the registry (internal database) to reflect the change.

If you run an odacli describe-system you will get the old timezone if you don't run:
# odacli update-registry -n system -f 

- Second: There is a bug that SYSDATE may be wrong after migrating from ODA Release 18.x to 19.x. Please check, using vi /u01/app/12.1.0.2/grid/crs/install/s_crsconfig_oda1_env.txt, that the timezone isn't specified with any ' ' or " " in the file. If so, change it back. Also check with srvctl getenv all listeners, databases and asm if the right time zone is still enabled. If you set them manually restart all parts affected by the change.

No comments:

Post a Comment

Your comment will be published soon...