类似 Oracle 的重量级的数据库都是不建议上云的,对硬件要求苛刻;不过重量级的数据库上云也是趋势,希望 Oralce 赶快改架构;

使用的 oralce 镜像是来自 registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g

apiVersion: apps/v1beta2
kind: Deployment
metadata:
name: oracle
spec:
selector:
matchLabels:
k8s-app: oracle
replicas: 1
template:
metadata:
labels:
k8s-app: oracle
app: oracle
spec:
containers:
- name: oracle
image: registry.cn-hangzhou.aliyuncs.com/fengxin58/oracle:11.2
ports:
- containerPort: 1521
apiVersion: v1
kind: Service
metadata:
name: oracle
spec:
ports:
- name: oracle
nodePort: 31521
port: 1521
protocol: TCP
targetPort: 1521
selector:
k8s-app: oracle
type: LoadBalancer

使用上面配置一个 serice ,阿里云会自动创建一个负载均衡器,然后开放 targetPort 指定的 1521端口 。

$ kubectl exec -it oracle-6495bd4bd6-kh5ct /bin/bash
$ source /home/oracle/.bash_profile
$ sqlplus /nolog
SQL> connect /as sysdba
SQL> create user test identified by test;
SQL> grant connect,resource,dba to test;
SQL> select instance_name from V$instance;
SQL> show parameter service;