oracle19c的k8s部署

前提条件

1、首先要有一个oracle 账号

2、需要一台能连接网络并安装docker的机器用Oracle账号登录Home

点击database 跳转到下一个页面

记得一定sign in ,否则无法拉取镜像

docker pull
container-registry.oracle.com/database/enterprise:latest

执行拉取后使用镜像进行部署

oracle-dplm.yml

apiVersion: v1
kind: Namespace
metadata:
  name: test-oracle

---
apiVersion: v1
kind: ConfigMap
metadata:
  name: oracle-init-script
  namespace: test-oracle
data:
  init.sh: |
    # 这里粘贴你的init.sh脚本内容
    echo "non-cdb setup"

    sed -i -e 's/^createAsContainerDatabase=.*/createAsContainerDatabase=false/g' \n    -e 's/^numberOfPDBs=.*/numberOfPDBs=0/g' \n    -e 's/^emConfiguration=.*/emConfiguration=NONE/g' \n    -e 's/^pdbName=###ORACLE_PDB###/#pdbName=###ORACLE_PDB###/g'  \n    -e 's/^pdbAdminPassword=###ORACLE_PWD###/#pdbAdminPassword=###ORACLE_PWD###/g' \n    /opt/oracle/dbca.rsp.tmpl

    sed -i -e 's/ALTER PLUGGABLE DATABASE/-- ALTER PLUGGABLE DATABASE/g' \n    -e 's/EXEC DBMS_XDB_CONFIG/-- EXEC DBMS_XDB_CONFIG/g'  \n    /opt/oracle/createDB.sh

    sed -i -e 's/pdbs;/database;/g' /opt/oracle/checkDBStatus.sh

    egrep 'createAsContainerDatabase=|numberOfPDBs=|emConfiguration=|pdbName=|pdbAdminPassword=' /opt/oracle/dbca.rsp.tmpl

    grep 'ALTER PLUGGABLE DATABASE' /opt/oracle/createDB.sh
    grep DBMS_XDB_CONFIG /opt/oracle/createDB.sh

    grep database /opt/oracle/checkDBStatus.sh

    echo "run /opt/oracle/runOracle.sh"

    bash /opt/oracle/runOracle.sh

---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: oracle-oradata-pv
spec:
  capacity:
    storage: 10Gi
  accessModes:
    - ReadWriteOnce
  persistentVolumeReclaimPolicy: Retain
  hostPath:
    path: /home/testoraclepvc


---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: oracle-oradata-pvc
  namespace: test-oracle
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 10Gi


---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: oracle-deployment
  namespace: test-oracle
spec:
  replicas: 1
  selector:
    matchLabels:
      app: oracle
  template:
    metadata:
      labels:
        app: oracle
    spec:
      containers:
      - name: oracle
        image: container-registry-tokyo.oracle.com/database/enterprise:19.3.0.0
        imagePullPolicy: IfNotPresent
        env:
        - name: TZ
          value: Asia/Shanghai
        - name: ORACLE_SID
          value: ORCL
        - name: ORACLE_PWD
          value: "123456"
        - name: ENABLE_ARCHIVELOG
          value: "false"
        - name: ORACLE_CHARACTERSET
          value: AL32UTF8
        - name: ORACLE_BASE
          value: /opt/oracle
        - name: ORACLE_HOME
          value: /opt/oracle/product/19c/dbhome_1
        - name: PATH
          value: /opt/oracle/product/19c/dbhome_1/bin:/opt/oracle/product/19c/dbhome_1/OPatch/:/usr/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
        command: ["/bin/bash", "-c", "/opt/oracle/init.sh"]
        volumeMounts:
        - name: init-script
          mountPath: /opt/oracle/init.sh
          subPath: init.sh
        - name: oradata
          mountPath: /opt/oracle/oradata
        resources:
          limits:
            memory: "6Gi"
          requests:
            memory: "2Gi"
        ports:
        - containerPort: 1521
        - containerPort: 8080
      volumes:
      - name: init-script
        configMap:
          name: oracle-init-script
          defaultMode: 493
      - name: oradata
        persistentVolumeClaim:
          claimName: oracle-oradata-pvc

oracle-service.yaml

apiVersion: v1
kind: Service
metadata:
  name: oracle-service
  namespace: test-oracle
spec:
  type: NodePort
  selector:
    app: oracle
  ports:
  - name: oracle-port  # 添加端口名称
    port: 1521         # 服务内部使用的端口
    targetPort: 1521   # 容器中监听的端口
    nodePort: 31521    # NodePort 类型使用的端口
  - name: http-port    # 添加另一个端口名称
    port: 8080         # 另一个服务端口
    targetPort: 8080
    nodePort: 31522     # 可选,NodePort 类型的另一个端口
相关推荐
斯普信专业组2 小时前
K8s企业应用之容器化迁移
云原生·容器·kubernetes
颜淡慕潇2 小时前
【K8S系列】Kubernetes 中 Service IP 分配 问题及解决方案【已解决】
后端·云原生·容器·kubernetes
陈小肚2 小时前
k8s 1.28.2 集群部署 Thanos 对接 MinIO 实现 Prometheus 数据长期存储
kubernetes·prometheus·thanos
YCyjs2 小时前
Kubeadm搭建k8s
容器·kubernetes
摇曳 *2 小时前
Kubernetes:(三)Kubeadm搭建K8s 1.20集群
云原生·容器·kubernetes
网络笨猪2 小时前
K8S 容器可视化管理工具-kuboard 监控管理工具搭建
云原生·容器·kubernetes
陈小肚3 小时前
k8s 1.28.2 集群部署 NFS server 和 NFS Subdir External Provisioner
云原生·容器·kubernetes
ps酷教程4 小时前
docker基础篇(尚硅谷)
运维·docker·容器
CloudJourney5 小时前
初始Docker
运维·docker·容器
丶21366 小时前
【云原生】云原生后端详解:架构与实践
后端·云原生·架构