Archive for the 'Linux Admin' Category

Twitter Tools: Call to undefined function curl_init()

Changes to the requirements for apps connecting to Twitter have resulted in the update of the Twitter Tools plugin used in this and many other blogs to provide a twitter feed in the sidebar.  There is now a requirement for a a sequence of keys to authorize access to your twitter account.

Unfortunately, when I updated and configure the new version of Twitter Tools, it would not connect to Twitter, instead giving a

Call to undefined function curl_init()……….

error.  This is because php was not configured with curl support.  To fix this on a Debian-based system, do the following:

sudo apt-get install php5-curl

then add the following line to your /etc/php5/apache2/php.ini file:

extension=curl.so

finally, restart Apache:

/etc/init.d/apache2 restart

Twitter Tools (and any other php Twitter app) should connect to your Twitter account correctly.

MySQL Corrupt But Won’t Repair

I had a problem this week installing a second copy of WordPress on my server from which to run a personal blog.  The installation kept failing to access the database, pointing to a permissions problem.  Running a GRANT statement to give the correct privileges to the new database gave no error but on checking the mysql.users table I discovered that no changes were actually being written to the permissions!

check table user

returned an error:

Table ‘.mysql.user’ is marked as crashed and should be repaired.

repair table user

returned

Table is already up to date

and the circle continued……..

So I had a corrupt user table which wouldn’t let me repair it.  However, there is another repair utility which is used on upgraded tables from MySQL 4.x which will repair tables in these circumstances.  To use it, just navigate to your MySQL data directory and run:

myisamchk -r *.MYI

This will check and repair all tables in the directory.  Of course you can repair just a single table by replacing * with the table name.

VirtualBox – Guest Additions

I wanted to take a quick look at Ubuntu 10.04 so I downloaded the latest VirtualBox VM software and grabbed the Ubuntu ISO so that I could just run a test on my local PC inside a virtual machine so I could play with it while doing other things.  I haven’t used VirtualBox for a while and while the guest OS install went fine, I couldn’t get the screen resolution to increase so my Ubuntu desktop was fixed at 640 x 480, even in full screen mode.  It turns out the additional functionality is available through installing Guest Additions.  I’m not going to go into the details of how to do it because there’s several straight-forward How-To’s on the web, for example here.

Spamassassin Backup

spam If you do regular backups of your servers, when you come to restore you nearly always find something you didn’t realise you should have backed up.  One thing that can slip through the net on Linux mail servers is the spamassassin database.  If you use a cron job to analyse your spam messages everyday and learn from them, spamassassinwill have created a database of identifiers and tokens which can be lost if not backed up.

To create a backup of the database simply issue the following command (ideally in a daily cron job):

sa-learn –backup /etc/spamassassin/db-backup.txt

This will create a text file called db-backup.txt which is easy to backup in your regular routine and can be restored by:

sa-learn –restore=/etc/spamassassin/db-backup.txt

Debian MySQL Restore

Linux - Tux One of our servers is showing an intermittent lockup which could be caused by motherboard, PSU or hard drive so I’m configuring a replacement.  The new server is and AMD64 unit so the debian installation is a different version to that installed on the current server so I was expecting a few glitches with configuration changes between package versions, but one error that came up was when I restored the MySQL databases.  The procedure I followed was:

1)  Move original files in /etc/mysql to a directory call ‘original_files’.

2) Restore the config files in /etc/mysql from our backup server.

3) Move original installation databases in /var/lib/mysql to a directory called ‘original files’.

3) Restore the databases by copying them directly from our backup server to /var/lib/mysql.

4) Start MySQL.  This gave the error “error: ‘Access denied for user ‘debian-sys-maint’@'localhost’ (using password: YES)’”

The reason for this is that the new installation of Debian has assigned a new password to the debian-sys-maint user.  The new password can be found in /etc/mysql/debian.cnf and to give the user access to mysql you need the following commands:

# mysql -u root -p

mysql>  grant all privileges on *.* to ‘debian-sys-maint’@'localhost’ identified by ‘<password>” with grant option;

(Replacing <password> with the password from you /etc/mysql/debian.cnf file. )

mysql> quit

MySQL should now start correctly.  One thing to watch out for is that some sources say the the syntax of the Grant statement should be “IDENTIFIED BY PASSWORD ‘<password>’” but this does not work.  It should be “IDENTIFED BY ‘<password>’”.

Debian apt-get Key failure

Linux - Tux I had a need to do some work on an old Debian server last week and hit an error message running ‘apt-get update’.  It returned the following error message:


GPG error:  ftp://ftp.debian.org/etch Release:

The following signatures couldn’t be verified because the public key is not available:

NO_PUBKEY 9AA38DCD55BE302B

There is no public key available for the following key IDs:

9AA38DCD55BE302B


The problem is caused by Debian now attempting to verify the authenticity of the servers for updating.  The solution is to run the following two commands:

gpg – -keyserver pgpkeys.mit.edu – -recv-key 9AA38DCD55BE302B

gpg -a – -export 9AA38DCD55BE302B | sudo apt-key add -


Running an ‘apt-get update’ should now work OK.

Flexbackup On Debian

Linux - Tux Following on from my earlier post, I had a problem getting my tape backup working with the latest stable release of Debian on the new backup server.  I use flexbackup to run my tape backup and on the older Debian installation, flexbackup would correctly set the block size of the tape and run the backup.  On the latest installation, running flexbackup gave an error message running the following commands:

mt -f /dev/nst0 setblk 0

mt -f /dev/nst0 defblksize 0

Running the commands manually gave the response

mt: invalid argument `setblk’ for `tape operation’

A little research uncovered the fact that installing the mt-st package (apt-get install mt-st) fixed the problem and should be installed alongside flexbackup for proper operation on later Debian installations.

Linux Boot Failure

Linux - Tux I run a dedicated backup server who’s job it is to suck up all the data files from the other servers on a nightly basis to a hard drive and then transfer the lot to tape.  It’s been a little flakey lately so I’ve built a replacement which is, in line with other recent  changes, a smaller, quieter and altogether greener machine.

I needed to transfer some scripts from the old server to the new and discovered that the old server was not very happy that I had yanked it’s SCSI card and DAT drive.  It now failed to boot and gave me a segmentation fault instead.  Selecting the recovery option from the Debian GRUB prompt didn’t help so I resorted to a trusted method using SystemRescueCD which allowed me to boot from the CD then issue the following commands:

mkdir /mnt/hd

mount /dev/sda1 /mnt/hd

This created a mount point and mounted the root hard drive partition to it.  This enabled me to get at the module config files in the server’s /etc directory.

vi /mnt/hd/etc/modules

This loaded up the modules list for boot-up and I simply deleted the aic**** line to remove the SCSI module.

A reboot later after removing the CD and everything is fine again.

I could complain that the aic**** module should handle such a simple error without segmenting and locking up the system and if I hadn’t figured out a work-around I probably would but since I use linux for free, it seems harsh to moan!

Spamassassin Puzzle.

The hard drive on our mail server died this week, giving SATA media errors on the Linux console.  I had a spare server almost ready to go so I migrated our data and configuration over to it.  Everything appeared to go smoothly until I tried to send an email in from outside to test it.  Every message I sent appeard in the recipient’s inbox as a blank message.  No subject, no content and the To field marked as “undisclosed-recipients”.

I initially traced the problem to the spamassassin configuration in that if I disabled the spamfilter content filter in Postfix, emails were sent and received correctly, albeit they would include the 1500 or so junk messages the filter traps every day.  I tried removing and reinstalling spamassassin but that made no difference and I tried running “spamassassin –lint” to test our configuration but no errors were found.  Log files reported no problems.

In the end the solution was incredibly simple.  If you run

apt-get install spamassassin

on debian, you get a spamassassin installation with one important feature missing, the spamc program used to actually filter the messages through the spamd daemon.

apt-get install spamc

fixes the problem.  I don’t remember installing them seperately in the past but maybe I’ve just forgotten that I did!

I’ve Done The Unthinkable!

Apple vs Windows vs Linux  I have mentioned recently that i’ve been transferring my DVD collection to a media server so that I can stream the films from a couple of clients around the house.  My clients are Philips Streamium SLM5500 which so far have been pretty reliable.  On the server side, I started out using FreeNAS, but it’s UPnP server is pretty bare and I had a few lockups so I decided to try Twonky which, while not free, is well featured and reasonably priced at €29.

Now, being a devout fan of Linux for all server requirements, I started out with a Debian installation and downloaded the Twonky linux setup package.  Running the .sh script installed Twonky and started the server but from there I simply had no idea where to go. I needed to configure Twonky but that is all done through a web interface so I installed Apache and looked for the setup html file referenced in the Twonky files but a full search of the server couldn’t find it.

Now normally, I’d have persevered and got it sorted but my time on such things is limited these days with work and family commitments, and my patience when thinks aren’t working as they should is not so good.  So I did the unthinkable……… I installed XP, downloaded the windows version of Twonky and had it up and running and serving my movies and music in no time.

Whether this lapse in my character is my fault or Twonky’s is up for debate but the usual motto I have with Linux, “It Just Works”, has flipped on its head for this project.  I’m afraid, very afraid……..