kali ini GemarOprek akan membahas Perintah dasar OpenVZ, sekedar untuk anda ketahui OpenVZ adalah adalah sebuah platform virtualisasi berbasis Linux dan berdasarkan Linux Kernel. OpenVZ memungkinkan sebuah server fisik untuk menjalankan beberapa contoh sistem operasi terpencil dikenal sebagai kontainer.
OpenVZ hanya dapat menjalankan sistem operasi berbasis linux seperti Centos, Fedora, Gentoo, dan Debian. Salah satu kelemahan dari pengguna OpenVZ tidak dapat melakukan modifikasi kernel.
Semua server virtual harus bergaul dengan versi kernel host berjalan pada. Namun karena tidak memiliki overhead dari hypervisor benar sangat cepat dan efisien melalui KVM, Xen, KVM, VMware dan Cloud.
Namun disini saya akan membahas beberapa perintah yang umum digunakan openvz, yaitu
Perintah dasar OpenVZ
VZ Information To list all the running/stopped VPS in the node
1 |
vzlist -a |
To list all the running VPS in the node
1 |
vzlist |
To display the templates present in the server
1 |
vzpkgls |
Creating a VPS To create a VPS with VEID 101 and ostemplate fedora-core-4 with vps.basic configuration
1 |
vzctl create 101 --ostemplate fedora-core-4 -.config vps.basic |
Deleting a VPS To destroy a VPS with VEID 101
1 |
vzctl destroy 101 |
Configuring VPS (The changes are saved in /etc/vz/conf/<VEID>.conf) To automatically boot when a node is up
1 |
vzctl set 101 --onboot yes --save |
To set hostname
1 |
vzctl set 101 --hostname test101.my.org --save |
To add an IP address
1 |
vzctl set 101 --ipadd 10.0.186.1 --save |
To delete an IP address
1 |
vzctl set 101 --ipdel 10.0.186.1 --save |
To set the name servers
1 |
vzctl set 101 --nameserver 192.168.1.165 --save |
To set the root password of VPS 101
1 |
vzctl set 101 --userpasswd root:password |
To set shortname for VPS
1 |
vzctl set 101 --name test101 --save |
Start/Stop/Restart VPS To start a VPS
1 |
vzctl start 101 |
To start a disabled VPS
1 |
vzctl start 101 --force |
To stop a VPS
1 |
vzctl stop 101 |
To restart a VPS
1 |
vzctl restart 101 |
To know the status of a VPS
1 |
vzctl status 101 |
To get the details of the VPS like VEID, ClassID, number of processes inside each VPS and the IP addresses of VPS
1 |
cat /proc/vz/veinfo |
To enter into a VPS 101
1 |
vzctl enter 101 |
To execute a command in VPS 101
1 2 |
vzctl exec 101 command --- replace command with the command you need to execute vzctl exec 101 df -h |
Managing Disk Quotas To assign disk quotas – First limit is soft limit, second limit is hard limit
1 2 3 |
vzctl set 101 --diskspace 10485760 --save ==>> for setting 10GB OR vzctl set 101 --diskspace 1048576 --save ==>> for setting 1GB |
To assign disk inodes
1 |
vzctl set 101 --diskinodes 90000:91000 --save |
To check the disk quota of a VPS
1 |
vzquota stat 101 -t |
Managing CPU quota To display the available CPU power
1 |
vzcpucheck |
To set the number of CPUs available to a VPS
1 |
vzctl set 101 --cpus 2 --save |
To set the minimum and maximum CPU limits
1 2 |
vzctl set 101 --cpuunits nnnn --cpulimit nn --save (cpuunits is a an absolute number (fraction of power of the node) and cpulimit is taken as percentage) |
Managing memory quota To display memory usage
1 |
vzmemcheck -v |
To set kmem
1 |
vzctl set 101 --kmemsize 2211840:2359296 --save |
To set privvmpages
1 |
vzctl set 101 --privvmpages 2G:2G --save |
Other Commands To copy/clone a VPS
1 |
vzmlocal -C <source_veid>:<desitnation_veid> |
To disable a VPS
1 |
vzctl set 101 --disabled yes |
To enable a VPS
1 |
vzctl set 101 --disabled no |
To suspend a VPS
1 |
vzctl suspend 101 |
To resume a VPS
1 |
vzctl resume 101 |
To run yum update on a VPS
1 |
vzyum 101 -y update |
To install a package using yum on VPS
1 |
vzyum 101 -y install package |
To install a package using rpm on VPS
1 |
vzrpm 101 -ivh package |
atau anda dapat melihat dokumentasi lengkap Perintah dasar OpenVZ pada link ini http://download.openvz.org/doc/OpenVZ-Users-Guide.pdf