oracle / oracle-database-operator

The Oracle Database Operator for Kubernetes (a.k.a. OraOperator) helps developers, DBAs, DevOps and GitOps teams reduce the time and complexity of deploying and managing Oracle Databases. It eliminates the dependency on a human operator or administrator for the majority of database operations.
Universal Permissive License v1.0
141 stars 45 forks source link

23 Free won't start listener #101

Closed khooz closed 5 months ago

khooz commented 6 months ago

Since the rebranding from 23c to 23ai, the older image has been removed and a new one made available. I had initialized a single-instance DB using the old image. Unfortunately I used the latest tag. When I started k8s on docker desktop after the rebrand, I noticed the new image has been pulled but it won't. I used kubectl describe and log commands and found out the following statements:

PS C:\Users\Admin> kubectl logs -f pod/oracle-db-5b1bm -n database
Defaulted container "oracle-db" out of: oracle-db, init-permissions (init), init-prebuiltdb (init)
Starting Oracle Net Listener.
Starting Oracle Database instance FREE.
Oracle Database instance FREE started.

Failed to start Oracle Net Listener using /opt/oracle/product/23ai/dbhomeFree/bin/tnslsnr and Oracle Database using /opt/oracle/product/23ai/dbhomeFree/bin/sqlplus.
ORACLE_HOME = [/home/oracle] ? ORACLE_BASE environment variable is not being set since this
information is not available for the current user ID .
You can set ORACLE_BASE manually if it is required.
Resetting ORACLE_BASE to its previous value or ORACLE_HOME
The Oracle base remains unchanged with value /opt/oracle
/opt/oracle/setPassword.sh: line 28: sqlplus: command not found
ORACLE_HOME = [/home/oracle] ? ORACLE_BASE environment variable is not being set since this
information is not available for the current user ID .
You can set ORACLE_BASE manually if it is required.
Resetting ORACLE_BASE to its previous value or ORACLE_HOME
The Oracle base remains unchanged with value /opt/oracle
/opt/oracle/checkDBStatus.sh: line 26: sqlplus: command not found
#####################################
########### E R R O R ###############
DATABASE SETUP WAS NOT SUCCESSFUL!
Please check output for further info!
########### E R R O R ###############
#####################################
The following output is now a tail of the alert.log:
FREEPDB1(3):Tablespace created: USERS ts# 6
FREEPDB1(3):Completed: CREATE SMALLFILE TABLESPACE "USERS" LOGGING  DATAFILE  '/opt/oracle/oradata/FREE/FREEPDB1/users01.dbf' SIZE 5M REUSE AUTOEXTEND ON NEXT  1280K MAXSIZE UNLIMITED  EXTENT MANAGEMENT LOCAL  SEGMENT SPACE MANAGEMENT  AUTO
FREEPDB1(3):ALTER DATABASE DEFAULT TABLESPACE "USERS"
FREEPDB1(3):Completed: ALTER DATABASE DEFAULT TABLESPACE "USERS"
ALTER PLUGGABLE DATABASE FREEPDB1 SAVE STATE
Completed: ALTER PLUGGABLE DATABASE FREEPDB1 SAVE STATE
2024-04-24T21:27:27.562404+00:00
ALTER SYSTEM SET local_listener='' SCOPE=BOTH;
ALTER PLUGGABLE DATABASE FREEPDB1 SAVE STATE
Completed: ALTER PLUGGABLE DATABASE FREEPDB1 SAVE STATE

Here's my setup:

apiVersion: v1
kind: Namespace
metadata:
 name: database
---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: oracledb-vol
spec:
  capacity:
    storage: 100Gi
  accessModes:
    - ReadWriteOnce
    - ReadWriteMany
  persistentVolumeReclaimPolicy: Retain
  hostPath:
    path: "/run/desktop/mnt/host/d/dev/data/oradata"
    type: Directory
  storageClassName: hostpath
  volumeMode: Filesystem
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: oracledb-vclaim
  namespace: database
spec:
  resources:
    requests:
      storage: 100Gi
  volumeMode: Filesystem
  accessModes:
    - ReadWriteMany
    - ReadWriteOnce
  volumeName: oracledb-vol
---
apiVersion: v1
kind: Secret
type: Opaque
metadata:
  name: db-admin-secret
  namespace: database
data:
  oracle_pwd: <REDACTED>
---
---
#
# 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: oracle-db
  namespace: database
spec:

  ## Use only alphanumeric characters for sid
  sid: FREE

  ## DB edition
  edition: free

  ## Secret containing SIDB password mapped to secretKey
  adminPassword:
    secretName: db-admin-secret

  ## DB character set
  charset: AL32UTF8

  ## PDB name
  pdbName: FREEPDB1

  ## Enable/Disable Flashback
  flashBack: true

  ## Enable/Disable ArchiveLog. Should be true to allow DB cloning
  archiveLog: true

  ## Enable/Disable ForceLogging
  forceLog: true

  ## Enable TCPS
  enableTCPS: false

  listenerPort: 31521
  tcpsListenerPort: 31522

  ## Database image details
  image:
    ## Oracle Database Free is only supported from DB version 23.2 onwards
    pullFrom: container-registry.oracle.com/database/free:23.4.0.0
    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:
    volumeName: oracledb-vol
    size: 100Gi
    storageClass: hostpath
    ## oci-bv applies to OCI block volumes. Use "standard" storageClass for dynamic provisioning in Minikube. Update as appropriate for other cloud service providers
    accessMode: ReadWriteMany

  ## Type of service . Applicable on cloud enviroments only
  ## if loadBalService : false, service type = "NodePort" else "LoadBalancer"
  loadBalancer: false

  ## Count of Database Pods. Should be 1 for express edition.
  replicas: 1
khooz commented 6 months ago

I have deleted the contents of the PV and restarted the pod. It created a new instance and is now running. How ever I have lost my data. It was OK with this test environment but I think an autonomous upgrade path should be incorporated into images. Also digging through the alert logs I have noticed that domain name is predefined. Is there a way to join or initialize a DB to a domain so it could be monitored through cloud control?

yunus-qureshi commented 6 months ago

@khooz which domain name are you referring to here? and what is it pre-defined as?

oraclesean commented 6 months ago

I have deleted the contents of the PV and restarted the pod. It created a new instance and is now running. How ever I have lost my data. It was OK with this test environment but I think an autonomous upgrade path should be incorporated into images.

If the database wasn't configured to use a persistent volume for its data, dropping/recreating the pod deletes the data. This is true of any database, not just Oracle. :)

khooz commented 6 months ago

Thanks @oraclesean

If the database wasn't configured to use a persistent volume for its data, dropping/recreating the pod deletes the data. This is true of any database, not just Oracle. :)

I have manually setup the PV to be retained. as you can see here:

---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: oracledb-vol
spec:
  capacity:
    storage: 100Gi
  accessModes:
    - ReadWriteOnce
    - ReadWriteMany
  persistentVolumeReclaimPolicy: Retain
  hostPath:
    path: "/run/desktop/mnt/host/d/dev/data/oradata"
    type: Directory
  storageClassName: hostpath
  volumeMode: Filesystem
---
  persistence:
    volumeName: oracledb-vol
    size: 100Gi
    storageClass: hostpath
    ## oci-bv applies to OCI block volumes. Use "standard" storageClass for dynamic provisioning in Minikube. Update as appropriate for other cloud service providers
    accessMode: ReadWriteMany

It was working fine with image using 23c as brand (which is not available in the repository now). I have deleted and re-applied multiple times using the same image and PV before. I can do it now with 23ai too, but it seems there were no interoperability or upgrade path available.

yunus-qureshi commented 6 months ago

This is expected. There is no upgrade path for Free DB releases. Upgrade and patching are only supported with Enterprise edition.