So here we go...first thing first..we need a technology to enable that..and that technology is called OpenVZ . Right? Now I have recently stumble over an article published here and followed those instruction to make it possible for me.
I am running this experiment on Fedora 15 .
Step 1;
Get OpenVZ repo into your machine:
bhaskar@bhaskar-laptop_12:55:46_Mon Jul 04:/etc/yum.repos.d> sudo wget http://download.openvz.org/openvz.repo
[sudo] password for bhaskar:
--2011-07-04 12:56:05-- http://download.openvz.org/openvz.repo
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: 3841 (3.8K) [text/plain]
Saving to: “openvz.repo”
100%[===================================================================================================================>] 3,841 --.-K/s in 0.007s
2011-07-04 12:56:21 (503 KB/s) - “openvz.repo” saved [3841/3841]
Step 2:
Get the key for it:
bhaskar@bhaskar-laptop_12:56:21_Mon Jul 04:/etc/yum.repos.d> sudo rpm --import http://download.openvz.org/RPM-GPG-Key-OpenVZ
Step 3:
Search for the specific kernel related to OpenVZ:
bhaskar@bhaskar-laptop_13:01:59_Mon Jul 04:/etc/yum.repos.d> sudo yum search vzkernel
Loaded plugins: langpacks, presto, refresh-packagekit
google | 951 B 00:00
google-chrome | 951 B 00:00
http://mirror.switch.ch/ftp/mirror/rpmfusion/free/fedora/development/source/SRPMS/repodata/repomd.xml: [Errno 14] curl#6 - "Couldn't resolve host"
Trying other mirror.
rpmfusion-free-rawhide-source | 2.7 kB 00:00
rpmfusion-free-rawhide-source/primary_db | 79 kB 00:04
rpmfusion-free-updates | 2.7 kB 00:00
updates/metalink | 7.4 kB 00:00
updates | 4.7 kB 00:00
updates/primary_db | 2.1 MB 00:20
openvz-kernel-rhel6 12/12
updates/pkgtags | 31 kB 00:00
=================================================================== N/S Matched: vzkernel ===================================================================
vzkernel.i686 : The Linux kernel
vzkernel-debug.i686 : The Linux kernel compiled with extra debugging enabled
vzkernel-debug-devel.i686 : Development package for building kernel modules to match the debug kernel
vzkernel-devel.i686 : Development package for building kernel modules to match the kernel
vzkernel-firmware.noarch : Firmware files used by the Linux kernel
vzkernel-headers.i686 : Header files for the Linux kernel for use by glibc
Name and summary matches only, use "search all" for everything.
Step 4:
Install the Kernel:
bhaskar@bhaskar-laptop_13:04:24_Mon Jul 04:/etc/yum.repos.d> sudo yum install vzkernel.i686
[sudo] password for bhaskar:
Loaded plugins: langpacks, presto, refresh-packagekit
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package vzkernel.i686 0:2.6.32-042stab018.1 will be installed
--> Processing Dependency: virtual-vzkernel-install >= 2.0.0 for package: vzkernel-2.6.32-042stab018.1.i686
--> Running transaction check
---> Package vzctl.i386 0:3.0.28.3-1 will be installed
--> Processing Dependency: vzctl-lib = 3.0.28.3-1 for package: vzctl-3.0.28.3-1.i386
--> Processing Dependency: vzquota >= 2.7.0-4 for package: vzctl-3.0.28.3-1.i386
--> Processing Dependency: libvzctl-0.0.3.so for package: vzctl-3.0.28.3-1.i386
--> Running transaction check
---> Package vzctl-lib.i386 0:3.0.28.3-1 will be installed
---> Package vzquota.i386 0:3.0.12-1 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=============================================================================================================================================================
Package Arch Version Repository Size
=============================================================================================================================================================
Installing:
vzkernel i686 2.6.32-042stab018.1 openvz-kernel-rhel6 23 M
Installing for dependencies:
vzctl i386 3.0.28.3-1 openvz-utils 162 k
vzctl-lib i386 3.0.28.3-1 openvz-utils 186 k
vzquota i386 3.0.12-1 openvz-utils 82 k
Transaction Summary
=============================================================================================================================================================
Install 4 Package(s)
Total download size: 23 M
Installed size: 83 M
Is this ok [y/N]:
Downloading Packages:
Setting up and reading Presto delta metadata
Processing delta metadata
Package(s) data still to download: 23 M
(1/4): vzctl-3.0.28.3-1.i386.rpm | 162 kB 00:01
(2/4): vzctl-lib-3.0.28.3-1.i386.rpm | 186 kB 00:01
(3/4): vzkernel-2.6.32-042stab018.1.i686.rpm | 23 MB 00:58
(4/4): vzquota-3.0.12-1.i386.rpm | 82 kB 00:01
-------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 367 kB/s | 23 MB 01:05
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : vzctl-lib-3.0.28.3-1.i386 1/4
Installing : vzquota-3.0.12-1.i386 2/4
Installing : vzctl-3.0.28.3-1.i386 3/4
Installing : vzkernel-2.6.32-042stab018.1.i686 4/4
Installed:
vzkernel.i686 0:2.6.32-042stab018.1
Dependency Installed:
vzctl.i386 0:3.0.28.3-1 vzctl-lib.i386 0:3.0.28.3-1 vzquota.i386 0:3.0.12-1
Complete!
Step 6:
The Grub entry:
title OpenVZ-2.6.32-042stab018.1
root (hd0,5)
kernel /vmlinuz-2.6.32-042stab018.1 ro root=UUID=a2298586-fab5-42a5-a84e-276f9565fb37 rd_NO_LUKS rd_NO_LVM rd_NO_MD rd_NO_DM LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYBOARDTYPE=pc KEYTABLE=us
initrd /initramfs-2.6.32-042stab018.1.img
Step 7:
Installing some openvz tools:
bhaskar@bhaskar-laptop_13:44:13_Mon Jul 04:~> sudo yum install vzctl vzquota
[sudo] password for bhaskar:
Loaded plugins: langpacks, presto, refresh-packagekit
Setting up Install Process
Package vzctl-3.0.28.3-1.i386 already installed and latest version
Package vzquota-3.0.12-1.i386 already installed and latest version
Nothing to do
It is saying so because I have already installed those.
Step 8:
Need to change some kernel parameter:
bhaskar@bhaskar-laptop_13:47:37_Mon Jul 04:~> sudo sysctl -p
net.ipv4.ip_forward = 1
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.default.accept_source_route = 0
kernel.sysrq = 0
kernel.core_uses_pid = 1
net.ipv4.conf.default.proxy_arp = 0
net.ipv4.conf.all.rp_filter = 1
kernel.sysrq = 1
net.ipv4.conf.default.send_redirects = 1
net.ipv4.conf.all.send_redirects = 0
net.ipv4.icmp_echo_ignore_broadcasts = 1
net.ipv4.conf.default.forwarding = 1
Step 9:
Change some variable in vz.conf
vi /etc/vz/vz.conf
and put in
NEIGHBOUR_DEVS=all
Step 10:
Here is the file , where you can disable selinux
selinux disable
/etc/sysconfig/selinux
Step 11:
I am putting different ostemplate I have downloaded from here
And here it looks like :
cd /vz/template/cache/
the place to put different os template
I putting there funtoo,suse,slackware there
bhaskar@bhaskar-laptop_13:52:31_Mon Jul 04:/lvm> sudo mv -v suse-11.4-x86.tar.gz /vz/template/cache/
`suse-11.4-x86.tar.gz' -> `/vz/template/cache/suse-11.4-x86.tar.gz'
removed `suse-11.4-x86.tar.gz'
bhaskar@bhaskar-laptop_13:53:06_Mon Jul 04:/lvm> sudo mv -v slackware-13.37-i486-minimal.tar.gz /vz/template/cache/
`slackware-13.37-i486-minimal.tar.gz' -> `/vz/template/cache/slackware-13.37-i486-minimal.tar.gz'
removed `slackware-13.37-i486-minimal.tar.gz'
bhaskar@bhaskar-laptop_13:53:30_Mon Jul 04:/lvm> sudo mv -v funtoo-openvz-i686-funtoo-current-2011-05-26.tar.xz /vz/template/c
`funtoo-openvz-i686-funtoo-current-2011-05-26.tar.xz' -> `/vz/template/cache/funtoo-openvz-i686-funtoo-current-2011-05-26.tar.xz'
removed `funtoo-openvz-i686-funtoo-current-2011-05-26.tar.xz'
DO NOT UNTAR those files ever.
Step 12:
VPS implementation for SUSE:
bhaskar@bhaskar-laptop_14:05:59_Mon Jul 04:~> sudo vzctl create 101 --ostemplate suse-11.4-x86 --config basic
[sudo] password for bhaskar:
Creating container private area (suse-11.4-x86)
Performing postcreate actions
Saved parameters for CT 101
Container private area was created
Step 13:
Run at boot
bhaskar@bhaskar-laptop_14:08:54_Mon Jul 04:~> sudo vzctl set 101 --onboot yes --save
Saved parameters for CT 101
Step 14:
fix a hostname
bhaskar@bhaskar-laptop_14:10:01_Mon Jul 04:~> sudo vzctl set 101 --hostname SUSE --save
Saved parameters for CT 101
Step 15:
saving ip address
bhaskar@bhaskar-laptop_14:11:57_Mon Jul 04:~> sudo vzctl set 101 --ipadd 127.0.0.2 --save
Saved parameters for CT 101
Step 16:
save some socks
bhaskar@bhaskar-laptop_14:13:32_Mon Jul 04:~> sudo vzctl set 101 --numothersock 120 --save
Saved parameters for CT 101
Step 17:
Save Nameserver
vzctl set 101 --nameserver 8.8.8.8 --nameserver 8.8.4.4 --nameserver 145.253.2.75 --save
Step 18:
vz start and set root password
bhaskar@bhaskar-laptop_14:15:26_Mon Jul 04:~> sudo vzctl start 101
Starting container ...
Container is mounted
Adding IP address(es): 127.0.0.2 192.168.2.167
Setting CPU units: 1000
Set hostname: SUSE
File resolv.conf was modified
Container start in progress...
bhaskar@bhaskar-laptop_14:16:19_Mon Jul 04:~> sudo vzctl exec 101 passwd
New Password:
Bad password: too short
Reenter New Password: suse
Changing password for root.
Password changed.
Step 19:
Enter into one the vz..ie. suse
bhaskar@bhaskar-laptop_14:18:00_Mon Jul 04:~> sudo vzctl enter 101
entered into CT 101
SUSE:/ #
Step 20:
Slackware snapshot
bhaskar@bhaskar-laptop_14:31:54_Mon Jul 04:~> sudo vzctl enter 102
entered into CT 102
root@Slackware13:/# uname -a
Linux Slackware13 2.6.32-042stab018.1 #1 SMP Fri Jun 10 20:04:40 MSD 2011 i686 Intel(R) Core(TM)2 Duo CPU T5450 @ 1.66GHz GenuineIntel GNU/Linux
root@Slackware13:/# ls
bin/ boot/ dev/ etc/ fastboot home/ lib/ media/ mnt/ opt/ proc/ root/ sbin/ srv/ sys/ tmp/ usr/ var/
Step 21:
Inside Funtoo!!
bhaskar@bhaskar-laptop_14:41:38_Mon Jul 04:~> sudo vzctl start 103
Starting container ...
Container is mounted
Adding IP address(es): 192.168.2.118
Setting CPU units: 1000
Set hostname: Funtoo
File resolv.conf was modified
Container start in progress...
bhaskar@bhaskar-laptop_14:41:52_Mon Jul 04:~> sudo vzctl enter 103
entered into CT 103
Funtoo / # ls
bin boot dev etc fastboot home lib libexec mnt opt proc root sbin sys tmp usr var
Step 22:
Here is the vz list:
bhaskar@bhaskar-laptop_14:42:49_Mon Jul 04:~> sudo vzlist -a
CTID NPROC STATUS IP_ADDR HOSTNAME
101 16 running 192.168.2.167 SUSE
102 4 running 192.168.2.117 Slackware13
103 2 running 192.168.2.118 Funtoo
Hope this will help.
Cheers!
Bhaskar
No comments:
Post a Comment