My ultimate goal is to, using docker-compose, connect a python application to an Oracle database.
The python application currently uses
SQLAlchemy for trying to connect to Oracle. I’ve also tried using
cx_Oracle directly but got the same errors. I also have Oracle instant client installed in the python container.
For Oracle, I’m using the
store/oracle/database-enterprise:126.96.36.199 image from Docker, and when running the database container, I get the following from the logs:
ERROR: config DB failed, please check log /home/oracle/setup/log/configDB.log for details!
configDB.log I have the following:
Mon Nov 25 23:35:54 UTC 2019 Start Docker DB configuration Call configDBora.sh to configure database Mon Nov 25 23:35:54 UTC 2019 Configure DB as oracle user Setup Database directories ... startup database instance SQL*Plus: Release 188.8.131.52.0 Production on Mon Nov 25 23:35:55 2019 Copyright (c) 1982, 2016, Oracle. All rights reserved. Connected to an idle instance. SQL> ORA-01261: Parameter db_recovery_file_dest destination string cannot be translated ORA-01262: Stat failed on a file destination directory Linux-x86_64 Error: 2: No such file or directory SQL> Disconnected LSNRCTL for Linux: Version 184.108.40.206.0 - Production on 25-NOV-2019 23:35:56 Copyright (c) 1991, 2016, Oracle. All rights reserved. Starting /u01/app/oracle/product/12.2.0/dbhome_1/bin/tnslsnr: please wait... TNSLSNR for Linux: Version 220.127.116.11.0 - Production System parameter file is /u01/app/oracle/product/12.2.0/dbhome_1/admin/ORCLCDB/listener.ora Log messages written to /u01/app/oracle/diag/tnslsnr/a7b10c9a8f22/listener/alert/log.xml Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1521))) Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521))) Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=0.0.0.0)(PORT=1521))) STATUS of the LISTENER ------------------------ Alias LISTENER Version TNSLSNR for Linux: Version 18.104.22.168.0 - Production Start Date 25-NOV-2019 23:35:57 Uptime 0 days 0 hr. 0 min. 0 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /u01/app/oracle/product/12.2.0/dbhome_1/admin/ORCLCDB/listener.ora Listener Log File /u01/app/oracle/diag/tnslsnr/a7b10c9a8f22/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521))) The listener supports no services The command completed successfully DONE! Remove password info Docker DB configuration is complete !
From there I can spot two problems, the first one would be regarding
db_recovery_file_dest and the second regarding Oracle’s listener.
configDB.log we can find:
SQL> ORA-01261: Parameter db_recovery_file_dest destination string cannot be translated ORA-01262: Stat failed on a file destination directory Linux-x86_64 Error: 2: No such file or directory SQL> Disconnected
For this, I checked the folder specified for
db_recovery_file_dest which is
/u03/app/oracle/fast_recovery_area and it seems to have a broken link since it has red letters with black background. Then I created a volume map on my
docker-compose.yml to see what would happens and this solves the error leading to a similar problem now with the audit file folder. After trying to solve it the same way, I got:
db_1 | ln: failed to create symbolic link '/u02/app/oracle/audit/audit': Permission denied db_1 | ln: failed to create symbolic link '/u02/app/oracle/oradata': Permission denied db_1 | ln: failed to create symbolic link '/u03/app/oracle/fast_recovery_area/fast_recovery_area': File exists
configDB.log we have:
The listener supports no services. I believe this is the direct reason for the following error in the python container:
cx_Oracle.DatabaseError: ORA-12514: TNS:listener does not currently know of service requested in connect descriptor
I checked the file
listener.ora and it does not contain the
SID_LIST_LISTENER. I have a local version of
listener.ora containing this information, however, I don’t know how I can use my
listener.ora in the Oracle service. I tried creating a volume map for this, but it didn’t work.
Following is the base
docker-compose.yml I’m using:
version: '3' services: mdc: image: mdc-lite build: . volumes: - .:/usr/src/app links: - db:db networks: - appnet ports: - 7070:7070 command: python3 /usr/src/app/manage.py runserver 0.0.0.0:7070 environment: # https://github.com/awslabs/amazon-sagemaker-examples/issues/319 PYTHONUNBUFFERED: 1 db: image: store/oracle/database-enterprise:22.214.171.124 volumes: - dbdata:/ORCL - ./database-scripts:/scripts networks: - appnet ports: - 1521:1521 - 5500:5500 ulimits: # necessary to get rid of a memlock message memlock: 6000000000 shm_size: '2gb' environment: ORACLE_SID: ORCLCDB ORACLE_PDB: ORCLPDB1 ORACLE_PWD: secret networks: appnet: driver: 'bridge' volumes: dbdata: driver: "local"
Any idea on how to proceed? or on what to do? I appreciate any help or thoughts given.