Bonding configuration is ‘ specific

Posted in Linux SysAdmin on September 19th, 2007 by Johan Huysmans – Be the first to comment

I was configuring a bonding interface on one of the machines here, but i couldn’t connect to the host after a reboot or network restart.
The bond0 interface was up and running but no eth interfaces where marked as slave for that bond interface.
If I manually ran ifup eth0 the eth0 comes up and is marked as slave of bond0 and the connection to the outside can be established.
I started to debug the /etc/init.d/network script and also the ifup script. In that ifup script i noticed following lines of code:

if [ "${TYPE}" = "Bonding" ] || ethtool -i $DEVICE 2>/dev/null| grep -q "driver: bonding" ; then  for device in `LANG=C grep -l "^[[:space:]]*MASTER=${DEVICE}" /etc/sysconfig/network-scripts/ifcfg-*` ; do
    /sbin/ifup ${device##*/}
  done
fi

So it will grep for MASTER=bond0 and not for MASTER=’bond0′ (note the quotes around bond0).
When i removed the quotes from bond0 in the ifcfg-eth0 file the network started correctly.

For reference, here is my config:
ifcfg-bond0
DEVICE='bond0'
BOOTPROTO='static'
IPADDR='10.0.10.2'
NETWORK='10.0.10.0'
NETMASK='255.255.255.0'
BROADCAST='10.0.10.255'
STARTMODE='onboot'

ifcfg-eth0
DEVICE='eth0'
BOOTPROTO='none'
ONBOOT='yes'
SLAVE='yes'
MASTER=bond0

ifcfg-eth1
DEVICE='eth1'
BOOTPROTO='none'
ONBOOT='yes'
SLAVE='yes'
MASTER=bond0

Manual encrypting your shadow password

Posted in Linux SysAdmin on September 15th, 2007 by Johan Huysmans – 3 Comments

Your passwords are stored encrypted in the /etc/shadow file. This encryption is normally done by the passwd command, but for some cases you want to produce your own encrypted password for manually placing it in the shadow file.

With following perl oneliner you can produce encrypt your password:
# echo "EnterHereYourNonEncryptedPassword" | perl -nle 'print crypt($_, "\$1\$".join "", (".", "/", 0..9, "A".."Z", "a".."z")[rand 64, rand 64, rand 64, rand 64, rand 64, rand 64, rand 64, rand 64]);'
This will print an ecrypted string on the screen:
$1$UckA8UmW$Ck0rISvkyk2rDutFT4nU20

Let’s split the oneliner in different pieces so it is easier to understand. The most important perl function, which does the actual encrypting, used in the oneliner is:
crypt("password", "salt");
The “salt” is a random string starting with $1$. Following join will produce such 8 charachters long random string:
join "", (".", "/", 0..9, "A".."Z", "a".."z")[rand 64, rand 64, rand 64, rand 64, rand 64, rand 64, rand 64, rand 64];

More information about the crypt function can be found here: http://perldoc.perl.org/functions/crypt.html.
As you can notice the join is also listed on that page ;)

Managing user passwords with Puppet on CentOs

Posted in puppet on September 10th, 2007 by Johan Huysmans – 5 Comments

If you try to manage users and there passwords with puppet on CentOs you will receive the error explained by “Known issues” on following page: Puppet on RedHat/CentOS. That page also describes the solution: install the libshadow package on the client.
It is not that easy because there is not yet an rpm of the ruby shadow libraries for CentOs.

“Not yet” because there IS a ruby-shadow rpm available in fedora (see: https://bugzilla.redhat.com/show_bug.cgi?id=240008).

So we only need to download and rebuild it:
wget http://download.fedora.redhat.com/pub/fedora/linux/extras/6/SRPMS/ruby-shadow-1.4.1-6.fc6.src.rpm
rpmbuild --rebuild ruby-shadow-1.4.1-6.fc6.src.rpm

Once we have that rebuilded rpm we can install it on all our puppet-clients. Off course we are not going to do this manually but use puppet for it :) .
If you have a local repository you can just add the package, but this is not yet the case for my setup so we need some extra rules.
Here is a snippet of puppet manifest:

class ruby-shadow {
   package {
      "ruby-shadow":
         ensure   => installed,
         provider => rpm,
         source   => "/tmp/ruby-shadow-1.4.1-6.i386.rpm",
         require  => file["/tmp/ruby-shadow-1.4.1-6.i386.rpm"],
   }

   file {
      "/tmp/ruby-shadow-1.4.1-6.i386.rpm":
         source => "puppet://puppetmaster/files/ALL/tmp/ruby-shadow-1.4.1-6.i386.rpm"
   }
}

class users {
   include ruby-shadow
   user {
      "root":
         ensure   => present,
         name     => "root",
         password => "SomeAlreadyEncryptedPassword";
   }
}

With this code it will require 2 runs of the puppet client. Even if you add a require in the user section for the ruby-shadow package 2 runs are necessary. Don’t know if this is a bug or a feature…

New domain name

Posted in General on August 24th, 2007 by Johan Huysmans – Be the first to comment

My personal domain name raskas.be has just been activated!

This means that all my websites are move to http://www.raskas.be.
The specific url for my blog is: http://www.raskas.be/blog
The RSS of my blog is now: feed:http://www.raskas.be/blog/feed/

Please update all your bookmarks and rss feed readers to point to the correct url!

With some mod_rewrite magic you can still browse to the old url but you will be automatically redirected to my new domain name.

RewriteEngine on
RewriteRule ^(.*)$ http://www.raskas.be/$1

On http://www.ilovejackdaniels.com/apache/mod_rewrite-cheat-sheet/ i found some nice cheat sheet about apache’s mod_rewrite.

Updated full backup script

Posted in Backup on August 19th, 2007 by Johan Huysmans – Be the first to comment

This week I updated the full backup page. We jumped from version 0.4 to 0.8.
Thanks to my colleagues: Raf, Fred and Jos the script is updated to meet our requirements.

Here are some of the major features added to the newest version:

  • You can choose if you want to keep a history (= full weekly backups and daily incrementals) or only 1 backup.
  • All information will be written to a logfile which can be mailed to some addresses when the script is done (previously this was done by an extra command in the cron).
  • After the backup we will check the size of the local data and the size of the backup, printed to the logfile.
  • We will check the free space on the backupdisk and print it to the logfile.

The behavior of the script can be configured with the variables at the top of the script.

Heartbeat error: Cannot write to media pipe 0

Posted in Linux SysAdmin on July 17th, 2007 by Johan Huysmans – Be the first to comment

Today I tested a heartbeat setup. Everything went fine until…

I performed a reboot of one of the hosts. The host came back and started to communicate with the other heartbeat. At that moment heartbeat started to generate ERROR messages. The load of heartbeat and the load of syslog increased because of the amount of error messages and my /var/log/messages file grew quite a bit.

When the problem started heartbeat was printing lots of information in the log files, but after some time only this messages appeared in the logs.


Jul 17 16:27:33 heartbeat: [2893]: ERROR: Cannot write to media pipe 0: Resource temporarily unavailable
Jul 17 16:27:33 heartbeat: [2893]: ERROR: Shutting down.
Jul 17 16:27:33 heartbeat: [2893]: ERROR: Message hist queue is filling up (200 messages in queue)

20 minutes after the first occurrence of this message the master heartbeat process killed itself. During this time it generated over 30000 times the above error.

The guys of #linux-ha helped me with this error and explained that it is caused by the serial link. The messages sent over the cable didn’t arrive in time.
The fix for it is easy, increase the baud in your ha config file.

My baud was first configured at 9600 and increasing it to 19200 fixed this error.

Hackergotchi

Posted in General on July 2nd, 2007 by Johan Huysmans – Be the first to comment

I recently learned a new word ;)

Hackergotchi

A hackergotchi is a picture of a writer used as an avatar to identify the author of a given RSS feed in blog aggregators.

http://en.wikipedia.org/wiki/Hackergotchi

You can see the Hackergotchi of each X-Tend blogger, including mine, on http://planet.x-tend.be

Create GPX files with your TomTom (2)

Posted in TomTom on June 28th, 2007 by Johan Huysmans – 3 Comments

An other application for the TomTom devices is nmealogger. This logger will log all the data received from the gps device into a file. This data includes the actual position, the current date and time, the amount and reception of the satellites, …
The format of information which is generated by a gps device is mostly in the NMEA format, it is also stored in a file in that format. The information of these files can be converted to any other format by gpsbabel.

The zip file you can download from the site contains a .cab file and a .toc file. The files are provided in that format because it can be installed from the TomTom HOME application.
That TomTom application isn’t working on linux therefore you must install it manually.
The .cab file is the only file we need. It is an archive file containing all files which need to be stored on the cf of the TomTom device. These files need to be extracted and the directory structure has to be intact.

[johan@raskas ~]$ file nmealogger_v1.4.cab
nmealogger_v1.4.cab: Microsoft Cabinet archive data, 686973 bytes, 16 files
[johan@raskas ~]$ cabextract nmealogger_v1.4.cab
Extracting cabinet: nmealogger_v1.4.cab
extracting nmealogger/nmealogger
extracting skin/Arial.ttf
...
extracting skin/tomtom.bmp
extracting sdkregistry/nmealogger.bmp
extracting sdkregistry/nmealogger.cap

Once you’re device is booted with the nmealogger files installed you will find a new menu entry. There you can start / stop the logging.

Create GPX files with your TomTom

Posted in TomTom on June 5th, 2007 by Johan Huysmans – 2 Comments

I wanted to turn my TomTom One GPS device into a tracking device, producing gpx files that can be used in several programs.

The TomTom software delivered with the device isn’t capable of producing these files, luckely it is possible to add software.

In my first TomTom blog post I mentioned Event Logger. This is such software you can install on top of your tomtom device, while still using your navigation sofware like before.
The Event Logger software is capable of syncing your time with the gps-satellites, automatically switching between day and night colors, logging events, logging tracks, …
The packages also includes a build of top which proves that the device is really running Linux.

The functionality of Event Logger can be tuned in a configuration file. Some basic actions, like enabling or disabling of features, can be triggered from a button within the graphical menu on your device.

The downside of this extra program on your navigation device is that it takes longer to boot and shutdown.
Recently I noticed that when the device is powered off it automatically reboots. Still haven’t found why it is rebooting, I hope I find the problem or it gets fixed in the next release.

Beryl and Java apps

Posted in Fedora, Xen on May 28th, 2007 by Johan Huysmans – 1 Comment

While using Beryl as my default window manager, I noticed that some java applications didn’t work correctly, for example the XenServer Client.
The application started correctly but I only saw a gray screen.
Whenever my Metacity window manager (that’s the one of gnome) was active, instead of Beryl, the application works as it was meant to be.

This problem is explained in the beryl wiki.
The solution is also mentioned there.

Because I’m using java 5 (1.5.0u11 from Sun) the fix is very simple.
I added following line at the end of /etc/bashrc.

export AWT_TOOLKIT=MToolkit

After restarting the X server the java applications works without any problems.