Install Xenserver Hetzner for DS 5000 Guest Networking Enabled

Posted by Simson on February 4th, 2010
I have tested XensServer and i am very impress with it performance, compare to Vmware Esxi or Server.  even with Openvz (only Linux)
It takes me awhile until i am able to get it working on my dedicated server in Hetzner which has Diffrent IP addressing
First of all we would need :
- A webserver apart from the Dedicated server that we want to install XenServer.
- XenServer-5.5.0-Update2-install-cd.iso
- Fresh Install Centos Installed on Hetzner. ( this can be done on rescue mode Linux 32bit) and login to your server and execute “installimage” then follow all the wizard which kinda straight forward.
Ok here we are.
1. Download XenServer-5.5.0-Update2-install-cd.iso on your other webserver apart from hetzener we would use this server as source installation.
2. mount this iso with this command
# mount -o loop FREE_XenServer-5.5.0-install-cd.iso /mnt
# mkdir /var/www/xenserver
# cp -a /mnt/* /var/www/xenserver

3. Create file called xenserver.xml in /var/www/xenserver with this content below according to your needs.
<installation mode=”fresh” srtype=”lvm”>
<bootloader>grub</bootloader>
<primary-disk gueststorage=”yes”>sda</primary-disk>
<keymap>us</keymap>
<hostname>xen</hostname>
<root-password>my_password</root-password>
<source type =”url”>http://your_webserverip/xenserver</source>
<!– No Post install scripts configured –>
<admin-interface name=”eth0″ proto=”static”>
<ip>xxx.xxx.xxx.xxx</ip>
<subnet-mask>255.255.255.192</subnet-mask>
<gateway>xxx.xxx.xxx.xxx</gateway>
</admin-interface>
<nameserver>213.133.99.99</nameserver>
<nameserver>213.133.100.100</nameserver>
<timezone>Europe/Berlin</timezone>
<time-config-method>ntp</time-config-method>
<ntp-servers>ntp</ntp-servers>
<ntpservers>83.246.120.75</ntpservers>
<ntpservers>213.9.73.106</ntpservers>
<ntpservers>188.40.34.195</ntpservers>
</installation>
Attention: You must fill with your own IP and Gateway from Hetzener.
4. Login to your Dedicated server which we want to install XenServer and copy these 3 files from the iso files you have mounted and copy to your webserver public directory
#cd /boot
#wget http://your_webserverip/xenserver/boot/vmlinuz
#wget http://your_webserverip/xenserver/boot/xen.gz
#wget http://your_webserverip/install.img

5. Once they are downloaded to your Centos edit your /boot/grub/menu.1st
# Hetzner Online AG – installimage
# GRUB bootloader configuration file
#
timeout 5
default 1
title CentOS Linux (2.6.18-128.1.16.el5)
root (hd0,1)
kernel /boot/vmlinuz-2.6.18-128.1.16.el5 ro root=/dev/md2 vga=0×317
initrd /boot/initrd-2.6.18-128.1.16.el5.img
title Install Xenserver
root (hd0,1)
kernel /boot/xen.gz dom0_mem=752M acpi=off nosmp noapic noirqbalance
module /boot/vmlinuz answerfile=http://my_webserver_ip/xenserver/xenserver.xml install
module /boot/install.img

6. now reboot your Centos and start to check the installation log by logging to your webserver and check tail -f access_log
it might take some times depend on the connection between the two servers.
Once installation has been completed login to your fresh new Xenserver.. and start to configure the networking….
7. Makse sure your /etc/sysctl.conf has this :
# Kernel sysctl configuration file for Red Hat Linux
#
# For binary values, 0 is disabled, 1 is enabled.  See sysctl(8) and
# sysctl.conf(5) for more details.
# Controls IP packet forwarding
net.ipv4.ip_forward = 1
# Controls proxy arp
net.ipv4.conf.default.proxy_arp = 1
# Turn off redirects
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.default.send_redirects = 0
net.ipv4.conf.lo.send_redirects = 0
net.ipv4.conf.xenbr0.send_redirects = 0
and validated with ‘systcl -p’
# sysctl -p
net.ipv4.ip_forward = 1
net.ipv4.conf.default.proxy_arp = 1
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.default.send_redirects = 0
net.ipv4.conf.lo.send_redirects = 0
net.ipv4.conf.xenbr0.send_redirects = 0
net.ipv4.conf.default.rp_filter = 1
net.ipv4.icmp_echo_ignore_broadcasts = 1
net.ipv4.conf.default.accept_source_route = 0
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.all.send_redirects = 0
kernel.sysrq = 1
kernel.core_uses_pid = 1
net.ipv4.tcp_syncookies = 1
kernel.msgmnb = 65536
kernel.msgmax = 65536
kernel.shmmax = 4294967295
kernel.shmall = 268435456
vm.dirty_ratio = 5
kernel.printk = 4 4 1 4

8. Disable SeLinux with
# system-config-securitylevel-tui
9. add your additional subnetwork to your xenserver
# ip addr add 78.47.193.23/29 dev xenbr0
10. shutdown the iptables
# service iptables stop
11. Create Dummy interface as we would use this as gateway for all Guest machine (Linux or Windows)
let say you have this Ip subnet from Hetzner 78.47.125.24 until 78.47.125.31.
Network:   78.47.125.24/29
Broadcast: 78.47.125.31
HostMin:   78.47.125.25 (this one we would use as gatway for our guesthost)
HostMax:   78.47.125.30
# nano /etc/sysconfig/network-scripts/ifcfg-xenbr0:1
XEMANAGED=yes
DEVICE=xenbr0:1
ONBOOT=yes
BOOTPROTO=none
NETMASK=255.255.255.248
IPADDR=78.47.193.23

12. bring our xenguest gateway ip up
#ifup xenbr0:1
13. now you can use this range 78.47.125.26 until 78.47.125.30
NETMASK = 255.255.255.248
GATEWAY = 78.47.125.25
NAMESERVER = 213.133.99.99 213.133.100.100
Good luck
Thanks to : Jonathan Thorpe

How to Increase the Hard Disk Size of Guest OS

Posted by Simson on August 20th, 2009

The original copy of these instructions is located here –> http://vmetc.com/2007/11/07/increase-the-size-of-a-virtual-disk/

When I need to increase the size of a virtual disk (.vmdk), you use the console command vmkfstools and the Gparted LiveCD. If you did not know, Gparted is an open source Partition Magic Alternative. Available on sourceforge.net
These steps are for a Windows VM. They should work for any OS, however.
1. Download the Gparted LiveCD ISO. You will need to save it to a location you can use it to boot the VM, like uploading it using the VI client to the ESX host’s data store.
2. Shutdown the virtual machine you want to resize
3. Log into the ESX Server via Putty, or however you can get to the console.
4. Use vmkfstools to increase the size of the .vmdk For example if you had a VM named “MyOS” in a folder called “myVMFS” and you wanted to increase it from 20GB to 24GB you would type (it is case sensitive):
vmkfstools -X 24g /vmfs/volumes/myVMFS/myOS.vmdk
or
vmkfstools -X 24576m /vmfs/volumes/myVMFS/myOS.vmdk
5. Boot the VM to the Gparted ISO
6. Once the Gparted partition editor loads, click your disk in the partition list
7. Click the Resize/Move button
8. Drag the arrow to extend the size of the partition. Be sure to work out the free space before and/or after the partition by sliding the whole partition either left or right.
9. Next click the Apply button to start the resizing process.
10. After it completes click the Close button
11. Reboot the VM without the Gparted ISO to the VM’s OS.
12. You will have to wait for a chkdsk on the reboot. Then Windows will reboot again.
13. Check your new disk size in My Computer and Disk Manager!

As an alternative to steps 3 & 4, you can resize the disk using the VI client GUI by choosing to Edit Settings, then click on the HD you want to resize, type in the new size, click OK. Again, the VM has to be powered off in order to do this. Doing this still requires you to run the Gparted utility to resize a partition, otherwise you will only be able to ADD a partion using the new space. If the disk you are resizing happens to be a non-system disk, you may be able to extend the partition within Windows to use the new space.

Another way to do this is to use a “ghost” program:

1) Add a second HDD to the vm. The end size you want. In you’re case 40Gb.
2) Restart VM and boot off a bootable ghost disk.
3) Use ghost program to clone disk 1 to disk 2.
4) After this is done power off VM.
5) Remove 1st HDD and set the 2nd drive to drive 1 in Virtual device node under edit VM settings.
6) Power up vm and that should be it.

The above steps were mostly taken from the discussion boards on this site and tweaked slightly for readability and spelling.

Install snmp deamon on Gentoo

Posted by Simson on June 8th, 2009

Getting started
On the client machine you wish to monitor please enter:

emerge net-snmpConfigure SNMPd
SNMPv3
net-snmp-config –create-snmpv3-user -a “my_password” my_userWARNING: SNMPv3 pass phrases must be at least 8 characters long!

More info on configuring SNMPv3

Fast config
net-snmp-config –create-snmpv3-user -a “mypassword” my_userln -s /usr/share/snmp/snmpd.conf /etc/snmp/snmpd.conf/etc/init.d/snmpd start/sbin/rc-update add snmpd default SNMPv2
File: /etc/snmp/snmpd.conf
com2sec local 127.0.0.1/32 publiccom2sec local 10.10.10.0/24 publicgroup MyROGroup v1 localgroup MyROGroup v2c localgroup MyROGroup usm localview all included .1 80access MyROGroup “” any noauth exact all none nonesyslocation MyLocationsyscontact Me <
me@somewhere.orgThis e-mail address is being protected from spam bots, you need JavaScript enabled to view it
>
Starting SNMPd
/etc/init.d/snmpd start/sbin/rc-update add snmpd default

How to set Static Ip address on Debian BOX

Posted by Simson on April 24th, 2009

This is also another important stuff to read, i atempted to forgot how it setup so i publish it so next time i just open my own blog i can read this article:

To configure a static IP (an IP that will never change) in debian you must edit the file
/etc/networking/interfaces and put the following:

CODE

# /etc/network/interfaces — configuration file for ifup(8), ifdown(8)

# The loopback interface
auto lo
iface lo inet loopback

# The first network card – this entry was created during the Debian installation
# (network, broadcast and gateway are optional)
auto eth0

iface eth0 inet static
address 192.168.1.10
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1

The last section is the most important, the top may or may not be the same so don’t play with it unless you get an error. In this case the IP of the server is 192.168.1.10 so if you run it as a DNS server for example, you can set that in your router’s config and not worry about it changing.

To apply this configuration type /etc/init.d/networking restart

You’ll get a message that it’s restarting the network interface, then you’ll get booted off ssh (because the IP changed) so reconnect using the new IP and it should work.

In red hat this file is /etc/sysconfig/network-scripts/ifcfg-eth0 and you would put this in it:

CODE

DEVICE=eth0
BOOTPROTO=static
ONBOOT=yes
IPADDR=192.168.1.10
NETMASK=255.255.255.0
GATEWAY=192.168.1.1

Killing spicified Uer Process Linux

Posted by Simson on April 20th, 2009

Sometimes you may encounter some user programs or script hogging your Machine performa, this may couse by Bug on the application or exploit, so we may need to do fast killing all his/her process, this can be done by folowing script, safe it on your /usr/local/bin/kill-user #!/bin/bash USER=$1 USERNAAM=`basename $0` if [ ! -n "$USER" ] then echo "Usage: $USERNAAM username" >&2 exit 1 elif ! egrep "^$USER:" /etc/passwd >/dev/null then echo "User $USER does not exist!" >&2 exit 2 fi PIDS=`ps -U$USER | grep -v PID| awk '{print $1}'` echo "Killing " `echo $PIDS | wc -w` " processes for user $USER." for PID in $PIDS do kill -9 $PID 2>&1 >/dev/null done echo "User $USER has " `ps -U$USER | grep -v PID | wc -l` " processes still running."

after that script has been saved in binary folder then the script must be executable
do this: root@www:~ # chmod 755 /usr/local/bin/kill-user

In practice: root@www:~ # kill-user jerry Killing 10 processes for user jerry. User jerry has 0 processes still running.

Installing Nagios with NagioSQL Backend Administration

Posted by Simson on April 16th, 2009

What is Nagios?,

Nagios is the most popular Opensource Network Monitoring tools, today i would like to share you the script how to install this tools on your linux Box to monitor your Network and applications: #!/bin/sh # Any Failing Command Will Cause The Script To Stop set -e # Treat Unset Variables As Errors set -u echo "***** Starting Nagios Quick-Install: " `date` echo "***** Installing pre-requisites" echo "***** Installing WGET so we could download the packages that we need" yum -y install wget echo "***** WGET has been installed" # Installing Packages For Centos echo "***** Installing very Important packages otherwise out Nagios wont work" yum -y install make make autoconf httpd php-snmp.i386 php-pear.noarch php-pear-File.noarch php-rrdtool.i386 php-xml.i386 php-mcrypt.i386 php-mysql.i386 php-ncurses.i386 php-devel.i386 php-gd.i386 php-jpgraph.noarch php-common yum -y install gcc g++ flex byacc yum -y install glibc glibc-common yum -y install gd gd-devel yum -y install perl # Adding user nagios echo "***** Setting up the environment" useradd -m nagios echo "YOUR_DESIRED_PASSWORD" |passwd --stdin nagios groupadd nagcmd usermod -a -G nagcmd nagios usermod -a -G nagcmd apache # Getting Nagios Source Tarball with Plugins echo "***** Getting the Nagios Source and Plug-Ins" cd /usr/local/src wget http://osdn.dl.sourceforge.net/sourceforge/nagios/nagios-3.0.6.tar.gz wget http://osdn.dl.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.13.tar.gz tar xzf nagios-3.0.6.tar.gz tar xzf nagios-plugins-1.4.13.tar.gz # Compiling and Nagios Installation echo "***** Installing Nagios" cd /usr/local/src/nagios-3.0.6 ./configure --with-command-group=nagcmd make all make install make install-init make install-config make install-commandmode make install-webconf # Setting up Password for Web authentification echo "***** Setting up htpasswd auth" htpasswd -nb nagiosadmin M0n1t0r > /usr/local/nagios/etc/htpasswd.users service httpd restart # Installing Nagios Plugins if fail do make clean echo "***** Setting up Nagios Plug-Ins" cd /usr/local/src/nagios-plugins-1.4.13 ./configure --with-nagios-user=nagios --with-nagios-group=nagios make make install # Seting up SELinux echo "***** Fixing SELinux" chcon -R -t httpd_sys_content_t /usr/local/nagios/sbin/ chcon -R -t httpd_sys_content_t /usr/local/nagios/share/ echo "***** Starting Nagios" chkconfig --add nagios chkconfig nagios on service nagios start service iptables stop # Installing Nagiosql3 for nagios Web administration fir we are going to backup our Current Nagios cd /usr/local tar cfv nagios.tar nagios cd /usr/local/nagios/share # Getting Nagiosql3 source tarball wget http://ovh.dl.sourceforge.net/sourceforge/nagiosql/nagiosql302.tar.gz tar xzf nagiosql302.tar.gz rm nagiosql302.tar.gz # Enabling installer touch /usr/local/nagios/share/nagiosql3/install/ENABLE_INSTALLER # Make sure to delete it after installation # Install pear install HTML_Template_IT mode pear install HTML_Template_IT # Changing Permission on NagioSQL chmod 777 /usr/local/nagios/share/nagiosql/config -R # Making necessary Folders for NagioSQL3 mkdir /usr/local/nagios/services mkdir /usr/local/nagios/hosts mkdir /usr/local/nagios/import mkdir -p /usr/local/nagios/backup/services mkdir /usr/local/nagios/backup/hosts # Setting Right Permission chmod 777 /usr/local/nagios/services -R chmod 777 /usr/local/nagios/hosts -R chmod 777 /usr/local/nagios/hosts -R chmod 777 /usr/local/nagios/backup/services -R chmod 777 /usr/local/nagios/import -R # Installing MySQL server for Database Nagiosql3 yum -y install mysql-server mysql-client service mysqld start # Settingup Root Password of MySQL mysqladmin -u root password "YOUR_DESIRED_PASSWORD" # echo "Now Go to http://`hostname`/nagios/nagiosql echo "***** Done: " `date`

feel free to comment and share if there error or problem with this scripts.


Copyright © 2007 Free Cookies for Linux & Windows. All rights reserved.