【DB寶4】只需2步即可擁有Oracle19c的ASM+DB環境

lhrbest發表於2020-07-11

【DB寶4】只需2步即可擁有Oracle19c的ASM+DB環境

[TOC]

公眾號地址: https://mp.weixin.qq.com/s?__biz=MzIzOTA2NjEzNQ==&mid=2454779249&idx=1&sn=ffbac44408ab2fe893208230364f6c74&chksm=fe8b9809c9fc111f66ca71af9f8d14e88b8d2d32d5ca02ee4fd10460ba9191cb9cddba49e60c&scene=21#wechat_redirect

一、從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寶典)、新增小麥苗微信, 學習最實用的資料庫技術。
小麥苗資訊


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26736162/viewspace-2703950/,如需轉載,請註明出處,否則將追究法律責任。

相關文章