我的docker随笔29:oracle数据库部署

Posted 李迟

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了我的docker随笔29:oracle数据库部署相关的知识,希望对你有一定的参考价值。

本文涉及:
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"

参考

https://www.cnblogs.com/qiuxiangmuyu/p/7895154.html
https://www.cnblogs.com/YsirSun/p/13543313.html
https://blog.csdn.net/chenjin_csdn/article/details/106470108
https://github.com/oracle/docker-images/tree/master/OracleDatabase/SingleInstance#running-oracle-database-11gr2-express-edition-in-a-docker-container
https://www.cnblogs.com/yxb-blog/p/12654229.html
https://www.imooc.com/article/18498?block_id=tuijian_wz
https://www.cnblogs.com/lovling/p/12547007.html
https://blog.csdn.net/qq_27050005/article/details/81479171

2020.8.28 李迟

以上是关于我的docker随笔29:oracle数据库部署的主要内容,如果未能解决你的问题,请参考以下文章

我的docker随笔33:在容器中连接oracle数据库

我的docker随笔33:在容器中连接oracle数据库

我的docker随笔34:gitlab服务部署

我的docker随笔34:gitlab服务部署

我的docker随笔32:sftp服务部署

我的docker随笔35:jenkins服务部署