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

Example Analysis of OpenStack heat HA

2025-02-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

The editor will share with you the example analysis of OpenStack heat HA. I hope you will get something after reading this article. Let's discuss it together.

I remember that last year, people couldn't talk about OpenStack without the question: "Why doesn't OpenStack support the HA of virtual machines?"

It was also strange at that time that HA, a very basic reliability feature, was missing, so how could OpenStack be used in real situations?

The result of the community discussion at that time was: "the implementation of HA,OpenStack core modules by OpenStack upper-level components provides only basic operations."

So who does this so-called upper component refer to? It's Heat. Now Heat is the core module of OpenStack, that is to say, OpenStack already has the ability of HA.

Exceed expectations

In the past, we always talk about virtual machine HA, it seems that all the functions are designed around the virtual machine, and the virtual machine is the core. However, from the documentation of Heat, Heat believes that the service (Service) above the virtual machine is the ultimate goal, and the design of Heat HA is also extended to the service level, which can implement three levels of HA:

Service

Instance

Stack

For example, when the database process on the virtual machine becomes down, first try to solve it by restarting the database process. If it cannot be solved, restart or rebuild the virtual machine. If it still cannot be solved, rebuild the entire stack. From this point of view, the function of Heat HA is much more powerful than that of a simple virtual machine HA.

Realize

The HA feature of Heat is realized by the cooperation of OpenStack multi-modules, which involves Nova,Ceilometer,Heat-cfn-api,Heat-cloudwatch,Heat-cfntools and so on.

»Heat-cfntools

Heat-cfntools includes some gadgets used with Heat, which run inside the virtual machine. When creating a virtual machine image, you need to package cfntools into the image. The developer documentation of Heat describes how to package cfntools into the image. Here

The HA function of Heat uses cfn-push-stats to report the status of virtual machines or services.

Cfn-init-> configure virtual machines and simplify user_data scripts

Cfn-hub-> periodically detect whether the instance metadata has changed, and trigger the user-defined hooks according to the change

Cfn-signal-> send a signal of success or failure to execute the command

Cfn-push-stats-> report the status of the service or virtual machine

Cfn-get-metadata-> get instance metadata

Interested students can directly git clone a copy of the cfn-tools code to see.

Https://github.com/openstack/heat-cfntools.git

»Heat-template

Let's start with the HA template of Heat to analyze how to implement the HA of Heat through the configuration template.

Take the Heat template WordPress_Single_Instance_With_IHA.template on github as an example.

.. "WebServerRestartPolicy": {"Type": "OS::Heat::HARestarter", "Properties": {"InstanceId": {"Ref": "WikiDatabase"}}, "HeartbeatFailureAlarm": {"Type": "AWS::CloudWatch::Alarm", "DependsOn": "WaitCondition", "Properties": {"AlarmDescription": "Restart the WikiDatabase if we miss a heartbeat", "MetricName": "Heartbeat" "Namespace": "system/linux", "Statistic": "SampleCount", "Period": "60", "EvaluationPeriods": "1", "Threshold": "1", "AlarmActions": [{"Ref": "WebServerRestartPolicy"}], "ComparisonOperator": "LessThanThreshold"}}, "WikiDatabase": {"Type": "AWS::EC2::Instance" "Metadata": {... "/ tmp/cfn-hup-crontab.txt": {"content": {"Fn::Join": [", [" MAIL=\ "\"\ n ","\ n "," * / opt/aws/bin/cfn-hup-f\ n "," * / opt/aws/bin/cfn-push-stats ","-- watch " {"Ref": "HeartbeatFailureAlarm"}, "--heartbeat\ n"]}, "mode": "000600", "owner": "root", "group": "root"}

Let's first take a look at / tmp/cfn-hup-crontab.txt, which is actually a configuration file of crontab. In boot instance WikiDatabase, because UserData is configured, the cfn-init command will be called when the UserData script is executed. The function of cfn-init is to generate files, install software, execute scripts, etc., according to the configuration of the AWS::CloudFormation::Init section. At the end of the UserData script, the crontab of cfn-hup is enabled.

Cfn-push-stats sends a heartbeat request of type HeartbeatFailureAlarm to heat-api-cloudwatch every minute. HeartbeatFailureAlarm is actually an Alarm of Ceilometer.

According to the configuration of HeartbeatFailureAlarm, if no heartbeat request from instance WikiDatabase is received in 60 seconds, AlarmActionsOS::Heat::HARestarter will be triggered. According to Heat's definition of resource OS::Heat::HARestarter, Heat will delete the original virtual machine WikiDatabase and then create a new virtual machine.

For service monitoring, you can refer to another Heat template, WordPress_Single_Instance_With_HA.template.

After reading this article, I believe you have some understanding of "sample Analysis of OpenStack heat HA". If you want to know more about it, you are welcome to follow the industry information channel. Thank you for reading!

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

Servers

Wechat

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

12
Report