C H A P T E R 4 |
If your application is to be run on a master-eligible node, install the application binary files on the node.
If your application is to be run on a diskless node, install the binaries on the master node in:
/export/root/diskless_node_name/path
where diskless_node_name is the name of the diskless node and path is the path to the application. For example, if the binaries are installed in the /opt/mySvc/bin/myapp directory, the application binaries are installed in the /export/root/NetraDiskless1/opt/mySvc/bin/myapp directory for the NetraDiskless1 diskless node.
If your application will run on a dataless node, binaries can be installed either on the local disk (as in the master-eligible node case) or on the shared partition (as in the diskless node case), but they should be installed on the local disk.
For definitions of the terms diskfull, diskless, and dataless nodes, see Cluster Model in the Netra High Availability Suite 3.0 1/08 Foundation Services Overview.
To enable the compiler and linker to locate the required header files and libraries, specify the following entries in your makefile:
CFLAGS += -I/opt/SUNWcgha/includeLDFLAGS += -L/opt/SUNWcgha/lib \ -R/opt/SUNWcgha/lib |
Building a 32-bit application:
CFLAGS += -I/opt/sun/includeLDFLAGS += -L/opt/sun/lib |
Building a 64-bit application:
CFLAGS += -I/opt/sun/includeLDFLAGS += -L/opt/sun/lib64 |
Note - These entries apply only if the developer package header files and libraries are installed in their default locations. For information on installing the header files and libraries required by developers, see Installing Libraries and Header Files. |
For an example makefile that uses a specified code example, see EXAMPLE 4-4.
The applications you
develop using the CMM API can be compiled using the Sun Studio software compiler. For
more information, refer to the documentation supplied with Sun Studio
software.
Applications that are to run on a deployed Foundation Services cluster can be started automatically when the node is booted. For this, you can supply a startup script for the application. The startup script should be located in the /etc/init.d/ directory. Link the script to an entry in either the /etc/rc2.d/ directory or the /etc/rc3.d/ directory, and the script will be executed when the node boots. For more information, see the init(1M) man page.
If you require fast performance from a program, ensure that shared objects linked with the program are bound at startup. To prebind the shared objects, set the LD_BIND_NOW environment variable. For more information on this variable, see the Solaris documentation about Runtime Linker Linker and Libraries Guide, or for the Linux OS, refer to the ld(1) man page.
For better performance from programs running on diskless nodes, you can set the mlockall function within your program to lock address space. For more information, see the mlockall(3C) man page.
Applications that you develop on your development host can be tested on a cluster. For information about supported cluster configurations and how to connect your development host to a cluster, see the Netra High Availability Suite 3.0 1/08 Foundation Services Getting Started Guide.
To transfer applications from your development host to a cluster, use one of the following commands:
The code fragment shown in EXAMPLE 4-1 provides functions to display peer node membership information. This code is provided in the module common.c of the examples c and should be included when you run the CMM API examples provided in this guide. These functions use the set of functions cmm_member_isXXXX, which are explained in Chapter 5.
EXAMPLE 4-1 is accompanied by a common.h header file. The code in the common.h header file is used in many of the code samples in this guide and is shown in EXAMPLE 4-2.
#ifndef __CMM_COMMON__ #define __CMM_COMMON__ #include <cmm/cmm.h> extern void print_member(cmm_member_t const *P_Member) ; #endif |
For instructions on installing header files, see Installing Libraries and Header Files.
To check that your development host and cluster are running correctly and that you are able to compile and run code using the CMM API, an example, master_node.c, is provided. This example uses:
The common.h header file in EXAMPLE 4-2
The print_member function from the common.c code fragment in EXAMPLE 4-1
EXAMPLE 4-3 shows a sampling of this program.
An example makefile is also provided in this section. This example makefile enables you to compile the master_node.c code in EXAMPLE 4-3, using:
The common.h header file in EXAMPLE 4-2
The common.c in EXAMPLE 4-1
This example makefile is shown in EXAMPLE 4-4.
Building a 64-bit application for use with the the Linux OS:
Note - The preceding example is for the Solaris OS. If your system uses the Linux OS, modify the makefile as described in Setting Up a Makefile. |
The Netra HA Suite software is supplied with source code examples in the SUNWnhcmd developer package. These examples are installed in subdirectories of the /opt/SUNWcgha/examples/ directory for Solaris-based systems and in the /opt/sun/nhas/examples/ directory for Linux-based systems.
Copyright © 2008, Sun Microsystems, Inc. All rights reserved.