This post states some obvious commands, which are well known by majority of sys admins using XEN hypervisors.
Anyway I whish to share these commands since I think they are pretty useful, infact I had to deal with command line when my VM Manager had troubles.
Let's start saying that XM commands are performed connecting to physical Oracle VM servers and should be used carefully since they are pretty powerful and could potentially destroy your VM environment just with a click.
A good practice is to deal with XM CLI only if VM Manager is unusable, since it's preferrable to execute tasks by VM Manager itself rather than by physical server, especially in an environment with more than one physical server because XM CLI commands could potentially lead to inconsistencies between physical servers.
Another thing to note before using XM CLI is that as stated by server itself: making manual modifications in the management domain might cause inconsistencies between Oracle VM Manager and the server.
XM provide a lot of functionalities and you can check them all by just typing:
[root@orclvmsrv1 ~]# xm
Oracle VM identifies guest VMs by assigning them an unique ID, despite the name you gave to VM during creation, so when you perform an action using XM CLI you need to refer to VMs using that ID instead of the VM name you gave.
I suggest when you create a new VM using VM Manager to take note of "VM Name - assigned ID" because it could be useful for future references.
If you didn't do that don't be worried, there's a solution anyway, you can see what's the VM name on vm.cfg file:
[root@orclvmsrv1 ~]# cd /OVS/Repositories/0004fb0000030000fc2ad4059c973859
[root@orclvmsrv1 0004fb0000030000fc2ad4059c973859]# ls
Assemblies ISOs lost+found Templates VirtualDisks VirtualMachines
As you can see above:
0004fb0000030000fc2ad4059c973859 is the REPOSITORY ID, every repository contains the following folders: Assemblies ISOs lost+found Templates VirtualDisks VirtualMachines
VM configuration files are placed in VirtualMachines folder.In this case I've 3 VMs in this Repository and these are VM's ID.
[root@orclvmsrv1 0004fb0000030000fc2ad4059c973859]# ls VirtualMachines/
0004fb00000600003ace83d53d5313b0 0004fb0000060000e0f49015b41ead02 0004fb00000600005d4bfe48c8fe0cf9
To check what's the name of a certain VM just have a look at vm.cfg file contained in every of the folders above.
[root@orclvmsrv1 VirtualMachines]# cat 0004fb0000060000e0f49015b41ead02/vm.cfg | grep OVM_simple_name
and search for OVM_simple_name attribute which tells you what's the name you assigned to that VM.
OVM_simple_name = 'VMM'
Now that you know how to identify VMs by theyr ID it's time to do some basic stuff:
1)List all running VMs:
[root@orclvmsrv1 ~]# xm list
Name ID Mem VCPUs State Time(s)
0004fb00000600003ace83d53d5313b0 1 4096 4 -b---- 9343.5
0004fb0000060000e0f49015b41ead02 8 4096 4 -b---- 832.9
Domain-0 0 726 12 r----- 14059.0
As you can see I've two running VMs in my domain.
2)Stop a running VM:
[root@orclvmsrv1 ~]# xm shutdown 0004fb00000600003ace83d53d5313b0
I gracefully stopped a guest VM
3)Kill a running VM:
Same thing as above, but instead of "shutdown" use "destroy"
[root@orclvmsrv1 ~]# xm destroy 0004fb00000600003ace83d53d5313b0
4) Start a (non running) VM:
If you have a VM that is not currently in running state and you wish to start it:
[root@orclvmsrv1 VirtualMachines]# xm create 0004fb00000600005d4bfe48c8fe0cf9/vm.cfg
Please note that in this case I was in VirtualMachines folder.You could need to use full path to vm.cfg file.
5) Live migrate running VM to another Oracle VM server in the same Pool:
This can be done in two ways, specifying destination server IP address or, as I suggest, just typing destination server name.This is useful if you have a lot of servers in your infrastructure, and remembering server names it's usually easier than IP addresses.
You need to add your servers names to host file:
[root@orclvmsrv1 ~]# vi /etc/hosts
Add all your servers:
10.0.0.103 orclvmserver2
10.0.0.104 orclvmserver3
10.0.0.105 orclvmserver4
Save file, then you can migrate your VM to orclvmserver2:
[root@orclvmsrv1 ~]# xm migrate -l 0004fb00000600005d4bfe48c8fe0cf9 orclvmserver2
In a future post I will explain the use of another great CLI: Oracle VM Manager 3 CLI
which was introduced since VM Manager 3.1.1 build 365 and performs almost any task of VM manager but via CLI instead of web interface.
That's all!!
Nessun commento:
Posta un commento