我的容器是从头开始构建的 Oracle 18 xe 来源:github。
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
13afebdbdbdc oracle/database:18.4.0-xe "/bin/sh -c 'exec $O…" 8 hours ago Up 7 hours (healthy)
$ docker exec -it xedb ps -ef | grep xe
oracle 1736 1 0 09:42 ? 00:00:01 xe_pmon_XE
oracle 1738 1 0 09:42 ? 00:00:00 xe_clmn_XE
------------------------
59 lines......
$ docker exec -it --user=oracle xedb sqlplus / as sysdba
SQL*Plus: Release 18.0.0.0.0 - Production on Thu Jun 18 15:45:11 2020
Version 18.4.0.0.0
Copyright (c) 1982, 2018, Oracle. All rights reserved.
Connected to:
Oracle Database 18c Express Edition Release 18.0.0.0.0 - Production
Version 18.4.0.0.0
SQL> show con_name -- container name
NAME
------------------------------
CDB$ROOT
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 XEPDB1 READ WRITE NO
SQL>
实例已启动并运行以及可插拔数据库
如果您无法从 docker 终端以 sysdba 身份登录。您可以尝试使用 bash 命令
$ docker exec -it --user=oracle xedb bash
[oracle@13afebdbdbdc /]$
如果作为 Oracle 用户排除 --user 参数不起作用,请使用 bash 命令
$ docker exec -it xedb bash
bash-4.2# su oracle -- switch oracle user
[oracle@13afebdbdbdc /]$ echo $ORACLE_HOME -- verify environment
/opt/oracle/product/18c/dbhomeXE
[oracle@13afebdbdbdc /]$ echo $ORACLE_SID
XE
如果您的环境没有返回任何内容,您可以使用以下命令设置环境
[oracle@13afebdbdbdc /]$ . oraenv -- dot space oraenv
ORACLE_SID = [XE] ?
The Oracle base remains unchanged with value /opt/oracle
[oracle@13afebdbdbdc /]$ rlwrap sqlplus / as sysdba
SQL*Plus: Release 18.0.0.0.0 - Production on Thu Jun 18 15:58:39 2020
Version 18.4.0.0.0
Copyright (c) 1982, 2018, Oracle. All rights reserved.
Connected to an idle instance
SQL> startup -- start the database
ORACLE instance started.
Total System Global Area 1610609288 bytes
Fixed Size 8897160 bytes
Variable Size 620756992 bytes
Database Buffers 973078528 bytes
Redo Buffers 7876608 bytes
Database mounted.
Database opened.
SQL> select open_mode from v$database; -- check database status
OPEN_MODE
--------------------
READ WRITE
SQL> show pdbs -- check pdb open mode is read write
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 XEPDB1 READ WRITE NO
如果你碰巧看到 Pluggable 数据库处于挂载状态
SQL> show pdbs -- pdb xepdb1 is in mount state
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 XEPDB1 MOUNTED
SQL> alter pluggable database xepdb1 open; -- open pdb
Pluggable database altered.
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 XEPDB1 READ WRITE NO
SQL> alter pluggable database xepdb1 save state ; --------next restart pdb will be opened automagically
Pluggable database altered.