TheKoguryo's 기술 블로그

 Version 2024.04.01

4.2.2 Oracle Database Operator for Kubernetes (OraOperator)

지난 2023년 7월, Kubernetes Operator 방식을 지원하는 Oracle Database Operator for Kubernete가 Production 릴리즈로 v1.0.0이 출시되었습니다. 줄여서 OraOperator라 부릅니다.

Oracle Database Operator for Kubernetes를 사용하여, 쿠버네티스 클러스터내에 데이터베이스를 생성할 수 있습니다. 또한 Operator를 통해 쿠버네티스 YAML 설정으로, 쿠버네티스 외부에 있는 OCI 상의 또는 On-Premise 상의 오라클 데이터베이스에 대한 라이프사이클 관리를 지원합니다. 데이터베이스 별 가능한 오퍼레이션 내역은 Features Summary에서 확인합니다.

  • Oracle Database Operator for Kubernetes

    image-20231030092228259

  • 지원하는 데이터베이스

    • Containerized DB on Kubernetes Cluster

      • Containerized Single Instance databases (SIDB)
      • Containerized Sharded databases (SHARDED)
    • OCI-Only DB

      • Oracle Base Database Cloud Service (BDBCS)
      • Oracle Autonomous Database:
        • Oracle Autonomous Database shared Oracle Cloud Infrastructure (OCI) (ADB-S)
        • Oracle Autonomous Database on dedicated Cloud infrastructure (ADB-D)
        • Oracle Autonomous Container Database (ACD) (infrastructure) the infrastructure for provisionning Autonomous Databases.
    • On-Premise DB

      • Oracle Multitenant Databases (CDB/PDBs)

설치 및 테스트된 쿠버네티스 플랫폼

Oracle Container Engine for Kubernetes (OKE)는 물론 그외 쿠버네티스에서도 사용할 수 있습니다. 공식 GitHub Repository 문서상으로 설치 테스트된 쿠버네티스 환경은 다음과 같습니다.

Oracle Database Operator for Kubernetes 설치

cert-manager 설치
  1. 이미 설치되어 있지 않다면, 아래와 같이 설치합니다.

    kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.13.1/cert-manager.yaml
    
OraOperator 설치
  1. OraOperator를 설치합니다.

    kubectl apply -f https://raw.githubusercontent.com/oracle/oracle-database-operator/main/oracle-database-operator.yaml
    
  2. OraOperator의 기동을 확인합니다. 기본 3중화되어 설치됩니다.

    $ kubectl get pods -n oracle-database-operator-system
    NAME                                                           READY   STATUS    RESTARTS   AGE
    oracle-database-operator-controller-manager-758497dd49-42snr   1/1     Running   0          60s
    oracle-database-operator-controller-manager-758497dd49-8x2rq   1/1     Running   0          60s
    oracle-database-operator-controller-manager-758497dd49-mmxw6   1/1     Running   0          60s
    

쿠버네티스내 오라클 데이터베이스

쿠버네티스내에서 컨테이너 형식으로 구동되는 데이터베이스는 Single Instance와 Sharded 데이터베이스를 현재 지원합니다. RAC는 아직 쿠버네티스내 컨테이너 형식으로는 지원되지 않습니다. Data Guard는 Preview 상태로 지원중입니다.

  • Containerized Single Instance databases (SIDB)
  • Containerized Sharded databases (SHARDED)

여기에서는 단일 인스턴스 데이터베이스 SIDB를 Free 데이터베이스, Exress Edition, Enterprise Edition 이 세 가지의 각 기본 생성하는 과정을 확인해 봅니다.

#1. Oracle Database 23c Free – Developer Release 설치하기

2023년 4월 Oracle Database 23c Free – Developer Release이 Oracle Database의 새로운 무료 오퍼링으로 출시되었습니다. 데이터베이스 컨테이너 이미지는 Oracle Container Registry를 통해 제공합니다. 하지만, Oracle Free Use Terms and Conditions에 따라 계정 인증이나 라이선스 사용 문서 동의없이 바로 사용할 수 있습니다.

  • 참고사항

    • Provisioning Oracle Database Free is supported for release 23c (23.2.0) and later releases.

    • For Free database, only single replica mode (i.e. replicas: 1) is supported.

    • For Free database, you cannot change the init parameters i.e. cpuCount, processes, sgaTarget or pgaAggregateTarget.

    • Oracle Enterprise Manager is not supported from release 23c and later release.

  1. 데이터베이스 생성용 YAML 파일을 작성합니다. 예시 설치 구성 YAML 파일(config/samples/sidb/singleinstancedatabase_free.yaml)을 다운로드 받습니다.

    wget https://raw.githubusercontent.com/oracle/oracle-database-operator/main/config/samples/sidb/singleinstancedatabase_free.yaml
    
  2. 필요하면 예시 파일을 수정합니다.

    #
    # Copyright (c) 2023, Oracle and/or its affiliates.
    # Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
    #
    
    apiVersion: database.oracle.com/v1alpha1
    kind: SingleInstanceDatabase
    metadata:
      name: freedb-sample
      namespace: default
    spec:
    
      ## Use only alphanumeric characters for sid
      sid: FREE
    
      ## DB edition
      edition: free
    
      ## Secret containing SIDB password mapped to secretKey
      adminPassword:
        secretName: freedb-admin-secret
    
      ## Database image details
      image:
        ## Oracle Database Free is only supported from DB version 23.2 onwards
        pullFrom: container-registry.oracle.com/database/free:latest
        prebuiltDB: true
    
      ## size is the required minimum size of the persistent volume
      ## storageClass is specified for automatic volume provisioning
      ## accessMode can only accept one of ReadWriteOnce, ReadWriteMany
      persistence:
        size: 50Gi
        ## oci-bv applies to OCI block volumes. Use "standard" storageClass for dynamic provisioning in Minikube. Update as appropriate for other cloud service providers
        storageClass: "oci-bv"
        accessMode: "ReadWriteOnce"
    
      ## Count of Database Pods. Should be 1 for express edition.
      replicas: 1
    
    • persistence: OKE 기준 예시로 oci-bv StorageClass를 사용합니다. 필요시 각자환경에 맞게 수정합니다.

      $ kubectl get sc
      NAME               PROVISIONER                       RECLAIMPOLICY   VOLUMEBINDINGMODE      ALLOWVOLUMEEXPANSION   AGE
      oci                oracle.com/oci                    Delete          Immediate              false                  57d
      oci-bv (default)   blockvolume.csi.oraclecloud.com   Delete          WaitForFirstConsumer   true                   57d
      
    • 서비스 타입: 기본은 NodePort 타입입니다. Load Balancer를 사용하고자 하거나, 그와 더불어 Internal용으로 Private Load Balancer를 쓸 경우 아래 내용을 참고하여 추가로 설정합니다.

        ## Type of service . Applicable on cloud enviroments only
        ## if loadBalService : false, service type = "NodePort" else "LoadBalancer"
        loadBalancer: false
      
        ## 'listenerPort' and 'tcpsListenerPort' fields customizes port cofigurations for normal and tcps database listeners
        ## 'tcpsListenerPort' will come in effect only when 'enableTCPS' field is set
        ## If loadBalancer is enabled, the listenerPort, tcpsListenerPort will be the load balancer ports
        ## If loadBalancer is disabled, the listenerPort, tcpsListenerPort will be the node ports(should be in range 30000-32767)
        ## If enableTCPS is set, and listenerPort is commented/not mentioned in the YAML file, only TCPS endpoint will be exposed
        #listenerPort: 30001
        #tcpsListenerPort: 30002
      
        ## Service Annotations (Cloud provider specific), for configuring the service (e.g. private LoadBalancer service)
        #serviceAnnotations:
        #  service.beta.kubernetes.io/oci-load-balancer-internal: "true"
      
  3. 관리자 암호를 위한 Secret을 데이터베이스 생성용 YAML에서 지정한 이름으로 만듭니다.

    cat <<EOF | kubectl apply -f -
    ## Oracle Database Free Admin password secret
    apiVersion: v1
    kind: Secret
    metadata:
      name: freedb-admin-secret
      namespace: default
    type: Opaque
    stringData:
      ## Specify your DB password here
      oracle_pwd: Welcome_SIDB_1234
    EOF
    
  4. 데이터베이스 생성용 YAML 파일을 통해 데이터베이스를 생성합니다.

    kubectl apply -f singleinstancedatabase_free.yaml
    
  5. 처음 실행하는 경우를 포함하여 Worker Node에 이미지가 없으면, 이미지를 가져오는데 시간이 걸립니다. 컨테이너 이미지 파일 용량이 커서 오래 걸릴 수 있습니다. (2023년 10월 기준, 9.16GB)

    $ kubectl get events --sort-by='.metadata.creationTimestamp' -A
    default     4m53s       Normal   Pulling                  pod/freedb-sample-awfu6                Pulling image "container-registry.oracle.com/database/free:latest"
    default     3s          Normal   Pulled                   pod/freedb-sample-awfu6                Successfully pulled image "container-registry.oracle.com/database/free:latest" in 4m49.676290519s (4m49.676389866s including waiting)
    default     3s          Normal   Created                  pod/freedb-sample-awfu6                Created container init-permissions
    default     2s          Normal   Started                  pod/freedb-sample-awfu6                Started container init-permissions
    ...
    
  6. 데이터베이스 상태 status가 Healthy인지 확인합니다.

    $ kubectl get SingleInstanceDatabase
    NAME            EDITION   STATUS    ROLE      VERSION        CONNECT STR              TCPS CONNECT STR   OEM EXPRESS URL
    freedb-sample   Free      Healthy   PRIMARY   23.3.0.23.09   10.0.10.225:32750/FREE   Unavailable        Unavailable
    
  7. CONNECT STR 칼럼에 있는 Connection String도 확인합니다.

  8. NodePort로 오픈된 것을 볼 수 있습니다.

    $ kubectl get pod -o wide
    NAME                                        READY   STATUS    RESTARTS   AGE   IP            NODE          NOMINATED NODE   READINESS GATES
    freedb-sample-awfu6                         1/1     Running   0          14m   10.244.0.13   10.0.10.225   <none>           <none>
    $ kubectl get svc
    NAME                TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)                         AGE
    freedb-sample       ClusterIP   10.96.210.28    <none>        1521/TCP                        12m
    freedb-sample-ext   NodePort    10.96.133.142   <none>        5500:31389/TCP,1521:32750/TCP   12m
    kubernetes          ClusterIP   10.96.0.1       <none>        443/TCP,12250/TCP               57d
    
  9. Connection String 상의 주소로 접근 가능한 곳에서 연결할 수 있습니다. 여기서는 테스트로 해당 Pod에 들어가서 데이터베이스 연결을 확인해봅니다.

    $ kubectl exec -it freedb-sample-awfu6 -- /bin/bash
    Defaulted container "freedb-sample" out of: freedb-sample, init-permissions (init), init-prebuiltdb (init)
    bash-4.4$ sqlplus sys/Welcome_SIDB_1234@10.0.10.225:32750/FREE as sysdba
    
    SQL*Plus: Release 23.0.0.0.0 - Production on Thu Oct 26 15:34:09 2023
    Version 23.3.0.23.09
    
    Copyright (c) 1982, 2023, Oracle.  All rights reserved.
    
    
    Connected to:
    Oracle Database 23c Free Release 23.0.0.0.0 - Develop, Learn, and Run for Free
    Version 23.3.0.23.09
    
    SQL> 
    
#2. Oracle Database Express Edition (XE) 설치하기

무료 오라클 데이터베이스인 Express Edition을 컨테이너 이미지로 설치합니다. 데이터베이스 컨테이너 이미지는 Oracle Container Registry를 통해 제공합니다. 하지만, Oracle Free Use Terms and Conditions에 따라 계정 인증이나 라이선스 사용 문서 동의없이 바로 사용할 수 있습니다.

  • 참고사항

    • Provisioning Oracle Database express edition is supported for release 21c (21.3.0) only.

    • For XE database, only single replica mode (i.e. replicas: 1) is supported.

    • For XE database, you cannot change the init parameters i.e. cpuCount, processes, sgaTarget or pgaAggregateTarget.

  1. 데이터베이스 생성용 YAML 파일을 작성합니다. 예시 설치 구성 YAML 파일(config/samples/sidb/singleinstancedatabase_express.yaml)을 다운로드 받습니다.

    wget https://raw.githubusercontent.com/oracle/oracle-database-operator/main/config/samples/sidb/singleinstancedatabase_express.yaml
    
  2. 필요하면 예시 파일을 수정합니다.

    • 서비스 타입: 기본은 NodePort 타입입니다. 여기서는 기능 확인차 Load Balancer를 사용하도록 설정을 추가합니다.
    #
    # Copyright (c) 2023, Oracle and/or its affiliates.
    # Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
    #
    
    apiVersion: database.oracle.com/v1alpha1
    kind: SingleInstanceDatabase
    metadata:
      name: xedb-sample
      namespace: default
    spec:
    
      ## Use only alphanumeric characters for sid
      sid: XE
    
      ## DB edition
      edition: express
    
      ## Secret containing SIDB password mapped to secretKey
      adminPassword:
        secretName: xedb-admin-secret
    
      ## Database image details
      image:
        pullFrom: container-registry.oracle.com/database/express:latest
        prebuiltDB: true
    
      ## size is the required minimum size of the persistent volume
      ## storageClass is specified for automatic volume provisioning
      ## accessMode can only accept one of ReadWriteOnce, ReadWriteMany
      persistence:
        size: 50Gi
        ## oci-bv applies to OCI block volumes. Use "standard" storageClass for dynamic provisioning in Minikube. Update as appropriate for other cloud service providers
        storageClass: "oci-bv"
        accessMode: "ReadWriteOnce"
    
      ## Count of Database Pods. Should be 1 for express edition.
      replicas: 1
    
      ## Type of service . Applicable on cloud enviroments only
      ## if loadBalService : false, service type = "NodePort" else "LoadBalancer"
      loadBalancer: true  
    
  3. 관리자 암호를 위한 Secret을 데이터베이스 생성용 YAML에서 지정한 이름으로 만듭니다.

    cat <<EOF | kubectl apply -f -
    ## Oracle Database Free Admin password secret
    apiVersion: v1
    kind: Secret
    metadata:
      name: xedb-admin-secret
      namespace: default
    type: Opaque
    stringData:
      ## Specify your DB password here
      oracle_pwd: Welcome_SIDB_1234
    EOF
    
  4. 데이터베이스 생성용 YAML 파일을 통해 데이터베이스를 생성합니다.

    kubectl apply -f singleinstancedatabase_express.yaml
    
  5. 처음 실행하는 경우를 포함하여 Worker Node에 이미지가 없으면, 이미지를 가져오는데 시간이 걸립니다. 컨테이너 이미지 파일 용량이 커서 오래 걸릴 수 있습니다. (2023년 10월 기준, 11.4GB)

  6. 데이터베이스 상태 status가 Healthy인지 확인합니다.

    $ kubectl get SingleInstanceDatabase
    NAME          EDITION   STATUS    ROLE      VERSION      CONNECT STR              TCPS CONNECT STR   OEM EXPRESS URL
    xedb-sample   Express   Healthy   PRIMARY   21.3.0.0.0   150.230.xxx.xx:1521/XE   Unavailable        https://150.230.xxx.xx:5500/em
    
  7. CONNECT STR 칼럼, OEM EXPRESS URL 칼럼값을 확인합니다.

  8. LoadBalancer로 오픈된 것을 볼 수 있습니다.

    $ kubectl get pod -o wide
    NAME                                        READY   STATUS    RESTARTS   AGE   IP            NODE         NOMINATED NODE   READINESS GATES
    xedb-sample-o83o6                           1/1     Running   0          16m   10.244.0.12   10.0.10.97   <none>           <none>
    $ kubectl get svc
    NAME              TYPE           CLUSTER-IP     EXTERNAL-IP      PORT(S)                         AGE
    kubernetes        ClusterIP      10.96.0.1      <none>           443/TCP,12250/TCP               57d
    xedb-sample       ClusterIP      10.96.111.26   <none>           1521/TCP                        7m18s
    xedb-sample-ext   LoadBalancer   10.96.142.44   150.230.xxx.xx   5500:32274/TCP,1521:32566/TCP   7m18s
    
  9. OEM EXPRESS URL 주소로 접속합니다. Self-Signed 인증서 문제 확인 후 그대로 접속합니다.

    image-20231027111935888

  10. 로그인한 Enterprise Manager(EM) 화면 예시입니다.

    image-20231027112431700

호스트에서 SQL Developer로 접속해 보기
  1. 개발자 데스크탑/랩탑에 사용할 클라이언트를 가정하여, SQL Developer로 아래와 같이 접속할 수 있습니다.

  2. 새 데이터베이스 접속을 만듭니다.

    • 접속 세부 정보: Connection String에 있던 정보 사용
    • 사용자 이름/비밀번호: SYS / 관리자 패스워드
    • 롤: SYS 유저로 접속시 SYSDBA 선택

    image-20231027113431231

  3. 접속 테스트를 하면 성공하는 것을 볼 수 있습니다.

#3. Oracle Database Enterprise Edition 설치하기

Oracle Database Operator for Kubernetes (OraOperator)은 무료이지만, Oracle Database Enterprise Edition을 사용할 경우에는 관련 라이센스가 필요합니다. 그래서 Oracle Container Registry에서 관련 라이센스 약관 동의 과정과 관련 작업이 필요합니다.

OCR(Oracle Container Registry)에서 이미지 가져오기
  1. 앞서 무료버전과는 달리, 여기서 사용할 컨테이너 이미지는 Oracle Container Registry에 로그인과, 라이센스 동의하는 과정이 필요합니다. 또한 이미지를 가져올때 사용할 Auth Token도 생성하여 사용해야 합니다.

  2. Oracle Container Registry에 접속하여, Database 저장소로 이동합니다.

    image-20231026184758131

  3. 저장소 중에서 enterprise를 선택합니다.

    image-20231026184902714

  4. 라이센스 동의를 위해 로그인합니다.

    image-20231026185012311

  5. Oracle Account로 로그인합니다. 계정이 없는 경우, 계정을 만듭니다.

    image-20231027182925574

  6. 라이센스 동의화면에서, 한국어로 표준 약관을 확인하고, 동의를 클릭합니다.

    image-20231027183112701

    image-20231027183258593

  7. docker login을 위한 Auth Token이 필요합니다. 로그인 유저 정보에서 Auth Token을 클릭합니다.

    image-20231027184134220

  8. Auth Token을 생성합니다.

    image-20231027184424643

  9. 생성된 키를 복사해 둡니다. 복사후에는 다시 확인할 수 없으니, 잘 보관해 둡니다.

    image-20231027184515264

  10. Oracle Container Registry에서 Oracle Database Enterprise Edition에서 아래 이미지 태그에서 보면, Default 서버 이외에 미러 사이트를 제공하고 있습니다. 서울, 춘천 미러사이트도 제공하고 있습니다.

    image-20231027185754895

  11. docker login 명령으로 Oracle Container Registry로 로그인합니다. (필요하면, 미러 사이트 주소를 사용합니다) 앞서 사용한 Oracle Account와 Auth Token으로 로그인합니다. 로그인 후에는 Oracle Database Enterprise Edition Docker Image를 잘 가져 오는 것을 볼 수 있습니다.

    당장 여기서 사용하지 않으면, 용량이 크므로 가져오는 것만 확인하고 취소합니다.

    $ docker pull container-registry.oracle.com/database/enterprise:latest
    Error response from daemon: Head "https://container-registry.oracle.com/v2/database/enterprise/manifests/latest": unauthorized: authentication required
    
    $ docker login container-registry.oracle.com
    Username: <oracle sso username>
    Password: <Auth Token - Generated Secret Key>
    Login Succeeded
    
    $ docker pull container-registry.oracle.com/database/enterprise:latest
    latest: Pulling from database/enterprise
    7c8051acdded: Pulling fs layer
    e8e925221939: Download complete
    588ca0fc7bfb: Downloading [=======>                                           ]  1.957kB/12.98kB
    ...
    ^C
    
  12. 로그인한 정보를 기준으로 Image Pull Secret을 생성합니다.

    kubectl create secret generic oracle-container-registry-secret --from-file=.dockerconfigjson=.docker/config.json --type=kubernetes.io/dockerconfigjson
    
Oracle Database Enterprise Edition 설치하기
  • 참고사항

    • For ease of use, the storage class oci-bv is specified in the singleinstancedatabase_create.yaml. This storage class facilitates dynamic provisioning of the OCI block volumes on the Oracle OKE for persistent storage of the database. The supported access mode for this class is ReadWriteOnce. For other cloud providers, you can similarly use their dynamic provisioning storage classes.
    • It is beneficial to have the database replica pods more than or equal to the number of available nodes if ReadWriteMany access mode is used with the OCI NFS volume. By doing so, the pods get distributed on different nodes and the database image is downloaded on all those nodes. This helps in reducing time for the database fail-over if the active database pod dies.
    • Supports Oracle Database Enterprise Edition (19.3.0), and later releases.
    • To pull the database image faster from the container registry, so that you can bring up the SIDB instance quickly, you can use the container-registry mirror of the corresponding cluster’s region. For example, if the cluster exists in Mumbai region, then you can use the container-registry-bom.oracle.com mirror. For more information on container-registry mirrors, follow the link https://blogs.oracle.com/wim/post/oracle-container-registry-mirrors-in-oracle-cloud-infrastructure.
    • To update the init parameters like sgaTarget and pgaAggregateTarget, refer the initParams section of the singleinstancedatabase.yaml file.
  1. 데이터베이스 생성용 YAML 파일을 작성합니다. 예시 설치 구성 YAML 파일(config/samples/sidb/singleinstancedatabase_create.yaml)을 다운로드 받습니다.

    wget https://raw.githubusercontent.com/oracle/oracle-database-operator/main/config/samples/sidb/singleinstancedatabase_create.yaml
    
  2. 필요하면 예시 파일을 수정합니다.

    • 서비스 타입: 기본은 NodePort 타입입니다. 여기서는 기능 확인차 Load Balancer를 사용하도록 설정을 추가합니다.
    • image.pullFrom: 필요하면, 미러 사이트로 변경합니다.
    #
    # Copyright (c) 2023, Oracle and/or its affiliates.
    # Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
    #
    
    apiVersion: database.oracle.com/v1alpha1
    kind: SingleInstanceDatabase
    metadata:
      # Creates base sidb-sample. Use singleinstancedatabase_clone.yaml for cloning
      #                           and singleinstancedatabase_patch.yaml for patching
      name: sidb-sample
      namespace: default
    spec:
    
      ## Use only alphanumeric characters for sid
      sid: ORCL1
    
      ## DB edition.
      edition: enterprise
    
      ## Secret containing SIDB password mapped to secretKey 
      adminPassword:
        secretName: db-admin-secret
    
      ## DB character set
      charset: AL32UTF8
    
      ## PDB name
      pdbName: orclpdb1
    
      ## Enable/Disable ArchiveLog. Should be true to allow DB cloning
      archiveLog: true
    
      ## Database image details
      image:
        pullFrom: container-registry.oracle.com/database/enterprise:latest
        pullSecrets: oracle-container-registry-secret
    
      ## size is the required minimum size of the persistent volume
      ## storageClass is specified for automatic volume provisioning
      ## accessMode can only accept one of ReadWriteOnce, ReadWriteMany
      persistence:
        size: 100Gi
        ## oci-bv applies to OCI block volumes. Use "standard" storageClass for dynamic provisioning in Minikube. Update as appropriate for other cloud service providers
        storageClass: "oci-bv"
        accessMode: "ReadWriteOnce"
    
      ## Count of Database Pods.
      replicas: 1
    
      ## Type of service . Applicable on cloud enviroments only
      ## if loadBalService : false, service type = "NodePort" else "LoadBalancer"
      loadBalancer: true  
    
  3. 관리자 암호를 위한 Secret을 데이터베이스 생성용 YAML에서 지정한 이름으로 만듭니다.

    cat <<EOF | kubectl apply -f -
    ## Oracle Database Free Admin password secret
    apiVersion: v1
    kind: Secret
    metadata:
      name: db-admin-secret
      namespace: default
    type: Opaque
    stringData:
      ## Specify your DB password here
      oracle_pwd: Welcome_SIDB_1234
    EOF
    
  4. 데이터베이스 생성용 YAML 파일을 통해 데이터베이스를 생성합니다.

    kubectl apply -f singleinstancedatabase_create.yaml
    
  5. 처음 실행하는 경우를 포함하여 Worker Node에 이미지가 없으면, 이미지를 가져오는데 시간이 걸립니다. 컨테이너 이미지 파일 용량이 커서 오래 걸릴 수 있습니다. (2023년 10월 기준, 8.58GB)

  6. 데이터베이스 상태 status가 Healthy인지 확인합니다.

    $ kubectl get SingleInstanceDatabase
    NAME          EDITION      STATUS    ROLE      VERSION      CONNECT STR               TCPS CONNECT STR   OEM EXPRESS URL
    sidb-sample   Enterprise   Healthy   PRIMARY   21.3.0.0.0   158.180.xx.x:1521/ORCL1   Unavailable        https://158.180.xx.x:5500/em
    
  7. CONNECT STR 칼럼, OEM EXPRESS URL 칼럼값을 확인합니다.

  8. OEM EXPRESS URL 주소로 접속합니다. Self-Signed 인증서 문제 확인 후 그대로 접속합니다.

    • 접속 주소: 예, https://158.180.xx.x:5500/em
    • Username: SYS
    • Password: 관리자 Secret 생성시 사용한 패스워드
    • Container Name: 입력안함
  9. 로그인한 Enterprise Manager(EM) 화면 예시입니다.

    image-20231030165735298

호스트에서 SQL Developer로 접속해 보기
  1. 개발자 데스크탑/랩탑에 사용할 클라이언트를 가정하여, SQL Developer로 아래와 같이 접속할 수 있습니다.

  2. 새 데이터베이스 접속을 만듭니다.

    • 접속 세부 정보: Connection String에 있던 정보 사용
    • 사용자 이름/비밀번호: SYS / 관리자 패스워드
    • 롤: SYS 유저로 접속시 SYSDBA 선택

    image-20231030170656466

  3. 접속 테스트를 하면 성공하는 것을 볼 수 있습니다.

멀티 Replica로 실행하기
  1. 스케일합니다.

    kubectl scale --replicas=2 SingleInstanceDatabase/sidb-sample
    
  2. 스케일 후 Pod를 조회합니다.

    $ kubectl get pod
    NAME                                        READY   STATUS    RESTARTS   AGE
    sidb-sample-8xe7h                           1/1     Running   0          4m43s
    sidb-sample-a28ph                           0/1     Running   0          2m47s
    
  3. 스케일 후 나중에 기동한 두 번째 Pod의 로그를 확인해 봅니다.

    $ kubectl logs -f sidb-sample-a28ph
    ...
    
    Connected to an idle instance.
    
    SQL> ORACLE instance shut down.
    SQL> ORACLE instance started.
    
    Total System Global Area 1610612080 bytes
    Fixed Size                  9686384 bytes
    Variable Size             503316480 bytes
    Database Buffers         1090519040 bytes
    Redo Buffers                7090176 bytes
    SQL> Disconnected from Oracle Database 21c Enterprise Edition Release 21.0.0.0.0 - Production
    Version 21.3.0.0.0
    [2023:10:30 08:28:06]: Releasing lock .ORCL1.create_lck
    [2023:10:30 08:28:06]: Lock released .ORCL1.create_lck
    [2023:10:30 08:28:06]: Acquiring lock .ORCL1.exist_lck with heartbeat 30 secs
    
  4. 현재 RAC를 지원하지 않습니다. 그래서 현재 버전에서 Replica만 2개 이상으로 늘리면, 실제 실행중인 Active Pod 이외의 Pod는 컨테이너는 실행되었지만, 아직 READY 상태가 아닙니다. Active Pod 장애시 Fail Over를 준비하고 있는 상태이며, 로그 상에서 lock을 통해 Active Pod로 전환할 지를 체크하고 있는 것을 볼 수 있습니다.

  5. PV의 AccessMode에 따라 ReadWriteOnce인 경우 같은 Worker Node에 Replica Pod가 추가 생성됩니다. File Storage 서비스를 사용하여 ReadWriteMany인 경우에는 다른 Worker Node에 Replica Pod들이 추가 생성됩니다. 두 번째이후의 Pod들은 빠른 Fail Over를 위한 준비 상태로 대기한다고 이해하면 됩니다. 미리 만들어 놓지 않으면, 실행될 Worker Node에 이미지 파일이 없는 경우 이미지 Pull 시간, 그리고 DB 생성 시간 등의 시간 까지 Fail Over를 위해 신규 Pod가 Ready가 될때 까지 총 시간이 길어지기 때문에 이 시간을 줄이는 용도로 사용할 수 있습니다.



이 글은 개인으로서, 개인의 시간을 할애하여 작성된 글입니다. 글의 내용에 오류가 있을 수 있으며, 글 속의 의견은 개인적인 의견입니다.

Last updated on 30 Oct 2023