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 set master properties

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the knowledge of "how to set master features". 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!

9 Special consideration

9.1 Licensing

We encourage developers to use GPL (GNU GeneralPublic License) 2.0 or later at any time. The shell library function is not strictly limited to this, it is based on LGPL (GNU Lesser General Public License) version 2.1 or later, so that agents of non-GPL resources can be used.

The resource agent must explicitly indicate its authorization information in the source code.

9.2 Local Settings

When running the. ocf-shellfuncs (described in initialization section 4. 3), the resource agent automatically sets the locale for LANG and LC_ALL to C. The resource agent can expect to always operate in the locale of C without the need to reset the LANG and LC_ environment variables.

9.3 Test run process

To test whether a specified process (knowing the process id) is running, it is common practice to send a zero signal and catch an error. For example:

one

two

three

four

five

six

If kill-s 0`cat $daemon_pid_ file`; then

Ocf_log debug "Process is currently running"

Else

Ocf_log warn "Process is dead, removing pid file"

Rm-f $daemon_pid_file

If

Important: an example that is much better than the above approach is the use of a daemon's client to invoke a daemon's functionality, such as the example in Section 5.3 monitor action.

9.4 set master properties

Master/slave resources must set their own master features, which provide cluster management with some information to help it determine who is the most appropriate node to promote to the master role.

Important: it is acceptable for multiple instances to have the same master features. In that example, the cluster resource manager can automatically select a resource agent to promote to the master role. If all instances have a default master score of 0, the cluster manager does not promote any instances. Thus, it is important to keep the master score of at least one instance positive.

For this purpose, crm_master is more convenient. It encapsulates crm_attribute to set the property master-$OCF_RESOURCE_INSTANCE on its running node to a specific value. The cluster manager converts these changes to the corresponding instance into a promotion score, which is based on the characteristics of the promotion.

Stateful resource agents execute crm_master in monitor and notity behaviors.

The following example assumes that the foobar resource agent can test the status of the application by executing an execution file with a return value. This return value depends on whether:

The resource is a master role or a slave role (fully captured by master), or

The resource is a slave role, but lags behind master due to asynchronous replication, or

The resource is safely stopped, or

The resource failed unexpectedly.

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

forty-six

forty-seven

Foobar_monitor () {

Local rc

# exit immediately if configuration is not valid

Foobar_validate_all | | exit $?

Ocf_run frobnicate-test

# This example assumes the following exit code convention

# for frobnicate:

# 0: running, and fully caught up with master

# 1: gracefully stopped

# 2: running, but lagging behind master

# any other: error

Case "$?" In

0)

Rc=$OCF_SUCCESS

Ocf_log debug "Resource is running"

# Set a high master preference. The current master

# will always get this, plus 1. Any current slaves

# will get a high preference so that if the master

# fails, they are next in line to take over.

Crm_master-l reboot-v 100

1)

Rc=$OCF_NOT_RUNNING

Ocf_log debug "Resource is not running"

# Remove the master preference for this node

Crm_master-l reboot-D

2)

Rc=$OCF_SUCCESS

Ocf_log debug "Resource is lagging behind master"

# Set a low master preference: if the master fails

# right now, and there is another slave that does

# not lag behind the master, its higher master

# preference will win and that slave will become

# the new master

Crm_master-l reboot-v 5

*)

Ocf_log err "Resource has failed"

Exit $OCF_ERR_GENERIC

Esac

Return $rc

}

That's all for "how to set master features". 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