andreasdijkman / oracle-systemd-scripts

Scripts for start/stopping Oracle databases with systemd
GNU General Public License v3.0
9 stars 2 forks source link

Support for multiple listener with different ORACLE_HOMEs #6

Open Rendanic opened 3 years ago

Rendanic commented 3 years ago

I need the ability to create multiple listeneres in different ORACLE_HOMEs. Any idea how we can add this?

I could create a /etc/sysconfig/oracle with ansible for all listeners but I need a structure for it.

andreasdijkman commented 3 years ago

I was thinking about using multiple ENV-variables for the LISTENER, but a reload would reload these changes. I tend towards defining a kind of listener-tab-file with similar format for multiple ORACLE_HOME's and LISTENER-names. The only listener that can be started is LISTENER. But if you have multiple listeners in one ORACLE_HOME, there is no way to start these now.

A listener-tab with something like:

<ORACLE_HOME_1>:<LISTENER_NAME>
<ORACLE_HOME_2>:<LISTENER_NAME>

The LISTENER_NAME could even be optional. A reload of the service would reload this file and would stop the extra listeners, but more importantly would start them at boot.

Rendanic commented 3 years ago

Could we change it to:

<LISTENER_NAME>:<ORACLE_HOME_1>

That fits better to the oratab. LISTENER_NAME = LISTENER when column is empty.

andreasdijkman commented 3 years ago

Yes, that would be more inline with the listener. But on the other hand, this file is totally different and leaving the first column empty would start the line with a :. That looks kind of ugly.

Or just make the listener-name mandatory. I want to make the listener-tab optional anyway. If it's not there, just leave it with that and use LISTENER_ORACLE_HOME, to keep everything backwards compatible.

Rendanic commented 3 years ago

Looks fine for me:

We should not use LISTENER_ORACLE_HOME and Listener-tab together, because that could create strange mixed configurations with possible problems at a later time.

That offers the needed flexibility and it is easy to use in simple environments.

ibre5041 commented 2 years ago

I created PR #10 , it contains antlr3 based library for parsing listener.ora files. So /etc/sysconfig/oracle can contain:

LISTENER_NAME=LISTENER

The script oracle-systemd-service.py iterates over all OHs, until it finds the one where specified listener is configured, read-only OHs are supported too. The format could be even simpler:

LISTENER_NAME=LISTENER,LISTENER_DG,LISTENER_THREE

Matching OH can be deduced by parsing all listener.ora files.

andreasdijkman commented 2 years ago

@ibre5041 thanks for the PR!

How do you start 2 listeners in this case with the same LISTENER_NAME (LISTENER for instance) but from a different ORACLE_HOME?

And if it finds 2 LISTENER's with the same name in 2 ORACLE_HOME's, which LISTENER does it start?

ibre5041 commented 2 years ago

It is not bullet proof. At this moment is does not support multiple listeners. Such a change would require changes in internal structures, and I did not have courage to do that(yet).

So some future change can introduce a format like:

 LISTENER_NAME=LISTENER,LISTENER_DG,LISTENER_THREE

or

 LISTENER_NAME=LISTENER:/u01/oracle/product/12.2.0:LISTENER_DG:@LATEST@

In mine installations I do not use multiples listeners so often, and I never use multiple LISTENERs having same name. Also I did not implement any code which would deduce a patch level for each ORACLE_HOME, it would by quite hard. So I just sort ORACLE_HOMEs alphabetically(desc) and I do search for LISTENER_NAME in each ORACLE_HOME until I find it.

For 90% of mine installations the 2nd feature I implemented is just suitable:

LISTENER_ORACLE_HOME=@LATEST@

This will start default listener named ("LISTENER") using alphabetically last ORACLE_HOME. This also simplifies Ansible installations. There is no need to specify particular ORACLE_HOME, when the script can parse oratab and it is good practice to use listener from most recent OH.