我的docker随笔31:oracle数据库再次部署

本文涉及一种在容器中部署 oracle 数据库的方法。经验证,可达到预期目标,并能应用在实际工作中。

引言

去年曾经部署过 oracle,当时使用阿里云仓库上的镜像,版本为 11.2, 但一直解决不了永久存储问题,后因其它工作的事没有继续。过年期间到现在,内网(人为地)一直断开,无法访问数据库,对工作造成一定的影响,所以有必完成此事。
oracle 官方有创建 docker 的说明(可能是 docker 官方),本文即根据文档进行实践。
本文着重实践性,且必须与生产数据库版本、表名尽量保持一致。

技术小结

  • 宿主机挂载的目录必须能让 uid 为 54321 的用户读写。可创建该 uid 的用户,也可直接设置权限为777。

实践

下载

根据在 github 仓库的 安装说明文档 进行操作。

仓库没有提供 oracle 软件(可能是因为太大了),具体的软件下载可访问此页面 ,本文所用版本为 Linux x86-64 ,名称为 LINUX.X64_193000_db_home.zip ,大小为 2.8GB,md5 为 1858bd0d281c60f4ddabd87b1c214a4f。注意,下载需要登录,先进行注册(注册也花了一定时间)。

按官方说法需将软件压缩包重命名为:linuxx64_19.3.0_database.zip ,但实际并不需要。将 LINUX.X64_193000_db_home.zip 拷贝到 docker-images/OracleDatabase/SingleInstance/dockerfiles/19.3.0 目录。

修改为非CDB方式

自 12 版本后
修改文件所有目录:docker-images/OracleDatabase/SingleInstance/dockerfiles/19.3.0。
修改文件 dbca.rsp.tmpl:

1
2
3
4
5
6
7
8
createAsContainerDatabase=false
numberOfPDBs=0
## 注释掉
#pdbName=###ORACLE_PDB###
#pdbAdminPassword=###ORACLE_PWD###

# em关掉
emConfiguration=NONE

修改文件 createDB.sh 如下语句:

1
2
ALTER PLUGGABLE DATABASE $ORACLE_PDB SAVE STATE;
EXEC DBMS_XDB_CONFIG.SETGLOBALPORTENABLED (TRUE);

修改文件 checkDBStatus.sh:

1
2
3
v\\$pdbs
改为
v\\$database

创建镜像

进入docker-images/OracleDatabase/SingleInstance/dockerfiles 目录,执行命令:

1
./buildContainerImage.sh -e -i -v 19.3.0

注:-i表示不校验md5(如检验md5提示某文件找不到,故自行检验)。
双核4G虚拟机,耗时约40分钟。20核64G服务器耗时约12分钟。

打标签并提交阿里云仓库:

1
2
docker tag oracle/database:19.3.0-ee registry.cn-hangzhou.aliyuncs.com/latelee/database:19.3.0-ee
docker push registry.cn-hangzhou.aliyuncs.com/latelee/database:19.3.0-ee

运行容器

官方示例:

1
2
3
4
5
6
7
8
9
10
11
docker run --name <container name> \
-p <host port>:1521 -p <host port>:5500 \
-e ORACLE_SID=<your SID> \
-e ORACLE_PDB=<your PDB name> \
-e ORACLE_PWD=<your database passwords> \
-e INIT_SGA_SIZE=<your database SGA memory in MB> \
-e INIT_PGA_SIZE=<your database PGA memory in MB> \
-e ORACLE_EDITION=<your database edition> \
-e ORACLE_CHARACTERSET=<your character set> \
-v [<host mount point>:]/opt/oracle/oradata \
oracle/database:19.3.0-ee

说明:
挂载 /opt/oracle/oradata 的目录必须可以由 uid 为 54321 的用户(该用户为容器oracle的 uid)访问,否则容器无法创建目录。实际中,挂载目录权限更改为 777 。
变量及默认值:
ORACLE_SID ORCLCDB
ORACLE_PDB ORCLPDB1
ORACLE_PWD 自动随机产生
ORACLE_CHARACTERSET AL32UTF8
实际:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
docker run -itd \
--name oracle \
-p 1521:1521 \
-e ORACLE_SID=ORCLCDB \
-e ORACLE_PDB=ORCLPDB1 \
-e ORACLE_PWD=123456 \
-e ORACLE_CHARACTERSET=ZHS16GBK \
-e TZ="Asia/Shanghai" \
-v oracledata:/opt/oracle/oradata \
oracle/database:19.3.0-ee


最简单的,无任何功能
docker run -it --rm --name oracle registry.cn-hangzhou.aliyuncs.com/latelee/database:19.3.0-ee bash

加时区的测试:
docker run -it --rm --name oracle -e TZ="Asia/Shanghai" registry.cn-hangzhou.aliyuncs.com/latelee/database:19.3.0-ee bash

实际中使用 docker-compose 启动,docker-compose.yml 文件如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
version: '2'

services:
lloracle:
image: registry.cn-hangzhou.aliyuncs.com/latelee/database:19.3.0-ee
container_name: lloracle
shm_size: 4gb
restart: always
#command:
volumes:
- ./oracle_data/oradata:/opt/oracle/oradata
- ./oracle_data/dbs:/opt/oracle/product/19c/dbhome_1/dbs
- ./oracle_data/admin:/opt/oracle/admin
environment:
- TZ=Asia/Shanghai
- ORACLE_SID=ORCLCDB
- ORACLE_PDB=ORCLPDB1
- ORACLE_PWD=123456
- ORACLE_CHARACTERSET=ZHS16GBK
ports:
- 1521:1521
networks:
- lloracle-net

networks:
lloracle-net:
driver: bridge

注1:INIT_SGA_SIZE、INIT_PGA_SIZE未设置。
注2:设置共享内容为2GB(相当于docker的 –shm-size 参数),设置了东八区时区,映射1521端口。字符编码设置为 GBK,非 UTF8。
注3:在虚拟机耗时约半小时。
注4:在 docker-compose.yml 同一目录下创建三个子目录:oradata、dbs、admin,将三个目录权限改为777。

验证服务

进入容器:

1
docker exec -it lloracle bash

验证:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
$ sqlplus / as sysdba

SQL*Plus: Release 19.0.0.0.0 - Production on Wed Mar 24 15:34:16 2021
Version 19.3.0.0.0

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


Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0

注:此处没有 Connected to an idle instance.

SQL> show pdbs;
SQL> select CDB from v$database; # 显示为NO表示非CDB

CDB
---
NO

创建表空间和用户

创建目录

进入容器,创建目录

1
2
docker exec -it lloracle bash
mkdir /opt/oracle/oradata/FEE_DATA

注:此处是为了创建 54321 用户权限的目录,也可以在宿主机上创建,再用 chown 修改。

在navicat创建表空间和用户名

使用 navicat 连接 oracle,本次连接参数为:
端口:1521
服务名:ORCLCDB
用户及密码:system/123456

结果如图1所示:
图1

点击“其它”、“表空间”、“新建表空间”。在默认“常规”:名称:system01.dbf,大小1,单位G,路径:’/opt/oracle/oradata/FEE_DATA/‘(注意最后的斜杠)。自动扩展:ON。(疑惑:此处的大小表征的是什么?如果后续数据超过1G会如何?)
点击“保存”,输入表空间名: FEE_DATA。

点击“用户”、“用户”,“新建用户”,输入用户名称 FEE (大写),密码 123456,默认表空间选择刚才创建的表空间。“成员属于”,勾选DBA所有项。“保存”。

使用新用户连接

使用 navicat 连接 oracle,本次连接参数为:
端口:1521
服务名:ORCLCDB
用户及密码:FEE/123456

结果如图2所示:
图2

另外,还再次创建另一表空间,另一用户名,再以 FEE 连接,依然可访问另一用户名的表空间。

小结

本文使用非 CDB 方式以 docker 运行 oracle19.3,经初步验证,可以正常使用,至于是否可经长期考验,等后续观察。

成果

本文完成的镜像如下:

1
2
registry.cn-hangzhou.aliyuncs.com/latelee/database:19.3.0-ee      # 非cdb版本
registry.cn-hangzhou.aliyuncs.com/latelee/database:19.3.0-ee-cdb # cdb版本

容器探索

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
容器的用户名:

oracle:x:54321:54321::/home/oracle:/bin/bash

容器中的环境变量:
$ env
ORACLE_SID=ORCLCDB
INSTALL_FILE_1=LINUX.X64_193000_db_home.zip
ORACLE_BASE=/opt/oracle
CHECK_SPACE_FILE=checkSpace.sh
ORACLE_PDB=ORCLPDB1
PWD_FILE=setPassword.sh
TZ=Asia/Shanghai
SLIMMING=true
RUN_FILE=runOracle.sh
CREATE_DB_FILE=createDB.sh
SHLVL=1
ORACLE_PWD=123456
ORACLE_HOME=/opt/oracle/product/19c/dbhome_1

参考

官方仓库:https://github.com/oracle/docker-images
修改后的仓库:https://github.com/latelee/docker-images
安装说明文档
下载软件:https://www.oracle.com/database/technologies/oracle-database-software-downloads.html
共享内存参考:https://blog.csdn.net/weisubao/article/details/108704236
Docker安装Oracle19c(NONCDB): https://www.jianshu.com/p/f0139aff1746
oracle镜像issue:https://github.com/oracle/docker-images/issues/791

构建镜像部分日志:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
Removing intermediate container 2bbee773477c
---> f6b8442fcfaa
Step 19/22 : USER oracle
---> Running in 85995f303fab
Removing intermediate container 85995f303fab
---> 14525605ab30
Step 20/22 : WORKDIR /home/oracle
---> Running in b6c49a7101ee
Removing intermediate container b6c49a7101ee
---> d56853fe77c1
Step 21/22 : HEALTHCHECK --interval=1m --start-period=5m CMD "$ORACLE_BASE/$CHECK_DB_FILE" >/dev/null || exit 1
---> Running in 656e69b54359
Removing intermediate container 656e69b54359
---> c717fbcbc80e
Step 22/22 : CMD exec $ORACLE_BASE/$RUN_FILE
---> Running in 730cea346f50
Removing intermediate container 730cea346f50
---> 492ae2b9dbf8
Successfully built 492ae2b9dbf8
Successfully tagged oracle/database:19.3.0-ee


Oracle Database container image for 'ee' version 19.3.0 is ready to be extended:

--> oracle/database:19.3.0-ee

Build completed in 2288 seconds.

正常启动日志:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# docker-compose up
Starting oracle ... done
Attaching to oracle
oracle | ORACLE EDITION: ENTERPRISE # !!! 版本为商业版
oracle | ORACLE PASSWORD FOR SYS, SYSTEM AND PDBADMIN: 123456 # !!! 密码较简单,下面会出现提示
oracle |
oracle | LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 02-MAR-2021 15:42:22
oracle |
oracle | Copyright (c) 1991, 2019, Oracle. All rights reserved.
oracle |
oracle | Starting /opt/oracle/product/19c/dbhome_1/bin/tnslsnr: please wait...
oracle |
oracle | TNSLSNR for Linux: Version 19.0.0.0.0 - Production
oracle | System parameter file is /opt/oracle/product/19c/dbhome_1/network/admin/listener.ora
oracle | Log messages written to /opt/oracle/diag/tnslsnr/153722b1c570/listener/alert/log.xml
oracle | Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
oracle | Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1521)))
oracle |
oracle | Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
oracle | STATUS of the LISTENER
oracle | ------------------------
oracle | Alias LISTENER
oracle | Version TNSLSNR for Linux: Version 19.0.0.0.0 - Production
oracle | Start Date 02-MAR-2021 15:42:22
oracle | Uptime 0 days 0 hr. 0 min. 0 sec
oracle | Trace Level off
oracle | Security ON: Local OS Authentication
oracle | SNMP OFF
oracle | Listener Parameter File /opt/oracle/product/19c/dbhome_1/network/admin/listener.ora
oracle | Listener Log File /opt/oracle/diag/tnslsnr/153722b1c570/listener/alert/log.xml
oracle | Listening Endpoints Summary...
oracle | (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
oracle | (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1521))) # !!!端口
oracle | The listener supports no services
oracle | The command completed successfully
oracle | [WARNING] [DBT-06208] The 'SYS' password entered does not conform to the Oracle recommended standards.
oracle | CAUSE:
oracle | a. Oracle recommends that the password entered should be at least 8 characters in length, contain at least 1 uppercase character, 1 lower case character and 1 digit [0-9].
oracle | b.The password entered is a keyword that Oracle does not recommend to be used as password
oracle | ACTION: Specify a strong password. If required refer Oracle documentation for guidelines.
oracle | [WARNING] [DBT-06208] The 'SYSTEM' password entered does not conform to the Oracle recommended standards.
oracle | CAUSE:
oracle | a. Oracle recommends that the password entered should be at least 8 characters in length, contain at least 1 uppercase character, 1 lower case character and 1 digit [0-9].
oracle | b.The password entered is a keyword that Oracle does not recommend to be used as password
oracle | ACTION: Specify a strong password. If required refer Oracle documentation for guidelines.
oracle | [WARNING] [DBT-06208] The 'PDBADMIN' password entered does not conform to the Oracle recommended standards.
oracle | CAUSE:
oracle | a. Oracle recommends that the password entered should be at least 8 characters in length, contain at least 1 uppercase character, 1 lower case character and 1 digit [0-9].
oracle | b.The password entered is a keyword that Oracle does not recommend to be used as password
oracle | ACTION: Specify a strong password. If required refer Oracle documentation for guidelines.
oracle | Prepare for db operation
oracle | 8% complete
oracle | Copying database files
oracle | 31% complete
oracle | Creating and starting Oracle instance
oracle | 32% complete
oracle | 36% complete
oracle | 40% complete
oracle | 43% complete
oracle | 46% complete
oracle | Completing Database Creation
oracle | 51% complete
oracle | 54% complete
oracle | Creating Pluggable Databases
oracle | 58% complete
oracle | 77% complete
oracle | Executing Post Configuration Actions
oracle | 100% complete
oracle | Database creation complete. For details check the logfiles at:
oracle | /opt/oracle/cfgtoollogs/dbca/TOLLPDB.
oracle | Database Information:
oracle | Global Database Name:TOLLPDB
oracle | System Identifier(SID):TOLLPDB
oracle | Look at the log file "/opt/oracle/cfgtoollogs/dbca/TOLLPDB/TOLLPDB0.log" for further details.
oracle |
oracle | SQL*Plus: Release 19.0.0.0.0 - Production on Tue Mar 2 16:09:31 2021
oracle | Version 19.3.0.0.0
oracle |
oracle | Copyright (c) 1982, 2019, Oracle. All rights reserved.
oracle |
oracle |
oracle | Connected to:
oracle | Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
oracle | Version 19.3.0.0.0
oracle |
oracle | SQL>
oracle | System altered.
oracle |
oracle | SQL>
oracle | System altered.
oracle |
oracle | SQL>
oracle | Pluggable database altered.
oracle |
oracle | SQL>
oracle | PL/SQL procedure successfully completed.
oracle |
oracle | SQL> Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
oracle | Version 19.3.0.0.0
oracle | The Oracle base remains unchanged with value /opt/oracle
oracle | #########################
oracle | DATABASE IS READY TO USE! # !!! 数据库可用
oracle | #########################
oracle | The following output is now a tail of the alert.log:
oracle | FEE(3):Completed: ALTER DATABASE DEFAULT TABLESPACE "USERS"
oracle | 2021-03-02T16:09:31.874025+08:00
oracle | ALTER SYSTEM SET control_files='/opt/oracle/oradata/TOLLPDB/control01.ctl' SCOPE=SPFILE;
oracle | 2021-03-02T16:09:31.898097+08:00
oracle | ALTER SYSTEM SET local_listener='' SCOPE=BOTH;
oracle | ALTER PLUGGABLE DATABASE FEE SAVE STATE
oracle | Completed: ALTER PLUGGABLE DATABASE FEE SAVE STATE
oracle | 2021-03-02T16:09:33.007808+08:00
oracle |
oracle | XDB initialized.

停止后第二次启动的日志:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
Attaching to oracle
oracle | ORACLE EDITION: ENTERPRISE
oracle |
oracle | LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 02-MAR-2021 16:21:58
oracle |
oracle | Copyright (c) 1991, 2019, Oracle. All rights reserved.
oracle |
oracle | Starting /opt/oracle/product/19c/dbhome_1/bin/tnslsnr: please wait...
oracle |
oracle | TNSLSNR for Linux: Version 19.0.0.0.0 - Production
oracle | System parameter file is /opt/oracle/product/19c/dbhome_1/network/admin/listener.ora
oracle | Log messages written to /opt/oracle/diag/tnslsnr/11585b67b20f/listener/alert/log.xml
oracle | Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
oracle | Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1521)))
oracle |
oracle | Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
oracle | STATUS of the LISTENER
oracle | ------------------------
oracle | Alias LISTENER
oracle | Version TNSLSNR for Linux: Version 19.0.0.0.0 - Production
oracle | Start Date 02-MAR-2021 16:21:58
oracle | Uptime 0 days 0 hr. 0 min. 0 sec
oracle | Trace Level off
oracle | Security ON: Local OS Authentication
oracle | SNMP OFF
oracle | Listener Parameter File /opt/oracle/product/19c/dbhome_1/network/admin/listener.ora
oracle | Listener Log File /opt/oracle/diag/tnslsnr/11585b67b20f/listener/alert/log.xml
oracle | Listening Endpoints Summary...
oracle | (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
oracle | (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1521)))
oracle | The listener supports no services
oracle | The command completed successfully
oracle |
oracle | SQL*Plus: Release 19.0.0.0.0 - Production on Tue Mar 2 16:21:58 2021
oracle | Version 19.3.0.0.0
oracle |
oracle | Copyright (c) 1982, 2019, Oracle. All rights reserved.
oracle |
oracle | Connected to an idle instance.
oracle |
oracle | SQL> ORACLE instance started.
oracle |
oracle | Total System Global Area 1610609888 bytes
oracle | Fixed Size 9135328 bytes
oracle | Variable Size 402653184 bytes
oracle | Database Buffers 1191182336 bytes
oracle | Redo Buffers 7639040 bytes
oracle | Database mounted.
oracle | Database opened.
oracle | SQL> Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
oracle | Version 19.3.0.0.0
oracle | The Oracle base remains unchanged with value /opt/oracle
oracle | #########################
oracle | DATABASE IS READY TO USE!
oracle | #########################
oracle | The following output is now a tail of the alert.log:
oracle | QPI: qopiprep.bat file present
oracle | 2021-03-02T16:22:33.798020+08:00
oracle | FEE(3):Opening pdb with no Resource Manager plan active
oracle | FEE(3):joxcsys_required_dirobj_exists: directory object exists with required path /opt/oracle/product/19c/dbhome_1/javavm/admin/, pid 119 cid 3
oracle | Pluggable database FEE opened read write
oracle | 2021-03-02T16:22:35.449498+08:00
oracle | Starting background process CJQ0
oracle | 2021-03-02T16:22:35.469509+08:00
oracle | CJQ0 started with pid=54, OS id=303
oracle | Completed: ALTER DATABASE OPEN
oracle | 2021-03-02T16:22:40.261727+08:00
oracle | ===========================================================
oracle | Dumping current patch information
oracle | ===========================================================
oracle | Patch Id: 29517242
oracle | Patch Description: Database Release Update : 19.3.0.0.190416 (29517242)
oracle | Patch Apply Time: 2019-04-18T15:21:17+08:00
oracle | Bugs Fixed: 14735102,19697993,20313356,21965541,25806201,25883179,25986062,
oracle | 26476244,26611353,26872233,27369515,27423500,27666312,27710072,27846298,
oracle | 27957203,28064977,28072567,28129791,28181021,28210681,28279456,28313275,

oracledata目录权限不足提示的信息:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
 mkdir: cannot create directory '/opt/oracle/oradata/dbconfig': Permission denied
oracle | mv: cannot stat '/opt/oracle/product/19c/dbhome_1/dbs/spfileTOLLPDB.ora': No such file or directory
oracle | mv: cannot stat '/opt/oracle/product/19c/dbhome_1/dbs/orapwTOLLPDB': No such file or directory
oracle | mv: cannot move '/opt/oracle/product/19c/dbhome_1/network/admin/sqlnet.ora' to '/opt/oracle/oradata/dbconfig/TOLLPDB/': No such file or directory
oracle | mv: cannot move '/opt/oracle/product/19c/dbhome_1/network/admin/listener.ora' to '/opt/oracle/oradata/dbconfig/TOLLPDB/': No such file or directory
oracle | mv: cannot move '/opt/oracle/product/19c/dbhome_1/network/admin/tnsnames.ora' to '/opt/oracle/oradata/dbconfig/TOLLPDB/': No such file or directory
oracle | mv: cannot move '/opt/oracle/product/19c/dbhome_1/install/.docker_enterprise' to '/opt/oracle/oradata/dbconfig/TOLLPDB/': No such file or directory
oracle | cp: cannot create regular file '/opt/oracle/oradata/dbconfig/TOLLPDB/': No such file or directory
oracle | ln: failed to create symbolic link '/opt/oracle/product/19c/dbhome_1/network/admin/sqlnet.ora': File exists
oracle | ln: failed to create symbolic link '/opt/oracle/product/19c/dbhome_1/network/admin/listener.ora': File exists
oracle | ln: failed to create symbolic link '/opt/oracle/product/19c/dbhome_1/network/admin/tnsnames.ora': File exists
oracle | cp: cannot stat '/opt/oracle/oradata/dbconfig/TOLLPDB/oratab': No such file or directory
oracle | ORACLE_HOME = [/home/oracle] ? ORACLE_BASE environment variable is not being set since this
oracle | information is not available for the current user ID .
oracle | You can set ORACLE_BASE manually if it is required.
oracle | Resetting ORACLE_BASE to its previous value or ORACLE_HOME
oracle | The Oracle base remains unchanged with value /opt/oracle
oracle | /opt/oracle/checkDBStatus.sh: line 26: sqlplus: command not found
oracle | #####################################
oracle | ########### E R R O R ###############
oracle | DATABASE SETUP WAS NOT SUCCESSFUL!
oracle | Please check output for further info!
oracle | ########### E R R O R ###############
oracle | #####################################
oracle | The following output is now a tail of the alert.log:

曾经的尝试

仅备档记录仅备档记录仅备档记录

进入容器,可用如下命令连接:

1
2
3
4
5
6
7
8
sqlplus /nolog

sqlplus sys/123456@//localhost:1521/tollpdb as sysdba
sqlplus system/123456@//localhost:1521/tollpdb
sqlplus pdbadmin/123456@//localhost:1521/fee # 注:修改密码,会登录失败,说明已经生效,但用navicat登录不了。

select * from all_users;

用 navicat 使用 system/123456 可登录(此时应该是cbd)。但用fee和sysdba无法登录。原因未明。

查看pdb:

1
2
3
4
5
6
7
8
sqlplus sys/123456@//localhost:1521/tollpdb as sysdba

SQL> show pdbs;

CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 FEE READ WRITE NO

注:必须以sysdba登录,system查看提示SP2-0382: The SHOW PDBS command is not available

使用 sysdba 登录做一些操作:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
sqlplus / as sysdba

SQL*Plus: Release 19.0.0.0.0 - Production on Wed Mar 3 10:11:26 2021
Version 19.3.0.0.0

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

Connected to an idle instance. # !!这里应该有错了

SQL> grant sysdba to system; # !! 执行,但不可用
grant sysdba to system
*
ERROR at line 1:
ORA-01034: ORACLE not available
Process ID: 0
Session ID: 0 Serial number: 0


SQL> show pdbs; # !! 执行,但不可用
ERROR:
ORA-01034: ORACLE not available
Process ID: 0
Session ID: 0 Serial number: 0

SP2-1545: This feature requires Database availability.

SQL> startup # !! 启动,但失败
ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/opt/oracle/product/19c/dbhome_1/dbs/inittollpdb.ora'

拷贝一个inittollpdb.ora文件。

1
2
3
4
5
6
ORA-00845: MEMORY_TARGET not supported on this system
共享内存太小了

默认的init.ora中:memory_target=1G。

ORA-01102: cannot mount database in EXCLUSIVE mode

查看数据库是否为 CDB:

1
2
3
4
5
select CDB from v$database; -- 如果得到的结果为YES,那么就是CDB的数据库,否则,则不是。
切入要操作的pdb
show pdbs; -- 展示pdb数据库集合
alter session set container=FEE; -- 切入到PDB 数据库
alter session set container=CDB$ROOT; -- 切回到CDB 容器数据库

2021年2月 开始着手研究,3月完成 李迟