Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Metadata

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 use Metadata". In the operation of actual cases, many people will encounter such a dilemma. Then 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!

2. API definition

2.1 Environmental variables

A resource agent obtains all the configuration information of a resource through environment variables. The names of those environment variables are often prefixed with OCF_RESKEY, which is the name of the resource. For example, if the resource has an ip parameter set to 192.168.1.1, the resource agent uses the environment variable OCF_RESKEY_ip to hold the value.

For any resource that does not need to be set by the user-that is, when the resource agent metadata parameter definition is not set to required= "true"-the resource agent must:

Provide a reasonable default value. This must be made clear in the metadata. For convenience, the resource agent uses a variable shaped like OCF _ RESKEY__default to hold this value

Another option is that the value is empty, but the program runs correctly

In addition, the cluster manager can also support meta-resource parameters. These do not apply directly to resource configuration, but rather specify how the cluster resource manager manages resources. For example, pacemaker uses the target-role meta parameter to specify whether the resource should be started or stopped.

The meta-parameter is passed to the resource agent through OCF_RESKEY_CRM_meta_ naming, and note that all hyphens are converted to underscores. So that the target-role attributes are mapped to the environment variable OCF_RESKEY_CRM_meta_target_role.

2.2 Actions

Any resource agent must support a command line argument that specifies the execution of the resource agent. The following behaviors must be supported by the resource agent:

Start-start resources

Stop-stop resources

Monitor-query resource status

Meta-data-Export Resource Agent metadata

In addition, the resource agent can choose to support the following behaviors:

Promote-promote a resource to the Master role (for Master/Slave resources only)

Demote-convert a resource to a Slave role (for Master/Slave resources only)

Migrate_to and migrate_from-to achieve hot migration of resources

Validate_all-verify the configuration of resources

Usage or help-displays usage information or help information. Is the display of the resource itself with the command line runtime

Status-has been discarded. Is the behavior previously used by monitor

2.3 Timeouts

Action timeouts is used to force the resource agent to run correctly from the outside. The cluster manager is responsible for monitoring how long an action of the resource agent runs and terminates the program if it is not completed within a limited time. In this way, the resource agent does not have to check that the time has expired.

However, the resource agent can suggest this timeout value (if set, it will be enforced by the cluster manager on time). Details will be covered in more detail in later chapters.

2.4 Metadata (metadata)

Each resource agent must specify the parameters it supports for its purpose in an XML metadata. This metadata table is used by the cluster manager to provide online help, and the man manual of the resource agent can also be exported here. Here is a fictional resource proxy metadata:

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

thirty-four

thirty-five

thirty-six

thirty-seven

thirty-eight

thirty-nine

forty

forty-one

forty-two

forty-three

forty-four

forty-five

0.1

This is a fictitious example resource agent written for the

OCF Resource Agent Developers Guide.

Example resource agent

For budding OCF RA developers

Number of eggs, an example numeric parameter

Number of eggs

Enable superfrobnication, an example boolean parameter

Enable superfrobnication

Data directory, an example string parameter

Data directory

The above defines the resouce-agent element, which must have one and is defined with name and version.

The longdesc and shortdec elements provide long and short descriptions of resource proxy functionality. Shortdesc provides only one sentence and a list of profiles. Longdesc provides a complete description of more details.

The parameters element describes the resource agent parameters and can have multiple parameter child elements, each of which is a parameter supported by the resource agent.

Each parameter parameter should have a shortdesc and a longdesc to describe the details of the parameter, and a content element to describe what the parameter expects. Parameter supports the following attributes:

Required indicates whether the parameter is mandatory (required= "1") or optional (require= "0") (required by test 1)

Unique (allowed values: 0 and 1) indicates that the specified value is unique across the cluster. For example, a highly available floating IP address will be defined as unique because there can only be one address in the entire cluster and cannot be repeated. (test 1 represents unique and cannot be repeated)

The content element has two attributes:

Type describes the type of parameter (string,integer, or boolean). If not set, type defaults to string.

For some optional parameter, you usually use the default property to set an appropriate

The actions list defines the supported behavior declared by the resource agent.

Each action has its own timeout value. This is the minimum timeout value that indicates the user's behavior. This approach adapts to resources that can be started quickly (such as IP addresses, file systems) and resources that take minutes to start (such as databases).

In addition, some repetitive behaviors (such as monitor) should have a recommended minimum interval interval, which is the time between two consecutive calls to the same behavior. Like timeout, this value has no default. This value only provides a minimum value for reference.

That's all for the content of "how to use Metadata". Thank you for 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.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report