In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "how to realize the resource behavior of OCF". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
4 Resource agent structure
A typical (shell-based) resource broker has some standard structural elements. This chapter will be described in order. The details of each supported behavior of the resource agent will be described in the description. This chapter will take a hypothetical foobar function as an example.
4.1 Resource Agent interpreter
Each resource agent looks up with the standard "shebang" (#!)
one
#! / bin/sh
If the resource agent is written in shell, it is best to specify a generic shell interpreter (#! / bin/sh), but not mandatory. Using a / bin/sh-compatible resource agent must not use a particular shell dialect (such as ${! variable} in bash), and it is recommended that you use a checker for the resource agent, such as checkbashisms.
Some people consider using a patch to make previous sh-compliant resource proxies only available for bash, ksh, or other non-generic shell. However, for newly completed resource agents, it is best to explicitly define a specified shell interpreter, such as / bin/bash.
4.2 author and authorization information
The resource agent should contain a comment describing the author and copyright information, as well as authorization information for the resource agent, such as:
one
two
three
four
five
six
#
# Resource Agent for managing foobar resources.
#
# License: GNU General Public License (GPL)
# (c) 2008-2010 John Doe, Jane Roe
# and Linux-HA contributors
If the resource agent uses a different version of the license, the default can be assumed to be the current version.
4.3 initialization
Any shell resource agent should run the. ocf_shellfuncs function library According to the following syntax, such as $OCF_FUNCTION_DIR, this is for testing and writing documentation, and this variable may be repeatedly defined.
one
two
three
# Initialization:
: ${OCF_FUNCTIONS_DIR=$ {OCF_ROOT} / lib/heartbeat}
. ${OCF_FUNCTIONS_DIR} / ocf-shellfuncs
4.4 functional implementation of resource behavior
The following is a functional implementation of the behavior advertised by the resource agent. The details of each behavior will be described in Chapter 5.
4.5 execution block
The following is part of the code that a resource agent actually executes. It usually follows the following standard structure:
one
two
three
four
five
six
seven
eight
nine
ten
eleven
twelve
thirteen
fourteen
fifteen
sixteen
seventeen
eighteen
nineteen
twenty
twenty-one
twenty-two
twenty-three
twenty-four
twenty-five
twenty-six
twenty-seven
twenty-eight
twenty-nine
thirty
thirty-one
thirty-two
thirty-three
# Make sure meta-data and usage always succeed
Case $_ _ OCF_ACTION in
Meta-data) foobar_meta_data
Exit $OCF_SUCCESS
Usage | help) foobar_usage
Exit $OCF_SUCCESS
Esac
# Anything other than meta-data and usage must pass validation
Foobar_validate_all | | exit $?
# Translate each action into the appropriate function call
Case $_ _ OCF_ACTION in
Start) foobar_start
Stop) foobar_stop
Status | monitor) foobar_monitor
Promote) foobar_promote
Demote) foobar_demote
Reload) ocf_log info "Reloading..."
Foobar_start
Validate-all)
*) foobar_usage
Exit $OCF_ERR_UNIMPLEMENTED
Esac
Rc=$?
# The resource agent may optionally log a debug message
Ocf_log debug "${OCF_RESOURCE_INSTANCE} $_ _ OCF_ACTION returned $rc"
Exit $rc
This is the end of the content of "how to realize the resource behavior of OCF". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.