本文涉及: oracle 的容器化部署。
下载镜像:
docker pull registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g
镜像列表:
REPOSITORY TAG IMAGE ID CREATED SIZE
registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g latest 3fa112fd3642 4 years ago 6.85 GB
启动容器:
docker run -itd -p 1521:1521 --name oracle registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g
数据持久化:
docker run -itd -p 1521:1521 \
--name=oracle \
-v $PWD/helowin:/home/oracle/app/oracle/oradata/helowin \
-v $PWD/flash_recovery_area:/home/oracle/app/oracle/flash_recovery_area \
registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g bash
--restart=always
状态:
# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d3b1cd3efbc7 registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g "/bin/sh -c '/home..." 32 seconds ago Up 6 seconds 0.0.0.0:1521->1521/tcp oracle
默认账号和密码:
#username: system
#password: helowin
进入容器:
docker exec -it oracle bash
连接数据库。
source /home/oracle/.bash_profile
sqlplus /nolog
SQL> conn / as sysdba
Connected.
或
$ sqlplus
SQL*Plus: Release 11.2.0.1.0 Production on Mon Oct 26 09:17:43 2020
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Enter user-name: system # 账号
Enter password: # 密码为helowin
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
修改账号密码。
SQL> alter user system identified by system; ## 账号和密码为system
User altered.
SQL> alter user sys identified by sys; ## 账号和密码为sys
User altered.
SQL>
SQL> alter profile default limit password_life_time unlimited;
Profile altered.
SQL> exit
$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 30-AUG-2020 00:54:57
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 27-AUG-2020 23:26:21
Uptime 2 days 1 hr. 28 min. 36 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/d3b1cd3efbc7/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=d3b1cd3efbc7)(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
问题
ORA-12528: TNS: 监听程序: 所有适用例程都无法建立新连接。
查看状态为 BLOCKED:
$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 26-OCT-2020 11:05:00
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 26-OCT-2020 10:11:00
Uptime 0 days 0 hr. 53 min. 59 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/5041887d0189/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=5041887d0189)(PORT=1521)))
Services Summary...
Service "helowin" has 1 instance(s).
Instance "helowin", status BLOCKED, has 1 handler(s) for this service...
The command completed successfully
小结
尝试挂载数据库目录,但无法访问,原因未明。所有内容在容器中,可以正常使用。
附
默认启动命令:
"Volumes": {
"/home/oracle/app/oracle/oradata": {}
},
"WorkingDir": "",
"Entrypoint": [
"/bin/sh",
"-c",
"/home/oracle/app/oracle/product/11.2.0/dbhome_2/bin/dbstart /home/oracle/app/oracle/product/11.2.0/dbhome_2 && tail -f /home/oracle/app/oracle/product/11.2.0/dbhome_2/startup.log"
参考
www.cnblogs.com/qiuxiangmuy…
www.cnblogs.com/YsirSun/p/1…
blog.csdn.net/chenjin_csd…
github.com/oracle/dock…
www.cnblogs.com/yxb-blog/p/…
www.imooc.com/article/184…
www.cnblogs.com/lovling/p/1…
blog.csdn.net/qq_27050005…