- 查看 docker 容器目錄
docker info | grep 'Docker Root Dir'
[root@localhost ~]# docker info | grep 'Docker Root Dir' WARNING: You're not using the default seccomp profile WARNING: bridge-nf-call-iptables is disabled WARNING: bridge-nf-call-ip6tables is disabled Docker Root Dir: /data/docker [root@localhost ~]#
- 查看已創建的容器:
docker ps -a
[root@localhost ~]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES a89bffd7afe8 registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g "/bin/sh -c '/home..." 3 days ago Up 8 minutes 0.0.0.0:11521->1521/tcp oracle_11g [root@localhost ~]#
- 進入 oracle_11g 安裝目錄:
docker 容器在安裝目錄中的 containers 文件夾下:
根據上述條件,進入安裝目錄:cd /data/docker/containers/a89bffd7afe8ed7168bc1ba641f7327ba1f5da662563ba335f69bad8dadee038/
- 查看 vim 版本:
vim -v
yum -y install vim
- 通知 docker:
systemctl stop docker
- 編輯 hostconfig.json 文件:
vim hostconfig.json
:%!python -m json.tool
"PortBindings": { "1521/tcp": [ { "HostIp": "", "HostPort": "11521" } ] }
"PortBindings": { "1521/tcp": [ { "HostIp": "", "HostPort": "11521" } ], "1522/tcp": [ { "HostIp": "", "HostPort": "11522" } ] }
- 編輯 config.v2.json 文件:
vim config.v2.json
:%!python -m json.tool
"ExposedPorts": { "1521/tcp": {}, "1522/tcp": {} },
- 啓動 docker:
systemctl start docker
- 查看已創建的容器:
docker ps -a
[root@localhost a89bffd7afe8ed7168bc1ba641f7327ba1f5da662563ba335f69bad8dadee038]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES a89bffd7afe8 registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g "/bin/sh -c '/home..." 3 days ago Up 4 seconds 0.0.0.0:11521->1521/tcp, 0.0.0.0:11522->1522/tcp oracle_11g [root@localhost a89bffd7afe8ed7168bc1ba641f7327ba1f5da662563ba335f69bad8dadee038]#
- 開通本機(非 docker)11522端口:
firewall-cmd --zone=public --add-port=11522/tcp --permanent firewall-cmd --reload firewall-cmd --list-all
- 進入 oracle11g:
docker exec -it oracle_11g bash
[root@localhost a89bffd7afe8ed7168bc1ba641f7327ba1f5da662563ba335f69bad8dadee038]# docker exec -it oracle_11g bash [oracle@a89bffd7afe8 /]$
- 編輯 tnsnames.ora:
vi /home/oracle/app/oracle/product/11.2.0/dbhome_2/network/admin/tnsnames.ora
LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = )(PORT = 1521)) ) ) ADR_BASE_LISTENER = /home/oracle/app/oracle
LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = )(PORT = 1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = )(PORT = 1522)) ) ) ADR_BASE_LISTENER = /home/oracle/app/oracle
- 重啓監聽:
停止監聽:lsnrctl stop
[oracle@a89bffd7afe8 /]$ lsnrctl stop LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 14-JUN-2020 22:56:27 Copyright (c) 1991, 2009, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521))) The command completed successfully [oracle@a89bffd7afe8 /]$
lsnrctl start
[oracle@a89bffd7afe8 /]$ lsnrctl start LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 14-JUN-2020 22:56:35 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/a89bffd7afe8/listener/alert/log.xml Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521))) Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=a89bffd7afe8)(PORT=1521))) Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=a89bffd7afe8)(PORT=1522))) 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 14-JUN-2020 22:56:35 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/a89bffd7afe8/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=a89bffd7afe8)(PORT=1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=a89bffd7afe8)(PORT=1522))) The listener supports no services The command completed successfully [oracle@a89bffd7afe8 /]$
- 重啓數據庫:
使用 dba 登錄數據庫:sqlplus / as sysdba
[oracle@a89bffd7afe8 /]$ sqlplus / as sysdba SQL*Plus: Release 11.2.0.1.0 Production on Sun Jun 14 22:57:40 2020 Copyright (c) 1982, 2009, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL>
shutdown immediate;
SQL> shutdown immediate; Database closed. Database dismounted. ORACLE instance shut down. SQL>
startup;
SQL> startup; ORACLE instance started. Total System Global Area 1603411968 bytes Fixed Size 2213776 bytes Variable Size 402655344 bytes Database Buffers 1191182336 bytes Redo Buffers 7360512 bytes Database mounted. Database opened. SQL>
- 使用 11521 連接:
- 使用 11522 連接:
CentOS 7.7 1908 使用 Docker 中的數據庫增加監聽端口與端口映射
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.