Installation & Managing OpenVZ

Virtual Private Server (VPS), juga dikenal dengan Virtual Dedicated Server (VDS) atau Virtual Server adalah teknologi server side tentang operating system dan software yang memungkinkan sebuah mesin dengan kapasitas besar di bagi ke beberapa virtual mesin. Tiap virtual mesin ini melayani operating system dan software secara independen dan dengan konfigurasi yang cepat.

Salah satu solusi membangun VPS adalah menggunakan OpenVZ. OpenVZ menawarkan solusi server virtualization dalam sistem operasi Linux.  Tutorial Installation dan  Managing OpenVZ yang saya implementasikan diterapkan pada Sistem operasi Debian 5 (Lenny).  Hasil akhirnya adalah membuat banyak server VPS dengan hardware yang sama. Jika sudah berhasil mengimplementasikan teknologi virtualisasi ini, tak elok rasanya jika tidak berbagi ilmu dengan yang lain. Untuk ini saya dokumentasikan hasil instalasi disalah satu server vps yang terletak di Gedung Cyber Mampang Jakarta.

Sistem operasi yang sudah siap Debian 5 (Lenny),  beberapa IP Publik dengan koneksi internet.

Sistem operasi Linux Debian versi 5 sudah memuat Openvz kernel packages dan tools pada main repositorynya. Jika sistem operasinya versi sebelum 5, diharapkan upgrade dahulu ke versi Lenny ini. Setelah mendapat root dan password serta ip publik pemilik server ini, aku pun langsung meluncur ke server tersebut menggunakan ssh. Berikut dokumentasinya :

– Diawal kernel masih memakai bawaan debian lenny.

server13:/home/gtoms# uname -a
Linux server13 2.6.26-2-686 #1 SMP Fri Aug 14 01:27:18 UTC 2009 i686 GNU/Linux

– Instalasi OpenVZ kernel dan konfigurasi :

server13:/home/gtoms# apt-get install linux-image-openvz-686
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following packages were automatically installed and are no longer required:
libpq5
Use ‘apt-get autoremove’ to remove them.
The following extra packages will be installed:
linux-image-2.6.26-2-openvz-686 rsync vzctl vzquota
Suggested packages:
linux-doc-2.6.26 linux-patch-openvz kernel-patch-openvz
The following NEW packages will be installed:
linux-image-2.6.26-2-openvz-686 linux-image-openvz-686 rsync vzctl vzquota
0 upgraded, 5 newly installed, 0 to remove and 0 not upgraded.
Need to get 21.0MB of archives.
After this operation, 63.7MB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 http://kebo.vlsm.org lenny/main vzquota 3.0.11-1 [73.8kB]
Get:2 http://security.debian.org lenny/updates/main linux-image-2.6.26-2-openvz-686 2.6.26-17lenny2 [20.4MB]
Get:3 http://kebo.vlsm.org lenny/main vzctl 3.0.22-14 [192kB]
Get:4 http://kebo.vlsm.org lenny/main linux-image-openvz-686 2.6.26+17+lenny1 [2614B]
Get:5 http://kebo.vlsm.org lenny/main rsync 3.0.3-2 [328kB]
Fetched 21.0MB in 33s (630kB/s)
Preconfiguring packages …
Selecting previously deselected package vzquota.
(Reading database … 25053 files and directories currently installed.)
Unpacking vzquota (from …/vzquota_3.0.11-1_i386.deb) …
Selecting previously deselected package vzctl.
Unpacking vzctl (from …/vzctl_3.0.22-14_i386.deb) …
Selecting previously deselected package linux-image-2.6.26-2-openvz-686.
Unpacking linux-image-2.6.26-2-openvz-686 (from …/linux-image-2.6.26-2-openvz-686_2.6.26-17lenny2_i386.deb) …
Done.
Selecting previously deselected package linux-image-openvz-686.
Unpacking linux-image-openvz-686 (from …/linux-image-openvz-686_2.6.26+17+lenny1_i386.deb) …
Selecting previously deselected package rsync.
Unpacking rsync (from …/rsync_3.0.3-2_i386.deb) …
Processing triggers for man-db …
Setting up vzquota (3.0.11-1) …
Setting up vzctl (3.0.22-14) …
Setting up linux-image-2.6.26-2-openvz-686 (2.6.26-17lenny2) …
Running depmod.
Running mkinitramfs-kpkg.
Running postinst hook script update-grub.
Searching for GRUB installation directory … found: /boot/grub
Searching for default file … found: /boot/grub/default
Testing for an existing GRUB menu.lst file … found: /boot/grub/menu.lst
Searching for splash image … none found, skipping …
Found kernel: /boot/vmlinuz-2.6.26-2-openvz-686
Found kernel: /boot/vmlinuz-2.6.26-2-686
Found kernel: /boot/vmlinuz-2.6.26-1-686
Updating /boot/grub/menu.lst … done

Setting up linux-image-openvz-686 (2.6.26+17+lenny1) …
Setting up rsync (3.0.3-2) …
server13:/home/gtoms#

vzctl sebagai tool untuk mengatur OpenVZ containers (create, destroy, start, stop, set parameters etc.)
vzquota sebagai tool mengatur quotas untuk containers.

server13:/home/gtoms# cat /boot/grub/menu.lst |grep openvz
title           Debian GNU/Linux, kernel 2.6.26-2-openvz-686
kernel          /boot/vmlinuz-2.6.26-2-openvz-686 root=/dev/hdc1 ro quiet
initrd          /boot/initrd.img-2.6.26-2-openvz-686
title           Debian GNU/Linux, kernel 2.6.26-2-openvz-686 (single-user mode)
kernel          /boot/vmlinuz-2.6.26-2-openvz-686 root=/dev/hdc1 ro single
initrd          /boot/initrd.img-2.6.26-2-openvz-686
server13:/home/gtoms#

server13:/home/gtoms# ln -s /var/lib/vz /vz
server13:/home/gtoms# nano /etc/sysctl.conf

server13:/home/gtoms# sysctl -p
net.ipv4.conf.all.rp_filter = 1
net.ipv4.ip_forward = 1
net.ipv4.icmp_echo_ignore_broadcasts = 1
net.ipv4.conf.default.send_redirects = 1
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.default.proxy_arp = 0
kernel.sysrq = 1
server13:/home/gtoms#

server13:/home/gtoms# nano /etc/vz/vz.conf
NEIGHBOUR_DEVS=ALL

server13:/home/gtoms# apt-get install cstream
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following packages were automatically installed and are no longer required:
libpq5
Use ‘apt-get autoremove’ to remove them.
The following NEW packages will be installed:
cstream
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 28.0kB of archives.
After this operation, 57.3kB of additional disk space will be used.
Get:1 http://kebo.vlsm.org lenny/main cstream 2.7.4-3 [28.0kB]
Fetched 28.0kB in 0s (56.1kB/s)
Selecting previously deselected package cstream.
(Reading database … 27794 files and directories currently installed.)
Unpacking cstream (from …/cstream_2.7.4-3_i386.deb) …
Processing triggers for man-db …
Setting up cstream (2.7.4-3) …
server13:/home/gtoms#

vzdump sebagai tool untuk backup dan restore container.

server13:/home/gtoms# wget http://www.proxmox.com/cms_proxmox/cms/upload/vzdump/vzdump_1.1-1_all.deb
–2009-09-04 20:49:41–  http://www.proxmox.com/cms_proxmox/cms/upload/vzdump/vzdump_1.1-1_all.deb
Resolving www.proxmox.com… 87.230.14.152
Connecting to www.proxmox.com|87.230.14.152|:80… connected.
HTTP request sent, awaiting response… 200 OK
Length: 18416 (18K) [application/x-debian-package]
Saving to: `vzdump_1.1-1_all.deb’

100%[==============================================>] 18,416      30.4K/s   in 0.6s

2009-09-04 20:49:43 (30.4 KB/s) – `vzdump_1.1-1_all.deb’ saved [18416/18416]

server13:/home/gtoms# dpkg -i vzdump_1.1-1_all.deb
(Reading database … 28021 files and directories currently installed.)
Preparing to replace vzdump 1.1-1 (using vzdump_1.1-1_all.deb) …
Unpacking replacement vzdump …
Setting up vzdump (1.1-1) …
Processing triggers for man-db …
server13:/home/gtoms#

vzprocps sebagai tool untuk menampilkan system information (vzps dan vztop)

server13:/home/gtoms# wget http://download.openvz.org/debian-systs/pool/openvz/v/vzprocps/vzprocps_2.0.11-1dso2_i386.deb
–2009-09-04 20:53:45–  http://download.openvz.org/debian-systs/pool/openvz/v/vzprocps/vzprocps_2.0.11-1dso2_i386.deb
Resolving download.openvz.org… 64.131.90.11
Connecting to download.openvz.org|64.131.90.11|:80… connected.
HTTP request sent, awaiting response… 200 OK
Length: 95280 (93K) [application/x-debian-package]
Saving to: `vzprocps_2.0.11-1dso2_i386.deb’

100%[===============================================>] 95,280      66.8K/s   in 1.4s

2009-09-04 20:53:48 (66.8 KB/s) – `vzprocps_2.0.11-1dso2_i386.deb’ saved [95280/95280]
server13:/home/gtoms#

server13:/home/gtoms# dpkg -i vzprocps_2.0.11-1dso2_i386.deb
Selecting previously deselected package vzprocps.
(Reading database … 28021 files and directories currently installed.)
Unpacking vzprocps (from vzprocps_2.0.11-1dso2_i386.deb) …
Setting up vzprocps (2.0.11-1dso2) …
Processing triggers for man-db …
server13:/home/gtoms#

server13:/home/gtoms#reboot

server13:/home/gtoms# uname -r
2.6.26-2-openvz-686

server13:/home/gtoms# nano /etc/apt/sources.list
deb http://download.openvz.org/debian-systs lenny openvz

server13:/etc/apt# nano /etc/apt/preferences
Package: *
Pin: release o=Debian
Pin-Priority: 700

Package: *
Pin: release o=debian.systs.org lenny archive
Pin-Priority: 650

server13:/home/gtoms#wget -q http://download.openvz.org/debian-systs/dso_archiv_signing_key.asc -O- | apt-key add – && apt-get update
OK
Hit http://kebo.vlsm.org lenny Release.gpg
Ign http://kebo.vlsm.org lenny/main Translation-en_US
Hit http://kebo.vlsm.org lenny Release
Ign http://kebo.vlsm.org lenny/main Packages/DiffIndex
Ign http://kebo.vlsm.org lenny/main Sources/DiffIndex
Hit http://kebo.vlsm.org lenny/main Packages
Hit http://kebo.vlsm.org lenny/main Sources
Get:1 http://download.openvz.org lenny Release.gpg [197B]
Hit http://volatile.debian.org lenny/volatile Release.gpg
Ign http://volatile.debian.org lenny/volatile/main Translation-en_US
Ign http://download.openvz.org lenny/openvz Translation-en_US
Hit http://volatile.debian.org lenny/volatile Release
Hit http://security.debian.org lenny/updates Release.gpg
Ign http://security.debian.org lenny/updates/main Translation-en_US
Ign http://volatile.debian.org lenny/volatile/main Packages/DiffIndex
Hit http://security.debian.org lenny/updates Release
Ign http://volatile.debian.org lenny/volatile/main Sources/DiffIndex
Get:2 http://download.openvz.org lenny Release [8730B]
Hit http://volatile.debian.org lenny/volatile/main Packages
Ign http://security.debian.org lenny/updates/main Packages/DiffIndex
Hit http://volatile.debian.org lenny/volatile/main Sources
Ign http://security.debian.org lenny/updates/main Sources/DiffIndex
Hit http://security.debian.org lenny/updates/main Packages
Get:3 http://download.openvz.org lenny/openvz Packages [1514B]
Hit http://security.debian.org lenny/updates/main Sources
Fetched 10.4kB in 2s (3871B/s)
Reading package lists… Done
server13:/etc/apt#

server13:/etc/apt# apt-cache search openvz
atl2-modules-2.6-openvz-686 – Atheros L2 Ethernet Adapter driver for Linux 2.6 on PPro/Celeron/PII/PIII/P4
atl2-modules-2.6.26-2-openvz-686 – Atheros L2 Ethernet Adapter driver for Linux 2.6.26 on PPro/Celeron/PII/PIII/P4
aufs-modules-2.6-openvz-686 – Stackable unification filesystem for Linux 2.6 on PPro/Celeron/PII/PIII/P4
aufs-modules-2.6.26-2-openvz-686 – Stackable unification filesystem for Linux 2.6.26 on PPro/Celeron/PII/PIII/P4
drbd8-modules-2.6-openvz-686 – RAID 1 over TCP/IP for Linux 2.6 on PPro/Celeron/PII/PIII/P4
drbd8-modules-2.6.26-2-openvz-686 – RAID 1 over TCP/IP for Linux 2.6.26 on PPro/Celeron/PII/PIII/P4
et131x-modules-2.6-openvz-686 – et131x Ethernet Adapter driver for Linux 2.6 on PPro/Celeron/PII/PIII/P4
et131x-modules-2.6.26-2-openvz-686 – et131x Ethernet Adapter driver for Linux 2.6.26 on PPro/Celeron/PII/PIII/P4
gspca-modules-2.6-openvz-686 – Driver for webcams and digicams based on spca5xx chipset for Linux 2.6 on PPro/Celeron/PII/PIII/P4
gspca-modules-2.6.26-2-openvz-686 – Driver for webcams and digicams based on spca5xx chipset for Linux 2.6.26 on PPro/Celeron/PII/PIII/P4
iscsitarget-modules-2.6-openvz-686 – iSCSI Enterprise Target for Linux 2.6 on PPro/Celeron/PII/PIII/P4
iscsitarget-modules-2.6.26-2-openvz-686 – iSCSI Enterprise Target for Linux 2.6.26 on PPro/Celeron/PII/PIII/P4
linux-headers-2.6-openvz-686 – Header files for Linux 2.6-openvz-686
linux-image-2.6-openvz-686 – Linux 2.6 image on PPro/Celeron/PII/PIII/P4, OpenVZ support
linux-image-openvz-686 – Linux image on PPro/Celeron/PII/PIII/P4, OpenVZ support
loop-aes-modules-2.6-openvz-686 – loop-AES encryption for Linux 2.6 on PPro/Celeron/PII/PIII/P4
loop-aes-modules-2.6.26-2-openvz-686 – loop-AES encryption for Linux 2.6.26 on PPro/Celeron/PII/PIII/P4
lzma-modules-2.6-openvz-686 – Lempel Ziv compression method (LZMA) for Linux 2.6 on PPro/Celeron/PII/PIII/P4
lzma-modules-2.6.26-2-openvz-686 – Lempel Ziv compression method (LZMA) for Linux 2.6.26 on PPro/Celeron/PII/PIII/P4
nilfs2-modules-2.6-openvz-686 – Log-structured snapshotting filesystem for Linux 2.6 on PPro/Celeron/PII/PIII/P4
nilfs2-modules-2.6.26-2-openvz-686 – Log-structured snapshotting filesystem for Linux 2.6.26 on PPro/Celeron/PII/PIII/P4
redhat-cluster-modules-2.6-openvz-686 – Redhat Cluster infrastructure for Linux 2.6 on PPro/Celeron/PII/PIII/P4
redhat-cluster-modules-2.6.26-2-openvz-686 – Redhat Cluster infrastructure for Linux 2.6.26 on PPro/Celeron/PII/PIII/P4
speakup-modules-2.6-openvz-686 – Screen review module for Linux 2.6 on PPro/Celeron/PII/PIII/P4
speakup-modules-2.6.26-2-openvz-686 – Screen review module for Linux 2.6.26 on PPro/Celeron/PII/PIII/P4
squashfs-modules-2.6-openvz-686 – Compression filesystem for Linux 2.6 on PPro/Celeron/PII/PIII/P4
squashfs-modules-2.6.26-2-openvz-686 – Compression filesystem for Linux 2.6.26 on PPro/Celeron/PII/PIII/P4
tp-smapi-modules-2.6-openvz-686 – ThinkPad hardware/firmware access for Linux 2.6 on PPro/Celeron/PII/PIII/P4
tp-smapi-modules-2.6.26-2-openvz-686 – ThinkPad hardware/firmware access for Linux 2.6.26 on PPro/Celeron/PII/PIII/P4
virtualbox-ose-guest-modules-2.6-openvz-686 – PC virtualization solution for Linux 2.6 on PPro/Celeron/PII/PIII/P4
virtualbox-ose-guest-modules-2.6.26-2-openvz-686 – PC virtualization solution for Linux 2.6.26 on PPro/Celeron/PII/PIII/P4
virtualbox-ose-modules-2.6-openvz-686 – PC virtualization solution for Linux 2.6 on PPro/Celeron/PII/PIII/P4
virtualbox-ose-modules-2.6.26-2-openvz-686 – PC virtualization solution for Linux 2.6.26 on PPro/Celeron/PII/PIII/P4
linux-headers-2.6.26-1-common-openvz – Common header files for Linux 2.6.26-1-openvz
linux-headers-2.6.26-1-openvz-686 – Header files for Linux 2.6.26-1-openvz-686
linux-headers-2.6.26-2-common-openvz – Common header files for Linux 2.6.26-2-openvz
linux-headers-2.6.26-2-openvz-686 – Header files for Linux 2.6.26-2-openvz-686
linux-image-2.6.26-1-openvz-686 – Linux 2.6.26 image on PPro/Celeron/PII/PIII/P4, OpenVZ support
linux-image-2.6.26-2-openvz-686 – Linux 2.6.26 image on PPro/Celeron/PII/PIII/P4, OpenVZ support
vzctl – OpenVZ – server virtualization solution – control tools
vzctl-ostmpl-debian-4.0-i386-minimal – OpenVZ – OS Template debian-4.0-i386-minimal
vzctl-ostmpl-debian-5.0-i386-minimal – OpenVZ – OS Template debian-5.0-i386-minimal
vzquota – OpenVZ – server virtualization solution – quota tools
vzdump – OpenVZ backup scripts
vzprocps – OpenVZ – server virtualization solution – procps utilities
server13:/etc/apt#

server13:/etc/apt# apt-get install vzctl-ostmpl-debian-5.0-i386-minimal
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following packages were automatically installed and are no longer required:
libpq5
Use ‘apt-get autoremove’ to remove them.
The following NEW packages will be installed:
vzctl-ostmpl-debian-5.0-i386-minimal
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 62.0MB of archives.
After this operation, 0B of additional disk space will be used.
Get:1 http://download.openvz.org lenny/openvz vzctl-ostmpl-debian-5.0-i386-minimal 20090121 [62.0MB]
Fetched 62.0MB in 1min30s (685kB/s)
Selecting previously deselected package vzctl-ostmpl-debian-5.0-i386-minimal.
(Reading database … 28028 files and directories currently installed.)
Unpacking vzctl-ostmpl-debian-5.0-i386-minimal (from …/vzctl-ostmpl-debian-5.0-i386-minimal_20090121_i386.deb) …
Setting up vzctl-ostmpl-debian-5.0-i386-minimal (20090121) …
server13:/etc/apt#

server13:/etc/apt# cd /var/lib/vz/template/cache
server13:/var/lib/vz/template/cache# ls -al
total 60888
drwxr-xr-x 2 root root     4096 2009-09-04 21:15 .
drwxr-xr-x 3 root root     4096 2009-09-04 20:29 ..
-rw-r–r– 1 root root 62274628 2009-01-21 19:28 debian-5.0-i386-minimal.tar.gz
server13:/var/lib/vz/template/cache#

server13:/var/lib/vz/template/cache# vzctl create 66 –ostemplate debian-5.0-i386-minimal –config vps.basic
Creating VE private area (debian-5.0-i386-minimal)
Performing postcreate actions
VE private area was created
server13:/var/lib/vz/template/cache#

server13:/var/lib/vz/template/cache# vzctl set 66 –onboot yes –save
Saved parameters for VE 66
server13:/var/lib/vz/template/cache#

server13:/var/lib/vz/template/cache# vzctl set 66 –hostname vps.galxxxx.co.id –save
Saved parameters for VE 66
server13:/var/lib/vz/template/cache# vzctl set 66 –ipadd 202.69.192.xx –save
Saved parameters for VE 66
server13:/var/lib/vz/template/cache#

server13:/var/lib/vz/template/cache# vzctl set 66 –numothersock 120 –save
Saved parameters for VE 66
server13:/var/lib/vz/template/cache# vzctl set 66 –nameserver 202.69.xxx.x –nameserver 202.69.xxx.x –save
Saved parameters for VE 66
server13:/var/lib/vz/template/cache#

server13:/var/lib/vz/template/cache# vzctl enter 66
entered into VE 66

root@vps:/# ls
bin  boot  dev  etc  home  lib  media  mnt  opt  proc  root  sbin  selinux  srv  sys  tmp  usr  var

root@vps:/# ps axf
PID TTY      STAT   TIME COMMAND
322 ?        Ss     0:00 vzctl: pts/0
323 pts/0    Ss     0:00  \_ -bash
327 pts/0    R+     0:00      \_ ps axf
1 ?        Ss     0:00 init [2]
281 ?        Sl     0:00 /usr/sbin/rsyslogd -c3
294 ?        Ss     0:00 /usr/sbin/sshd
309 ?        Ss     0:00 /usr/sbin/cron

root@vps:/# netstat -nltup
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      294/sshd
tcp6       0      0 :::22                   :::*                    LISTEN      294/sshd

root@vps:/# uname -a
Linux vps.galxxxx.co.id 2.6.26-2-openvz-686 #1 SMP Fri Aug 14 02:44:04 UTC 2009 i686 GNU/Linux
root@vps:/#

root@vps:/etc/apt# ifconfig
lo        Link encap:Local Loopback
inet addr:127.0.0.1  Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING  MTU:16436  Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

venet0    Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
inet addr:127.0.0.1  P-t-P:127.0.0.1  Bcast:0.0.0.0  Mask:255.255.255.255
UP BROADCAST POINTOPOINT RUNNING NOARP  MTU:1500  Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:30 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B)  TX bytes:2058 (2.0 KiB)

venet0:0  Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
inet addr:202.69.192.xx  P-t-P:202.69.192.xx  Bcast:0.0.0.0  Mask:255.255.255.255
UP BROADCAST POINTOPOINT RUNNING NOARP  MTU:1500  Metric:1
root@vps:/etc/apt#

root@vps:/etc/apt# exit
logout
exited from VE 66
server13:/var/lib/vz/template/cache#

server13:/var/lib/vz/template/cache# vzlist -a
VEID      NPROC STATUS  IP_ADDR         HOSTNAME
66          6 running 202.69.192.xx   vps.galxxxx.co.id
server13:/var/lib/vz/template/cache#

server13:/var/lib/vz/template/cache# vzctl exec 66 cat /proc/user_beancounters
Version: 2.5
uid  resource           held    maxheld    barrier      limit    failcnt
66:  kmemsize         463527     896120   11055923   11377049          0
lockedpages           0          0        256        256          0
privvmpages        7006       8001      65536      69632          0
shmpages              0          0      21504      21504          0
dummy                 0          0          0          0          0
numproc               7         12        240        240          0
physpages           609       1402          0 2147483647          0
vmguarpages           0          0      33792 2147483647          0
oomguarpages        609       1402      26112 2147483647          0
numtcpsock            2          2        360        360          0
numflock              1          2        188        206          0
numpty                0          1         16         16          0
numsiginfo            0          4        256        256          0
tcpsndbuf         17920          0    1720320    2703360          0
tcprcvbuf         32768          0    1720320    2703360          0
othersockbuf          0      14848    1126080    2097152          0
dgramrcvbuf           0          0     262144     262144          0
numothersock         11         17        120        120          0
dcachesize        46725      62475    3409920    3624960          0
numfile             168        273       9312       9312          0
dummy                 0          0          0          0          0
dummy                 0          0          0          0          0
dummy                 0          0          0          0          0
numiptent            10         10        128        128          0
server13:/var/lib/vz/template/cache#

server13:/home/gtoms/webvz# vzlist -a 66
VEID      NPROC STATUS  IP_ADDR         HOSTNAME
66          6 running 202.69.192.xx   vps.galxxxx.co.id
server13:/home/gtoms/webvz#

server13:/home/gtoms/webvz# vzctl status 66
VEID 66 exist mounted running

server13:/home/gtoms/webvz# vzlist -o veid,diskinodes.s -s diskinodes.s
VEID DQINODES.S
66     200000

server13:/home/gtoms/webvz# vzctl exec 66 /etc/init.d/ssh start
Starting OpenBSD Secure Shell server: sshd.

server13:/home/gtoms/webvz# vzmemcheck -v
Output values in %
veid        LowMem  LowMem     RAM MemSwap MemSwap   Alloc   Alloc   Alloc
util  commit    util    util  commit    util  commit   limit
66            0.29   12.12    0.72    0.18    8.15    1.87   10.19   19.68
————————————————————————-
Summary:      0.29   12.12    0.72    0.18    8.15    1.87   10.19   19.68

server13:/home/gtoms/webvz# vzcalc 66
Resource     Current(%)  Promised(%)  Max(%)
Memory           1.87      12.12      19.68

server13:/home/gtoms/webvz# vzctl restart 66
Restarting VE
Stopping VE …
VE was stopped
VE is unmounted
Starting VE …
VE is mounted
Adding IP address(es): 202.69.192.xx
Setting CPU units: 1000
Configure meminfo: 65536
Set hostname: vps.galxxxx.co.id
File resolv.conf was modified
VE start in progress…
server13:/home/gtoms/webvz#

Biar lebih mudah memanage OpenVZ via web based digunakan WebVZ

InstalasiWebVZ

server13:/home/gtoms# apt-get install ruby rubygems libsqlite3-ruby sqlite3 irb1.8 libopenssl-ruby1.8 libreadline-ruby1.8 rdoc1.8
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following packages were automatically installed and are no longer required:
libpq5
Use ‘apt-get autoremove’ to remove them.
The following extra packages will be installed:
libruby1.8 libsqlite3-ruby1.8 ruby1.8 rubygems1.8
Suggested packages:
graphviz ruby1.8-examples ri1.8 ruby1.8-dev build-essential rubygems-doc sqlite3-doc
The following NEW packages will be installed:
irb1.8 libopenssl-ruby1.8 libreadline-ruby1.8 libruby1.8 libsqlite3-ruby libsqlite3-ruby1.8 rdoc1.8 ruby ruby1.8 rubygems rubygems1.8 sqlite3
0 upgraded, 12 newly installed, 0 to remove and 0 not upgraded.
Need to get 3598kB of archives.
After this operation, 10.6MB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 http://kebo.vlsm.org lenny/main libsqlite3-ruby1.8 1.2.2-1 [46.0kB]
Get:2 http://security.debian.org lenny/updates/main libruby1.8 1.8.7.72-3lenny1 [1675kB]
Get:3 http://kebo.vlsm.org lenny/main libsqlite3-ruby 1.2.2-1 [3540B]
Get:4 http://kebo.vlsm.org lenny/main ruby 4.2 [20.6kB]
Get:5 http://kebo.vlsm.org lenny/main rubygems1.8 1.2.0-3 [164kB]
Get:6 http://kebo.vlsm.org lenny/main rubygems 1.2.0-3 [56.6kB]
Get:7 http://security.debian.org lenny/updates/main ruby1.8 1.8.7.72-3lenny1 [284kB]
Get:8 http://kebo.vlsm.org lenny/main sqlite3 3.5.9-6 [24.2kB]
Get:9 http://security.debian.org lenny/updates/main libreadline-ruby1.8 1.8.7.72-3lenny1 [264kB]
Get:10 http://security.debian.org lenny/updates/main irb1.8 1.8.7.72-3lenny1 [304kB]
Get:11 http://security.debian.org lenny/updates/main libopenssl-ruby1.8 1.8.7.72-3lenny1 [379kB]
Get:12 http://security.debian.org lenny/updates/main rdoc1.8 1.8.7.72-3lenny1 [379kB]
Fetched 3598kB in 7s (510kB/s)
Selecting previously deselected package libruby1.8.
(Reading database … 28031 files and directories currently installed.)
Unpacking libruby1.8 (from …/libruby1.8_1.8.7.72-3lenny1_i386.deb) …
Selecting previously deselected package ruby1.8.
Unpacking ruby1.8 (from …/ruby1.8_1.8.7.72-3lenny1_i386.deb) …
Selecting previously deselected package libreadline-ruby1.8.
Unpacking libreadline-ruby1.8 (from …/libreadline-ruby1.8_1.8.7.72-3lenny1_i386.deb) …
Selecting previously deselected package irb1.8.
Unpacking irb1.8 (from …/irb1.8_1.8.7.72-3lenny1_all.deb) …
Selecting previously deselected package libopenssl-ruby1.8.
Unpacking libopenssl-ruby1.8 (from …/libopenssl-ruby1.8_1.8.7.72-3lenny1_i386.deb) …
Selecting previously deselected package libsqlite3-ruby1.8.
Unpacking libsqlite3-ruby1.8 (from …/libsqlite3-ruby1.8_1.2.2-1_i386.deb) …
Selecting previously deselected package libsqlite3-ruby.
Unpacking libsqlite3-ruby (from …/libsqlite3-ruby_1.2.2-1_all.deb) …
Selecting previously deselected package rdoc1.8.
Unpacking rdoc1.8 (from …/rdoc1.8_1.8.7.72-3lenny1_all.deb) …
Selecting previously deselected package ruby.
Unpacking ruby (from …/apt/archives/ruby_4.2_all.deb) …
Selecting previously deselected package rubygems1.8.
Unpacking rubygems1.8 (from …/rubygems1.8_1.2.0-3_all.deb) …
Selecting previously deselected package rubygems.
Unpacking rubygems (from …/rubygems_1.2.0-3_all.deb) …
Selecting previously deselected package sqlite3.
Unpacking sqlite3 (from …/sqlite3_3.5.9-6_i386.deb) …
Processing triggers for man-db …
Setting up libruby1.8 (1.8.7.72-3lenny1) …
Setting up ruby1.8 (1.8.7.72-3lenny1) …
Setting up libreadline-ruby1.8 (1.8.7.72-3lenny1) …
Setting up irb1.8 (1.8.7.72-3lenny1) …
Setting up libopenssl-ruby1.8 (1.8.7.72-3lenny1) …
Setting up libsqlite3-ruby1.8 (1.2.2-1) …
Setting up libsqlite3-ruby (1.2.2-1) …
Setting up rdoc1.8 (1.8.7.72-3lenny1) …
Setting up ruby (4.2) …
Setting up rubygems1.8 (1.2.0-3) …
Setting up rubygems (1.2.0-3) …
Setting up sqlite3 (3.5.9-6) …
server13:/home/gtoms#

server13:/home/gtoms# gem install -v=2.1.0 rails
Successfully installed rake-0.8.7
Successfully installed activesupport-2.1.0
Successfully installed activerecord-2.1.0
Successfully installed actionpack-2.1.0
Successfully installed actionmailer-2.1.0
Successfully installed activeresource-2.1.0
Successfully installed rails-2.1.0
7 gems installed
Installing ri documentation for rake-0.8.7…
Installing ri documentation for activesupport-2.1.0…
Installing ri documentation for activerecord-2.1.0…
Installing ri documentation for actionpack-2.1.0…
Installing ri documentation for actionmailer-2.1.0…
Installing ri documentation for activeresource-2.1.0…
Installing RDoc documentation for rake-0.8.7…
Installing RDoc documentation for activesupport-2.1.0…
Installing RDoc documentation for activerecord-2.1.0…
Installing RDoc documentation for actionpack-2.1.0…
Installing RDoc documentation for actionmailer-2.1.0…
Installing RDoc documentation for activeresource-2.1.0…
server13:/home/gtoms#

server13:/home/gtoms# wget http://dfn.dl.sourceforge.net/sourceforge/webvz/webvz.2.0.tar.gz
–2009-09-04 22:04:29–  http://dfn.dl.sourceforge.net/sourceforge/webvz/webvz.2.0.tar.gz
Resolving dfn.dl.sourceforge.net… 194.95.236.6
Connecting to dfn.dl.sourceforge.net|194.95.236.6|:80… connected.
HTTP request sent, awaiting response… 302 Found
Location: http://downloads.sourceforge.net/sourceforge/webvz/webvz.2.0.tar.gz?download&failedmirror=dfn.dl.sourceforge.net [following]
–2009-09-04 22:04:33–  http://downloads.sourceforge.net/sourceforge/webvz/webvz.2.0.tar.gz?download&failedmirror=dfn.dl.sourceforge.net
Resolving downloads.sourceforge.net… 216.34.181.59
Connecting to downloads.sourceforge.net|216.34.181.59|:80… connected.
HTTP request sent, awaiting response… 302 Found
Location: http://biznetnetworks.dl.sourceforge.net/project/webvz/webvz/webvz%202.0/webvz.2.0.tar.gz [following]
–2009-09-04 22:04:34–  http://biznetnetworks.dl.sourceforge.net/project/webvz/webvz/webvz%202.0/webvz.2.0.tar.gz
Resolving biznetnetworks.dl.sourceforge.net… 203.142.84.220
Connecting to biznetnetworks.dl.sourceforge.net|203.142.84.220|:80… connected.
HTTP request sent, awaiting response… 200 OK
Length: 293350 (286K) [application/x-gzip]
Saving to: `webvz.2.0.tar.gz’

100%[============================================>] 293,350      932K/s   in 0.3s

2009-09-04 22:04:48 (932 KB/s) – `webvz.2.0.tar.gz’ saved [293350/293350]
server13:/home/gtoms#

server13:/home/gtoms# tar xvfz webvz.2.0.tar.gz
server13:/home/gtoms# mv webvz.2.0 webvz
server13:/home/gtoms# cd webvz
server13:/home/gtoms/webvz# ln -s /var/lib/vz /vz
server13:/home/gtoms/webvz# ln -s /usr/bin/irb1.8 /usr/bin/irb
server13:/home/gtoms/webvz# mkdir /etc/sysconfig
server13:/home/gtoms/webvz# ln -s /etc/vz/conf /etc/sysconfig/vz-scripts
server13:/home/gtoms/webvz#

Menjalankan webVZ
server13:/home/gtoms/webvz# ruby script/server
=> Booting WEBrick…
=> Rails 2.1.0 application started on http://0.0.0.0:3000
=> Ctrl-C to shutdown server; call with –help for options
[2009-09-04 22:07:18] INFO  WEBrick 1.3.1
[2009-09-04 22:07:18] INFO  ruby 1.8.7 (2008-08-11) [i486-linux]
[2009-09-04 22:07:18] INFO  WEBrick::HTTPServer#start: pid=3805 port=3000

Login  :
http://202.69.192.xy:3000
admin
admin123
ganti password admin setelah masuk ke webVZ control panel.

WebVZ- OpenVZ Management ToolLogin

webvzlogin2

webvzlogin3

Tinggal menambah account server vps client sesuai kebutuhan.

Catatan ps axf dan log sistem :

server13:/home/gtoms# ps axf |grep 66
663 ?        S<     0:00  \_ [ata/0]
664 ?        S<     0:00  \_ [ata_aux]
3137 pts/0    S+     0:00  |                   \_ vzctl enter 66
3139 /var/lib/vz/root/66/dev/pts/0 Ss+   0:00  |                           \_ -bash
3198 pts/1    S+     0:00                      \_ grep 66
server13:/home/gtoms#

server13:/home/gtoms# tail -f /var/log/syslog
Sep  4 21:17:01 server13 /USR/SBIN/CRON[2670]: (root) CMD (   cd / && run-parts –report /etc/cron.hourly)
Sep  4 21:20:01 server13 /USR/SBIN/CRON[2675]: (root) CMD (/usr/share/vzctl/scripts/vpsreboot)
Sep  4 21:20:01 server13 /USR/SBIN/CRON[2679]: (root) CMD (/usr/share/vzctl/scripts/vpsnetclean)
Sep  4 21:25:01 server13 /USR/SBIN/CRON[2729]: (root) CMD (/usr/share/vzctl/scripts/vpsreboot)
Sep  4 21:25:01 server13 /USR/SBIN/CRON[2736]: (root) CMD (/usr/share/vzctl/scripts/vpsnetclean)
Sep  4 21:28:49 server13 kernel: [ 1804.324616] CT: 66: started
Sep  4 21:30:01 server13 /USR/SBIN/CRON[3110]: (root) CMD (/usr/share/vzctl/scripts/vpsreboot)
Sep  4 21:30:01 server13 /USR/SBIN/CRON[3117]: (root) CMD (/usr/share/vzctl/scripts/vpsnetclean)
Sep  4 21:35:02 server13 /USR/SBIN/CRON[3149]: (root) CMD (/usr/share/vzctl/scripts/vpsnetclean)
Sep  4 21:35:02 server13 /USR/SBIN/CRON[3150]: (root) CMD (/usr/share/vzctl/scripts/vpsreboot)

4 thoughts on “Installation & Managing OpenVZ

  1. jayadi

    maz klo untuk penggunaan, openvz tetapi bisa membagi processor seperti yang dilihat pada vps server hostingan….nah apa yang menjadi kenadala biasanya ketika membagi core processor untuk setiap satu vps….

    terima kasih mas sebelumnya

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.