参考文章:https://blog.csdn.net/weixin_44593275/article/details/124856201
docker拉取文件
docker pull loliconneko/oracle-ee-11g
推送到私库harbor
#标记镜像
docker tag loliconneko/oracle-ee-11g:latest ren:8088/oracle/loliconneko/oracle-ee-11g:v11.2.0.4
#推送到远端
docker push ren:8088/oracle/loliconneko/oracle-ee-11g:v11.2.0.4
扩展k8s端口
参考文章
https://blog.csdn.net/weixin_44593275/article/details/124856137
创建oracle pod
注意:nfs要选主节点的
apiVersion: v1
kind: Service
metadata:
name: oralce-svc
namespace: my-oracle
labels:
app: oralce
spec:
type: NodePort
ports:
- port: 1521
targetPort: 1521
nodePort: 1521
name: oracle1521
- port: 8080
targetPort: 8080
name: oralce8080
selector:
app: oralce
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: oralce
namespace: my-oracle
spec:
replicas: 1
selector:
matchLabels:
app: oralce
strategy:
type: Recreate
template:
metadata:
labels:
app: oralce
spec:
containers:
- image: ren:8088/oracle/loliconneko/oracle-ee-11g@sha256:257908b404ac17df681e4054f852a5f8ad8563169d9cc68578bae269c93f3964
name: oralce
#- containerPort: 1521
# name: oralce1521
#- containerPort: 8080
# name: oralce8080
volumeMounts:
- name: oralce-data
mountPath: /u01/app/oracle
volumes:
- name: oralce-data
nfs:
path: /nfs/data/oracle
server: ren
查看pod
查看service
kubectl get svc -n my-oracle
查看oracle pod 安装进度
kubectl logs -f oralce-778489db6f-4c6tm -n my-oracle
进入oracle pod
kubectl get pod -n my-oracle
kubectl exec -it oralce-778489db6f-nfz79 bash -n my-oracle
服务端启用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
vi /etc/profile
# 在文件最后写上下面内容
export ORACLE_HOME=/u01/app/oracle-product/11.2.0/EE
export ORACLE_SID=EE
export PATH=$ORACLE_HOME/bin:$PATH
# 保存后执行source /etc/profile 加载环境变量
创建软链接
ln -s $ORACLE_HOME/bin/sqlplus /usr/bin
切换到oracle用户
su - oracle
登录sqlplus
sqlplus / as sysdba
客户端启用sqlplus
选择k8s集群内任意一机器,安装sqlplus
参考文章:
https://rainylog.com/post/install-sqlplus-on-centos/
https://blog.51cto.com/zhangxueliang/4953116
连接
sqlplus system/oracle@//bai:1521/EE.oracle.docker
oracle pod内部操作
创建用户并授权
sqlplus / as sysdba;
SQL> create user sync_user identified by qwe123789;
SQL> grant connect,resource,DBA to sync_user;