650) this.width=650; "Title=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20160505-1462405976888071388.png "src=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20160505-1462406117194014284.jpg "style=" border:0px;float:none; "/>
This section details the instance launch and shut off operations, as well as tips on how to quickly locate useful information in the log.
Launch
Launch instance should count Nova's most important operations.
Careful study of Lanuch operations can help us fully understand the coordination and operational mechanisms of the Nova sub-services.
We have discussed each nova-* sub-service in detail in the launch operation as an example. We will not repeat them here, just to review the process.
650) this.width=650; "Title=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20160505-1462406161564029503.png "src=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20160505-1462406161564029503.png "alt=" Image146.png "style=" border:0px; "/>
The customer (which can be an OpenStack end-user or other program) sends a request to the API (NOVA-API): "Create a Instance for me"
After the API has made some necessary processing of the request, a message is sent to Messaging (RabbitMQ): "Let Scheduler create a Instance"
Scheduler (Nova-scheduler) Gets the message from Messaging to the API, then executes the scheduling algorithm and selects node A from several compute nodes
Scheduler sent a message to Messaging: "Create this Instance on compute node A"
The Compute (nova-compute) of compute node A gets the message Scheduler sent to it from Messaging and then creates Hypervisor from the Driver Instance of this node.
During the Instance creation process, Compute sends a message to conductor (Nova-conductor) through Messaging if the database information needs to be queried or updated, conductor is responsible for database access.
Shut Off
Below is the flowchart of shut off instance
650) this.width=650; "Title=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20160505-1462405976886068896.png "src=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20160505-1462406117362002622.jpg "style=" border:0px;white-space:normal;float:none; "/>
Send a request to NOVA-API
Nova-api sending messages
Nova-compute Performing actions
Let's discuss each step in detail below.
send a request to Nova-api
The customer (which can be an OpenStack end user or another program) sends a request to the API (NOVA-API): "Help me close this Instance."
650) this.width=650; "Title=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20160505-1462405976813067357.png "src=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20160505-1462406117468067205.jpg "style=" border:0px;white-space:normal;float:none; "/>
View Log/opt/stack/logs/n-api.log
650) this.width=650; "Title=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20160505-1462405976966070190.png "src=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20160505-1462406117547059095.jpg "style=" border:0px;white-space:normal;float:none; "/>
Talk a little more about how to quickly find useful information in a log file. For beginners, this is not an easy thing, because there are a lot of entries and content in the log, especially when the debug option is opened, it is easy to be dazzled by people.
Here are a few tips for you:
First determine the large scope, such as before the operation with Tail-f to print the log file, so that the need to view the log must be in the print output after the operation of these contents. You can also use timestamps to determine the required log range.
Use the code module to quickly locate useful information. nova-* Sub-services have their own specific code modelBLOCK:
Nova-api
nova.api.openstack.compute.servers
Nova.compute.api
Nova.api.openstack.wsgi
Nova-compute
Nova.compute.manager
nova.virt.libvirt.*
Nova-scheduler
nova.scheduler.*
Use the Request ID to find related log information. In the above log, we can use the Request ID "REQ-1758B389-A2D0-44CC-A95A-6F75E4DC07FD" to quickly locate other log entries in the N-api.log phase and shut off operation. It should be added that the Request ID is a cross-log file, and this feature helps us to find the relevant information in the log files of other sub-services, and we will see the application of this technique shortly after.
Nova-api sending Messages
Nova-api sent a message to Messaging (RabbitMQ): "Close this Instance" Nova-api did not log the action to send the message, but we can verify it by looking at the source code. When it comes to source code, you might think you're in a haystack. In fact, it is very simple, the above log has been clearly told we need to see the source code in/opt/stack/nova/nova/compute/api.py 1977 lines, the method is force_stop.
650) this.width=650; "Title=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20160505-1462405976966073662.png "src=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20160505-1462406117669074754.jpg "style=" border:0px;white-space:normal;float:none; "/>
The Force_stop method finally calls the Stop_instance method of the object Self.compute_rpcapi. In the OpenStack source code, the object named Xxx_rpcapi is the message queue of XXX. The Xxx_rpcapi.yyy () method represents a message that sends a YYY operation to the message queue of XXX.
So the function of Self.compute_rpcapi.stop_instance () is to send a stop instance message to the Nova-compute message queue on RabbitMQ.
Here is a note: The premise of closing instance is that instance is currently running on a compute node, so there is no need for Nova-scheduler to help us pick the right node, which is different from the launch operation.
Nova-compute Performing Actions
View the log/opt/stack/logs/n-cpu.log on the COMPUTE node
650) this.width=650; "Title=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20160505-1462405976987074342.png "src=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20160505-1462406117774047180.jpg "style=" border:0px;white-space:normal;float:none; "/>
Here we take advantage of the Request ID "REQ-1758B389-A2D0-44CC-A95A-6F75E4DC07FD" to quickly locate the log entry in N-cpu.log to Nova-compute close instance.
Summary
When analyzing an operation, we first need to clarify the internal process of the operation, and then go to the corresponding node to view the log. For example, the process for shut off is:
Send a request to NOVA-API
Nova-api sending messages
Nova-compute Performing actions
1, 22 steps are performed on the control node to view the log of the NOVA-API. The 3rd step is performed on the compute nodes, viewing the logs of the Nova-compute.
650) this.width=650; "title=" "src=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20160505-1462406117920043007.jpg "style=" Border:0px;vertical-align:middle;color:rgb ( 63,63,63); font-family: ' Microsoft Yahei '; Font-size:15px;line-height:21.75px;text-align:justify;background-color: RGB (246,246,246); "/>
Launch and shut off operation details-5 minutes a day to play OpenStack (30)