Linux SysAdmin

Apt-rpm dependency problem

Posted in Linux SysAdmin on August 12th, 2009 by Johan Huysmans – Be the first to comment

When installing some rpm’s on a CentOS5 system I encountered a dependency problem.

Apt told me that it depends on a specific file which isn’t provided by any package in the repository. After some investigation I noticed that the rpm WAS available in the repository, and that yum correctly found that package.

The problem was that the specific file needed by the package was a symlink provided by the other package. The symlink file is known by the rpm (rpm -ql /path/to/file gives the rpm) but isn’t know by apt.

Instead of running genbasedir with the location of the repository as only argument, add the –bloat argument.

genbasedir --bloat /path/to/repository

This will solve the problem!


I noticed this problem during the installation of redhat-lsb on a very minimal CentOS5 system. redhat-lsb requires 2 files (which are symlinks), these files are provided by… redhat-lsb itselve…

If you didn’t use the –bloat argument the redhat-lsb package couldn’t be installed with apt, it could be installed with yum or rpm.

syslog-ng bug

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

Today I stumpled upon a syslog-ng bug.

We are using syslog-ng-2.1.3 on one of our machines which sends part of his messages over UDP to 2 syslog machines. On some days we noticed that syslog-ng and some other services are stopped. Restarting syslog-ng showed us that they were killed by the OOM-killer.
I directly suspected the java process that was also running on that machine.

After googling around I found this syslog-ng bug: https://bugzilla.balabit.com/show_bug.cgi?id=39

And indeed, we had the same problem. This is how I could reproduce it:

  • Stop the syslog service (on the host which receives the messages)
  • Restart syslog-ng
  • Watch the memory usage of syslog-ng growing until it starts swapping and triggers the OOM-killer

Luckily this bug is already solved, and by upgrading to syslog-ng-2.1.4 the problem is fixed.

CentOS doesn’t provide the rpm packages of syslog-ng, silfreed.net does: http://www.silfreed.net/download/repo/

Input/Output redirection, appending

Posted in Linux SysAdmin on August 15th, 2008 by Johan Huysmans – Be the first to comment

In a previous post I wrote about output redirection of STDOUT, STDERR and both to a file. Off course you can do the same to append to an existing file:

ls >> output.txt
ls 2>> error.txt

If you try this with &>> you will receive a bash syntax error:

ls &>> output_and_error.txt
bash: syntax error near unexpected token `>'

How come appending of both STDOUT and STDERR to a file does not work this way? Is this a bug in bash?
Yes, I know I can use the following, but I prefer the &>>:
ls 1>> output_and_error.txt 2>&1

And how come I can’t find a bugzilla for bash?
Yes, I know I can use the command bashbug to send a mail to a mailinglist, but this is not the same as bugzilla.

Installing Ubuntu

Posted in Fedora, Linux SysAdmin on July 18th, 2008 by Johan Huysmans – 3 Comments

This week I reinstalled one of my Fedora machines with an Ubuntu 8.04. Not that I don’t like Fedora anymore but just because I want something new.

One of the big annoyancies I noticed during the installation was that it didn’t recognize my lvm partitions. And I really need that, as my home and root partition are on lvm and I didn’t want to repartition my complete drive.

Luckily I found some explanation for lvm support during the installation. This is the summary of the actions you need to perform.

Become the root user:
ubuntu@ubuntu:~$ sudo -i

Load the dm-mod module:
root@ubuntu:~# modprobe dm-mod

Install the lvm2 package on the live system:
root@ubuntu:~# apt-get install lvm2

Activate the logical volumes of your volumegroup
root@ubuntu:~# lvchange -a y <volgroup name>

At this moment you can perform a normal installation, your existing logical volumes will be recognized and can be used during installation.
After the complete installation process you have to install lvm support for you new installation.

Mount the partitions of your new installation:
root@ubuntu:~# mount /dev/volgroup/root /mnt
root@ubuntu:~# mount /dev/sda1 /mnt/boot
root@ubuntu:~# mount -o bind /dev /mnt/dev

Chroot into your new installation:
root@ubuntu:~# chroot /mnt

Install the lvm2 package:
root@ubuntu:~# apt-get install lvm2

You can now exit your chroot environment and reboot your machine. If everything is OK, you can boot your fresh ubuntu installation.

Shell History Meme

Posted in Fedora, General, Linux SysAdmin on April 10th, 2008 by Johan Huysmans – Be the first to comment

There is a Shell history meme going on on planet Fedora; Let’s join.

[johan@laptop ~]$ history|awk '{a[$2]++ } END{for(i in a){print a[i] " " i}}'|sort -nr|head
201 ls
108 ssh
108 cd
98 sh
81 su
29 vi
24 rpm
24 ping
23 rm
20 mv

[johan@workstation ~]$ history|awk '{a[$2]++ } END{for(i in a){print a[i] " " i}}'|sort -nr|head
149 ls
128 cd
125 cvs
93 diff
71 echo
54 ssh
45 for
28 mkdir
26 md5sum
24 reset

My previous post of my Top 10 used commands was more than 1 year ago.

MySQL MYD and TMD files

Posted in Backup, WordPress on April 8th, 2008 by Johan Huysmans – 2 Comments

I just recovered from a database issue.

While running a mysqldump of my databases I received an error. Running a check on that specific database told me that the comments.MYD file was not found.

Investigating on the system showed me that due to an error the filesystem containing /var/lib/mysql was mounted read-only. Running a fsck on that specific filesystem solved that error but didn’t fix my corrupted table.

phpMyAdmin showed that the table was in use and while performing a check or repair it complained about the missing file.

The comments.MYD file was indeed missing, but there was a comments.TMD file, which wasn’t there for all the other tables.

Moving this TMD file to MYD solved the issue. I could repair the table and the check is again successful.

During this problem wordpress didn’t complain but it just didn’t show my comments. But I have no clue what caused this problem.

Using Xen for High Availability Clusters

Posted in Linux SysAdmin, Xen on February 6th, 2008 by Johan Huysmans – Be the first to comment

ONLAMPYesterday evening O’Reilly ONLamp.com published “Using Xen for High Availability Clusters“.

This article is written by my colleague, Kris Buytaert, and me and describes the setup of the clustering of the virtual gateways at Newtec.
It explains the networking in a xen dom0 and how to block all virtual machines from the network. It also explains how you can integrate this with linux-ha.

This is my first article on O’Reilly, this means that I now have a profile on O’Reillynet, you can check it out here: http://www.oreillynet.com/pub/au/3323.

Enjoy the reading !

3ware module refuses to load with xen kernel

Posted in Linux SysAdmin, Xen on January 17th, 2008 by Johan Huysmans – 2 Comments

Today I encountered a problem with the 3ware module.

The fresh installed CentOs 5, on a machine with a 3ware 9500 card, booted without any problems, but this wasn’t the case when booting with the xen enabled kernel. During boot of the xen kernel, which ended in a kernel panic, it showed something about ioremap. When googling about the problem I found a patch which solved the problem.

Here is a step-by-step guide how I’ve applied the patch and solved the problem… read more »

rsync daemon init script

Posted in Backup, Linux SysAdmin on December 21st, 2007 by Johan Huysmans – 1 Comment

Rsync, the popular file synchronization tool, can be used as a daemon. It is quite easy to start the daemon version of it, just execute:
rsync --daemon --config=/path/to/rsyncd.conf

If you want to start it at boottime you have to create an init script as it is not delivered with the rpm (or at least not with redhat/centos/fedora rpms).
You can search for any existing init scripts, for example systemimager-server delivers such init script, and use that script or write a simple init script yourself, using an existing script as guideline.

In my setup I needed 2 daemons, one running on port 873 (the default), the other one running on port 874. This is off course perfectly feasible but had some problems with the init scripts.
I wanted to be able to start and stop each daemon separately. But with the simple init script I could start both separately but when i wanted to stop one of them they are both stopped.

Diving into the daemon and killproc functions, which are stored in /etc/rc.d/init.d/functions and used by all init scripts, showed me that I have to use a combination of storing the pid file and the base filename of the init script.
The pid of the rsync daemon can be stored in any file (this is handle by rsync itself), this can be configured in the rsyncd configuration with following line: pid file = /var/run/rsyncd.pid

Following init script can start or stop the specific rsync daemon even if there are multiple daemons running on the system.
There is only requirement for this init script, which is explicitly explained in the script, the filename of the initscript must be the basename of the pidfile. For example if your initscript is /etc/init.d/custon-rsyncd the pid must be stored in /var/run/custom-rsyncd.pid.

#! /bin/sh
#
# chkconfig:   2345 50 50
# description: The rsync daemon

# source function library
 . /etc/rc.d/init.d/functions

PROG='/usr/bin/rsync'
BASE=${0##*/}

# Adapt the --config parameter to point to your rsync daemon configuration
# The config file must contain following line:
#  pid file = /var/run/<filename>.pid
# Where <filename> is the filename of the init script (= this file)
OPTIONS="--daemon --config=/etc/rsyncd.conf"

case "$1" in
  start)
    echo -n $"Starting $BASE: "
    daemon --check $BASE $PROG $OPTIONS
    RETVAL=$?
    [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$BASE
    echo
    ;;
  stop)
    echo -n $"Shutting down $BASE: "
    killproc $BASE
    RETVAL=$?
    [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$BASE
    echo
    ;;
  restart|force-reload)
    $0 stop
    sleep 1
    $0 start
    ;;
  *)
    echo "Usage: $0 {start|stop|restart|force-reload}" >&2
    exit 1
    ;;
esac

exit 0

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