gvenzl / oci-oracle-free

Build scripts for Oracle Database FREE container/docker images
Apache License 2.0
113 stars 28 forks source link

Ability to set ORACLE_SID #34

Closed Physium closed 5 months ago

Physium commented 6 months ago

Is there a way for me to tweak the ORACLE_SID? Seems like its set to FREE on build but i want it to be something else, is that possible?

gvenzl commented 5 months ago

Hey @Physium,

Thanks a lot for using these images!

Unfortunately, there is no way around the ORACLE_SID, it has to be called FREE (case-insensitive), see:

[oracle@c7d90a09e0bc dbs]$ export ORACLE_SID=MY_ORCL
[oracle@c7d90a09e0bc dbs]$ sqlplus / as sysdba

SQL*Plus: Release 23.0.0.0.0 - Production on Sun Jan 28 02:03:31 2024
Version 23.3.0.23.09

Copyright (c) 1982, 2023, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> startup
ORA-00441: Oracle Free Edition SID violation. Expected:free vs Actual:MY_ORCL
SQL>

However, you could just set the service_names parameter to the name you would like:

[oracle@c7d90a09e0bc ~]$ sqlplus / as sysdba

SQL*Plus: Release 23.0.0.0.0 - Production on Sun Jan 28 02:07:35 2024
Version 23.3.0.23.09

Copyright (c) 1982, 2023, Oracle.  All rights reserved.

Connected to:
Oracle Database 23c Free Release 23.0.0.0.0 - Develop, Learn, and Run for Free
Version 23.3.0.23.09

SQL> alter system set service_names='my_orcl';

System altered.

SQL> alter system register;

System altered.

SQL> exit
Disconnected from Oracle Database 23c Free Release 23.0.0.0.0 - Develop, Learn, and Run for Free
Version 23.3.0.23.09
[oracle@c7d90a09e0bc ~]$ lsnrctl status

LSNRCTL for Linux: Version 23.0.0.0.0 - Production on 28-JAN-2024 02:07:52

Copyright (c) 1991, 2023, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC_FOR_FREE)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 23.0.0.0.0 - Production
Start Date                28-JAN-2024 01:58:32
Uptime                    0 days 0 hr. 9 min. 20 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Default Service           FREE
Listener Parameter File   /opt/oracle/product/23c/dbhomeFree/network/admin/listener.ora
Listener Log File         /opt/oracle/diag/tnslsnr/c7d90a09e0bc/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC_FOR_FREE)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1521)))
Services Summary...
Service "FREE" has 1 instance(s).
  Instance "FREE", status READY, has 1 handler(s) for this service...
Service "FREEXDB" has 1 instance(s).
  Instance "FREE", status READY, has 0 handler(s) for this service...
Service "my_orcl" has 1 instance(s).
  Instance "FREE", status READY, has 1 handler(s) for this service...
The command completed successfully

Once the service my_orcl is registered, you can connect via it:

[oracle@c7d90a09e0bc ~]$ sqlplus system/LetsTest1@//localhost/my_orcl

SQL*Plus: Release 23.0.0.0.0 - Production on Sun Jan 28 02:08:09 2024
Version 23.3.0.23.09

Copyright (c) 1982, 2023, Oracle.  All rights reserved.

Last Successful login time: Mon Oct 30 2023 03:01:49 +00:00

Connected to:
Oracle Database 23c Free Release 23.0.0.0.0 - Develop, Learn, and Run for Free
Version 23.3.0.23.09

SQL> show con_name;

CON_NAME
------------------------------
CDB$ROOT
SQL>

The service_names parameter also accepts multiple service names via a comma-separated list, so you can pass on multiple, e.g: 'free,my_orcl,foobar':

SQL> alter system set service_names='free,my_orcl,foobar';

System altered.

SQL> alter system register;

System altered.

SQL> exit
Disconnected from Oracle Database 23c Free Release 23.0.0.0.0 - Develop, Learn, and Run for Free
Version 23.3.0.23.09
[oracle@c7d90a09e0bc ~]$ lsnrctl status

LSNRCTL for Linux: Version 23.0.0.0.0 - Production on 28-JAN-2024 02:10:05

Copyright (c) 1991, 2023, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC_FOR_FREE)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 23.0.0.0.0 - Production
Start Date                28-JAN-2024 01:58:32
Uptime                    0 days 0 hr. 11 min. 32 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Default Service           FREE
Listener Parameter File   /opt/oracle/product/23c/dbhomeFree/network/admin/listener.ora
Listener Log File         /opt/oracle/diag/tnslsnr/c7d90a09e0bc/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC_FOR_FREE)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1521)))
Services Summary...
Service "FREE" has 1 instance(s).
  Instance "FREE", status READY, has 1 handler(s) for this service...
Service "FREEXDB" has 1 instance(s).
  Instance "FREE", status READY, has 0 handler(s) for this service...
Service "foobar" has 1 instance(s).
  Instance "FREE", status READY, has 1 handler(s) for this service...
Service "my_orcl" has 1 instance(s).
  Instance "FREE", status READY, has 1 handler(s) for this service...
The command completed successfully

You can connect with either free, my_orcl, or foobar to the container database:

[oracle@c7d90a09e0bc ~]$ sqlplus system/LetsTest1@//localhost/foobar

SQL*Plus: Release 23.0.0.0.0 - Production on Sun Jan 28 02:10:12 2024
Version 23.3.0.23.09

Copyright (c) 1982, 2023, Oracle.  All rights reserved.

Last Successful login time: Sun Jan 28 2024 02:08:09 +00:00

Connected to:
Oracle Database 23c Free Release 23.0.0.0.0 - Develop, Learn, and Run for Free
Version 23.3.0.23.09

SQL> show con_name;

CON_NAME
------------------------------
CDB$ROOT
SQL> conn system/LetsTest1@//localhost/my_orcl
Connected.
SQL> show con_name;

CON_NAME
------------------------------
CDB$ROOT
SQL> conn system/LetsTest1@//localhost/free
Connected.
SQL> show con_name;

CON_NAME
------------------------------
CDB$ROOT
SQL>

Of course, you could also create a PDB with the desired name, but I am assuming you want the container database to have a different name.

Hope this helps!

Physium commented 5 months ago

i want it configured upfront because its acting as a CI image for me. It there a licensing issue if i were to tweak the dockerfile oracle_sid to whatever i want?

gvenzl commented 5 months ago

Hi @Physium,

I understand, but as said, you can't tweak the SID for Free. If you do, the Oracle Database will throw ORA-00441: Oracle Free Edition SID violation. Expected:free vs Actual:MY_ORCL and refuse to start up.

Physium commented 5 months ago

@gvenzl truly much appreciated. thanks for shedding lights in into this blackbox.

gvenzl commented 5 months ago

You are very welcome, @Physium!