Integration Oracle database with SMF in Solaris

In this article I will show how to add Oracle database as service in Solaris SMF.

To make it possible we need to do two things:

1. Create script which will stop and start database

2. Create xml manifest , which will cover configuration for our service.

Let’s start…

1. Preparing oratab file  and scripts dbstart,dbshut.

As first step will edit oratab file.

Files is stored in folder: /var/opt/oracle/oratab:

SolarisA#> ls -lrt /var/opt/oracle/oratab
-rw-rw-r– 1 oracle root 716 Aug 18 19:50 /var/opt/oracle/oratab

We are adding one line into it:

SolA:/u01/app/oracle/product/10.2.0:Y

where fields means:

<instance name>:$ORACLE_HOME:Y

This “Y” at the end means, that script dbstart have to start our instance.

We can and more than one instance in this file.

Next we start editing dbstart script. File is located in folder $ORACLE_HOME/bin, in my operating system it is:

/u01/app/oracle/product/10.2.0/bin/dbstart

We are adding:

– at the beginning of first line:

#!/bin/bash

– we change ORACLE_HOME_LISTNER  in dbstart script like below:

ORACLE_HOME_LISTNER=/u01/app/oracle/product/10.2.0

We change this if we want to start listener together with our database.

If we want aslo stop listener whan database will be stopped we are adding to dbshut ( is in same folader as dbstart) line:

/u01/app/oracle/product/10.2.0/bin/lsnrctl stop

before:

#
# Following loop shuts down ‘ASM Instance[s]’
#

2. Creating starting script.

Script we create in folder:

/lib/svc/method

I called it orasmf.sh and it contains following lines:

SolarisA#> cat /lib/svc/method/orasmf.sh


#!/sbin/sh
ORACLE_HOME=/u01/app/oracle/product/10.2.0
export ORACLE_HOME

case “$1” in
‘start’)
$ORACLE_HOME/bin/dbstart
;;

‘stop’)
$ORACLE_HOME/bin/dbshut
;;

*)
echo “Usage $0 {start | stop }”
exit 1
;;

esac
exit 0

3. Manifest creation.

Manifest will be stored in:

/var/svc/manifest/application/database/

I called mine oracle.xml and it lloks like below:

SolarisA#> cat /var/svc/manifest/application/database/oracle.xml

<?xml version=”1.0″?>
<!DOCTYPE service_bundle SYSTEM “/usr/share/lib/xml/dtd/service_bundle.dtd.1”>
<!–

Oracle manifest by admindot.pl.
–>

<service_bundle type=’manifest’ name=’oracle’>


<service
name=’application/database/oracle’
type=’service’
version=’1′>

<create_default_instance enabled=’true’ />

<single_instance />

<!–
Wait for all local filesystems to be mounted.
–>

<dependency name=’filesystem-local’
grouping=’require_all’
restart_on=’none’
type=’service’>
<service_fmri
value=’svc:/system/filesystem/local:default’/>
</dependency>


<dependency name=’name-services’
grouping=’require_all’
restart_on=’none’
type=’service’>
<service_fmri value=’svc:/milestone/name-services’ />
</dependency>

<exec_method
type=’method’
name=’start’
exec=’/lib/svc/method/orasmf.sh start’
timeout_seconds=’60’>
<method_context>
<method_credential user=’oracle’ group=’dba’ />
<method_environment>
<envvar name=’ORACLE_SID’ value=’SolA’ />
<envvar name=’ORACLE_HOME’ value=’/u01/app/oracle/product/10.2.0′ />
<envvar name=’ORACLE_BASE’ value=’/u01/app/oracle’ />
</method_environment>
</method_context>
</exec_method>

<exec_method
type=’method’
name=’stop’
exec=’/lib/svc/method/orasmf.sh stop’
timeout_seconds=’60’>
<method_context>
<method_credential user=’oracle’ group=’dba’ />
<method_environment>
<envvar name=’ORACLE_SID’ value=’SolA’ />
<envvar name=’ORACLE_HOME’ value=’/u01/app/oracle/product/10.2.0′ />
</method_environment>
</method_context>
</exec_method>

<property_group name=’start’ type=’method’>
<propval name=’action_authorization’ type=’astring’
value=’solaris.smf.manage.oracle’ />
<propval name=’modify_authorization’ type=’astring’
value=’solaris.smf.manage.oracle’ />
<propval name=’value_authorization’ type=’astring’
value=’solaris.smf.manage.oracle’ />
</property_group>
<property_group name=’stop’ type=’method’>
<propval name=’action_authorization’ type=’astring’
value=’solaris.smf.manage.oracle’ />
<propval name=’modify_authorization’ type=’astring’
value=’solaris.smf.manage.oracle’ />
<propval name=’value_authorization’ type=’astring’
value=’solaris.smf.manage.oracle’ />
</property_group>

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


<stability value=’Unstable’ />

<template>
<common_name>
<loctext xml:lang=’C’>
Oracle SMF
</loctext>
</common_name>
</template>

</service>

</service_bundle>

In manifest I defined that, oracle will start after local file systems are mounted and  name-services are started. Additional database will be started under  oracle user and  dba group, User oracle will be able to maintain oracle service in SMFa.

To made this maintenance possible we add in /etc/security/auth_attr file

line :

solaris.smf.manage.oracle:::Manage Oracle SMF service::

and run command:

SolarisA#>usermod -A solaris.smf.manage.oracle oracle

We are checking if our mainfest didn’t contains  errors:

SolarisA#> svccfg validate /var/svc/manifest/application/database/oracle.xml

If there are no output from this command it means our manifest is ok.

We are adding our service:

SolarisA#> svccfg import /var/svc/manifest/application/database/oracle.xml

and checking if it works:

SolarisA#> svcs oracle
STATE STIME FMRI
online 20:51:25 svc:/application/database/oracle:default

SolarisA#> ps -ef | grep -i ora
oracle 1048 1 0 20:51:40 ? 0:00 ora_q001_SolA
oracle 1014 1 0 20:51:20 ? 0:01 ora_pmon_SolA
oracle 1084 1 0 21:31:32 ? 0:01 ora_cjq0_SolA
oracle 1030 1 0 20:51:20 ? 0:01 ora_mmon_SolA
oracle 1063 859 0 21:05:22 pts/1 0:00 -bash
oracle 1024 1 0 20:51:20 ? 0:01 ora_ckpt_SolA
root 1105 1098 0 21:44:37 pts/1 0:00 grep -i ora
oracle 1018 1 0 20:51:20 ? 0:00 ora_mman_SolA
oracle 1036 1 0 20:51:25 ? 0:00 ora_qmnc_SolA
oracle 1020 1 0 20:51:20 ? 0:00 ora_dbw0_SolA
oracle 1046 1 0 20:51:35 ? 0:00 ora_q000_SolA
oracle 949 1 0 20:51:19 ? 0:00 /u01/app/oracle/product/10.2.0/bin/tnslsnr LISTENER -inherit
oracle 1016 1 0 20:51:20 ? 0:00 ora_psp0_SolA
oracle 1022 1 0 20:51:20 ? 0:00 ora_lgwr_SolA
oracle 1028 1 0 20:51:20 ? 0:00 ora_reco_SolA
oracle 1032 1 0 20:51:20 ? 0:04 ora_mmnl_SolA
oracle 1026 1 0 20:51:20 ? 0:00 ora_smon_SolA

One Response to “Integration Oracle database with SMF in Solaris”

  1. | cyberz.org says:

    […] the procedura on how to add Oracle 12c as SMF service in Solaris 11.1, based on this guide. The version provided here is slightly modified version which sacrifices the SVC method script to […]

Leave a Response