Can't restart oracle database inside docker - oracle

So I'm trying to configure debezium on a Oracle database inside this docker image, according to the documentation described here.
At the "Preparing the Database" the first config I have to do is:
ORACLE_SID=ORACLCDB dbz_oracle sqlplus /nolog
CONNECT sys/top_secret AS SYSDBA
alter system set db_recovery_file_dest_size = 10G;
alter system set db_recovery_file_dest = '/opt/oracle/oradata/recovery_area' scope=spfile;
shutdown immediate
startup mount
alter database archivelog;
alter database open;
-- Should now "Database log mode: Archive Mode"
archive log list
exit;
The problem is that when I run shutdown immediate, the database dies and never returns. When I try to run:
docker exec -ti oracle sqlplus sys/top_secret#localhost:1521/ORCLCDB as SYSDBA
I get the error:
SQL*Plus: Release 19.0.0.0.0 - Production on Tue Aug 10 07:44:23 2021
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
ERROR:
ORA-12514: TNS:listener does not currently know of service requested in connect
descriptor
I tried running this script inside the container, but still nothing. Anyone knows how could I start the database again?

There are 2 solutions for this
create a static listener configuration that has the database defined in the listener. Doing so enables startup through sqlnet like you tried.
run the script on the server using an account that is member of the local dba group. For startup use something like: ORAENV_ASK=NO; ORACLE_SID=ORCLCDB; source oraenv; “echo startup”| sqlplus / as sysdba.
This asumes that ORCLCDB is listed in /etc/oratab

Related

How to find default password of official Oracle database 21c (images) what run inside docker?

I run
docker pull container-registry.oracle.com/database/enterprise:latest
docker run -d --name oracle-db container-registry.oracle.com/database/enterprise:21.3.0.0
docker logs oracle-db
log
C:\Users\fffdfd>docker logs oracle-db
[2022:09:15 03:28:08]: Acquiring lock .ORCLCDB.create_lck with heartbeat 30 secs
[2022:09:15 03:28:08]: Lock acquired
[2022:09:15 03:28:08]: Starting heartbeat
[2022:09:15 03:28:08]: Lock held .ORCLCDB.create_lck
ORACLE EDITION: ENTERPRISE
LSNRCTL for Linux: Version 21.0.0.0.0 - Production on 15-SEP-2022 03:28:08
Copyright (c) 1991, 2021, Oracle. All rights reserved.
Starting /opt/oracle/product/21c/dbhome_1/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 21.0.0.0.0 - Production
System parameter file is /opt/oracle/homes/OraDB21Home1/network/admin/listener.ora
Log messages written to /opt/oracle/diag/tnslsnr/3ffbbd06854e/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 21.0.0.0.0 - Production
Start Date 15-SEP-2022 03:28:09
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /opt/oracle/homes/OraDB21Home1/network/admin/listener.ora
Listener Log File /opt/oracle/diag/tnslsnr/3ffbbd06854e/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1521)))
The listener supports no services
The command completed successfully
Prepare for db operation
8% complete
Copying database files
C:\Users\fffdfd>docker exec oracle-db ./setPassword.sh 12345678
The Oracle base remains unchanged with value /opt/oracle
SQL*Plus: Release 21.0.0.0.0 - Production on Thu Sep 15 03:29:55 2022
Version 21.3.0.0.0
Copyright (c) 1982, 2021, Oracle. All rights reserved.
Connected to:
Oracle Database 21c Enterprise Edition Release 21.0.0.0.0 - Production
Version 21.3.0.0.0
SQL> ALTER USER SYS IDENTIFIED BY "12345678"
*
ERROR at line 1:
ORA-01109: database not open
SQL> ALTER USER SYSTEM IDENTIFIED BY "12345678"
*
ERROR at line 1:
ORA-01109: database not open
SQL> ERROR:
ORA-65011: Pluggable database ORCLPDB1 does not exist.
SQL> ALTER USER PDBADMIN IDENTIFIED BY "12345678"
*
ERROR at line 1:
ORA-01109: database not open
SQL> Disconnected from Oracle Database 21c Enterprise Edition Release 21.0.0.0.0 - Production
Version 21.3.0.0.0
C:\Users\fffdfd>
Reference document at https://container-registry.oracle.com/ords/f?p=113:4:6576055923728:::4:P4_REPOSITORY,AI_REPOSITORY,AI_REPOSITORY_NAME,P4_REPOSITORY_NAME,P4_EULA_ID,P4_BUSINESS_AREA_ID:9,9,Oracle%20Database%20Enterprise%20Edition,Oracle%20Database%20Enterprise%20Edition,1,0&cs=3JV3L51pi5D5R69u0j2JIq9bovtnbkAkvZz0_bP7Tu1zHiE-Z_0Nrw_Cqh3q1gdQ5peQaDVEO2_JXEXQ0D_p_jA said
Note: Refer to the section titled "Changing the Default Password for
SYS User" to obtain the password.
but I don't see this. How to find default password of official Oracle database 21c (images) what run inside docker?
Reference document was wrong. Manual set password for user sys when create docker container, for example
docker run -d --name vyora -p 1521:1521 -p 5500:5500 -e ORACLE_SID=vyora -e ORACLE_PDB=vypdb -e ORACLE_PWD=12345678 -e INIT_SGA_SIZE=2000 -e INIT_PGA_SIZE=1000 -e ORACLE_EDITION=ee-or-se-database-edition -e ORACLE_CHARACTERSET=AL32UTF8 -e ENABLE_ARCHIVELOG=true -v "D:\oracle":/opt/oracle/oradata container-registry.oracle.com/database/enterprise:21.3.0.0
passowrd is 12345678 .
See https://docs.oracle.com/en/database/oracle/oracle-database/21/deeck/index.html#DEEDK-GUID-6589D4A1-14F3-42B3-8461-C9A7B840D148

sqlplus not connecting as "/ AS SYSDBA"

I installed oracle database express edition 18c. I'm using windows 10.
when I execute "/ AS SYSDBA" in sqlplus to user-name, it gives the following error.
ERROR:
ORA-28056: Writing audit records to Windows Event Log failed
ORA-28056: Writing audit records to Windows Event Log failed
when I execute below
Enter user-name: SYS AS SYSDBA
Enter password: <password I gave on installation>
it prints below error
ERROR:
ORA-28056: Writing audit records to Windows Event Log failed
OSD-32765: Message 32765 not found; product=RDBMS; facility=SOSD
O/S-Error: (OS 5) Access is denied.
ORA-28056: Writing audit records to Windows Event Log failed
OSD-32765: Message 32765 not found; product=RDBMS; facility=SOSD
O/S-Error: (OS 5) Access is denied.
when I try to execute below
Enter user-name: SYSTEM
Enter password: <password I gave on installation>
it prints below error
ERROR: ORA-01034: ORACLE not available ORA-27101: shared
memory realm does not exist Process ID: 0 Session ID: 0
Serial number: 0
So how can I connect to the database?
Note: I cleared all the event logs from event viewer. not worked!!
Additionally by default there are no environment variable set. so I set
set ORACLE_HOME=C:\app\user\product\18.0.0\dbhomeXE
set ORACLE_SID=CLRExtProc
After setting above it provides below error
ERROR:
ORA-12560: TNS:protocol adapter error
so please help me to connect to database
Thank you!!!
Probably you have not configured properly the sqlnet.ora file
Try to run this
C:\>sqlplus / as sysdba
SQL*Plus: Release 18.0.0.0.0 - Production on Wed Aug 26 15:49:17 2020
Version 18.4.0.0.0
Copyright (c) 1982, 2018, Oracle. All rights reserved.
ERROR:
ORA-01017: invalid username/password; logon denied
If you get this error, then open the SQLNET.ORA file and edit the following parameter AUTHENTICATION_SERVICES value to NTS. Save it.
SQLNET.AUTHENTICATION_SERVICES= (NONE)
to
SQLNET.AUTHENTICATION_SERVICES= (NTS)
Try again and it should work, as long as the windows service is running. Don't forget to set the ORACLE_SID environment variable
set ORACLE_SID=sid
Where sid is the name of the database you want to connect to. Finally
C:\>sqlplus / as sysdba
SQL*Plus: Release 18.0.0.0.0 - Production on Wed Aug 26 15:49:34 2020
Version 18.4.0.0.0
Copyright (c) 1982, 2018, Oracle. All rights reserved.
Connected to:
Oracle Database 18c Express Edition Release 18.0.0.0.0 - Production
Version 18.4.0.0.0
SQL>
Update
The database can't write into the Windows Event Log.
Open Event Viewer, click Start, click Control Panel, click Performance and Maintenance, click Administrative Tools, and then double-click Event Viewer. You must be logged on as an administrator or a member of the Administrators group to free an event log.
Then use any of the next options:
When a log is full, it stops recording new events. Clearing the log is one way to free the log and start recording new events. You can also free a log and start recording new events by overwriting old events. To overwrite events, on the Action menu, click Properties, and then click Overwrite events as needed. This ensures that all new events are written to the log, even when the log is full.
You can also start logging new events by increasing the maximum log size. To increase the log size, on the Action menu, click Properties, and then increase the Maximum log size.

Oracle Database error during REST services installation: PLS-00201: identifier 'ORDS.ENABLE_SCHEMA' must be declared

Installed on CentOS 8.
Tried both
Oracle Database Express Edition (XE)
Enterprise Edition
from here https://www.oracle.com/database/technologies/oracle-database-software-downloads.html
ords.war taken from https://www.oracle.com/database/technologies/appdev/rest-data-services-downloads.html
Installation went well
java -jar ords.war install
https://docs.oracle.com/cd/E56351_01/doc.30/e58123/rest.htm#GUID-4F666968-86CF-44EC-9784-1DFCE88F908F
On the step where I must execute PL/SQL procedure I am getting
[oracle#oracle-ee-8gb ~]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Wed Jul 28 11:08:59 2021
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
SQL> EXEC ords.enable_schema;
BEGIN ords.enable_schema; END;
*
ERROR at line 1:
ORA-06550: line 1, column 7:
PLS-00201: identifier 'ORDS.ENABLE_SCHEMA' must be declared
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
Of course, first I tried with a newly created user - exactly for SODA purposes
CREATE USER JSONDB IDENTIFIED BY MyNewPassword;
GRANT CONNECT, RESOURCE TO JSONDB;
GRANT UNLIMITED TABLESPACE TO JSONDB;
GRANT CREATE SESSION TO JSONDB;
and logged as
sqlplus JSONDB/MyNewPassword#localhost/ORCLCDB
Also tried to do the same on official Docker images https://github.com/oracle/docker-images/tree/main/OracleDatabase - same issue.
Output when I activate REST with docker
# docker run --name ords --network dbnet -p 8888:8888 -e ORACLE_HOST=oracledb -e ORACLE_PORT=1521 -e ORACLE_SERVICE=ORCLPDB1 -e ORACLE_PWD=*** -e ORDS_PWD=*** -e CONTEXT_ROOT=ords -v /root/ords-config-data:/opt/oracle/ords/config/ords oracle/restdataservices:21.2.0
Requires to login with administrator privileges to verify Oracle REST Data Services schema.
Connecting to database user: SYS AS SYSDBA url: jdbc:oracle:thin:#//oracledb:1521/ORCLPDB1
Retrieving information.
Enter a number to select a feature to enable:
[1] SQL Developer Web (Enables all features)
[2] REST Enabled SQL
[3] Database API
[4] REST Enabled SQL and Database API
[5] None
Choose [1]:
2021-07-28T14:17:01.072Z INFO HTTP and HTTP/2 cleartext listening on host: localhost port: 8888
2021-07-28T14:17:01.173Z INFO The document root is serving static resources located in: /opt/oracle/ords/doc_root
2021-07-28T14:17:02.540Z INFO No pools configured yet
2021-07-28T14:17:04.115Z INFO Oracle REST Data Services initialized
Oracle REST Data Services version : 21.2.0.r1741826
Oracle REST Data Services server info: jetty/9.4.42.v20210604
Of course, it gives 404 because I can't make it to enable REST for the schema
# curl -i -X PUT http://localhost:8888/ords/jsondb/soda/latest/mycoll
HTTP/1.1 404 Not Found
Content-Type: application/problem+json
Content-Length: 336
{
"code": "NotFound",
"title": "Not Found",
"message": "The request could not be mapped to any database. Check the request URL is correct, and that URL to database mappings have been correctly configured",
"type": "tag:oracle.com,2020:error/NotFound",
"instance": "tag:oracle.com,2020:ecid/au4ymHSYbdm27PDCJ9KjsA"
}
Docker setup:
# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f26a03a15512 oracle/restdataservices:21.2.0 "/bin/sh -c $ORDS_HO…" 4 minutes ago Up 4 minutes 0.0.0.0:8888->8888/tcp, :::8888->8888/tcp ords
6928780180b4 oracle-ee:latest "/bin/sh -c 'exec $O…" 51 minutes ago Up 51 minutes (healthy) 0.0.0.0:1521->1521/tcp, :::1521->1521/tcp, 0.0.0.0:5500->5500/tcp, :::5500->5500/tcp oracledb
Of course, I tried to install JDK locally and installing manually, not only using https://github.com/oracle/docker-images/tree/main/OracleRestDataServices
There's no option to even activate REST using SQL Developer
# java -jar ords.war install advanced
Specify the database connection type to use.
Enter number for [1] Basic [2] TNS [3] Custom URL [1]:1
Enter the name of the database server [localhost]:
Enter the database listen port [1521]:
Enter 1 to specify the database service name, or 2 to specify the database SID [1]:
Enter the database service name:ORCLPDB1
Enter 1 if you want to verify/install Oracle REST Data Services schema or 2 to skip this step [1]:
Enter the database password for ORDS_PUBLIC_USER:
Confirm password:
Requires to login with administrator privileges to verify Oracle REST Data Services schema.
Enter the administrator username:SYS AS SYSDBA
Enter the database password for SYS AS SYSDBA:
Confirm password:
Connecting to database user: SYS AS SYSDBA url: jdbc:oracle:thin:#//localhost:1521/ORCLPDB1
Retrieving information.
Enter the default tablespace for ORDS_METADATA [SYSAUX]:
Enter the temporary tablespace for ORDS_METADATA [TEMP]:
Enter the default tablespace for ORDS_PUBLIC_USER [SYSAUX]:
Enter the temporary tablespace for ORDS_PUBLIC_USER [TEMP]:
Enter 1 if you want to use PL/SQL Gateway or 2 to skip this step.
If using Oracle Application Express or migrating from mod_plsql then you must enter 1 [1]:2
Enter a number to select a feature to enable:
[1] SQL Developer Web (Enables all features)
[2] REST Enabled SQL
[3] Database API
[4] REST Enabled SQL and Database API
[5] None
Choose [1]:
2021-07-28T20:16:57.913Z INFO reloaded pools: []
Installing Oracle REST Data Services version 21.2.0.r1741826
... Log file written to /root/ords_install_core_2021-07-28_221658_00061.log
Warning: Nashorn engine is planned to be removed from a future JDK release
... Verified database prerequisites
... Created Oracle REST Data Services proxy user
... Created Oracle REST Data Services schema
... Granted privileges to Oracle REST Data Services
... Created Oracle REST Data Services database objects
... Log file written to /root/ords_install_datamodel_2021-07-28_221715_00056.log
... Log file written to /root/ords_install_apex_2021-07-28_221716_00329.log
Completed installation for Oracle REST Data Services version 21.2.0.r1741826. Elapsed time: 00:00:19.493
Enter 1 if you wish to start in standalone mode or 2 to exit [1]:2
advanced here is mandatory - then instead of selecting SID you must choose Service name and set pluggable database (PDB) - in case of Oracle DB XE it's XEPDB1, for Enterprise Edition - ORCLPDB1
that's how user should be created
$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Wed Jul 28 20:06:06 2021
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
SQL> ALTER SESSION SET CONTAINER=ORCLPDB1;
Session altered.
SQL> CREATE USER testuser1 IDENTIFIED BY MyNewPassword DEFAULT TABLESPACE users QUOTA UNLIMITED ON users;
User created.
SQL> GRANT CREATE SESSION, CREATE TABLE, CREATE PROCEDURE TO testuser1;
Grant succeeded.
SQL> GRANT CONNECT, RESOURCE TO testuser1;
Grant succeeded.
SQL> GRANT SODA_APP TO testuser1;
Grant succeeded.
SQL> quit
Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
that's how rest should be enabled for the schema
$ sqlplus /nolog
SQL*Plus: Release 19.0.0.0.0 - Production on Wed Jul 28 20:21:19 2021
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
SQL> CONN testuser1/MyNewPassword#ORCLPDB1
Connected.
SQL> EXEC ords.enable_schema;
PL/SQL procedure successfully completed.
SQL> COMMIT;
Commit complete.
alternatively, you can setup SQL Developer in the way of setting Service name instead of SID - Rest Services menu item will become available.

can not connect to oracledb running in a docker container

Mac OS and docker
From the oracledb console, I can not connect as sys, password I type in oracle and no go
SQL> connect sys as sysdba;
Enter password:
ERROR:
ORA-12547: TNS:lost contact
how did I get this far...
docker pull absolutapps/oracle-12c-ee
docker run -d --name oracle-12cR1-ee --privileged absolutapps/oracle-12c-ee
docker logs -f oracle-12cR1-ee
at then end of that I get
PL/SQL procedure successfully completed.
Please login to http://<ip_address>:8080/em to use enterprise manager
User: sys; Password oracle; Sysdba: true
Fixing permissions...
Running init scripts...
Init scripts in /oracle.init.d/: Ignoring /oracle.init.d/*
Done with scripts we are ready to go
Next command I run is
docker exec -it 28b0f34f7a81 bash -c "source /home/oracle/.bashrc; sqlplus /nolog"
SQL*Plus: Release 12.1.0.2.0 Production on Fri Jun 28 23:08:41 2019
Copyright (c) 1982, 2014, Oracle. All rights reserved.
SQL> connect sys as sysdba;
Enter password:
ERROR:
ORA-12547: TNS:lost contact
at this point, I am stuck...
Thoughts or seen this before?
Looking at the source code for that image you're using I was able to see that they're using gosu oracle sqlplus to connect to the database with elevated privileges, so I tried this in my environment and seems to fit perfectly to what you need:
docker exec -it oracle-12cR1-ee sh -c 'gosu oracle sqlplus "sys as sysdba"'
getting..
SQL*Plus: Release 12.1.0.2.0 Production on Sat Jun 29 00:33:12 2019
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Enter password:
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SQL>
and then being able to (for example):
SQL> SELECT USERNAME from SYS.ALL_USERS;
Enjoy! ;)
Edit:
Using just sqlplus / as sysdba also works as well, so it would be:
docker exec -it oracle-12cR1-ee sh -c 'gosu oracle sqlplus / as sysdba'

TNS listener does not currently know of SID given in connect descriptor

Hi,
I have installed Oracle 11g on my laptop for practicing Oracle.
I've connected to the HR account. It has been connected for 3 days, but after that I was getting this error when I tried to connect through SQL Developer:
TNS-12505: TNS:listener does not currently know of SID given in connect descriptor
Make sure that
Your DB is started up ;
$ sqlplus / as sysdba
SQL> startup
ORACLE_SID parameter is set to a path value;
on Windows, look-up by :
C:\Users\pc> echo %ORACLE_SID%
mydb
on Unix, look-up by :
$ echo $ORACLE_SID
mydb
and Listener is running :
$ lsnrctl status
LSNRCTL for Linux : Version 12.1.0.2.0 - Production on 03-JUN-2018 09:31:07
Copyright (c) 1991, 2014, Oracle. All rights reserved.
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 12.1.0.2.0 - Production
Start Date 30-MAR-2018 22:29:45
Uptime 53 days 11 hr. 1 min. 10 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/12.1.0.2/grid/network/admin/listener.ora
Listener Log File /u01/app/grid/diag/tnslsnr/mydb/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=172.16.15.81)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=mycompany.com)(PORT=5505))(Presentation=HTTP)(Session=RAW))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=mycompany.com)(PORT=5506))
(Security=(my_wallet_directory=/u01/app/oracle/product/12.1.0.2/dbhome_1/admin/mydb/xdb_wallet))(Presentation=HTTP)(Session=RAW))
Services Summary...
Instance "mydb", status READY, has 1 handler(s) for this service...
The command completed successfully
You should try the following ways and one of them may work for you.
Way-1: In windows: use this video: restart services OracleOraDB19Home1TNSListener then OracleServiceORCL.
Way-2: connect with system user password to sql plus as shown as:
Enter user-name: system/ as sysdba
Enter password: your_password
SQL> shutdown
SQL> startup nomount
SQL> alter system set db_recovery_file_dest_size=4G scope=both;
SQL> alter database mount;
SQL> alter database open;
And now check your problem fixed? If no set below code then check again.
SQL> alter system set local_listener='(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp) (HOST=127.0.0.1) (PORT=1521)))';
This work for me.

Resources