類似 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;