You are previewing Sun™ Cluster 3 Programming: Integrating Applications into the SunPlex™ Environment.
O'Reilly logo
Sun™ Cluster 3 Programming: Integrating Applications into the SunPlex™ Environment

Book Description

Customize Applications for Maximum Availability in Sun Cluster Environments

The Sun Cluster 3 environment offers developers and administrators a powerful API for creating custom "data services" that maximize the availability and enhance the horizontal scalability of many enterprise applications. Now, here's an authoritative tutorial and reference to building custom data services with the Sun Cluster 3 API. In Sun Cluster 3 Programming, three leading Sun Cluster experts systematically review the tools, programming interfaces, and features that make custom data services possible. Then, through a series of step-by-step examples, they demonstrate how to ensure that applications can recover smoothly from even the most serious failures.

This book

  • Reviews every facet of "availability" and what it takes to make software available

  • Provides extensive easy-to-understand code examples, all available for download

  • Covers all areas of agent development, from quick basics to advanced techniques

  • Covers all the APIs provided with Sun Cluster 3

  • Walks step-by-step through making existing applications available, scalable, and cluster-aware

  • Until now, this information has been available only in a three-day Sun training course. Now, with the help of Sun's in-house experts, you have all the information you need to build Sun Cluster 3 custom applications that deliver unprecedented levels of application availability.



    Table of Contents

    1. Copyright
      1. Dedication
    2. List of Figures
    3. List of Tables
    4. Foreword
    5. Preface
      1. About This Book
        1. Audience
        2. Assumptions
        3. Chapter 1: Introduction
        4. Chapter 2: Introducing Sun Cluster 3
        5. Chapter 3: Getting Started
        6. Chapter 4: Planning for Development
        7. Chapter 5: Developing with the SunPlex Agent Builder
        8. Chapter 6: Understanding the RGM
        9. Chapter 7: Programming with the RMAPI
        10. Chapter 8: Managing Processes
        11. Chapter 9: Using the DSDL
        12. Chapter 10: Developing for Existing Applications
        13. Chapter 11: Writing Scalable Services
        14. Chapter 12: Using Remote Shared Memory
        15. Chapter 13: Developing Cluster-Aware Applications
        16. Font Conventions
          1. Special Characters
          2. Programming Tools and Source Code
        17. Software Requirements
        18. Source Code for Examples
    6. Acknowledgments
      1. Joseph Bianco
      2. Peter Lees
      3. Kevin Rabito
    7. 1. Introduction
      1. Clusters and High Availability
        1. Clusters 101
        2. Cluster Types
          1. Cluster Architectures
            1. Loosely Coupled Clusters
            2. Tightly Coupled Clusters
          2. Specific Purposes
            1. Compute Clusters
            2. High-Availability Clusters
          3. Example Cluster Applications
            1. Grid Computing
            2. High-Performance Clusters
      2. High Availability
        1. Business Case for HA
          1. Service Availability
          2. Application Availability
          3. Cluster Availability
          4. Causes of Downtime
        2. Availability Solutions
          1. Fault Tolerance
          2. HA Clusters
      3. Summary
    8. 2. Introducing Sun Cluster 3
      1. Feature Set of Sun Cluster
        1. About Sun Cluster
          1. Installation
          2. Cluster Nodes
          3. Storage
          4. Failures
      2. Sun Cluster Framework
        1. Global Devices
        2. Global Filesystems
        3. Failover File Services
        4. Resource Group Manager
        5. Failover Resources
        6. Scalable Resources
        7. Resource Anatomy
          1. Resource Type
          2. Resources
          3. Resource Groups
          4. Resource Creation
        8. Sun Cluster Subtopics
          1. IPMP
          2. CMM
          3. CCR
          4. Quorum Devices
          5. Load Balancing
          6. Cluster Transport
          7. Volume Manager
        9. Application Monitoring
      3. Summary
    9. 3. Getting Started
      1. Up and Running
      2. Preparing the Cluster
        1. Preparing a Global Filesystem
        2. Preparing the Apache Web Server
      3. Creating an Agent with the GDS
      4. Operation
        1. Stopping
        2. Fault Probe
        3. Limitations
      5. Summary
    10. 4. Planning for Development
      1. The Importance of Planning
      2. Qualifying an Application
        1. Data Service Access
        2. Crash Tolerance
        3. Bounded Recovery Time
        4. File Location Independence
        5. Absence of a Tie to Physical Identity of Node
        6. Ability to Work on Multi-Homed Hosts
        7. Ability to Work with Logical Interfaces
        8. Client Recovery
        9. Requirements for Scalable Services
      3. Getting Around Requirements
      4. Determining Scope
        1. Cluster Awareness
        2. Failover or Scalable
        3. Fault Recovery
        4. Complex Monitoring
        5. Enterprise Architecture
      5. Gathering Application Information
        1. Start
        2. Stop
        3. Monitor
      6. Choosing a Tool
        1. Generic Data Service
        2. SunPlex Agent Builder
        3. Source from Scratch
      7. Choosing a Language
        1. C
        2. Korn Shell
        3. Others
      8. Summary
    11. 5. Developing with the SunPlex Agent Builder
      1. Installing the SunPlex Agent Builder
      2. Preparing Apache and the Cluster
        1. Review Configuration
      3. Using the Agent Builder GUI
        1. Creating a Resource Type
          1. Vendor and Application Name
          2. Working Directory
          3. Failover or Scalable
          4. Network Awareness
          5. Source Code Language
          6. Running the Creation Command
        2. Configuring the Resource Type
          1. Start Command
          2. Stop Command
          3. Probe Command
          4. Running the Configuration Command
      4. Installing and Controlling the Agent
        1. Creating and Starting a Resource
        2. Stopping and Removing a Resource
        3. Generating C or ksh Source with the GUI
      5. Using the Command-Line Tools
        1. Creating a Resource Type
        2. Configuring the Resource Type
      6. Advanced Topics
        1. The HOSTNAMES variable
        2. Multiple Processes
        3. Changing a Resource Type
        4. Changing the Source
          1. RTR File
          2. Start/Stop/Probe Source
        5. Remaking the Package
        6. Adding Items to the Package
        7. Advanced Fault Probing
      7. Summary
    12. 6. Understanding the RGM
      1. The Callback Model
        1. Semantic Overview of Sun Cluster Callback Model
      2. Sun Cluster API Callback Methods
      3. Callback Definitions
        1. Initialization Methods
          1. START
          2. STOP
          3. PRENET_START
          4. POSTNET_STOP
          5. INIT
          6. FINI
          7. BOOT
        2. Administration Methods
          1. VALIDATE
          2. UPDATE
        3. Application Monitoring Methods
          1. MONITOR_START
          2. MONITOR_STOP
          3. MONITOR_CHECK
        4. Idempotency
          1. Callback Exit Codes
        5. Application Monitoring
      4. Life Cycles for Resource Types
      5. Creating Resource Types
        1. Resource Type Registration File
          1. RTR File Sections
        2. Building the RTR File
          1. RTR Syntax Rules
          2. Simple RTR File
        3. Resource Property Types
          1. Tunable Property Values
          2. RGM Naming Restrictions
          3. RGM Values
          4. Resource Property Attributes
      6. Using Callback Methods
      7. Summary
    13. 7. Programming with the RMAPI
      1. Introduction
        1. Getting Started
      2. Overview of the RMAPI
      3. Access Methods
      4. Get Methods
        1. Cluster Access Methods
        2. scha_cluster_open()
        3. scha_cluster_get()
        4. scha_cluster_close()
        5. scha_cluster_get - CLI
        6. scha_cluster_getlogfacility()
        7. scha_cluster_getnodename()
        8. Resource Type Access Methods
        9. scha_resourcetype_open()
        10. scha_resourcetype_get()
        11. scha_resourcetype_close()
        12. scha_resourcetype_get - CLI
        13. Resource Access Methods
        14. scha_resource_open()
        15. scha_resource_get()
        16. scha_resource_close()
        17. scha_resource_get - CLI
        18. Resource Group Access Methods
        19. scha_resourcegroup_open()
        20. scha_resourcegroup_get()
        21. scha_resourcegroup_close()
        22. scha_resourcegroup_get - CLI
      5. Utility Methods
        1. scha_control()
        2. scha_control - CLI
        3. scha_resource_setstatus()
        4. State versus Status
        5. scha_resource_setstatus - CLI
        6. scha_strerror()
      6. Data Types
        1. Enumerated Types
        2. Structures
        3. scha_status_value_t
        4. scha_str_array_t
        5. scha_uint_array_t
        6. scha_extprop_value_t
        7. scha_err_t
        8. Void Typedefs
      7. Summary
    14. 8. Managing Processes
      1. Introduction
      2. Process Monitor Facility
        1. Process Monitoring Considerations
        2. Application Monitoring
        3. Starting a Process Monitor
        4. Child Process Monitoring
        5. Action Program
        6. Process Monitor Status
        7. Fault Monitoring
        8. Stopping the Process Monitor
      3. Time-Based Process Management
      4. File Locking
      5. Summary
    15. 9. Using the DSDL
      1. Introduction to the DSDL
      2. Using the DSDL
        1. RTR File Considerations
        2. Program Arguments
      3. DSDL Functions
        1. A Note on Man Page Entries
        2. Managing the DSDL Environment
          1. scds_initialize
          2. scds_close
        3. Functions for Resources
          1. scds_get_ext_property
          2. scds_get_ext_confdir_list
          3. scds_get_ext_monitor_retry_count
          4. scds_get_ext_monitor_retry_interval
          5. scds_get_ext_probe_timeout
          6. scds_get_netaddr_list
          7. scds_get_port_list
          8. scds_get_resource_name
          9. scds_restart_resource
          10. scds_get_rs_*
          11. scds_get_rs_hostnames
        4. Functions for Resource Groups
          1. scds_failover_rg
          2. scds_get_resource_group_name
          3. scds_get_rg_hostnames
          4. scds_restart_rg
          5. scds_get_rg_*
        5. Functions for Resource Types
          1. scds_get_resource_type_name
          2. scds_get_rt_*
        6. Application Control
          1. scds_pmf_get_status
          2. scds_pmf_restart_fm
          3. scds_pmf_signal
          4. scds_pmf_start
          5. scds_pmf_stop
          6. scds_pmf_stop_monitoring
          7. scds_svc_wait
        7. Fault Monitoring
          1. scds_fm_action
          2. scds_fm_print_probes
          3. scds_fm_sleep
          4. scds_fm_tcp_connect
          5. scds_fm_tcp_read
          6. scds_fm_tcp_write
          7. scds_fm_tcp_disconnect
          8. scds_simple_probe
          9. scds_timerun
        8. General Utilities
          1. scds_error_string
          2. scds_print_net_list
          3. scds_print_netaddr_list
          4. scds_print_port_list
          5. scds_syslog
          6. scds_syslog_debug
        9. Memory Handling
          1. scds_free_ext_property
          2. scds_free_net_list
          3. scds_free_netaddr_list
          4. scds_free_port_list
      4. Summary
    16. 10. Developing for Existing Applications
      1. Introduction
      2. System Environment
      3. Example Applications
        1. Understanding the Application
        2. MySQL Application
          1. Data Service Access
          2. Crash Tolerance
          3. Bounded Recovery
          4. File Location Independence
          5. Absence of a Tie to Physical Identity of Node
          6. Ability to Work on Multi-Homed Hosts
          7. Ability to Work with Logical Interfaces
          8. Client Recovery
        3. CUPS Application
          1. Data Service Access—CUPS
          2. Crash Tolerance—CUPS
          3. Bounded Recovery—CUPS
          4. File Location Independence—CUPS
          5. Absence of a Tie to Physical Identity of Node—CUPS
          6. Ability to Work on Multi-Homed Hosts—CUPS
          7. Ability to Work with Logical Interfaces—CUPS
          8. Client Recovery—CUPS
      4. Project Creation
        1. scdscreate (1HA)
        2. Creating the MySQL Resource Type
        3. Creating the CUPS Resource Type
        4. scdsconfig (1HA)
        5. Resource Type Registration File
          1. Callback Methods
          2. MySQL Callback Methods
          3. CUPS Callback Methods
          4. Extension Properties
          5. MySQL Extension Properties
          6. CUPS Extension Properties
      5. Developing Callback Methods
        1. Creating the MySQL Callback Methods
          1. Helper Shell Functions
          2. MySQL START Method
          3. MySQL STOP Method
            1. Stopping the MySQL Application
          4. MySQL MONITOR_START Method
          5. MySQL MONITOR_STOP Method
          6. MySQL Probe Program
            1. Restart_service Function
            2. Decide_restart_or_failover Function
          7. MySQL MONITOR_CHECK Method
          8. MySQL UPDATE Method
          9. MySQL VALIDATE Method
        2. Creating the CUPS Callback Methods
          1. CUPS START Method
          2. CUPS STOP Method
          3. CUPS MONITOR_START Method
          4. CUPS MONITOR_STOP Method
          5. CUPS Probe
          6. CUPS VALIDATE Method
          7. CUPS UPDATE Method
          8. CUPS MONITOR_CHECK Method
      6. Deploying the Agent
        1. To Package Add or Not
        2. Registering the Resource Type
        3. Creating the Resource
        4. Managing the Resource
      7. Summary
    17. 11. Writing Scalable Services
      1. Benefits of Scalable Services
        1. Increase Capacity
        2. Availability and Fast Failure Recovery
        3. Comparing Scalable Services to Other Distributed Service Mechanisms
        4. Parallel Databases
        5. Non-Networked Scalable Services
      2. Sun Cluster Facilities for Scalable Services
        1. Resources and the RGM
        2. Global Devices
        3. Global File Service
        4. Global Networking
        5. Public Network Management
        6. Dependencies
        7. Weighted Load Balancing
          1. Sticky Load Balancing
          2. Wildcard Sticky
      3. Developer Responsibilities
        1. Multiple Instances
        2. Data-Level Consistency
        3. Session State
        4. Cluster Awareness
      4. Developing a New Application to Be Scalable
        1. Sessionless Services
        2. Implementing a Sessionless Scalable Service
        3. Applications Using Internode Communication
      5. Remote Shared Memory
      6. Summary
    18. 12. Using Remote Shared Memory
      1. Introduction to RSM
      2. The RSMAPI
        1. Starting RSM Operations
        2. Exporting the Memory
        3. Publishing Exported Segments
        4. Identifying Segments
        5. Importing Segments
        6. Barriers
        7. Synchronization
        8. Nonmapping Operations
      3. Traps and Tricks
        1. Data Structure Considerations
        2. Error Handling and High Availability
      4. Summary
    19. 13. Developing Cluster-Aware Applications
      1. Cluster Aware versus Non-Cluster Aware
        1. Non-Cluster Aware
        2. Cluster Aware
      2. CRNP
        1. CRNP Framework
        2. CRNP Components
          1. syseventd
          2. cl_eventd
          3. cl_apid
          4. CRNP Messaging
        3. CRNP Resource Type
        4. CRNP Client Semantics
          1. Client Registration
          2. Message Passing
            1. Cluster Side Messages
            2. Message Error Handling
      3. Summary
    20. A. Resources
    21. B. RMAPI
    22. C. Data Service Development Library
    23. D. Process Utilities
    24. E. CRNP
    25. References