参考文章:https://blog.csdn.net/weixin_44593275/article/details/124856201

docker拉取文件

  1. docker pull loliconneko/oracle-ee-11g

查看镜像
image.png

推送到私库harbor

  1. #标记镜像
  2. docker tag loliconneko/oracle-ee-11g:latest ren:8088/oracle/loliconneko/oracle-ee-11g:v11.2.0.4
  3. #推送到远端
  4. docker push ren:8088/oracle/loliconneko/oracle-ee-11g:v11.2.0.4

image.png

扩展k8s端口

参考文章
https://blog.csdn.net/weixin_44593275/article/details/124856137

创建oracle pod

注意:nfs要选主节点的

  1. apiVersion: v1
  2. kind: Service
  3. metadata:
  4. name: oralce-svc
  5. namespace: my-oracle
  6. labels:
  7. app: oralce
  8. spec:
  9. type: NodePort
  10. ports:
  11. - port: 1521
  12. targetPort: 1521
  13. nodePort: 1521
  14. name: oracle1521
  15. - port: 8080
  16. targetPort: 8080
  17. name: oralce8080
  18. selector:
  19. app: oralce
  20. ---
  21. apiVersion: apps/v1
  22. kind: Deployment
  23. metadata:
  24. name: oralce
  25. namespace: my-oracle
  26. spec:
  27. replicas: 1
  28. selector:
  29. matchLabels:
  30. app: oralce
  31. strategy:
  32. type: Recreate
  33. template:
  34. metadata:
  35. labels:
  36. app: oralce
  37. spec:
  38. containers:
  39. - image: ren:8088/oracle/loliconneko/oracle-ee-11g@sha256:257908b404ac17df681e4054f852a5f8ad8563169d9cc68578bae269c93f3964
  40. name: oralce
  41. #- containerPort: 1521
  42. # name: oralce1521
  43. #- containerPort: 8080
  44. # name: oralce8080
  45. volumeMounts:
  46. - name: oralce-data
  47. mountPath: /u01/app/oracle
  48. volumes:
  49. - name: oralce-data
  50. nfs:
  51. path: /nfs/data/oracle
  52. server: ren

查看pod

image.png
image.png
image.png

查看service

  1. kubectl get svc -n my-oracle

image.png

查看oracle pod 安装进度

  1. kubectl logs -f oralce-778489db6f-4c6tm -n my-oracle

image.png

进入oracle pod

  1. kubectl get pod -n my-oracle

image.png

  1. kubectl exec -it oralce-778489db6f-nfz79 bash -n my-oracle

image.png

服务端启用sqlplus

参考文章:https://blog.csdn.net/qq_36039236/article/details/124224500?spm=1001.2014.3001.5502

hostname:bai
port: 1521
sid: EE
service name: EE.oracle.docker
username: system
password: oracle

  1. vi /etc/profile
  2. # 在文件最后写上下面内容
  3. export ORACLE_HOME=/u01/app/oracle-product/11.2.0/EE
  4. export ORACLE_SID=EE
  5. export PATH=$ORACLE_HOME/bin:$PATH
  6. # 保存后执行source /etc/profile 加载环境变量

创建软链接

  1. ln -s $ORACLE_HOME/bin/sqlplus /usr/bin

切换到oracle用户

  1. su - oracle

image.png

登录sqlplus

  1. sqlplus / as sysdba

客户端启用sqlplus

选择k8s集群内任意一机器,安装sqlplus

参考文章:
https://rainylog.com/post/install-sqlplus-on-centos/
https://blog.51cto.com/zhangxueliang/4953116

连接

  1. sqlplus system/oracle@//bai:1521/EE.oracle.docker

image.png

oracle pod内部操作

创建用户并授权

  1. sqlplus / as sysdba;
  2. SQL> create user sync_user identified by qwe123789;
  3. SQL> grant connect,resource,DBA to sync_user;