How To Create A Cluster Testbed Using CentOS 5 Virtualization And iSCSI - Page 2
D. Virtualization
1. virtual networks
As root, run
virt-manager
The Virtual Machine Manager window should appear. You'll see Domain-0 and the resources it is using.
1.a to create the virtual network:
- On the menu, click on Edit and then "Host details".
- In the Host Details window, you will only see "default" on the left frame. Below, click on "Add".
- The "Create a new virtual network" window will appear, click forward.
- Use "public1" (no quotes) and then hit forward.
- Network should be "192.168.222.0/24" then hit forward.
- DHCP range: Start: 192.168.222.128 end: 192.168.222.254 then hit forward.
- This will be an "Isolated virtual network". Hit forward.
- Summary:
Network Name: public1
IPV4 network:
Network: 192.168.222.0/24
Gateway: 192.168.222.1
Netmask: 255.255.255.0
DHCP
Start address: 192.168.222.128
End address : 192.168.222.254
Forwarding:
Connectivity: Isolated virtual network - Hit Finish.
You'll go back to the Host Details window and the public1 entry will appear. Now to the same steps for network private1 with the following settings:
Network Name: private1
IPV4 network:
Network: 192.168.100.0/24
Gateway: 192.168.100.1
Netmask: 255.255.255.0
DHCP
Start address: 192.168.100.128
End address : 192.168.100.254
Forwarding:
Connectivity: Isolated virtual network
When you are done, in the Host Details window, click on "File > Close" to go back to the Virtual Machine Manager Window. Then click on "File > Quit". NOTE: Don't leave the Virtual Manager window running if you are not going to use it. It will eat up a lot of memory. If this happens, you need to restart Xen.
Once done, vnet0 and vnet1 can be seen when you run
ifconfig
vnet0 Link encap:Ethernet HWaddr 00:00:00:00:00:00 inet addr:192.168.222.1 Bcast:192.168.222.255 Mask:255.255.255.0 inet6 addr: fe80::200:ff:fe00:0/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:28 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 b) TX bytes:7782 (7.5 KiB) vnet1 Link encap:Ethernet HWaddr 00:00:00:00:00:00 inet addr:192.168.100.1 Bcast:192.168.100.255 Mask:255.255.255.0 inet6 addr: fe80::200:ff:fe00:0/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:27 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 b) TX bytes:7712 (7.5 KiB)
2. kickstart files
I'm providing the kickstart file for node01 that you can also use for node02. You just need to mofiy the IP addresses and hostname entries.
2.a for node01
#START of node01_ks.cfg install text reboot #uncomment the line you want to use # for nfs nfs --server=192.168.222.1 --dir=/var/ftp/pub/centos5u1 ##url --url ftp://<username>:<password>@<server>/<dir> # this will be an anonymous ftp access #url --url ftp://192.168.222.1/pub/centos5u1/i386 #key --skip lang en_US.UTF-8 keyboard us skipx # private network --device eth1 --bootproto static --ip 192.168.100.10 --netmask 255.255.255.0 # public - disabled on initial install network --device eth0 --bootproto static --ip 192.168.222.10 --netmask 255.255.255.0 --gateway 192.168.222.1 --nameserver 192.168.222.1 --hostname node01.example.com ## password is n0de01pass rootpw --iscrypted $1$Lqk1Y$Y8TIWCMLiiPjVt1GjRS0F1 ## password is n0de02pass #rootpw --iscrypted $1$Rn47b$DDwgrOv3IFGf3HVhsxv9X0 firewall --disabled authconfig --enableshadow --enablemd5 selinux --disabled timezone --utc Asia/Singapore services --disabled ipsec,iptables,bluetooth,hplip,firstboot,cups,sendmail,xfs bootloader --location=mbr --driveorder=xvda,xvdb --append="rhgb quiet" clearpart --all --initlabel --drives=xvda part /boot --fstype ext3 --size=100 --ondisk=xvda part pv.2 --size=0 --grow --ondisk=xvda volgroup VolGroup00 --pesize=32768 pv.2 logvol swap --fstype swap --name=LogVol01 --vgname=VolGroup00 --size=1000 --grow --maxsize=1984 logvol / --fstype ext3 --name=LogVol00 --vgname=VolGroup00 --size=1024 --grow %packages @development-libs @system-tools @gnome-software-development @text-internet @x-software-development @dns-server @core @authoring-and-publishing @base @ftp-server @network-server @legacy-software-development @java @legacy-software-support @smb-server @base-x @web-server @printing @server-cfg @sql-server @admin-tools @development-tools emacs lsscsi gnutls-utils hwbrowser audit iptraf mesa-libGLU-devel kexec-tools device-mapper-multipath vnc-server xorg-x11-utils xorg-x11-server-Xnest xorg-x11-server-Xvfb imake iscsi-initiator-utils ypserv -sysreport %post cat <<EOT >> /etc/hosts # private or replace with nodeXY- 192.168.100.10 node01-priv 192.168.100.20 node02-priv 192.168.100.1 node00-priv #public or replace with nodeXY 192.168.222.10 node01 192.168.222.20 node02 192.168.222.1 node00 EOT # yum local repo mv /etc/yum.repos.d/*.repo /tmp cat > /etc/yum.repos.d/centos5.repo << EOF [centos5-Server] name=CEntos5 Server baseurl=http://node00/centos5u1/i386 enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5 EOF #change default runlevel ed /etc/inittab << EOF ,s/id:5:initdefault:/id:3:initdefault:/g . w EOF # vncserver stuff cat << EOT > /opt/vnc_xstartup #!/bin/sh # run vncserver and copy to your $HOME/.vnc/xstartup file # Uncomment the following two lines for normal desktop: # unset SESSION_MANAGER # exec /etc/X11/xinit/xinitrc [ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup [ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources xsetroot -solid grey vncconfig -iconic & xterm -geometry 130x30+12+12 -ls -bg black -fg green -title "$VNCDESKTOP Desktop" & mwm & EOT # END of nod01_ks.cfg
2.b for node02
Copy the node01_ks.cfg file above to node02_ks.cfg and change the appropriate entries for node02 (hostname and IP addresses).
3. Installing the guest systems (node01 and node02)
For the installation, we'll be invoking it in the CLI, using
virt-install
But first, generate the MAC addresses for the NICS of the virtual systems:
3.a MAC Address generation
We'll use a python script provided by the Red Hat Virtualization Guide:
#!/usr/bin/python # macgen.py script to generate a MAC address for Red Hat Virtualization guests import random # def randomMAC(): mac = [ 0x00, 0x16, 0x3e, random.randint(0x00, 0x7f), random.randint(0x00, 0xff), random.randint(0x00, 0xff) ] return ':'.join(map(lambda x: "%02x" % x, mac)) # print randomMAC() # careful with the indention # this is from the Virtualization guide from redhat.com # http://www.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/5.2/html/Virtualization/index.html
node01 NICs
# for eth0 . public1
[root@node00 ~]# ./macgen.py
00:16:3e:33:32:07
# for eth1 . private1
[root@ node00 ~]# ./macgen.py
00:16:3e:55:6b:83
Then do the same for node02's virtual NICs.
3.b virt-install command for node01
virt-install -p -n node01 -r 768 -f /dev/Virtual00VG/lvNODE01 -m 00:16:3e:33:32:07 \
-w network:public1 -m 00:16:3e:55:6b:83 -w network:private1 \
-l nfs:192.168.222.1:/var/ftp/pub/centos5u1/i386 \
-x "ksdevice=eth0 ks=http://192.168.222.1/centos5u1/node01_ks.cfg" --vnc
Parameters:
-n node01 = name of the guest system
-r 768 = amount of RAM in MB
-f /dev/Virtual00VG/lvNODE01 = disk to be used by the guest system (can be an unused partition in your system, like /dev/sda3 or /dev/hda9).
-m 00:16:3e:33:32:07 = mac address for eth0
-w network:public1 = eth0's network
-m 00:16:3e:55:6b:83 = mac address for eth1
-w network:private1 = eth0's network
-l nfs:192.168.222.1:/var/ftp/pub/centos5u1/i386 = installation source (not the actual one used during ks install
-x "ksdevice=eth0 ks=http://192.168.222.1/centos5u1/node01_ks.cfg" = kickstart directives. This will use dhcp to startup installation.
--vnc = will launch a gui window for you to view (if you are running virt-install from a vnc session or a gui terminal).
3.c virt-install command for node02
virt-install -p -n node02 -r 768 -f /dev/Virtual00VG/lvNODE02 -m 00:16:3e:1e:05:b6 \
-w network:public1 -m 00:16:3e:40:3d:b0 -w network:private1 \
-l nfs:192.168.222.1:/var/ftp/pub/centos5u1/i386 \
-x "ksdevice=eth0 ks=http://192.168.222.1/centos5u1/node02_ks.cfg" --vnc
I ran the above virt-install inside a vnc session in the physical host so the the guest installation screens automatically appear. You can start it in the physical host's console and the installation of the guest systems will run in the background. Their installation can be viewed by running virt-manager and then opening the guests.