原 【DB宝76】在Docker中只需2步即可拥有Oracle 21c环境
简介
Oracle Database 21c 于8月13日发布,首先发布的是Linux版本,可以从官方网站下载。21c整合了原计划2020年发布的 20c 版本,原计划 2021年上半年发布,因为疫情等原因推迟了发布。而且据悉,22c 版本号可能取消,23c将是下一个可见版本。
下载
https://www.oracle.com/database/technologies/oracle-database-software-downloads.html
https://www.oracle.com/database/technologies/oracle21c-linux-downloads.html
https://www.oracle.com/downloads/
单实例只需要下载LINUX.X64_213000_db_home.zip
即可。
当然,我们本文不教大家如何安装Oracle。 我们只需要看下面的内容即可!!!
一、从Docker Hub或阿里云镜像下载小麦苗上传的镜像文件
- 小麦苗的Docker Hub的地址:https://hub.docker.com/u/lhrbest
- Oracle 21c DB的地址:https://hub.docker.com/r/lhrbest/oracle21c_ee_db_21.3.0.0/tags
1 2 3 4 5 6 | # 从Docker hub下载,网络不好时,一般比较慢 docker pull lhrbest/oracle21c_ee_db_21.3.0.0 # 可以选择从阿里云下载 docker pull registry.cn-hangzhou.aliyuncs.com/lhrbest/oracle21c_ee_db_21.3.0.0 # 从阿里云下载后可以tag成如下形式 docker tag registry.cn-hangzhou.aliyuncs.com/lhrbest/oracle21c_ee_db_21.3.0.0 lhrbest/oracle21c_ee_db_21.3.0.0 |
镜像大概5.5G左右,解压后大约16G左右,所以请保留充足的空间。执行过程如下:
1 2 3 | [root@docker35 ~]# docker images | grep 21c lhrbest/oracle21c_ee_db_21.3.0.0 latest 86933671efb6 About an hour ago 16.3GB registry.cn-hangzhou.aliyuncs.com/lhrbest/oracle21c_ee_db_21.3.0.0 latest 86933671efb6 About an hour ago 16.3GB |
二、创建容器并启动数据库
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | # 1、创建容器 docker run -d --name lhroracle21c -h lhroracle21c \ -p 5510:5500 -p 55100:5501 -p 1530:1521 -p 3400:3389 \ -v /sys/fs/cgroup:/sys/fs/cgroup \ --privileged=true lhrbest/oracle21c_ee_db_21.3.0.0 \ /usr/sbin/init # 2、进入容器 docker exec -it lhroracle21c bash # 3、启动监听和数据库 su - oracle sas startup lsnrctl start |
执行过程如下:
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 | [root@docker35 ~]# docker run -d --name lhroracle21c -h lhroracle21c \ > -p 5510:5500 -p 55100:5501 -p 1530:1521 -p 3400:3389 \ > -v /sys/fs/cgroup:/sys/fs/cgroup \ > --privileged=true lhrbest/oracle21c_ee_db_21.3.0.0 \ > /usr/sbin/init c5c16e24b308fb5120811e2e0edbeceb11a9a292ae991840097e63e385d6517f [root@docker35 ~]# [root@docker35 ~]# docker exec -it lhroracle21c bash [root@lhroracle21c /]# su - oracle Last login: Mon Aug 16 14:05:17 CST 2021 on pts/0 [oracle@lhroracle21c ~]$ sas SQL*Plus: Release 21.0.0.0.0 - Production on Mon Aug 16 15:48:53 2021 Version 21.3.0.0.0 Copyright (c) 1982, 2021, Oracle. All rights reserved. Connected to an idle instance. SYS@LHRCDB> startup ORACLE instance started. Total System Global Area 859829400 bytes Fixed Size 9692312 bytes Variable Size 461373440 bytes Database Buffers 381681664 bytes Redo Buffers 7081984 bytes Database mounted. Database opened. SYS@LHRCDB> show pdbs CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 PDB2 READ WRITE NO SYS@LHRCDB> exit Disconnected from Oracle Database 21c Enterprise Edition Release 21.0.0.0.0 - Production Version 21.3.0.0.0 [oracle@lhroracle21c ~]$ lsnrctl start LSNRCTL for Linux: Version 21.0.0.0.0 - Production on 16-AUG-2021 15:50:54 Copyright (c) 1991, 2021, Oracle. All rights reserved. Starting /u01/app/oracle/product/21c/dbhome_1/bin/tnslsnr: please wait... TNSLSNR for Linux: Version 21.0.0.0.0 - Production System parameter file is /u01/app/oracle/product/21c/dbhome_1/network/admin/listener.ora Log messages written to /u01/app/oracle/diag/tnslsnr/lhroracle21c/listener/alert/log.xml Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=lhroracle21c)(PORT=1521))) Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521))) Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=lhroracle21c)(PORT=1521))) STATUS of the LISTENER ------------------------ Alias LISTENER Version TNSLSNR for Linux: Version 21.0.0.0.0 - Production Start Date 16-AUG-2021 15:50:54 Uptime 0 days 0 hr. 0 min. 0 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /u01/app/oracle/product/21c/dbhome_1/network/admin/listener.ora Listener Log File /u01/app/oracle/diag/tnslsnr/lhroracle21c/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=lhroracle21c)(PORT=1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521))) The listener supports no services The command completed successfully |
三、尽情使用吧
3.1 数据库使用
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 | [oracle@lhroracle21c ~]$ lsnrctl status LSNRCTL for Linux: Version 21.0.0.0.0 - Production on 16-AUG-2021 15:51:26 Copyright (c) 1991, 2021, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=lhroracle21c)(PORT=1521))) STATUS of the LISTENER ------------------------ Alias LISTENER Version TNSLSNR for Linux: Version 21.0.0.0.0 - Production Start Date 16-AUG-2021 15:50:54 Uptime 0 days 0 hr. 0 min. 31 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /u01/app/oracle/product/21c/dbhome_1/network/admin/listener.ora Listener Log File /u01/app/oracle/diag/tnslsnr/lhroracle21c/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=lhroracle21c)(PORT=1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=lhroracle21c)(PORT=5500))(Security=(my_wallet_directory=/u01/app/oracle/admin/LHRCDB/xdb_wallet))(Presentation=HTTP)(Session=RAW)) Services Summary... Service "LHRCDB" has 1 instance(s). Instance "LHRCDB", status READY, has 1 handler(s) for this service... Service "LHRCDBXDB" has 1 instance(s). Instance "LHRCDB", status READY, has 1 handler(s) for this service... Service "c9a73ae76f543a73e0530e0011acc4b4" has 1 instance(s). Instance "LHRCDB", status READY, has 1 handler(s) for this service... Service "pdb2" has 1 instance(s). Instance "LHRCDB", status READY, has 1 handler(s) for this service... The command completed successfully [oracle@lhroracle21c ~]$ sas SQL*Plus: Release 21.0.0.0.0 - Production on Mon Aug 16 16:12:35 2021 Version 21.3.0.0.0 Copyright (c) 1982, 2021, Oracle. All rights reserved. Connected to: Oracle Database 21c Enterprise Edition Release 21.0.0.0.0 - Production Version 21.3.0.0.0 SYS@LHRCDB> show pdbs CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 PDB2 READ WRITE NO SYS@LHRCDB> SYS@LHRCDB> create pluggable database dbaup admin user lhr identified by lhr ROLES = (dba) 2 file_name_convert=('/u01/app/oracle/oradata/LHRCDB/pdbseed/','/u01/app/oracle/oradata/CDBLHR/dbaup/'); Pluggable database created. SYS@LHRCDB> show pdbs CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 PDB2 READ WRITE NO 4 XMMUP MOUNTED SYS@LHRCDB> alter pluggable database dbaup open; Pluggable database altered. SYS@LHRCDB> show pdbs CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 PDB2 READ WRITE NO 4 XMMUP READ WRITE NO |
3.2 创建数据库
我们也可以自己创建自己需要的数据库,如下所示,创建了一个cdb的数据库,dbname和sid都是lhrdb:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | dbca -silent -createDatabase -templateName General_Purpose.dbc -responseFile NO_VALUE \ -gdbname lhrdb -sid lhrdb \ -createAsContainerDatabase TRUE \ -numberOfPDBs 1 \ -pdbName pdb2 \ -pdbAdminPassword lhr \ -sysPassword lhr -systemPassword lhr \ -datafileDestination '/u01/app/oracle/oradata' \ -recoveryAreaDestination '/u01/app/oracle/flash_recovery_area' \ -redoLogFileSize 50 \ -storageType FS \ -characterset AL32UTF8 -nationalCharacterSet AL16UTF16 \ -totalMemory 1024 \ -databaseType OLTP \ -emConfiguration NONE |
麦总最牛逼
感谢支持!