1、docker 镜像拉取以及启动
-
docker hub拉取镜像
docker pull jaspeen/oracle-11g
-
创建宿主机oracle安装目录以及数据目录
mkdir -p /server/oracle mkdir -p /server/dpdump
-
下载 oracle 并存放于服务器中
oracle 下载网址:https://www.oracle.com/database/technologies/oracle-database-software-downloads.html
-
解压缩并删除安装包
压缩包放到/server/oracle目录
[root@centos7 oracle]# ls linux.x64_11gR2_database_1of2 linux.x64_11gR2_database_2of2
unzip linux.x64_11gR2_database_1of2.zip unzip linux.x64_11gR2_database_2of2.zip
[root@centos7 oracle]# ls database
-
启动 docker
docker run -d -p 1521:1521 -v /server/oracle:/install -v /server/dpdump:/opt/oracle/dpdump --name=oracle11g jaspeen/oracle-11g
-
查看启动状态:
[root@centos7 oracle]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES c5e913b4e96b jaspeen/oracle-11g "/assets/entrypoin..." 3 days ago Up 3 seconds 0.0.0.0:1521->1521/tcp, 8080/tcp oracle11g2、自己的 docker 镜像制作
2、自己的 docker 镜像制作
-
由于版权问题,拉取下来的 docker 镜像是不包含任何版本的 oracle 的
-
故在启动 docker 后,需要创建一个自己的镜像以备使用
[root@centos7 oracle]# docker commit oracle11g oracle11g-installed [root@centos7 oracle]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE oracle11g-installed latest 4a55732efad1 3 days ago 2.83 GB docker.io/jaspeen/oracle-11g latest 0c8711fe4f0f 4 years ago 281 MB
3、使用pl/sql连接oracle
-
进入oracle容器
docker exec -it 8164f1475ee5 /bin/bash
-
修改oracle环境变量
[root@8164f1475ee5 /]# cd etc [root@8164f1475ee5 etc]# vi profile #在最后增加 export ORACLE_HOME=/opt/oracle/app/product/11.2.0/dbhome_1 export ORACLE_SID=orcl export PATH=$ORACLE_HOME/bin:$PATH #保存离开 :wq [root@localhost ~] source /etc/profile #使得修改生效
-
登陆oracle账号
[root@8164f1475ee5 /]# su - oracle Last login: Tue Jun 9 13:01:34 UTC 2020 [oracle@8164f1475ee5 ~]$ sqlplus /nolog SQL*Plus: Release 11.2.0.1.0 Production on Tue Jun 9 13:15:18 2020 Copyright (c) 1982, 2009, Oracle. All rights reserved. SQL> conn /as sysdba Connected. SQL> alter user system identified by system; User altered. SQL> alter user sys identified by sys; User altered. SQL> create user ETS identified by ETS; User created. SQL> grant connect,resource,dba to ETS; Grant succeeded. SQL> exit Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options [oracle@8164f1475ee5 ~]$ exit logout [root@8164f1475ee5 /]#
-
使用pl/sql连接