Go to main content

Developing System Services in Oracle® Solaris 11.3

Exit Print View

Updated: September 2018
 
 

Creating an Oracle Database Listener Service

This section describes the Oracle Database listener service manifest and the start/stop method script that is used in that manifest.

The listener is a process that manages the incoming traffic of client connection requests to the database instance.

Listener Service Manifest

The following are some features to note about the Oracle Database listener service. See the service manifest following this list.

  • As in the Oracle Database instance control service (database service), the service name and manifest name are the same. The service is named site/oracle/db/listener. The manifest file name is listener.xml and is located at /lib/svc/manifest/site/oracle/db/listener.xml.

  • No default instance is defined for this service. Add instances by using the svccfg add command. The name of each instance must match the name of an Oracle Database instance.

  • Three dependencies are defined. In addition to the two dependencies defined for the database service, the listener service depends on the database service.

  • The method_credential element is the same as the method_credential element in the database service manifest except that the user oracle is in the group oinstall.

  • The method script is the same as the database service method script: /lib/svc/method/svc-oracle-database. The listener argument calls the listener start or stop function instead of the database start or stop function. The %m, %i, and timeout_seconds arguments are the same as for the database service.

  • The action_authorization property is the same as for the database service.

<?xml version="1.0"?>
<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
<!--
	Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.

	Define a service to start or stop an Oracle Database instance.
-->

<service_bundle type="manifest" name="site/oracle/db/listener">
  <service name="site/oracle/db/listener" type="service" version="1">

    <dependency type="service"
        name="filesystem_dependency"
        grouping="require_all"
        restart_on="none">
        <service_fmri value="svc:/system/filesystem/local"/>
    </dependency>

    <dependency type="service"
        name="multi_user_dependency"
        grouping="require_all"
        restart_on="none">
        <service_fmri value="svc:/milestone/multi-user"/>
    </dependency>

    <dependency type="service"
        name="database_dependency"
        grouping="require_all"
        restart_on="none">
      <service_fmri value="svc:/site/oracle/db/database"/>
    </dependency>

    <method_context>
      <method_credential user="oracle" group="oinstall" />
      <method_environment>
        <envvar name="ORACLE_HOME" value="/opt/oracle/product/home" />
      </method_environment>
    </method_context>

    <exec_method type="method"
        name="start"
        exec="/lib/svc/method/svc-oracle-database listener %m %i"
        timeout_seconds="0"/>

    <exec_method type="method"
        name="stop"
        exec="/lib/svc/method/svc-oracle-database listener %m %i"
        timeout_seconds="0"/>

    <property_group name="general" type="framework">
      <propval type="astring"
        name="action_authorization"
        value="solaris.smf.manage.oracle"/>
    </property_group>

    <stability value="Evolving"/>
  </service>
</service_bundle>

Add name and description metadata to the manifest so that users can get information about this service from the svcs and svccfg describe commands. See the template element in the DTD.

Ensure the service manifest is valid:

# svccfg validate listener.xml

To install the service, copy the manifest to /lib/svc/manifest and restart the manifest-import service:

# cp listener.xml /lib/svc/manifest/site/oracle/db/listener.xml
# svcadm restart manifest-import

Note -  Before you enable the service, create and install the method script (Start/Stop Method Script for the Oracle Database Instance Control Service) and add service instances (Add Listener Service Instances).

Add Listener Service Instances

Verify that the start/stop method script is installed and executable.

Add instances by using the svccfg add command and specifying LISTENER as the name of the service instance, as described in Listener Control Utility in the Database Net Services Reference documentation.

$ svccfg -s site/oracle/db/listener add LISTENER
$ svccfg -s listener:LISTENER
svc:/site/oracle/db/listener:LISTENER> addpropvalue general/complete astring: dev
svc:/site/oracle/db/listener:LISTENER> addpropvalue general/enabled boolean: true
svc:/site/oracle/db/listener:LISTENER> refresh
svc:/site/oracle/db/listener:LISTENER> exit

The following command starts the listener:

# svcadm enable listener:LISTENER

Note that the preceding svccfg command set this service instance to be enabled by default.

Verify that the listener service is installed and the LISTENER instance is online:

# svcs listener

The following command stops the listener:

# svcadm disable listener:LISTENER