'데이터 엔지니어'로 성장하기

정리하는 걸 좋아하고, 남이 읽으면 더 좋아함

Storage/mariadb

Kubernetes)Mariadb tz변경_default_tz,extraEnv

MightyTedKim 2022. 2. 23. 13:20
728x90
반응형

timezone 변경

default-timzone으로 변경하면 tz 자체가 변경되고

extraEnvVar로 설정하면, system_time_zone이 변경되고, tz이 system을 따라간다는것을 확인함

방법1: default-timezone

primary:
  configuration: |-
    [mysqld]
    default-time-zone='+9:00'
방법2: extraEnv로 적용

  extraEnvVars:
    - name: TZ
      value: "Asia/Seoul" #"UTC" 

MariaDB [(none)]> show variables like '%time_zone%';
+------------------+--------+
| Variable_name    | Value  |
+------------------+--------+
| system_time_zone | UTC    |
| time_zone        | +09:00 |
+------------------+--------+
2 rows in set (0.001 sec)
MariaDB [db_pqe]> show variables like '%time_zone%';
+------------------+--------+
| Variable_name    | Value  |
+------------------+--------+
| system_time_zone | KST    |
| time_zone        | SYSTEM |
+------------------+--------+
2 rows in set (0.001 sec)

방법1: default-timezone

참고 : https://codens.info/1691

values.yaml

#primary, secondary 모두 추가
[mysqld] 섹션에 다음을 추가(수정)
default-time-zone=Asia/Seoul

primary:
  command: []
  args: []
  lifecycleHooks: {}
  hostAliases: []
  configuration: |-
    [mysqld]
    default-time-zone='+9:00'

secondary:
  command: []
  args: []
  lifecycleHooks: {}
  hostAliases: []
  configuration: |-
    [mysqld]
    default-time-zone='+9:00'

업데이트

$ helm  upgrade --install mariadb-20220222 hgkim/mariadb -n mariadb -f values.yaml --debug --insecure-skip-tls-verify
MariaDB [(none)]> select now();
+---------------------+
| now()               |
+---------------------+
| 2022-02-23 10:46:03 |
+---------------------+
1 row in set (0.000 sec)

MariaDB [(none)]> SELECT @@GLOBAL.time_zone, @@SESSION.time_zone, @@system_time_zone;
+--------------------+---------------------+--------------------+
| @@GLOBAL.time_zone | @@SESSION.time_zone | @@system_time_zone |
+--------------------+---------------------+--------------------+
| +09:00             | +09:00              | UTC                |
+--------------------+---------------------+--------------------+
1 row in set (0.000 sec)

MariaDB [(none)]> show variables like '%time_zone%';
+------------------+--------+
| Variable_name    | Value  |
+------------------+--------+
| system_time_zone | UTC    |
| time_zone        | +09:00 |
+------------------+--------+
2 rows in set (0.001 sec)


방법2: extraEnv로 적용

참고: https://stackoverflow.com/questions/61751986/timezone-in-requirements-yaml-to-add-dependency-to-a-helm-chart

values.yaml

  #extraEnvVars: []
  extraEnvVars:
    - name: TZ
      value: "Asia/Seoul" #"UTC" 

  #extraEnvVars: []
  extraEnvVars:
    - name: TZ
      value: "Asia/Seoul" #"UTC" 

업데이트

$ helm  upgrade --install mariadb-20220222 hgkim/mariadb -n mariadb -f values.yaml --debug --insecure-skip-tls-verify --set auth.replicationPassword=mysql
$ k get all -n mariadb
NAME                               READY   STATUS    RESTARTS   AGE
pod/mariadb-20220222-primary-0     1/1     Running   0          52s
pod/mariadb-20220222-secondary-0   1/1     Running   0          52s

$ k exec -it pod/mariadb-20220222-primary-0 -n mariadb -n mariadb -- /bin/sh

MariaDB [db_pqe]> select now();
+---------------------+
| now()               |
+---------------------+
| 2022-02-22 18:01:45 |
+---------------------+
1 row in set (0.000 sec)

MariaDB [db_pqe]> show variables like '%time_zone%';
+------------------+--------+
| Variable_name    | Value  |
+------------------+--------+
| system_time_zone | KST    |
| time_zone        | SYSTEM |
+------------------+--------+
2 rows in set (0.001 sec)

MariaDB [db_pqe]> SELECT @@GLOBAL.time_zone, @@SESSION.time_zone, @@system_time_zone;
+--------------------+---------------------+--------------------+
| @@GLOBAL.time_zone | @@SESSION.time_zone | @@system_time_zone |
+--------------------+---------------------+--------------------+
| SYSTEM             | SYSTEM              | KST                |
+--------------------+---------------------+--------------------+

 

설치는 아래 링크

https://mightytedkim.tistory.com/58

 

Kubernetes)Mariadb 설치

Kubernetes 1.12+ Helm 2.11+ or Helm 3.0-beta3+ PV provisioner support in the underlying infrastructure https://github.com/helm/charts/tree/master/stable/mariadb 결과 $ k get all -n mariadb NAME READ..

mightytedkim.tistory.com

 

728x90
반응형