Writing a custom agent

The simplest way to create a custom service is tu use the scdsbuilder GUI.( found under /usr/cluster/bin).

Here's the steps to create a simple shell script dataservice

Start scdsbuilder GUI :
# /usr/cluster/bin/scdsbuilder &

Then use the GUI :




We will create a service called apache, vendor DEMO :




The create button create the RTR file. Then we get to next screen window :




Here we can fill the start / stop / probe / validate commands that the application uses.



















Configure will then create the package, ready to be installed.

Then the only steps left is to install the new package produced, register the RT, and create the dataservice :

# pkgadd -d . DEMOapache

Processing package instance <DEMOapache> from </tmp/DEMOapache/pkg>

Sun Cluster resource type for apache server(sparc) 3.0.0,REV=
Sun Microsystems, Inc.
Using </opt> as the package base directory.
## Processing package information.
## Processing system information.
   4 package pathnames are already properly installed.
## Verifying package dependencies.
## Verifying disk space requirements.
## Checking for conflicts with packages already installed.
## Checking for setuid/setgid programs.

Installing Sun Cluster resource type for apache server as <DEMOapache>

## Installing part 1 of 1.
/opt/DEMOapache/README.apache
/opt/DEMOapache/bin/apache_mon_check.ksh
/opt/DEMOapache/bin/apache_mon_start.ksh
/opt/DEMOapache/bin/apache_mon_stop.ksh
/opt/DEMOapache/bin/apache_pmf_action.ksh
/opt/DEMOapache/bin/apache_probe.ksh
/opt/DEMOapache/bin/apache_scha_ctrl_wrapper.ksh
/opt/DEMOapache/bin/apache_svc_start.ksh
/opt/DEMOapache/bin/apache_svc_stop.ksh
/opt/DEMOapache/bin/apache_update.ksh
/opt/DEMOapache/bin/apache_validate.ksh
/opt/DEMOapache/bin/gethostnames
/opt/DEMOapache/bin/hasp_check
/opt/DEMOapache/bin/simple_probe
/opt/DEMOapache/etc/DEMO.apache
/opt/DEMOapache/man/man1m/apache_config.1m
/opt/DEMOapache/man/man1m/removeapache.1m
/opt/DEMOapache/man/man1m/startapache.1m
/opt/DEMOapache/man/man1m/stopapache.1m
/opt/DEMOapache/util/apache_config
/opt/DEMOapache/util/removeapache
/opt/DEMOapache/util/startapache
/opt/DEMOapache/util/stopapache
/opt/cluster/lib/rgm/rtreg/DEMO.apache <symbolic link>
[ verifying class <none> ]


Installation of <DEMOapache> was successful.


# cd /opt/DEMOapache/util
#ls
apache_config  removeapache   startapache    stopapache

# ./startapache -h apache-ip-1 -p 80/tcp
No nafo groups or network adapters specified ... will try to auto-discover the network adapters 
and configure them into nafo groups.
Creating a failover instance ...
Registering resource type <DEMO.apache:1.0>...done.
Creating failover resource group <apache-harg>...done.
Creating logical host resource <apache-ip-1>...done.
Creating resource <apache-hars> for the resource type <DEMO.apache:1.0>...done.
Bringing resource group <apache-harg> online...[Fri Apr 17 15:48:46 2009] 
[warn] module perl_module is already loaded, skipping
/usr/apache/bin/apachectl start: httpd started         done.

Et voila, the service is up, you can point your favorite browser to the public http address given to the dataservice.

Here we assume apache was already setup as a non clustered application, and was properly working )


to remove :

./stopapache -h apache-ip-1 
Disabling resource <apache-hars> ...done.
Disabling the network resource <apache-ip-1> ...done.
Offlining resource group <apache-harg> on all nodes ...done.

# ./removeapache -h apache-ip-1
Disabling the resource <apache-hars> ...done.
Removing the resource <apache-hars> ...done.
Removing the resource type <DEMO.apache:1.0> ...done.
Disabling the resource <apache-ip-1> ...done.
Removing the resource <apache-ip-1> ...done.
Offlining the resource group <apache-harg> ...done.
Unmanaging the resource group <apache-harg> ...done.
Removing the resource group <apache-harg> ...done.



These steps can also be done via regular cluster commands :

#clrt register DEMO.apache

#clresourcegroup create -n v4u-4800e-doma-sin06,v4u-4800e-dombc-sin06 apache-rg 

#clreslogicalhostname create -g apache-rg apache-ip-1 

#clresource create -g apache-rg -t DEMO.apache apache-rs 

bring rg online :

#clresourcegroup online -M apache-rg 

et voila !

To remove the rg :

#clrg offline apache-rg

#clrs disable apache-rs

#clrs disable apache-ip-1

#clrs delete apache-rs

#clrs delete apache-ip-1

#clrg delete apache-rg

#clrt unregister DEMO.apache

Now let's create a GDS dataservice to achieve the same goal

#clrt register SUNW.gds

#clresourcegroup create -n v4u-4800e-doma-sin06,v4u-4800e-dombc-sin06 apache-rg 

#clreslogicalhostname create -g apache-rg apache-ip-1 

#clresource create -g apache-rg -t SUNW.gds -p Start_command="/usr/apache/bin/apachectl start" 
-p Stop_command="/usr/apache/bin/apachectl stop" -p Port_List=80/tcp apache-rs 


Bring rg online :


#clresourcegroup online -M apache-rg 

Et voila !

To remove :

#clrg offline apache-rg

#clrs disable apache-rs

#clrs disable apache-ip-1

#clrs delete apache-rs

#clrs delete apache-ip-1

#clrg delete apache-rg

#clrt unregister SUNW.gds
Comments:

Post a Comment:
  • HTML Syntax: NOT allowed
About

Jean-Christophe Lamoure

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today