Difference between revisions of "Manage VM in console"
Line 93: | Line 93: | ||
virsh shutdown kvm<ID> #for example kvm101 | virsh shutdown kvm<ID> #for example kvm101 | ||
</pre> | </pre> | ||
− | |||
− | |||
Soft reboot VM | Soft reboot VM | ||
Line 118: | Line 116: | ||
Force kvm start. Could be usefull if you disabled selinux and machines were hiobernated before node reboot. so simply clean start: | Force kvm start. Could be usefull if you disabled selinux and machines were hiobernated before node reboot. so simply clean start: | ||
virsh start <machinename> --force-boot | virsh start <machinename> --force-boot | ||
+ | |||
+ | Increase a VM's disk space [do not use for RAW images!!] | ||
+ | qemu-img resize vmdisk.img +10G | ||
+ | |||
"[[Category:Admin area]]" | "[[Category:Admin area]]" |
Revision as of 15:59, 30 September 2015
OpenVZ
Show all OpenVZ containers:
vzlist -a
Show all OVZ templates:
ls /vz/template/cache/
Stop container:
vzctl stop <vmID>
Srart container:
vzctl start <vmID>
Restart container:
vzctl restart <vmID>
Create container:
vzctl create <vmID>
More details about CT creation: http://openvz.org/Configuring_container_creation
ovz container creation example:
vzctl create 115 --ostemplate centos-6-x86
Remove container:
vzctl destroy
For extended description refer to man vzctl. Also we recommend to read Basic operations in OpenZV environment http://openvz.org/Basic_operations_in_OpenVZ_environment
get active vz containers count:
vzlist | wc -l
get containers disk usage in %
vzlist -a -H -o hostname,diskspace,diskspace.s,veid | awk '{ printf( "%2.f%\t%s\t%s\n"), $2*100/$3, $4, $1}' | sort -r
get 10 top CPU openvz containers
ps -e h -o pid --sort -pcpu | head -10 | vzpid -
show PID containerID owner, user, exe path:
ll /proc/<PID> #or ls -l /proc/<PID>
show all containers load average:
vzlist -o ctid,laverage
SHow all possibly abusive containers. also show containers with RAM utilization/problems:
dmesg|egrep -v '(SMTP-LOG|INPUT-DROP|LIMIT-PPS-DROP|FORWARD-DROP)' TTL=64 ID=0 PROTO=UDP SPT=68 DPT=67 LEN=556
Show 10 top memory intensive processes:
ps -auxf | sort -nr -k 4 | head -10
Show 10 top CT's based on number of processes:
/usr/sbin/vzlist -H -o ctid,numproc|sort -r -n -k2|head
Show 10 top CT's based on socket usage:
/usr/sbin/vzstat -t -s sock|awk 'NF==10{print $0}'
Sort containers on TCP send /receive buffer usage:
vzlist -H -o ctid,tcpsndbuf |sort -r -n -k2 vzlist -H -o ctid,tcprcvbuf |sort -r -n -k2
Sort CT's based on inbound/outbound NW traffic:
vznetstat -r |awk '$3 ~ /G/ {print $0}'|sort -r -nk3 vznetstat -r |awk '$5 ~ /G/ {print $0}'|sort -r -nk5
KVM
Show all Virtual Machines (logical volumes):
lvdisplay
Show state of Virtual Machines:
virsh list --all
You can use virtual machine kvm<ID> or kvm_name as identificator. If VM not turned on you can identify it via name, there no ID assigned to offline VMs.
Soft shutdown VM. This will sent shutdown command to VMs OS.
virsh shutdown kvm<ID> #for example kvm101
Soft reboot VM
virsh reboot kvm<ID>
Hard power off. This will be equal to unplugging power cord from physical machine.
virsh destroy kvm<ID>
Hard power on
virsh start kvm<ID>
Edit virtual machine config :
virsh edit kvm<ID> #or virsh edit <machine_name>
For extended description refer to man virsh.
Force kvm start. Could be usefull if you disabled selinux and machines were hiobernated before node reboot. so simply clean start:
virsh start <machinename> --force-boot
Increase a VM's disk space [do not use for RAW images!!]
qemu-img resize vmdisk.img +10G
""