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

数据库就可以使用了。

相关推荐
johnny23318 小时前
运维管理面板:AcePanel、OpenOcta、DeepSentry
运维
青梅橘子皮18 小时前
Linux---基本指令
linux·运维·服务器
REDcker19 小时前
Linux信号机制详解 POSIX语义与内核要点 sigaction与备用栈实践
linux·运维·php
绘梨衣54719 小时前
Docker+FastAPI+MySQL 项目部署报错汇总
mysql·docker·fastapi
cui_ruicheng20 小时前
Linux进程间通信(三):System V IPC与共享内存
linux·运维·服务器
蚰蜒螟20 小时前
深入 Linux 内核同步机制:从 futex 到 spinlock 的完整旅程
linux·windows·microsoft
dllmayday21 小时前
Linux 上用终端连接 WiFi
linux·服务器·windows
ACP广源盛1392462567321 小时前
IX8024与科学大模型的碰撞@ACP#筑牢科研 AI 算力高速枢纽分享
运维·服务器·网络·数据库·人工智能·嵌入式硬件·电脑
百年੭ ᐕ)੭*⁾⁾1 天前
docker使用neo4j
docker·容器·neo4j
峥无1 天前
Linux系统编程基石:静态库·动态库·ELF文件·进程地址空间全景图
linux·运维·服务器