728x90
반응형
- 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 READY STATUS RESTARTS AGE
pod/mariadb-20220222-primary-0 1/1 Running 0 114s
pod/mariadb-20220222-secondary-0 1/1 Running 0 114s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/mariadb-20220222-primary NodePort 10.102.244.92 <none> 3306:30009/TCP 114s
service/mariadb-20220222-secondary NodePort 10.106.51.198 <none> 3306:30008/TCP 114s
NAME READY AGE
statefulset.apps/mariadb-20220222-primary 1/1 114s
설치
$ helm search repo mariadb
NAME CHART VERSION APP VERSION DESCRIPTION
hgkim/mariadb 10.1.0 10.5.13 Fast, reliable, scalable, and easy to use open-...
$helm pull hgkim/mariadb --insecure-skip-tls-verify
$ ll
-rw-r--r-- 1 bigdata bigdata 37303 Feb 22 16:35 mariadb-10.1.0.tgz
$ tar -xvzf ./mariadb-10.1.0.tgz
$ cd mariadb
$ helm install mariadb-20220222 hgkim/mariadb -n mariadb -f values.yaml --debug --insecure-skip-tls-verify
$ helm list -n mariadb
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
mariadb-20220222 mariadb 1 2022-02-22 16:50:47.130794417 +0900 KST deployed mariadb-10.1.0 10.5.13
$ k get all -n mariadb
NAME READY STATUS RESTARTS AGE
pod/mariadb-20220222-primary-0 0/1 Running 0 36s
pod/mariadb-20220222-secondary-0 0/1 Running 0 36s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/mariadb-20220222-primary NodePort 10.102.244.92 <none> 3306:30009/TCP 36s
service/mariadb-20220222-secondary NodePort 10.106.51.198 <none> 3306:30008/TCP 36s
NAME READY AGE
statefulset.apps/mariadb-20220222-primary 0/1 36s
statefulset.apps/mariadb-20220222-secondary 0/1 36s
특이사항
init
$ k exec -it pod/mariadb-20220222-primary-0 -n mariadb -- /bin/sh
$ mysql -uroot -pmysql
MariaDB [mysql]> create database db_pqe
MariaDB [mysql]> CREATE USER 'hgkim'@'%' IDENTIFIED BY 'dpszhdk';
MariaDB [mysql]> select host, user, Password from user;
+-----------+-------------+-------------------------------------------+
| Host | User | Password |
+-----------+-------------+-------------------------------------------+
| localhost | mariadb.sys | |
| % | root | *E74858DB86EBA20BC33D0AECAE8A8108C56B17FA |
| % | replicator | *F824DC8B536AEAAFEDE113A686D102B2DA2B1BEA |
| % | hgkim | *C6B9B7B84E7D9098DE633A46F23D4E429046DDE4 |
+-----------+-------------+-------------------------------------------+
MariaDB [db_pqe]> use db_pqe;
Database changed
MariaDB [db_pqe]> show variables like '%time_zone%';
+------------------+--------+
| Variable_name | Value |
+------------------+--------+
| system_time_zone | UTC |
| time_zone | SYSTEM |
+------------------+--------+
2 rows in set (0.001 sec)
MariaDB [db_pqe]> SELECT NOW();
+---------------------+
| NOW() |
+---------------------+
| 2022-02-22 08:12:16 |
+---------------------+
timezone 변경, extraEnv로 적용
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
history.go:56: [debug] getting history for release mariadb-20220222
upgrade.go:139: [debug] preparing upgrade for mariadb-20220222
upgrade.go:147: [debug] performing update for mariadb-20220222
upgrade.go:319: [debug] creating upgraded release for mariadb-20220222
client.go:218: [debug] checking 8 resources for changes
client.go:501: [debug] Looks like there are no changes for ServiceAccount "mariadb-20220222"
client.go:501: [debug] Looks like there are no changes for ConfigMap "mariadb-20220222-primary"
client.go:501: [debug] Looks like there are no changes for ConfigMap "mariadb-20220222-secondary"
client.go:501: [debug] Looks like there are no changes for Service "mariadb-20220222-primary"
client.go:501: [debug] Looks like there are no changes for Service "mariadb-20220222-secondary"
upgrade.go:154: [debug] updating status for upgraded release for mariadb-20220222
Release "mariadb-20220222" has been upgraded. Happy Helming!
NAME: mariadb-20220222
LAST DEPLOYED: Tue Feb 22 17:54:03 2022
NAMESPACE: mariadb
STATUS: deployed
REVISION: 5
TEST SUITE: None
USER-SUPPLIED VALUES:
architecture: replication
primary:
extraEnvVars:
- name: TZ
value: Asia/Seoul
secondary:
extraEnvVars:
- name: TZ
value: Asia/Seoul
COMPUTED VALUES:
architecture: replication
extraEnvVars:
- name: TZ
value: Asia/Seoul
extraEnvVars:
- name: TZ
value: Asia/Seoul
containers:
- name: mariadb
env:
- name: TZ
value: Asia/Seoul
# 여러 군데에 적용된 것을 볼 수 있음
$ 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 |
+--------------------+---------------------+--------------------+
timzone 변경 방법은 아래에
728x90
반응형
'Storage > mariadb' 카테고리의 다른 글
Kubernetes) helm mariadb innodb recovery 하기 (1) | 2022.09.21 |
---|---|
Mariadb) binary 파일 정리하기_k8s에서 pvc 넘침 (0) | 2022.04.28 |
mariadb) pvc 부족으로 인한 fail -> binary 파일이 원인 (0) | 2022.04.15 |
Kubernetes)Mariadb tz변경_default_tz,extraEnv (0) | 2022.02.23 |