2 Replies Latest reply: Oct 3, 2012 8:38 AM by Shiyer-Oracle RSS

    Dataguard trigger for linux services

    Web
      Hi,
      we are running oracle database 11.2.0.3 and tomcat on the same machine(SLES 11).
      I need to contol tomcat(start/stop) depending to database status. For example, if database stops or become standby then to stop tomcat service. Please help me to find solution.

      Thanks in advance!
        • 1. Re: Dataguard trigger for linux services
          mseberg
          Hello;

          If you have a standby then you should look at "Transparent Application Failover"

          Sample
          ernie =
           (DESCRIPTION =
              (ADDRESS_LIST =
                 (ADDRESS = (PROTOCOL = TCP)(HOST = primary)(PORT = 1521))
                 (ADDRESS = (PROTOCOL = TCP)(HOST = standby)(PORT = 1521))
                 )
                 (CONNECT_DATA =
                 (SERVICE_NAME = ernie)
              )
           )
          Then create the service on the Primary
          BEGIN
           
             DBMS_SERVICE.CREATE_SERVICE('ernie','ernie');
          
          END;
          /
          After creating the service needs to be manually started.
          BEGIN
           
             DBMS_SERVICE.START_SERVICE('ernie');
           
           END;
           /
          Several of the default parameters can now be set for 'ernie'.
          BEGIN
             DBMS_SERVICE.MODIFY_SERVICE
             ('ernie',
             FAILOVER_METHOD => 'BASIC',
             FAILOVER_TYPE => 'SELECT',
             FAILOVER_RETRIES => 200,
             FAILOVER_DELAY => 1);
          END;
          /
          Finally a database STARTUP trigger should be created to ensures that this service is only offered if the database is primary.

          CREATE TRIGGER CHECK_ERNIE_START AFTER STARTUP ON DATABASE
          DECLARE
           V_ROLE VARCHAR(30);
          BEGIN
           SELECT DATABASE_ROLE INTO V_ROLE FROM V$DATABASE;
           IF V_ROLE = 'PRIMARY' THEN
           DBMS_SERVICE.START_SERVICE('ernie');
           ELSE
           DBMS_SERVICE.STOP_SERVICE('ernie');
           END IF;
          END;
          /
          The event after startup is fired, if an instance changes from status MOUNT to OPEN.

          For additional information search on "DBMS_SERVICE.CREATE_SERVICE"

          Best Regards

          mseberg
          • 2. Re: Dataguard trigger for linux services
            Shiyer-Oracle
            Please check this new offering "Oracle Grid Infrastructure Bundled Agents" :-

            http://www.oracle.com/technetwork/products/clusterware/overview/index.html

            It has Tomcat integration with Clusterware. A dependency is setup from the Tomcat resource to the Database/Service - when the service or database goes offline, the tomcat resource will also be stopped.