Tuesday, December 15, 2009

Citrix XenServer 5.5 command line (Storage issue)

The reality is that you can always do more from command line. Citrix XenCenter is very powerful however sometimes you are going to find issues that only can be resolved from command line.

I am going to show an example of a situation when you start to use command line.
First you have to understand that Citrix Xen defines each component with an uuid on its database. Each component on your system have an uuid
1- Host
2- VM
3- Storage
4- Pool and so on

Example:

[root@xenserver01 ~]#
[root@xenserver01 ~]# xe host-list
uuid ( RO) : d5003241-d252-4bc7-9485-2fa5838e09f3
name-label ( RW): xenserver01
name-description ( RO): Default install of XenServer

[root@xenserver01 ~]#


My problem: I took out one of the hard drive from xenserver01, I restart the server and Xencenter is showing my storage resource no available. I try to delete the SR however Xencenter is not allowing me to perform this operation. The resource stays red on my Xencenter console.

To resolve it, basically go command line and do the following:

[root@xenserver01 ~]# xe sr-list

This command will list all the SR you have on your system.

uuid ( RO) : 8311c845-beaf-b0ff-008a-2f03d256ebf5
name-label ( RW): Local Disk2
name-description ( RW):
host ( RO): xenserver01
type ( RO): lvm
content-type ( RO): user

Make sure you copy the uuid for the resource you want to work on. This case , we copy 8311c845-beaf-b0ff-008a-2f03d256ebf5 .

Then run the following command to delete it from Citrix Xen Database.

#xe sr-forget uuid= 8311c845-beaf-b0ff-008a-2f03d256ebf5

Now resource has been forgot from Citrix Xen database.

The same way you can use other commands so try :

#xe help --all

This command will show you all available command. Moreover, the xe command allows you to use TAB for auto completion .


Problems changing LDAP password from Ubuntu 9.04

You would think that the default LDAP Ubuntu configuration (client) would be able to change your password, but it is not. http://blog.carlosgomez.net/2009/10/setting-up-ldap-client-for-ubuntu-904.html

If you are a user and you want to change your password you will get this results.

#passwd
password:******
passwd: Authentication information cannot be recovered
passwd: password unchanged

The fix .....

Edit /etc/pam.d/common-passwd file. Look for use_authok and delete it. Save the file and done.

I do not know if this is a bug or not ...but I can tell you that users should be able to change password.


Wednesday, December 9, 2009

Quick tip: Deploying command on multiple servers (easy script)

When you maintain hundreds of server, A good sysadmin starts to design scripts that make his life easier. Let me show you what I do.

First make sure you have a file with a the list of server names or IPs.

#cat server.list
1.1.1.1
2.2.2.2
3.3.3.3

Second make sure you have setup ssh keys from your machine (user root) to all the machines on the list. This is the only part that can be complicated, however if you have deployed machines using a Kickstart server you can make sure that all the server on pools use the same auth keys on root directory.

Now you can create the script.

#!/bin/sh
for i in `cat $1`
do
ssh -o ConnectTimeout=10 -o BatchMode=yes $i $2;
done

Very simple right. I will call it run.sh.

Let me explain it really quick.
The script will take every line of file (IP or name) and it will ssh to that machine so it can run $2 (command).
The Option ConnectTimeout will guarantee that the ssh will try to connect for 10 seconds.
Batchmode will guarantee that no password will be asked so the ssh connection will pass.


Then you can use it ....


#./run.sh server.list "/etc/init.d/apache restart"

Very helpful to restart apache on a Web server Farm.

Let's add something else to the script.

The script performs commands sequentially meaning that it has to wait until the command finishes to continue with the next server. But if you want to perform the command at the same time in all the servers we need to add the flag -f to the ssh command.

Change

ssh -o ConnectTimeout=10 -o BatchMode=yes $i $2;

to

ssh -f -o ConnectTimeout=10 -o BatchMode=yes $i $2;

Done

Enjoy it....

Quick tip: Scanning scsi bus (Linux) to add new hard drive on VMware and Citrix Xen

Probably this is not a hot topic, however I regularly go through the trouble of adding more disk space to VMs on any of the VM environments (VMWare and Citrix Xen). You would think it should not be different however it is quite different depending on the Hypervisor or Linux flavor.

For Citrix Xen, it is very simple you only create the disk and attached to the VM and finally you can run fdisk and create partitions. It is like magic, however as soon as you add the disk you can detached until you poweroff the VM.

For VMWare, it is not that simple you can create the disk and added to the VM , however the VM is not detecting the new disk, that's because the VM requires to scan de scsi bus to detect new devices.

There are different ways to do that however that depends of the Linux OS that you are running.

For Red Hat, or Centos, you can force the scan, this blog can show you how http://misterd77.blogspot.com/2007/12/how-to-scan-scsi-bus-with-26-kernel.html

For Ubuntu , forcing the scan using the procedures for Centos does not work ...so I decided to take a look and I have found this utility that can help you http://www.garloff.de/kurt/linux/scsidev/

This rescan utility it is also valid for any type of linux OS so try it ...

Tuesday, December 8, 2009

Quick Tip: Getting DELL asset tag info from linux server

This is a pretty helpful command to get info from hardware.

#dmidecode -s system-serial-number



Wednesday, December 2, 2009

Opensource Storage Solution: FreeNAS and Openfiler

After dealing with both products, I came out with the following conclusion


FreeNAS is a great product for HOME. It can be installed in a very small machine, contains all protocols (CIFS,NFS,FTP,ISCSI) used by commercial products plus a media server and bittorrent. Basically,the FreeNAS media server allows you to stream music and video in your local network. so you can play them with any media server client (PS3,PC). It is not commercial supported.


OpenFiler is also a great product. It requires a machine with more RAM and disk space.It has all protocol used by commercial products however it lacks of media server and bittorrent.It is commercial supported. So I suggest you to go Openfiler for businesses.