OpenStack cloud host management

1) Required knowledge

1. Cloud host and snapshot management
a-Cloud host management

Cloud host management is the core function of the OpenStack cloud computing platform. Generally, cloud host management includes creation, deletion, and query. The following commands can be used to manage OpenStack cloud hosts:

openstack server <操作><云主机名>[选项]

Common operations and function descriptions of cloud host management commands:

Common operations Function Description
create Create a cloud host
delete Delete cloud host
list List existing cloud hosts
start Turn on the cloud host
stop Shut down the cloud host
lock lock cloud host
unlock Unlock cloud host
pause Pause the cloud host, save the current state to the content
unpause Unpause a cloud host
reboot Restart cloud host
rebuild Rebuild the cloud host
rescue Repair cloud host
unrescue Cancel repair cloud host
resize Adjust cloud host specifications
restore Restore cloud host
suspend Suspend the cloud host and save the current state to disk
resume Unsuspend the cloud host
show View the details of the cloud host

Common options and function descriptions of cloud host management commands:

Common options Function Description
–h show help information
–image The image used when creating the cloud host
–flavor The instance type used when creating the cloud host
–volume Volumes used when creating cloud hosts
–snapshot Snapshots used when creating cloud hosts
–security-group The security group used when creating the cloud host
–host Specify a server to create a cloud host
–network The network connected to the cloud host
–port The port connected to the cloud host
–nic<net-id=net-uuid,v4-fixed-ip=ip-addr,v6-fixed-ip=ip-addr,port-id=port-uuid,auto,none> This option is used to set the network properties of the cloud host: "net-id" is the network connected to the cloud host; "v4-fixed-ip" "v6-fixed-ip" is the bound IP address; "port-id" is The port connected to the cloud host; "auto" means automatically connecting to the network; "none" means not connecting to the network
–key-name Inject the key pair into the cloud host
b-example

Create a cloud host named "VM_host" with the "cirros" image and the "myflavor" instance type

openstack server create VM_host --image cirros --flavor myflavor --network vm-network

View the list of existing cloud hosts

openstack server list

Restart cloud host:
There are two types of restarts, namely soft restart and hard restart. A soft restart is to try to shut down the cloud host normally and restart it, and a hard restart is to power off and restart the cloud host.
Soft reboot as follows:

openstack server reboot VM_host
#可以通过云主机名或者云主机ID进行操作

Hard reboot as follows:

openstack server reboot VM_host --hard
#可以通过云主机名或者云主机ID进行操作
#其中,--hard选项代表采用硬重启方式

Pause and suspend the cloud host:
save the current state of the cloud host into the memory when suspending, and deactivate the cloud host. After the suspension, you can cancel the suspension, restore the cloud host to the state before the suspension and enable it.
When suspending, save the current state of the cloud host to the disk, and deactivate the cloud host. After the suspension, the suspension can be canceled, and the cloud host can be restored to the state before the suspension and enabled.
Pause the cloud host:

openstack server pause VM_host
#可以通过云主机名或者云主机ID进行操作

To unpause a cloud host:

openstack server unpause VM_host
#可以通过云主机名或者云主机ID进行操作

Suspend the cloud host:

openstack server suspend VM_host
#可以通过云主机名或者云主机ID进行操作

Unsuspend the cloud host:

openstack server unsuspend VM_host
#可以通过云主机名或者云主机ID进行操作

Shut down the cloud host:

openstack server stop VM_host
#可以通过云主机名或者云主机ID进行操作

Start the cloud host:

openstack server start VM_host
#可以通过云主机名或者云主机ID进行操作

Rebuild the cloud host:
If the existing cloud host fails, the cloud host can be restored through the reconstruction operation.

openstack server rebuild VM_host --image cirros
#可以通过云主机名或者云主机ID进行操作

Delete cloud host:

openstack server delete VM_host
#可以通过云主机名或者云主机ID进行操作

Snapshot management:
A mirror can be obtained by taking a snapshot of the cloud host, and this mirror can be used to restore the cloud host or create a new cloud host.

openstack server image create <快照名>[选项]
#例如
openstack server image create VM_host --name vmSnapshot
#生成的镜像可以通过Glance进行管理,查看已有的镜像列表
openstack image list
2. Cloud Console
a.virsh cloud host management tool

Virsh is a management tool provided by the Libvirt package. It provides a series of management functions for cloud hosts, such as starting, deleting, controlling, and monitoring cloud hosts. Virsh has powerful functions, but its management commands are more complicated. I will use two examples to illustrate how to use virsh to connect to a virtual machine and operate it. The Libvirt software package has been installed on the computing node, and the virsh management command is initiated from the computing node.

b. Example

View the list of started cloud hosts

virsh list

Use virsh to connect to the cloud host whose ID is "1"

virsh console 1

After connecting, you need to enter your user name and password, depending on the specific situation. After successful login, $ will be displayed, and then you can enter the corresponding system management commands. Press【ctrl+]】to exit.

2) Project implementation

The following are all done on the control node.

1. Create a cloud host with command mode

Import environment variables

source admin-login

View the network list and get network information

openstack network list

View a list of instance types

openstack flavor list

View the mirror list and get mirror information

openstack image list

Create an instance
Create a cloud host named "VM_host" using the network, instance type, and image information obtained earlier.

openstack server create VM_host --image <镜像名> --flavor <实例类型名> --nicnet-id=<网络id>

View a list of existing instances

openstack server list
2. Manage cloud hosts with command mode

The cloud host can be operated on the control node through the instance name (repeatable) or instance ID (unique).
The cloud host named VM_host is used as a demonstration below

a. Restart the cloud host

Soft restart cloud host:

openstack server reboot VM_host

Hard restart cloud host:

openstack server reboot VM_host --hard
b. Pause and suspend the cloud host

Pause the cloud host:

openstack server pause VM_host

To unpause a cloud host:

openstack server unpause VM_host

Suspend the cloud host:

openstack server suspend VM_host

Unsuspend the cloud host:

openstack server resuspend VM_host
c. Stop and start the cloud host

Stop the cloud host:

openstack server stop VM_host

Start the cloud host:

openstack server start VM_host
d. Delete cloud host
openstack server delete VM_host
3. Create and manage snapshots with command mode
a - create a snapshot with command mode

Create a snapshot named kz-demo for the cloud host
View the list of cloud hosts:

openstack server list

Take a snapshot of an existing cloud host named VM_host:

openstack server image create VM_host --name kz-demo

View the list of snapshots:

openstack image list
b-Manage snapshots with command mode

Rebuild the cloud host:

openstack server rebuild VM_host --image kz-demo

To delete a snapshot or mirror:

openstack image delete kz-demo

Guess you like

Origin blog.csdn.net/xiaoyu070321/article/details/131906553