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 understand Migrate Instance operation

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

Share

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

This article introduces you how to understand Migrate Instance operation, the content is very detailed, interested friends can use for reference, I hope it can be helpful to you.

The purpose of the Migrate operation is to migrate the instance from the current compute node to another node.

Migrate do not ask that the source and destination nodes must share storage, and of course shared storage is possible. A condition must be met before Migrate: password-free access for nova users needs to be configured between computing nodes.

Send a request to nova-api

Customers (either OpenStack end users or other programs) send a request to API (nova-api): "help me migrate this Instance" Migrate operation is a privileged operation that can only be executed in the instance menu of Admin

View log / opt/stack/logs/n-api.log

Nova-api sends messages

Nova-api sends a message to Messaging (RabbitMQ): "migrate this Instance" to see the source code / opt/stack/nova/nova/compute/api.py, using resize. Yes, it's resize, not migrate.

This is because migrate is actually implemented through resize operations, and as to why it is designed this way, we will examine it in more detail in the next section resize.

Nova-scheduler execution scheduling

When nova-scheduler receives the message, it selects the appropriate target compute node for instance. View log / opt/stack/logs/n-sch.log

As you can see, because the weight of devstack-compute1 is larger than that of devstack-controller, devstack-compute1 is finally selected as the target node.

If you see the log above, do you find any problems?

When analyzing this log, I found that the compute node selected by scheduler may be the current node source node! Because scheduler does not eliminate the source node at the initial time, but put it together with other nodes to do filter, according to this logic, as long as the weight of the source node is large enough, it is possible to become the target node.

The next question is: if the source node and target node are the same, what happens to the migrate operation?

The experiment shows that nova-compute checks the target node when doing migrate, and throws a UnableToMigrateToSelf exception if it is found that the target node is the same as the source node. After the Nova-compute fails, scheduler will reschedule, and because of the RetryFilter, it will filter out the previously selected source node, so that different computing nodes can be selected. Do you still remember RetryFilter? If you are rusty, you can read the previous chapter.

Okay, let's get down to business. In the above operation, the target node selected by sheduler is devstack-compute1, which means that instance will migrate from devstack-controller to devstack-compute1.

Nova-scheduler sends messages

Nova-scheduler sends a message informing the compute node that instance can be migrated. The source code is on line 95 of / opt/stack/nova/nova/scheduler/filter_scheduler.py, and the method is select_destinations

Nova-compute executes the operation

Nova-compute performs operations on the source and target compute nodes, respectively.

Source Compute Node devstack-controller

The migration operation first closes the instance on the source node, and then transfers the image file of the instance to the target node. Log in / opt/stack/logs/n-cpu.log, and the specific steps are as follows:

Start migrate

Create a directory for instance on the target node

Nova-compute will first try to touch a temporary file in the instance directory on the target node through ssh. The log is as follows.

If the touch fails, there is no directory for the instance on the target node, that is, the source and destination nodes do not have shared storage. The next step is to create a directory of instance on the target node, with the following log

Close instance

Transfer the image file of instance to the target node through scp

Target Compute Node devstack-compute1

Starting instance on the target node is very similar to launch instance. Will go through the following steps: 1. Prepare CPU, memory, and disk resources for instance 2. Create an instance image file 3. Create the XML definition file for instance 4. Create a virtual network and start instance

The log is recorded in / opt/stack/logs/n-cpu.log, and the analysis is left for everyone to practice.

Confirm

At this point, the instance will be in a "Confirm or Revert Resize/Migrate" state, requiring the user to confirm or reverse the current migration operation, which actually gives the user a chance to go back on his promise.

When we press the Confirm button, the following happens:

Nova-api received a message from confirm

The source compute node deletes the directory of instance and deletes instance on Hypervisor.

The target computing node does not need to do anything

Revert

What happens if you perform a Revert operation?

Nova-api received a message from revert

Close instance on the target compute node, delete the directory of instance, and delete instance on Hypervisor.

Start instance on the source compute node because the previous migration only turned off the instance,revert operation on the source node and only needed to restart instance.

The above is the complete process of Migrate operation. It is important to note that ssh and scp are needed before the source and destination nodes are migrated. In order for the operation to proceed smoothly, it is necessary to ensure that the initiator of the nova-compute process (usually nova or root, which can be confirmed by the ps command) can access the compute nodes without a password. Otherwise, nova-compute will wait for the password to be entered, but the backend service cannot enter the password, and the migration operation will always be stuck there.

On how to understand the operation of Migrate Instance to share here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

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