利用docker在windows 11 wsl中安装oracle 12cR2

  1. 拉取镜像

    docker pull registry.cn-hangzhou.aliyuncs.com/lhrbest/oracle_12cr2_ee_lhr_12.2.0.1:2.0

    Trying to pull registry.cn-hangzhou.aliyuncs.com/lhrbest/oracle_12cr2_ee_lhr_12.2.0.1:2.0...
    Getting image source signatures
    Copying blob 2bbf3863a307 done
    Copying config eb1a87913a done
    Writing manifest to image destination
    Storing signatures
    eb1a87913afe19faaa6c654619afcd3d724e9eb69c20e2246290259e6224faca

  2. 查看镜像

    docker image list -a
    REPOSITORY TAG IMAGE ID CREATED SIZE
    registry.cn-hangzhou.aliyuncs.com/lhrbest/oracle_12cr2_ee_lhr_12.2.0.1 2.0 eb1a87913afe 5 years ago 16.2 GB

  3. 创建目录并设置权限

wsl环境, 在C盘d目录下建立oracle12g

复制代码
cd /mnt/c/d
mkdir -p oracle12g/ora_data
mkdir -p oracle12g/data_temp
chmod 777 oracle12g
  1. 启动容器

注意:不要使用刚才创建的目录,否则会找不到路径,如下所示

复制代码
docker run -itd --name oracle12c  \
--privileged=true \
--restart=always \
-p 1521:1521 \
-p 5500:5500 \
-p 5501:5501 \
-p 5522:22 \
-p 3389:3389 \
-v /mnt/c/d/oracle12g/data_temp:/home/oracle/data_temp  \
-v /mnt/c/d/oracle12g/ora_data:/u01/app/oracle/  \
eb1a87913afe init
597bce2c1ffb181001a7adeae6318690170d0cfa7bc5b41db41a254ac2e377b5
docker exec -it oracle12c /bin/bash

[root@597bce2c1ffb /]# su - oracle
Last login: Fri Aug 21 11:24:52 CST 2020 on pts/4
[oracle@597bce2c1ffb ~]$ sqlplus system/oracle
rlwrap: error: Cannot execute sqlplus: No such file or directory

这是因为rlwrap引用的路径被-v 参数指定到了刚才创建的宿主目录,那个目录下没有内容。

正确的写法如下,将刚才创建的目录映射到容器中一个无关的路径/par。在此之前先删除错误的容器。

复制代码
docker stop oracle12c
oracle12c
docker rm oracle12c
597bce2c1ffb181001a7adeae6318690170d0cfa7bc5b41db41a254ac2e377b5
docker run -itd --name oracle12c  \
--privileged=true \
--restart=always \
-p 1521:1521 \
-p 5500:5500 \
-p 5501:5501 \
-p 5522:22 \
-p 3389:3389 \
-v /mnt/c/d/oracle12g/ora_data:/par  \
eb1a87913afe init
03796669a3be7c1ed904ae7d60724a06283af463abd32b06e63d0e273bd47392
docker exec -it oracle12c /bin/bash
[root@03796669a3be /]# su - oracle
Last login: Fri Aug 21 11:24:52 CST 2020 on pts/4
[oracle@03796669a3be ~]$ sqlplus / as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Sun Dec 21 10:26:12 2025

Copyright (c) 1982, 2016, Oracle.  All rights reserved.

Connected to an idle instance.
  1. 启动数据库实例

直接启动报错

复制代码
SYS@lhrcdb1> startup
ORA-00821: Specified value of sga_target 768M is too small, needs to be at least 872M
ORA-01078: failure in processing system parameters

用如下命令将spfile的内容保存到参数文件pfile(文件名是init+ORACLE_SID+.ora), 并退出sqlplus修改pfile相应行,然后进入sqlplus用参数文件pfile启动。

复制代码
SYS@lhrcdb1> create pfile from spfile;

File created.

SYS@lhrcdb1> exit;
Disconnected
[oracle@03796669a3be dbs]$ ls
hc_lhrcdb1.dat  initlhrcdb1.ora  lkLHRCDB1  orapwlhrcdb1  snapcf_lhrcdb1.f  spfilelhrcdb1.ora
hc_lhrsdb.dat   init.ora         lkLHRSDB   orapwlhrsdb   snapcf_lhrsdb.f   spfilelhrsdb.ora
[oracle@03796669a3be dbs]$ vi initlhrcdb1.ora
[oracle@03796669a3be dbs]$ sqlplus / as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Sun Dec 21 10:35:35 2025

Copyright (c) 1982, 2016, Oracle.  All rights reserved.

Connected to an idle instance.

SYS@lhrcdb1> startup pfile='/u01/app/oracle/product/12.2.0.1/dbhome_1/dbs/initlhrcdb1.ora';
ORACLE instance started.

Total System Global Area 1015021568 bytes
Fixed Size                  8800328 bytes
Variable Size             771753912 bytes
Database Buffers          226492416 bytes
Redo Buffers                7974912 bytes
Database mounted.
Database opened.

数据库就可以使用了。

相关推荐
峥无8 小时前
Linux进程信号:从基础概念到内核底层原理
linux·运维·服务器·信号处理
土星云SaturnCloud9 小时前
土星云AI边缘计算SE110S系列模型部署实战-YOLOv5
服务器·人工智能·yolo·docker·边缘计算
北山有鸟9 小时前
用开发板的.config替换ubuntu中内核源码目录的.config
linux·运维·ubuntu
qq_452396239 小时前
第二十篇:《Docker 故障排查常用命令与技巧》
运维·docker·容器
jcbut9 小时前
离线安装dify 1.7
linux·运维·dify
Qiuner9 小时前
Pico 重塑Agent时代人与数据交互方式
windows·docker·ai·架构
云计算磊哥@9 小时前
运维开发宝典024-Linux云计算运维入门阶段总结
linux·运维·运维开发
周小码10 小时前
10分钟搭建私有Git服务器:Soft Serve实战
运维·服务器·git
FL162386312910 小时前
Windows x64 系统安装 ChromeDriver
windows
木雷坞10 小时前
6月 Docker 国内镜像源配置:daemon.json、/v2/ 连通性和 pull 验证
docker·eureka·json