Running "Vservers" environment on Debian Etch
Installation
1) Install a vserver enables kernel
# apt-get update
# apt-get install linux-image-vserver-X.X.X // choose actual kernel image for your platform and
reconfigure your GRUB, or edit /boot/grub/menu.lst and set "kernel x.xx.x -vserver" to default
boot kernel.
# sync; sync; reboot
2) Install all needed userland binaries
# apt-get install util-vserver vserver-debiantools
Configuration
1) crate symlink to point to your $VROOTDIR
# mkdir /home/vservers
# ln -s /home/vservers /etc/vservers/.defaults/vdirbase
configure /etc/vserver/newvserver-vars as your need
#mcedit /etc/vserver/newvserver-vars
# Architecture: overide on non-Debian host such as Redhat otherwise dpkg
# will detect whether we are i386/powerpc/sparc/etc
#ARCH=""
# Which debian distribution (Warning. unstable and testing distributions
# change frequently so you can not expect it to work out of the box).
DIST="etch"
# Local or nearest location of a debian mirror (must include the /debian)
MIRROR="http://debian.co.il/debian"
# Default network interface for vservers:
INTERFACE="eth0"
# Package caching
#PKGCACHE=1
Creating Vservers
1) create new vserver
# newvserver -v --hostname vsrv1 --domain "example.com" --ip 192.168.1.11 \\ your domain and IPADDRESS
2) start new vserver
# vserver vsrv1 start
* Starting system log daemon...
...done.
* Starting OpenBSD Secure Shell server...
...done.
3) enter to the new vserver
# vserver vsrv1 enter
vsrv1: # apt-get update && apt-get dist-upgrade
vsrv1: # apt-get install PACKAGES (what you want)
vsrv1: # exit
4) stop the vserver
# vserver vsrv1 stop
* Stopping OpenBSD Secure Shell server... [ ok ]
* Stopping system log daemon... [ ok ]
* Sending all processes the TERM signal... [ ok ]
* Sending all processes the KILL signal... [ ok ]
* Unmounting remote and non-toplevel virtual filesystems... [ ok ]
* Shutting down LVM Volume Groups... [ ok ]
let init start the new vserver
# echo "default" > /etc/vservers/vsrv1/apps/init/mark
For extended conntrol on new vservers use following command
# vserver-info
Versions:
Kernel: 2.6.18-5-vserver-686
VS-API: 0x00020002
util-vserver: 0.30.212; Dec 9 2006, 12:26:51
Features:
CC: gcc, gcc (GCC) 4.1.2 20061115 (prerelease) (Debian 4.1.1-20)
CXX: g++, g++ (GCC) 4.1.2 20061115 (prerelease) (Debian 4.1.1-20)
CPPFLAGS: ''
CFLAGS: '-Wall -g -O2 -std=c99 -Wall -pedantic -W -funit-at-a-time'
CXXFLAGS: '-g -O2 -ansi -Wall -pedantic -W -fmessage-length=0 -funit-at-a-time'
build/host: i486-pc-linux-gnu/i486-pc-linux-gnu
Use dietlibc: yes
Build C++ programs: yes
Build C99 programs: yes
Available APIs: compat,v11,fscompat,v13,net,v21,oldproc,olduts
ext2fs Source: e2fsprogs
syscall(2) invocation: alternative
vserver(2) syscall#: 273/glibc
Paths:
prefix: /usr
sysconf-Directory: /etc
cfg-Directory: /etc/vservers
initrd-Directory: $(sysconfdir)/init.d
pkgstate-Directory: /var/run/vservers
vserver-Rootdir: /var/lib/vservers
# vserver-stat \\get statistics about vservers
CTX PROC VSZ RSS userTIME sysTIME UPTIME NAME
0 58 109.1M 17.6M 19d16h01 2d08h04 112d03h38 root server
49160 379 2G 650.6M 4d18h38 11h01m48 48d01h05 devel
49161 121 3.1G 324M 1h35m03 6m03s50 48d01h05 sys
49162 245 3.5G 412M 2d23m32 9h04m23 48d01h05 vsrv1
# vps -ef vsrv1: \\like ps but only for vservers
root 8102 0 MAIN 8100 0 12:40 pts/1 00:00:00 -bash
root 8210 49159 vsrv1 5542 0 12:49 ? 00:00:00 sshd: root@pts/2
root 8212 49159 vsrv1 8210 0 12:49 pts/2 00:00:00 -bash
root 8271 1 ALL_PROC 8102 0 12:57 pts/1 00:00:00 vps -ef
root 8272 1 ALL_PROC 8271 0 12:57 pts/1 00:00:00 ps -ef
Useful vserver binaries
vapt-get: use apt-get in given or all vservers
# vserver vsrv1 enter
vsrv1: # htop
bash: htop: command not found
vsrv1: # exit
# vapt-get vsrv1 -- install htop
Reading package lists... Done
Building dependency tree... Done
The following NEW packages will be installed:
htop
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 40.2kB of archives.
After unpacking 164kB of additional disk space will be used.
Get:1 http://debian.co.il/debian etch htop 0.5.2-1 [40.2kB]
Fetched 40.2kB in 0s (710kB/s)
Preconfiguring packages ...
Selecting previously deselected package htop.
(Reading database ... 9417 files and directories currently installed.)
Unpacking htop (from .../archives/htop_0.5.2-1_i386.deb) ...
Setting up htop (0.5.2-1) ...
# vserver vsrv1 enter
vsrv1: # htop
Very important !!
If after login via ssh to virtual server You have been redirected
to mother server - please login to mother server
and change in /etc/ssh/sshd_config variable "ListenAddress 0.0.0.0"
to your IP .
Regards.
Tuesday, June 17, 2008
Running Vservers on Debian
Posted by Dmitriy Morozovsky at 4:43 AM
Labels: Vservers on Debian