【DB宝4】只需2步即可拥有Oracle19c的ASM+DB环境
目录
一、从Docker Hub下载小麦苗上传的镜像
小麦苗的Docker Hub的地址:https://hub.docker.com/u/lhrbest
-- 下载镜像命令:
docker pull lhrbest/oracle19casm_lhr:1.0
镜像有点大,下载时间取决于自己的网络环境,建议晚上放后台下载:
-- 放后台下载镜像命令:
nohup docker pull lhrbest/oracle19casm_lhr:1.0 &
下载完成后:
[root@docker35 ~]# docker images | grep oracle19casm_lhr
lhrbest/oracle19casm_lhr 1.0 d695caf63520 17 hours ago 46.6GB
二、创建容器
--创建容器
docker run -itd -h lhr2019ocpasm --name oracle19casmlhr -p 1521:1521 -p 5500:5500 -p 5501:5501 --privileged=true lhrbest/oracle19casm_lhr:1.0 /usr/sbin/init
--进入容器
docker exec -it oracle19casmlhr bash
三、尽情使用吧
注意事项:
① 该镜像使用二进制包的方式安装Oracle 19c企业版的ASM和db,包括一个CDB,名称为lhr19cdb,一个非cdb,名称为lhr19sdb,所有密码均为lhr
② ASM磁盘脚本:/etc/initASMDISK.sh
3.1 数据库使用示例:
[root@docker35 ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b9c33f914de6 lhrbest/oracle19casm_lhr:1.0 "/usr/sbin/init" 17 hours ago Up 17 hours 0.0.0.0:1521->1521/tcp, 22/tcp, 5501-5501/tcp, 0.0.0.0:5500->5500/tcp oracle19casmlhr
[root@docker35 ~]# docker exec -it oracle19casmlhr bash
[root@lhr2019ocpasm /]# oracleasm listdisks
ASM1
ASM2
ASM3
ASM4
ASM5
ASM6
ASM7
[root@lhr2019ocpasm /]# crsctl stat res -t
--------------------------------------------------------------------------------
Name Target State Server State details
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.DATA.dg
ONLINE ONLINE lhr2019ocpasm STABLE
ora.FRA.dg
ONLINE ONLINE lhr2019ocpasm STABLE
ora.LISTENER.lsnr
ONLINE ONLINE lhr2019ocpasm STABLE
ora.asm
ONLINE ONLINE lhr2019ocpasm Started,STABLE
ora.ons
OFFLINE OFFLINE lhr2019ocpasm STABLE
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.cssd
1 ONLINE ONLINE lhr2019ocpasm STABLE
ora.diskmon
1 OFFLINE OFFLINE STABLE
ora.evmd
1 ONLINE ONLINE lhr2019ocpasm STABLE
ora.lhr19cdb.db
1 ONLINE ONLINE lhr2019ocpasm Open,HOME=/u01/app/o
racle/product/19.3.0
/dbhome_1,STABLE
ora.lhr19sdb.db
1 ONLINE ONLINE lhr2019ocpasm Open,HOME=/u01/app/o
racle/product/19.3.0
/dbhome_1,STABLE
--------------------------------------------------------------------------------
[root@lhr2019ocpasm /]# su - oracle
Last login: Sun Jun 28 16:36:43 CST 2020 on pts/0
[oracle@lhr2019ocpasm ~]$ sas
SQL*Plus: Release 19.0.0.0.0 - Production on Mon Jun 29 10:13:11 2020
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
SYS@lhr19cdb> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
SYS@lhr19cdb> exit
Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
[oracle@lhr2019ocpasm dbs]$ . oraenv
ORACLE_SID = [lhr19cdb] ? lhr19sdb
The Oracle base remains unchanged with value /u01/app/oracle
[oracle@lhr2019ocpasm dbs]$ sas
SQL*Plus: Release 19.0.0.0.0 - Production on Mon Jun 29 10:18:45 2020
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
SYS@lhr19sdb> show pdbs
SYS@lhr19sdb> exit
Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
[oracle@lhr2019ocpasm dbs]$ ps -ef|grep pmon
grid 1173 1 0 Jun28 ? 00:00:05 asm_pmon_+ASM
oracle 1642 1 0 Jun28 ? 00:00:07 ora_pmon_lhr19cdb
oracle 23410 0 0 10:17 ? 00:00:00 ora_pmon_lhr19sdb
oracle 23882 23073 0 10:18 pts/2 00:00:00 grep --color=auto pmon
[oracle@lhr2019ocpasm dbs]$ lsnrctl status
LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 29-JUN-2020 10:19:02
Copyright (c) 1991, 2019, Oracle. All rights reserved.
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 19.0.0.0.0 - Production
Start Date 28-JUN-2020 17:29:47
Uptime 0 days 16 hr. 49 min. 14 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/19.3.0/grid/network/admin/listener.ora
Listener Log File /u01/app/grid/diag/tnslsnr/lhr2019ocpasm/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=lhr2019ocpasm)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=lhr2019ocpasm)(PORT=5500))(Security=(my_wallet_directory=/u01/app/oracle/product/19.3.0/dbhome_1/admin/lhr19cdb/xdb_wallet))(Presentation=HTTP)(Session=RAW))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=lhr2019ocpasm)(PORT=5501))(Security=(my_wallet_directory=/u01/app/oracle/admin/lhr19sdb/xdb_wallet))(Presentation=HTTP)(Session=RAW))
Services Summary...
Service "+ASM" has 1 instance(s).
Instance "+ASM", status READY, has 1 handler(s) for this service...
Service "+ASM_DATA" has 1 instance(s).
Instance "+ASM", status READY, has 1 handler(s) for this service...
Service "+ASM_FRA" has 1 instance(s).
Instance "+ASM", status READY, has 1 handler(s) for this service...
Service "86b637b62fdf7a65e053f706e80a27ca" has 1 instance(s).
Instance "lhr19cdb", status READY, has 1 handler(s) for this service...
Service "lhr19cdb" has 1 instance(s).
Instance "lhr19cdb", status READY, has 1 handler(s) for this service...
Service "lhr19cdbXDB" has 1 instance(s).
Instance "lhr19cdb", status READY, has 1 handler(s) for this service...
Service "lhr19sdb" has 1 instance(s).
Instance "lhr19sdb", status READY, has 1 handler(s) for this service...
Service "lhrsdbXDB" has 1 instance(s).
Instance "lhr19sdb", status READY, has 1 handler(s) for this service...
The command completed successfully
从监听中可以看到,数据库lhr19cdb的EM端口为5500,数据库lhr19sdb的EM端口为5501
3.2 在外部访问容器内数据库
Microsoft Windows [版本 10.0.17134.765]
(c) 2018 Microsoft Corporation。保留所有权利。
C:\Users\lhrxxt>sqlplus sys/lhr@192.168.1.35:1521/lhr19cdb as sysdba
SQL*Plus: Release 12.1.0.2.0 Production on Mon Jun 29 10:22:29 2020
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
SYS@192.168.1.35:1521/lhr19cdb> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
SYS@192.168.1.35:1521/lhr19cdb> exit
Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
C:\Users\lhrxxt>sqlplus sys/lhr@192.168.1.35:1521/lhr19sdb as sysdba
SQL*Plus: Release 12.1.0.2.0 Production on Mon Jun 29 10:22:40 2020
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
SYS@192.168.1.35:1521/lhr19sdb>
3.3 访问容器内的EM
访问地址:
https://192.168.1.35:5500/em
https://192.168.1.35:5501/em
3.4 使用ssh连接到容器内
C:\Users\lhrxxt>ssh root@192.168.1.35 -p222
The authenticity of host '[192.168.1.35]:222 ([192.168.1.35]:222)' can't be established.
ECDSA key fingerprint is SHA256:F5eg+8MD/fIIF5xnbNr1P0ddok7orVtFb+jji5xq33I.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '[192.168.1.35]:222' (ECDSA) to the list of known hosts.
root@192.168.1.35's password:
Last login: Wed Jun 24 11:07:12 2020
[root@lhr2019ocpasm ~]#
[root@lhr2019ocpasm ~]#
[root@lhr2019ocpasm ~]#
[root@lhr2019ocpasm ~]# crsctl stat res -t
--------------------------------------------------------------------------------
Name Target State Server State details
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.DATA.dg
ONLINE ONLINE lhr2019ocpasm STABLE
ora.FRA.dg
ONLINE ONLINE lhr2019ocpasm STABLE
ora.LISTENER.lsnr
ONLINE ONLINE lhr2019ocpasm STABLE
ora.asm
ONLINE ONLINE lhr2019ocpasm Started,STABLE
ora.ons
OFFLINE OFFLINE lhr2019ocpasm STABLE
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.cssd
1 ONLINE ONLINE lhr2019ocpasm STABLE
ora.diskmon
1 OFFLINE OFFLINE STABLE
ora.evmd
1 ONLINE ONLINE lhr2019ocpasm STABLE
ora.lhr19cdb.db
1 ONLINE OFFLINE lhr2019ocpasm Instance Shutdown,ST
ARTING
ora.lhr19sdb.db
1 ONLINE ONLINE lhr2019ocpasm Open,HOME=/u01/app/o
racle/product/19.3.0
/dbhome_1,STABLE
--------------------------------------------------------------------------------
About Me
● 本文作者:小麦苗,部分内容整理自网络,若有侵权请联系小麦苗删除
● 本文在个人微 信公众号(DB宝)上有同步更新
● QQ群号: 230161599 、618766405,微信群私聊
● 个人QQ号(646634621),微 信号(db_bao),注明添加缘由
● 于 2020年7月 在西安完成
● 最新修改时间:2020年7月
● 版权所有,欢迎分享本文,转载请保留出处
●小麦苗的微店: https://weidian.com/s/793741433?wfr=c&ifr=shopdetail
●小麦苗出版的数据库类丛书: http://blog.itpub.net/26736162/viewspace-2142121/
●小麦苗OCP、OCM、高可用、DBA学习班: http://blog.itpub.net/26736162/viewspace-2148098/
●数据库笔试面试题库及解答: http://blog.itpub.net/26736162/viewspace-2134706/
使用微信客户端扫描下面的二维码来关注小麦苗的微信公众号(DB宝)及QQ群(DBA宝典)、添加小麦苗微信, 学习最实用的数据库技术。