Posts

NRPE errors regarding SSL handshake

Error:

CHECK_NRPE: Error - Could not complete SSL handshake.

If you are trying to work with Nagios and setup NRPE, when performing check_nrpe -H hostname you might get the above error. Usually it happens when you have added another IP to the list of allowed hosts and you have added a SPACE after the coma. Just remove the space after the coma so your /etc/nagios/nrpe.cfg contains a line like this:

allowed_hosts=127.0.0.1,XXX.XXX.XXX.XXX

MySQL errors after update , error 1018 (HY000), errno: 24

Today I’ve updated MySQL server on one of my Ubuntu 12.04 servers. After the upgrade finished, shock and horror: all websites were down, WordPress sites were presenting install page. Quickly connected to mysql via CLI and tried to see if the databases are still there:

mysql> show databases;
ERROR 1018 (HY000): Can't read dir of '.' (errno: 24)

I’ve tried setting limits as in this article, but that didn’t seem to help. Only after adding “open-files-limit = 2048” to my.cnf and restarting the MySQL server things went back to normal. So a big thank you to the author of the article, but I would like to know if there is any need setting those limits or not(obviously I was stressed out over the web sites being down and didn’t test all things).

Anyone else has any experience with this problem?

Installing MongoDB PECL extension

The MongoDB PECL extension has not been installed or enabled

If you have installed MongoDB and you get the above error or something similar to it, you will need to install the php extension. It’s quite easy, shouldn’t take more than a couple of minutes. All the commands were executed as root, if you want to use the sudo mechanism, just prefix all the commands with sudo.

Install the required packages

apt-get install php-pear php5-dev make

If everything went ok, simply install the extension by executing this command:

pecl install mongo

Activate the MongoDB extension

I have Ubuntu 12.04 server edition installed on the server so I simply added a new ini file containing one line:

echo "extension=mongo.so" > /etc/php5/apache2/conf.d/mongo.ini

Now restart web server (in my case Apache 2.2) and enjoy:

service apache2 restart

mod_fcgid: HTTP request length exceeds MaxRequestLen

Symptoms:
When trying to upload a file you get “Error 500, Internal server error”. In the error log file you get something like:

[Tue Aug 21 20:40:39 2012] [warn] [client x.x.x.x] mod_fcgid: HTTP request length 132532 (so far) exceeds MaxRequestLen (131072), referer: http://www.example.com/upload.php

This problem is present in ISPConfig 3 running on Ubuntu 12.04, when running Apache2 with mod_fcgid.

Fix:
Edit “/etc/apache2/mods-available/fcgid.conf” and add:

FcgidMaxRequestLen  1073741824

file command error for application/msword when checking mime type

If you updated your system and file command started to behave strangely when trying to determine file type for Microsoft Word, giving you “ERROR: (null)” instead of “application/msword” here is a quick solution to fix it.

# Checkout source files
git clone https://github.com/glensc/file

# generate configure/make and stuff
cd file
libtoolize --force
aclocal
autoheader
automake --force-missing --add-missing
autoconf

# Usual configure/make and checkinstall
./configure
make
sudo checkinstall --pkgname=file --pkgversion "5.11" --backup=no --fstran

# ldconfig
sudo ldconfig -v

Mysql max_allowed_packet error

You are probably here because you tried to import a big database (several GB) and got the following error:

ERROR 1153 (08S01) at line 2533: Got a packet bigger than 'max_allowed_packet' bytes

If you have access to your mysql server and SUPER privileges things are easy, you just need to log in as superuser to mysql and type this:

mysql>set global max_allowed_packet=64*1024*1024;

and then import the database normally, just adding “–max_allowed_packet=64M” to the parameter list. Example:

$mysql --max_allowed_packet=64M database < database.sql

Everything is so easy. But if you are using Amazon RDS you are out of luck. You setup a user when you create the instance but of course it doesn’t have the SUPER privilege so if you try to execute the above command it will fail. Not even “grant super on *.* to myuberuser” will help you, no no. So after some googling and reading a lot of crap I found this blog which had the same error as mine. Yuppy! Thanks Henry!

The solution is to use DB Parameter Groups. Grab your mouse and start copy pasting fast.

Download Amazon RDS Command Line Toolkit
The latest version can be found here

wget http://s3.amazonaws.com/rds-downloads/RDSCli.zip
unzip RDSCli.zip
cd RDSCli-1.3.003 (this will surely change so make sure you cd to the right directory)
export AWS_RDS_HOME=`pwd`
export JAVA_HOME=/usr/lib/jvm/java-1.6.0-openjdk (this may vary depending on your java location and may not have to set it)
cp credential-file-path.template credential-file
vi credential-file (set your aws credentials there, use whatever text editor you like)
export AWS_CREDENTIAL_FILE=${AWS_RDS_HOME}/credential-file
cd bin
./rds --help

If everything went well you should get some output. On Henry blog he says he suggests that you create a parameter group. Well the reality is you have to create it since Amazon won’t let you modify parameters inside the default group.

./rds-create-db-parameter-group mygroup -f MySQL5.1 -d "My group"
./rds-modify-db-parameter-group mygroup --parameters "name=max_allowed_packet,value=67108864,method=immediate"
./rds-modify-db-instance YOURINSTANCENAMEHERE --db-parameter-group-name mygroup

Go to Amazon management console and check that the new parameter group is created and applied to your instance. You can begin now the import as you would do normally just add “–max_allowed_packet=64M” to the list of your options.

Hope it helps!