前提条件
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 类型的另一个端口