利用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.

数据库就可以使用了。

相关推荐
CCPC不拿奖不改名2 小时前
大模型推理架构与开源生态知识整理
数据库·windows·python·架构·langchain·开源·github
敖行客 Allthinker4 小时前
Parallels Ubuntu虚拟机项目如何让手机访问?完整解决方案
linux·运维·ubuntu
王维同学5 小时前
[自学][Windows C++]RunOnceEx 注册表分组键的安全遍历
c++·windows·安全·开源
BullSmall5 小时前
Anolis OS 8.10 完整安装 Docker CE(生产可用,解决 podman 冲突)
docker·容器·podman
元Y亨H5 小时前
生产环境监控与故障应急处理(5-5-5 标准)指南
运维
踏月的造梦星球6 小时前
达梦数据库执行计划与性能分析入门:EXPLAIN、AUTOTRACE 与 ET
服务器·数据库·oracle
观山岳五楼6 小时前
Ubuntu 24 怎么使用Ubuntu 20 的镜像源
linux·运维·ubuntu
寒晓星7 小时前
[linux]线程及多线程
linux·运维
慧一居士8 小时前
Linux如何设置固定的静态ip
运维
梦梦代码精8 小时前
开源AI应用平台BuildingAI解析:插件化架构、应用市场与热门案例
人工智能·机器学习·docker·开源