Thursday, December 15, 2011

XenServer - Cannot Shut VM

Have you ever experienced  a situation where you could not shut one of your running XenServer running VM's?   In this brief article I'll present a workaround for this common problem...  From my personal experiences this problem is often caused when the domain of the specific VM is still active (this often happens as a result of inproper shutdown and/or storage cutoffs) - in such case the domain needs to be destroyed manually.  OK, so here's the problem - from the XenServer (v 5.6 SP1) dom0 CLI I'm trying to shut a VM (using the force option): #xe vm-reset-powerstate vm=xxxxxxx force=true
 
However the output I get is:  The operation could not be performed because a domain still exists for the specified VM.
vm: f087dxxxxx (xxxxxx)
domid: 5
  From the output we will need  two parameters :the domain id (5 in our case) and the UUID of the problematic VM , so write them down somewhere. Now we need to destroy the currently active domain, XenServer includes couple of good tools under /opt/xensource, the command that is relevant is:   #/opt/xensource/debug/destroy_domain -domid 5  Now, finally, we will be able shut the VM with:  #xe vm-reboot uuid=XXXX --force  And we're done.  Hope that helped some one out there. Cheers!

Wednesday, December 7, 2011

Perl SSH Log-in

Hi Folks, 

In the following post I will demonstrate a password-less login into Cisco appliance via the SSH protocol using a Perl script.

When combined with cron, it can be a great solution for saving your appliance configuration (show run) or checking status without the need to log-in into the appliance each time.



Pre requirements:
  • Perl
  • SSH client (duh!)
  • Net-SSH-Perl module

On Red-Hat (and friends) the module can be obtained via:
#yum install perl-Net-SSH-Perl -y 

Be sure to have a proper repository installed such as rpmforge 
 
Our simple script connects to the Cisco appliance via SSH and runs "show run" command (this account has enabled privilege).
The script itself should look like this:

#!/usr/bin/perl -w
use strict;
use warnings;
use Net::SSH::Perl;
my $ssh = Net::SSH::Perl->new('hostname');
$ssh->login('username', 'password');
my($out) = $ssh->cmd("show run");
print $out;

Since the script contains your appliance username & password don't forget to remove permissions for others:
#chmod o-rwx script.pl

Now, let's run the script:
#./script.pl

Output:
Building configuration...

Current configuration : 8011 bytes
...more output ommited...


Works like charm!
Now, the only thing is left is to synchronize it with cron :)

Enjoy.

Sunday, November 27, 2011

Howto configure LDAP with TLS

Configuring LDAP over TLS is a crucial step in order to achieve a secure directory based authentication.
In the following tutorial I'll demonstrate how to configure OpenLDAP with TLS.

For the demonstration both server & client I've used are CentOS 5.5 x86_64
My LDAP server is OpenLDAP v2.3.43

Let's get started.

Step1 - Generating and Signing Certificates:

First of all we need to generate and sign the OpenLDAP server certificates.
In this scenario we will both generate and sign our certificate (self signed), this solution is good for internal and usually small environments.
If you ever plan to use this in a big enterprise production environment you will need a proper CA, like Verisign or Terrena to sign the certificates.

Before continuing please make sure the open SSL package is installed.


Generate your private key and a certificate request form:

#cd /etc/openldap/cacerts
#openssl req -nodes -newkey rsa:2048 -keyout server.key -out server.csr  Sign the certificate with:
#openssl x509 -in server.csr -out server.crt -req -signkey server.key -days 3650
 
Now you got both private and public keys.

After the certificates have been generated, assign the correct permissions and ownerships:

#chown ldap server.*
#chmod 0400 server.key
#chmod 0644 server.crt

Step2 - Server Side:

The following two lines need to be added in your server configuration file
(/etc/openldap/slapd.conf):



TLSCertificateFile      /etc/openldap/cacerts/server.crt
TLSCertificateKeyFile   /etc/openldap/cacerts/server.key
 
Restart the LDAP server:
#/etc/init.d/ldap restart 

Step3 - Client Side:

Make sure the ssl parameter in your LDAP client configuration file (/etc/ldap.conf) looks like this:

ssl start_tls

Also, make sure /etc/openldap/ldap.conf includes the following parameters:

TLS_CACERTDIR /etc/openldap/cacerts
TLS_REQCERT allow



That's it, from this point your OpenLDAP is ready to be used over TLS.
Stay secure ;)



Monday, September 26, 2011

XenServer Backup Script

This handy bash script I wrote, enables Xen Server Administrators to create On-Line backups (Importing the VM into.xva file) while the backed up virtual machine is up and running.

I found this extremely useful for big production environments - where lots of VM's require an appropriate & efficient back-up solution and downtime is not an option.

The script is very simple and user friendly, it's executed as root from the dom0 machine and used as follows:
In order to list all the available VM's on the system:
#./xen_onlinebackup.sh -l

In order to back up a VM:
#./xen_onlinebackup.sh -p /path/to/backupdir -s vm-name

The script supports both interactive and unattended mode (-u flag), the later designed to be built into scripts as an automation solution for large production environments.

For any help/usage, just run:
#./xen_onlinebackup.sh -h

Tested succesefully on XenServer 5.6 FP1 & XenServer 5.6 SP2.
Any comments, feed-backs or suggestions for improvements are very welcomed.


 #!/bin/bash
#
#This script used to create XenServer VM's online backup #Importing the VM into .xva file #Written by Paul Podolny - July 2011

#Variables
COUNT=0
AUTO=0 #Used for unattended mode
VMLIST=`xe vm-list is-control-domain=false |grep -i name-label|awk -F": " '{print $2}'`

#Functions
list() {
echo "====================================="
echo "Listing available VM's on $HOSTNAME..."
echo "====================================="
for i in $VMLIST;do
      echo $i;let COUNT+=1
done
echo "================================="
echo "Total $COUNT Virtual Machines"
echo "================================="
exit 0
}

usage() {
cat << EOF
This script will backup your Xen VMs on-line:
------
Usage:
------
-h Help/Usage.
-l List VM's.
-u Run in unattended mode (No questions asked).
-s Server Name (Backed Up VM).
-p Path to backup.

--------
Example:
--------
$0 -s server01 -p /nfs/backupdir/ -u
EOF
exit 0
}
check_dir() {
echo "=============================================================="
echo "XenServer Online Backup"
echo "=============================================================="
if  [ -e ${BACKUPPATH}/${VMNAME} ];then
        echo "Directory ${VMNAME} on path ${BACKUPPATH} seem to exist, will use it."

else
      echo "Creating dir. ${VMNAME} on backup path: ${BACKUPPATH}"
      mkdir ${BACKUPPATH}/${VMNAME}
fi

echo "`date +%H:%M` Backing Up ${VMNAME}, please hold on...Do NOT interrupt with CTRL+C !!!"
echo "================================================="
}


################################
#MAIN Prog
################################
while getopts "s:p:lhu" flag ; do
        case $flag in
                l ) list;;
                s ) VMNAME=$OPTARG;;
                p)  BACKUPPATH=$OPTARG;;
                h ) usage;;
                u)  AUTO=1;;
                *)  usage;;
        esac
done

#Sanity check  - Make sure backup path + VM name specificed if [ -z ${VMNAME} ] || [ -z ${BACKUPPATH} ];then echo  "Error:Both backup path AND VM name must be specified, exiting..."
echo  "Use $0 -h  for help"
exit 1
fi

#If running in interactive mode
if [ ${AUTO} != "1" ];then
      echo "Going to back-up ${VMNAME} to ${BACKUPPATH} ,is this OK? [y/n]"
      read ANSWER
      if [ ${ANSWER} != "y" ] && [ ${ANSWER} != "Y" ];then
            echo "Exiting by users request..."
            exit 1
      fi
fi
      #else proceed with main program...
      else
            check_dir
            TEMPUUID=$(xe vm-snapshot vm=$VMNAME new-name-label=snap_tmp_`date +%F`)
            xe template-param-set is-a-template=false ha-always-run=false uuid=$TEMPUUID
            xe vm-export vm=${TEMPUUID} filename=${BACKUPPATH}/${VMNAME}/${VMNAME}_backup_`date +%F`.xva
            echo "Removing Temporary Snapshot....(DO NOT PANIC!)"
            xe vm-uninstall uuid=${TEMPUUID} force=true
            echo "==============================================================="
            echo "### Back Up of ${VMNAME} Completed!###"
            echo  "`date +%H:%M`"

#END OF SCRIPT

Thursday, September 22, 2011

Adding Users in OpenLDAP

In this quick tutorial I will show how to add users to your directory.
I will be using two CentOS 5.5 x64 hosts for this presentation:
  • server - will be my test OpenLDAP server.
  • test - will be my test client host.
Before we begin I will assume OpenLDAP is already correctly installed on your system  (you can refer to this procedure, to learn more about primary OpenLDAP installation & configuration).

In this example my root dn is:"dc=example,dc=org"
And my admin user on the LDAP server is "cn=Manager,dc=example,dc=org"

OK, let's get our hands dirty:

Server side:
First, check that LDAP server is installed and running:
root@server# rpm -qa|grep -i ldap
openldap-2.3.43-12.el5_6.7
openldap-clients-2.3.43-12.el5_6.7
nss_ldap-253-25.el5
openldap-servers-2.3.43-12.el5_6.7
php-ldap-5.1.6-27.el5
nss_ldap-253-25.el5
openldap-2.3.43-12.el5_6.7
root@server# lsof -i :389
COMMAND   PID USER   FD   TYPE  DEVICE SIZE NODE NAME
slapd   20221 ldap    7u  IPv6 4349285       TCP *:ldap (LISTEN)
slapd   20221 ldap    8u  IPv4 4349286       TCP *:ldap (LISTEN)

Next, we will add a user and change it's password:
root@server# useradd -g ldap-users john
root@server# passwd john

Now, we will copy user's "john" data from /etc/passwd and use one of the migration scripts OpenLDAP provides in order to create an appropriate "ldif" file:

root@server# grep john /etc/passwd > /etc/openldap/passwd.john
root@server# /usr/share/openldap/migration/migrate_passwd.pl /etc/openldap/passwd.john /etc/openldap/passwd.john.ldif

We will add the newly created "ldif" file into our LDAP DB:

root@server# ldapadd -x -D "cn=Manager,dc=example,dc=org" -W -f  /etc/openldap/passwd.john.ldif

Enter LDAP Password:  
adding new entry "uid=john,ou=People,dc=example,dc=org"

Let's try to search for john user in the LDAP DB:

root@server# ldapsearch -x -LLL '(uid=john)'
dn: uid=john,ou=People,dc=example,dc=org
uid: john
cn: john
objectClass: account
objectClass: posixAccount
objectClass: top
objectClass: shadowAccount
userPassword:: e2NyeXB0fSEh
shadowLastChange: 15239
shadowMin: 0
shadowMax: 99999
shadowWarning: 7
loginShell: /bin/bash
uidNumber: 500
gidNumber: 500
homeDirectory: /home/john

Seems to be working, now let's switch to the client.


Client side:
Check that your client is configured with the LDAP server:
Add the server and the domain inside: /etc/ldap/ldap.conf

uri ldap://server.example.org/
base dc=example,dc=org

Edit /etc/nsswitch.conf for LDAP authentication:

passwd: files ldap
shadow: files ldap
group: files ldap

It's time to test our configuration from the client side:
First check that john isn't listed in your /etc/passwd local  file:

root@test# grep john /etc/passwd
root@test#

As we can see, no john here.
Now try to "id" john:

root@test# id john
uid=500(john) gid=500 groups=500

Just as we wanted.

Monday, September 12, 2011

Import/Export MySQL Databases

Well to be honest, this is quite trivial but useful nevertheless so I will get straight to the point:


In order to export a DB into a file:
#mysqldump -u username -p{password} database_name > dbfile.sql
   
In a scenario where multiple DB's need a backup solution
A simple script like this can be implemented:

#!/bin/bash
for i in `mysql -e "show databases;" |egrep -v '^Database$'`; do
#dump and backup to remote server
mysqldump -Q |gzip -cf >/backupdir/db_${i}-`date + %F`.sql.gz
rsync -avz -e ssh /backupdir/. server:/remote_dir/. 
done


To import an exported DB from a file:

# mysql -u username -p db_name < dbfile.sql 


Sunday, August 28, 2011

Puppet - Quick Tutorial

Puppet is an Open Source configuration management framework (somewhat similar to Cfengine) written in Ruby.
It provides a declarative language syntax and an abstraction layer that allow you to write configuration definitions that can be propogated across large scale computing environment - making it a critical tool for midsize-large computing sites.

In the following tutorial I will explain how to configure both client & server side, so let's start:

I will use 2 CentOS v5.5 x64 machines for this tutorial.

Server Side (hostname=test1):
1)Install RPMforge repository:

 #rpm -Uvh http://apt.sw.be/redhat/el5/en/x86_64/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm

2)Install the needed packages:
#yum -y puppet-server ruby ruby-rdoc

3)Configure server behaviour side:
#vi /etc/sysconfig/puppetmaster

...un-comment the following lines:
PUPPETMASTER_MANIFEST=/etc/puppet/manifests/site.pp
PUPPETMASTER_LOG=syslog

4)Configure site manifests;

We first tell puppet to import all the configuration under classes directory.
Next we tell Puppet that test2 will be our client upon which we want to use the 'test'  function:

#vi /etc/puppet/manifests/site.pp
import "classes/*" 


node "test2.domain.com" {
    include test
}


Here we will define the 'test' function:
The configuration is pretty straighforward, we declare a file on which the owner and the group will be root, also the permission will be 440, so if permissions are modified , after puppet daemon is run it will be back to it's origin - aka 440:

#vi /etc/puppet/manifests/classes/test.pp
class test {
    file { "/tmp/puppet-test":
        owner => root,
        group => root,
        mode  => 440
    }
}

5)Restart the server and check the configuration:
#/etc/init.d/puppetmaster restart
#puppetmaster --debug

Client Side (hostname=test2):

1)Install RPMforge repository:
#rpm -Uvh http://apt.sw.be/redhat/el5/en/x86_64/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm

2)Install the needed packages:
#yum install -y puppet ruby ruby-rdoc 

3)Configure client behavior side:
#vi /etc/sysconfig/puppet 
PUPPET_SERVER=test1.domain.com
PUPPET_LOG=/var/log/puppet/puppet.log


#vi /etc/puppet/puppet.conf

Under the[puppetd]section add the server name:
server = test1.domain.com


4)Restart the client and and check for any errors (-t flag is used for test):
#/etc/init.d/puppet restart
#puppetd -t

If no errors are found try to create the file with different permissions than 440 ,like:
#touch /tmp/puppet-test;chmod 777/tmp/puppet-test

Now run the Puppet client...
#puppetd --server test1.domain.com

You should see the following output:
notice: Starting Puppet client version 0.23.2
info: Facts have changed; recompiling
info: Caching configuration at /var/lib/puppet/localconfig.yaml
notice: Starting configuration run
notice: //test2.domain.com/test/File[/tmp/puppet-test]/mode: mode changed '644' to '440'
notice: Finished configuration run in 0.02 seconds


Check the permissions again:
#ls -ld /tmp/puppet-test
-r--r----- 1 root root 0 Aug 28 14:19 /tmp/puppet-test


...and it worked, the file is back to it's pre-configured status on Puppet master, just as we wanted.
This is just the very beginning, I will leave you to explore further by yourself.

Cheers!

Wednesday, July 20, 2011

Howto:Reduce LVM Root Partition

In this short tutorial I'll demonstrate how to reduce the size of LVM (/dev/VolGroup00/LogVol00) mounted on "/" (aka root partition).
Since the procedure cannot be done on the run (you will need to unmount the root partition...) , you will have to boot your machine either with some sort of Linux LiveCD or either with the original CentOS DVD/ISO which offers special rescue mode.

I didn't have a LiveCD so I used the original CentOS DVD for this task.

Boot the machine with a CentOS DVD/ISO (v 5.5 in my case) and enter the rescue mode by typing:
#linux rescue

CentOS will boot in rescue mode when a menu pops up and asks you if you want to mount your old partitions, chose "SKIP" (otherwise your original disk partitions will be mounted under /mnt/sysimage - in that case umount it before proceeding).

After you made sure your original disk partitions are not mounted you will have to activate the LVM in Rescue Mode:
# lvm vgchange -a y

Check the LVM for any filesystem errors, this is crucial for next step:
# e2fsck -f /dev/VolGroup00/LogVol00

It's time to resize the filesystem to a new size ,note that you should leave enough space for current data on the root partition or you will suffer a data loss.
In our case we are reducing the partition to a new size of 20GB.
Note that the procedure may take some time (depending on your root partition size, so do not panic!):
# resize2fs -f /dev/VolGroup00/LogVol00 20G

Finally, resize the LVM to the new size (20 GB):
#lvm lvreduce -L20G /dev/VolGroup00/LogVol00

You should boot your OS into regular mode and cross your fingers ...

Disclaimer: Do at your own risk, I'm not responsible for any data loss which may be caused to your system.

Tuesday, July 12, 2011

Enable SNMP on Cisco Devices (part 1)

In this short tutorial I'll demonstrate how to quickly configure SNMP on your Cisco appliance and test it's working.


There will be another tutorial dealing with how to configure the SNMP manager side.


1) Let's start by logging in to your Cisco appliance (In my case I used 851 series Cisco router with IOS version 12.3).

2) Enter configuration mode:
cisco851#configure terminal

3) Set your community string and the mode (read only, read write):
cisco851(config)#snmp-server community myComunity1 RW

4) Point the appliance to the SNMP manager (in our case 192.168.2.4) , with the same community string you've set before: 

 cisco851(config)#snmp-server host 192.168.2.4 version 2c myComunity1


5) Enable the trap types you wish to monitor, for example:

cisco851(config)#snmp-server enable traps snmp linkdown linkup coldstart warmstart

6) Save the configuration:
cisco851(config)#do wr

At this point the basic configuration on the Cisco appliance is done, let's see if we able to querry the appliance from our server.

I have used Ubuntu 11.04 x64 box with "snmp" package installed.

Check it's indeed installed with:
root@ubuntu:~#dpkg --list |grep snmp
If not get it with:
root@ubuntu:~#apt-get install snmp

After snmp package has been succefully installed it's time test the configuration.

Issue the following command and see if you're able to retrieve the SNMPv1 agent  or our Cisco appliance (192.168.2.1) MIB tree list :

root@ubuntu:~#snmpwalk -v 1 -c myComunity1 192.168.2.1

At this point you should be able to list the entire tree (output was ommited), means Cisco side is configured successfully.

You can now get the desired info for monitoring purposes, like the system uptime:

root@ubuntu:~#snmpget -v 1 -c myComunity1 192.168.2.1 iso.org.dod.internet.mgmt.mib-2.system.sysUpTime.0


DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (490514418) 56 days, 18:32:24.18
 
Or our appiance hostname:

root@ubuntu:~#snmpget -v 1 -c myComunity1 192.168.2.1 iso.org.dod.internet.mgmt.mib-2.system.sysName.0


SNMPv2-MIB::sysName.0 = STRING: gw1.slsphr.net.il
 
Mission accomplished.
 
In the next SNMP article I will touch the server side configuration.
 
Cheers.

Tuesday, June 7, 2011

Installing and configuring fail2ban

If you're running a server that's exposed to the internet you will sooner or later realize while checking the server security logs that you're constantly being attacked, it can be via multiple ftp,ssh,http break-in attempts (brute force attacks),(D)DoS attacks and many other nasty stuff, what's for sure - this is not something that can be neglected.

A great solution for such scenario is an open source, Python-based application called "Fail2ban".

Fail2ban is capable of working with multiple log filesand multiple services.
The flexibility and integration with iptables is a major benefit of fail2ban - so the IP filtering is performed at the kernel-level.

Instalaltion pre-requirements:
1)python
2)logrotate
3)iptables

Basically ,all of these should already be installed on your system (default install).

Installation process (I used a CentOS box for this example):

1)Install the application using Yum
#yum install fail2ban -y

2)Edit fail2ban configuration file called "jail.conf"
#vi /etc/fail2ban/jail.conf

3)Under the[DEFAULT] section we can find global configuration such as - friendly hosts, ban time, search time etc, lets adjust these parameters to meet our needs.

Here we will allow localhost, host1@friendly.com and 192.168.1.0/24 subnet  to be ignored by fail2ban:

ignoreip = 127.0.0.1, host1@friendly.com, 192.168.1.0/24

If the host is violating the rules it will be banned to this amount of time (in seconds):

bantime  = 1209600

A host is banned if it has generated "maxretry" during the last "findtime"

findtime  = 1800

The number of failures before a host get banned.
maxretry = 3


4)Let's say we want  to enable fail2ban scan on ssh log-in attempts.
Scroll to section "[ssh-iptables]" and enable it:

enabled = true

Next,change the the SSH logfile we want to scan:

logfile = /var/log/secure

Adjust the max failures the system will allow:

maxretry = 3

Comment out the "sendmail-whois" section and change it to your mail, so you will receive mail alerts when fail2ban has banned some IP.

sendmail-whois[name=SSH, dest=admin@somedomain.org, sender=fail2ban]

5) That's it, save the file and restart fail2ban and iptables.
#/etc/init.d/iptables restart 
#/etc/init.d/fail2ban restart
 
#chkconfig iptables on
#chkconfig failban on

Don't forget to check that email works, and you are done.

Monday, May 2, 2011

Howto remove old NAT configuration from Cisco router

Recently I came upon a situation where my ISP has assigned me a static IP - instead of L2TP dialer (Virtual PPP Interface in Cisco) I was using before ...
Anyway, I started to remove old and irrelevant NAT settings that were associated with my old dialer ,but when I've tried to configure the new NAT settings I got an error:
%Dynamic mapping in use, cannot change

After scratching my head for awhile I found the solution.

To remove old NAT settings on Cisco router you need to 

1)Clear all old NAT translations
router#clear ip nat translatiom *

2)Disable old NAT pool settings
router(config)#no ip nat pool public_access 200.100.10.33 netmask 255.255.255.252

3)And finally, disable the translation:
router(config)#no ip nat inside source list 1 pool public_access overload

From this point you can safely configure the new NAT settings.
Cheers.

Tuesday, April 26, 2011

Howto configure Apache with SSL (CentOS):

Configuring Apache server with SSL is an easy task when you know what you're doing ;) 
I decided to make one easy-to-understand quick tutorial that will serve as a memory refresher, In my case I used CentOS 5.5 x64.

So...here we go:

1.Make sure Apache is installed:
#rpm -qa|grep httpd

if no, install it:
#yum install httpd

2.Install mod_ssl module for Apache 2 to enable SSL support:
#yum install mod_ssl

3.Generate the certificate request and send the request (contents of server.csr) to your CA (such as Verisign for example):
#openssl req -nodes -newkey rsa:2048 -keyout myserver.key\
-out server.csr

Grant read permissions only to root on your private key:
#chmod 0400 myserver.key

4. After receiving the public key + bundle from your CA, unzip and put them in the same directory as your private key, in my case I used "/etc/ssl/crt":
#mv myserver.key /etc/ssl/crt/
#mv my_server_org_il* /etc/ssl/crt

There is a neat way to check if public key mathes private key, go to the directory with your certificates and execute the following commands:
For public key:
# openssl x509 -noout -modulus -in hostcert.pem | openssl sha1
4e9d47dec86984789b15db10d204faa5e7aa7777
For private key:
# openssl rsa -noout -modulus -in hostkey.pem | openssl sha1
4e9d47dec86984789b15db10d204faa5e7aa7777

As you can see the output is the same - means we're good to go.


5.Before making any change, backup both configuration files:
#cp /etc/httpd/conf.d/ssl.conf /etc/httpd/conf.d/ssl.conf.bak
#cp /etc/httpd/conf/http.conf /etc/httpd/conf/http.conf.bak

Edit ssl.conf:

#vi /etc/httpd/conf.d/ssl.conf

Now, it's up to you to decide whether you will be using VirtualHost block or not (http://httpd.apache.org/docs/trunk/mod/core.html#virtualhost), anyway the configuration should include the following lines:
 
ServerAdmin root@localhost
DocumentRoot /var/www/html/support
ServerName support.mydoimain.com
ErrorLog logs/support_mydoimain_com-error_log
CustomLog logs/support_mydoimain_com-access_log common
SSLEngine on
SSLCertificateFile /etc/ssl/crt/support_mydoimain_com.crt
SSLCertificateKeyFile /etc/ssl/crt/myserver.key
SSLCACertificateFile /etc/ssl/crt/support_mydoimain_com.ca-bundle


6. For proper URL redirection  - you can use this line to redirect all incoming http traffic to your https server, add it to: httpd.conf

RedirectPermanent / https://support.mydomain.com/


7. Restart httpd service:
#/etc/init.d/httpd restart

Make sure Listen 443 line is located in ssl.conf
Make sure Listen 80 line is located in httpd.conf

To check the web-server is listening on both ports run:
#lsof -i :80
#lsof -i :443

Basic configuration is done, try to access the server from the browser:
http://support.mydomain.com

Thursday, April 14, 2011

Howto Connect NetApp iSCSI to XenServer 5.6 FP1


Since iSCSI is a great choice as a SR for your XenServer, in terms of performance and scalability, I've decided to created a straight forward and easy to understand guide of how to connect NetApp iSCSI based storage to XenServer, read on...
On the NetApp side:
1) Enable iSCSI service on the filer:











2) Create the desired LUN:
·        










3) Dedicate a separate NIC for iSCSI traffic, be sure the filer iSCSI dedicated NIC is assigned with a proper IP address:

·        









4)From the XenServer copy it's iscsi FQN:














5)Add the new initiator:













6)Map the new LUN to the new initiator:














On the XenServer side:
1)      Be sure you have a NIC assigned to iSCSI traffic.


2)      Right click on the XenServer -> New storage-> Software iSCSI












Click on Discover IQNs, it should find the NetApp IQN.
Next, click on Discover LUN's, it should find the available LUN's.

Click "Finish" to attach the SR.

Your newly created LUN should be successfully attached to XenServer at this point.


Wednesday, April 6, 2011

Howto rescan NICs on XenServer

1. First list the physical NIC's:
#xe pif-list

2. After making a note of the information, run the following command for each one of the new NIC's that appear as disconnected:
#xe pif-forget uuid=UUID


3. Next, have the system scan for the correct uuids, you will need the uuid of your server (find it with "xe host-list" ):
#xe pif-scan host-uuid=UUID

4. List the NICs again to see what we have found:
#xe pif-list

5. You should see the correct UUID's of your NICs. 
Then, run the following command for each one of the new NIC's to add them back:
#xe pif-plug UUID

At this point your new NICs should appear as connected.

Sunday, April 3, 2011

Howto Backup VM's in XenServer

I found this technique to be the easiest and most efficient, importing the whole virtual machine to *xva file. Though it's not the quickest method it worked flawlessly for me.

1. At XenServer console as root, mount some SR (CIFS or NFS) to a folder:
#mount -t cifs //myfiler01/ntfs_share /backup/

2. Check the mount:
#mount |grep backup

3. To find the VM you want to export Run:
#xe vm-list


4. Run the export VM command:
#xe vm-export vm=centos5 filename=/backup/centos5_backup.xva

That's it, the VM exported as *.xva file which is easy to import in case of failure. 

In case you want to import the VM, run:

#xe vm-import vm=centos5 filename=/backup/centos5_backup.xva