Oracle Cloud OCI - Ajustando o timezone do serviço de banco de dados

No artigo de hoje, estarei demonstrando como realizar a alteração do timezone do Oracle Database Service, apos o serviço já estar criado e disponível.

No exemplo abaixo, o serviço de banco de dados foi criado no datacenter de São Paulo, com timezone UTC, ou seja, 3 horas adiantado em relação ao horario de Brasília.

Horario de Brasilia:09:19
Horario do Servidor de banco: 12:19


Para ajustar o timezone, o primeiro passo necessário é conectar via ssh no servidor de banco de dados, uma vez que não existe opção de alteração via console.

Posteriormente, com o usuário root, devemos editar o arquivo /etc/sysconfig/clock com o timezone correto. No exemplo abaixo, estaremos alterando de UTC para America/Sao_Paulo e comentando as demais entradas.
[root@standbycloud ~]# cat /etc/sysconfig/clock
ZONE="UTC"
UTC=true
ARC=false
[root@standbycloud ~]# vi /etc/sysconfig/clock
[root@standbycloud ~]# cat /etc/sysconfig/clock
ZONE="America/Sao_Paulo"
#UTC=true
#ARC=false

Os timezones disponíveis podem ser validados no diretório /usr/share/zoneinfo/
Após a edição do arquivo, vamos recriar o link /etc/localtime e com isso o horário da maquina já estará ajustado.
[root@standbycloud ~]# date
Tue Sep 17 12:28:04 UTC 2019
[root@standbycloud ~]# ln -sf /usr/share/zoneinfo/America/Sao_Paulo /etc/localtime
[root@standbycloud ~]# date
Tue Sep 17 09:28:23 -03 2019
[root@standbycloud ~]#
Posteriormente, é necessário ajustar o horario no grid. Para isso, devemos parar os serviços e ajustar o arquivo GRID_HOME/crs/install/s_crsconfig_<node_name>_env.txt, alterando a variável TZ. Este ajuste deve ser feito em todos os nodes, para ambientes cluster.
[root@standbycloud ~]# ls -ltr /u01/app/18.0.0.0/grid/crs/install/s_crsconfig*
-rwxr-xr-x 1 root oinstall 3593 Dec 30  2014 /u01/app/18.0.0.0/grid/crs/install/s_crsconfig_defs
-rwxr-xr-x 1 root oinstall  990 Sep  9 09:21 /u01/app/18.0.0.0/grid/crs/install/s_crsconfig_standbycloud_env.txt
[root@standbycloud ~]# cat /u01/app/18.0.0.0/grid/crs/install/s_crsconfig_standbycloud_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=UTC
NLS_LANG=AMERICAN_AMERICA.AL32UTF8
CRS_LIMIT_STACK=2048
CRS_LIMIT_OPENFILE=65536
CRS_LIMIT_NPROC=65536
TNS_ADMIN=
[root@standbycloud ~]# vi /u01/app/18.0.0.0/grid/crs/install/s_crsconfig_standbycloud_env.txt
[root@standbycloud ~]# cat /u01/app/18.0.0.0/grid/crs/install/s_crsconfig_standbycloud_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/SAO_PAULO
NLS_LANG=AMERICAN_AMERICA.AL32UTF8
CRS_LIMIT_STACK=2048
CRS_LIMIT_OPENFILE=65536
CRS_LIMIT_NPROC=65536
TNS_ADMIN=
[root@standbycloud ~]#
Concluído o ajuste do arquivo do listener, devemos ajustar os serviços do listener e database e depois iniciar os serviços.
Grid:
srvctl setenv listener -l listener -t 'TZ=America/Sao_Paulo'

Oracle:
srvctl setenv database -d LAMIM -t 'TZ=America/Sao_Paulo'

[root@standbycloud ~]# service ohasd start
Starting ohasd:

CRS-4123: Oracle High Availability Services has been started.
[root@standbycloud ~]#
Referência: 
https://minersoracleblog.wordpress.com/2014/09/19/changing-timezone-settings-on-oracle-database-servers/

How do I change the timezone setting of my Oracle Cloud Database? (Doc ID 2165725.1)


Comentários

  1. Boa tarde Jhonata. Você tem o procedimento no caso da OCI-C?

    ResponderExcluir
    Respostas
    1. Boa Noite,
      tudo bem?
      No classic nao cheguei a fazer, mas acredito que o procedimento seja o mesmo.
      Qualquer coisa me manda um email.

      Excluir

Postar um comentário