相關文檔:
CentOS 7.7 1908 使用 Docker 安裝 Oracle 11g
- 使用 Docker 創建第二個 Oracle 11g(oracle_11g_2):
docker run --restart=always -p 11522:1522 --name oracle_11g_2 -d registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g
- 查看運行鏡像:
docker ps -a
[root@localhost ~]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 843281daf217 registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g "/bin/sh -c '/home..." 3 minutes ago Up 3 minutes 1521/tcp, 0.0.0.0:11522->1522/tcp oracle_11g_2 a89bffd7afe8 registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g "/bin/sh -c '/home..." 22 hours ago Up 4 minutes 0.0.0.0:11521->1521/tcp oracle_11g [root@localhost ~]#
- 開通端口:
firewall-cmd --zone=public --add-port=11522/tcp --permanent firewall-cmd --reload firewall-cmd --list-all
- 進入 oracle_11g_2:
docker exec -it oracle_11g_2 bash
- 執行結果:
[root@localhost ~]# docker exec -it oracle_11g_2 bash [oracle@6f0d3d29babc /]$
- 查看監聽:
lsnrctl status
[oracle@6f0d3d29babc /]$ lsnrctl status bash: lsnrctl: command not found [oracle@6f0d3d29babc /]$
source /home/oracle/.bash_profile
[oracle@6f0d3d29babc /]$ lsnrctl status LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 11-JUN-2020 23:36:44 Copyright (c) 1991, 2009, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521))) STATUS of the LISTENER ------------------------ Alias LISTENER Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production Start Date 11-JUN-2020 23:34:00 Uptime 0 days 0 hr. 2 min. 43 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /home/oracle/app/oracle/product/11.2.0/dbhome_2/network/admin/listener.ora Listener Log File /home/oracle/app/oracle/diag/tnslsnr/6f0d3d29babc/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=6f0d3d29babc)(PORT=1521))) Services Summary... Service "helowin" has 1 instance(s). Instance "helowin", status READY, has 1 handler(s) for this service... Service "helowinXDB" has 1 instance(s). Instance "helowin", status READY, has 1 handler(s) for this service... The command completed successfully [oracle@6f0d3d29babc /]$
- 修改 listener.ora 端口:
vi /home/oracle/app/oracle/product/11.2.0/dbhome_2/network/admin/listener.ora
2、將 PORT = 1521 修改爲 PORT = 1522# listener.ora Network Configuration File: /home/oracle/app/oracle/product/11.2.0/dbhome_2/network/admin/listener.ora # Generated by Oracle configuration tools. LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1522)) (ADDRESS = (PROTOCOL = TCP)(HOST = )(PORT = 1522)) ) ) ADR_BASE_LISTENER = /home/oracle/app/oracle
- 修改 tnsnames.ora:
vi /home/oracle/app/oracle/product/11.2.0/dbhome_2/network/admin/tnsnames.ora
# tnsnames.ora Network Configuration File: /home/oracle/app/oracle/product/11.2.0/dbhome_2/network/admin/tnsnames.ora # Generated by Oracle configuration tools. LISTENER_HELOWIN = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1522)) HELOWIN = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1522)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = helowin) ) )
- 重啓監聽:
lsnrctl start
[oracle@6f0d3d29babc /]$ lsnrctl start LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 11-JUN-2020 23:54:32 Copyright (c) 1991, 2009, Oracle. All rights reserved. Starting /home/oracle/app/oracle/product/11.2.0/dbhome_2/bin/tnslsnr: please wait... TNSLSNR for Linux: Version 11.2.0.1.0 - Production System parameter file is /home/oracle/app/oracle/product/11.2.0/dbhome_2/network/admin/listener.ora Log messages written to /home/oracle/app/oracle/diag/tnslsnr/6f0d3d29babc/listener/alert/log.xml Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1522))) Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=6f0d3d29babc)(PORT=1522))) Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1522))) STATUS of the LISTENER ------------------------ Alias LISTENER Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production Start Date 11-JUN-2020 23:54:32 Uptime 0 days 0 hr. 0 min. 0 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /home/oracle/app/oracle/product/11.2.0/dbhome_2/network/admin/listener.ora Listener Log File /home/oracle/app/oracle/diag/tnslsnr/6f0d3d29babc/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1522))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=6f0d3d29babc)(PORT=1522))) The listener supports no services The command completed successfully [oracle@6f0d3d29babc /]$
- 重啓 oracle:
- 使用 dba 登錄 Oracle:
sqlplus / as sysdba
- 關閉數據庫:
shutdown immediate;
- 開啓數據庫:
startup;
- 使用 dba 登錄 Oracle:
- 遠程連接: