Posts

Showing posts from 2009

Tune the way linux use the swap with the swappiness parameter

Image
On linux, you can tune the way the system use the swap via the 'swappiness' parameter. Check how the swap is used on your machine: You can print how the system is using the swap with the vmstat command : thomas@home:~$ vmstat 2 procs -----------memory---------- --- swap -- -----io---- -system-- ----cpu---- r b swpd free buff cache si so bi bo in cs us sy id wa 0 0 25192 81956 93052 2383988 0 0 8 15 1 1 1 1 98 0 6 0 25192 71076 93100 2384224 0 0 10 272 1148 1265 8 10 80 2 0 0 25192 97492 93016 2368148 0 0 132 1186 1380 1845 26 35 39 0 0 0 25192 96648 93032 2368740 0 0 70 188 1121 1066 2 2 96 1 0 0 25192 96400 93044 2368976 0 0 0 188 1117 1082 1 1 98 0 the '2' parameter stands for the refresh time in seconds. si stands for Swap IN (byte written to the swap) so stands for Swap OUT (byte removed from the swap) On a server which has enough

Reset Bacula database and files

Image
Today I need to purge my bacula for several reasons. Here is how I did. First backup the database and files used in your previous setup, one never knows you might actually need it after the purge... /usr/bin/mysqldump -aecqQ bacula > bacula_before_purge.sql and copy the volumes and bsr files. Stop bacula : service bacula-director stop service bacula-fd stop service bacula-sd stop then : mysql -u root -p drop database bacula; create database bacula; quit next we need to recreate bacula tables. There's a bacula script to do that, but the file needs to be changed to set the correct database name. cp /usr/share/bacula-director/make_mysql_tables ~/ vi ~/make_mysql_tables change XXX_DBNAME_XXX by your bacula database (let's say 'bacula') save and exit. then run as root the script ~/make_mysql_tables it should have recreated the tables : mysql -u root -p use bacula; show tables; +------------------+ | Tables_in_bacula | +-----------

locale configuration issue on Ubuntu 9.04

Image
I've rent a new server by dedibox.fr and the ubuntu server version is tunned by the dedibox team... On the Ubuntu Server 9.04 64bit/english version, there's a locale configuration issue. whenever you do a aptitude update or run the 'locale' command you get a warning like this : thomas@sd1:~$ locale locale: Cannot set LC_CTYPE to default locale: No such file or directory locale: Cannot set LC_MESSAGES to default locale: No such file or directory locale: Cannot set LC_ALL to default locale: No such file or directory LANG=en_US.ISO-8859-15 LANGUAGE=en_US:en:en_GB:en LC_CTYPE="en_US.ISO-8859-15" LC_NUMERIC="en_US.ISO-8859-15" LC_TIME="en_US.ISO-8859-15" LC_COLLATE="en_US.ISO-8859-15" LC_MONETARY="en_US.ISO-8859-15" LC_MESSAGES="en_US.ISO-8859-15" LC_PAPER="en_US.ISO-8859-15" LC_NAME="en_US.ISO-8859-15" LC_ADDRESS="en_US.ISO-8859-15" LC_TELEPHONE="en_US.ISO-8859-15" L

Add 2 disk for RAID 1 setup

Image
On the dev server I spoke previously, we add 2 hard drives of 500GB in order to have 500GB in RAID1 as a network storage. Here is the setup procedure: Check the disk sudo fdisk -l thomas@dev:~$ sudo fdisk -l Disk /dev/sda: 82.3 GB, 82348277760 bytes 255 heads, 63 sectors/track, 10011 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk identifier: 0x00059bfb Device Boot Start End Blocks Id System /dev/sda1 * 1 36 289138+ fd Linux raid autodetect /dev/sda2 37 218 1461915 fd Linux raid autodetect /dev/sda3 219 826 4883760 fd Linux raid autodetect /dev/sda4 827 10011 73778512+ fd Linux raid autodetect Disk /dev/sdb: 82.3 GB, 82348277760 bytes 255 heads, 63 sectors/track, 10011 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk identifier: 0x000d96f2 Device Boot Start End Blocks Id System /dev/sdb1 *

Raid on linux - re-add a drive

Image
Today, one of the developer of 123Monsite.com mess up with one server, and this lead to this : They configure fake hardware on the mother board while it's a software raid... noticing it didn't work, they remove a drive to boot on a degraded raid... and try to find what's wrong... that's when I interrupt the massacre this lead to this : the partitions of the removed drive was marked as deleted (even if it has been replugged and fake-hardware disabled) : thomas@dev:~$ sudo mdadm --query --detail /dev/md3 /dev/md3: Version : 00.90 Creation Time : Thu Sep 4 23:15:23 2008 Raid Level : raid1 Array Size : 73778432 (70.36 GiB 75.55 GB) Used Dev Size : 73778432 (70.36 GiB 75.55 GB) Raid Devices : 2 Total Devices : 1 Preferred Minor : 3 Persistence : Superblock is persistent Update Time : Mon Aug 10 22:45:33 2009 State : clean, degraded Active Devices : 1 Working Devices : 1 Failed Devices : 0 Spare Devices : 0 UUID : 6c7f5b4f:27e96317:a44ec9ef:2b057faa Events : 0.29

Week Numbers in google calendar

Image
I've found this website : http://sites.google.com/site/gcalweeknumbers/googlecalendarweeknumbers that provide a calendar that displays week numbers in you calendar which is very usefull as at work (at least in France) where we refer to week number for planning.

MySQL backup

In this post, I'll setup an automatic backup script that create an sql compressed with bz2 file per database. sudo -s Autologin with MySQL : sudo -s vi /root/.my.cnf [client] user=root password=TheRootPassword protocol=tcp chmod 400 /root/.my.cnf Test : [root@dell1 ~]# mysql Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 870724 to server version: 4.1.22 Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> quit Bye [root@dell1 ~]# Script vi /root/scripts/cron/backupDatabaseJob.sh #!/bin/bash TIME=`date` echo "Starting MySQL Backup at $TIME" BACKUPLOCATION=/home/backup/databases CURRENTDATE=`date +%Y%m%d` CURRENTLOCATION=$BACKUPLOCATION/MySQL_$CURRENTDATE if [ ! -d $BACKUPLOCATION ] then echo "create directory for database saves $BACKUPLOCATION" mkdir $BACKUPLOCATION fi echo "Databases saves at $CURRENTLOCATION"; mkdir -p $CURRENTLOCATION mysql --def

setup tomcat6 (with native library) with apache2 integration

Image
In this post, I'll setup a apache2 with php5 and tomcat6 integrated with apache2. Since Tomcat 5, you don't need a front http server anymore, but since I want to have php5 and tomcat6 on port 80, I need the tomcat6-apache2 integration with modjk since a lot of operation need the root privilege, switch to root : sudo -s Apache2 & PHP5 installation The following command install php5, php5 command line interface (CLI to use php as shell script) and some common php extension. aptitude install php5 php5-cli apache2 php5-xmlrpc php5-mysql php5-gd php5-imagick php-pear php5-mcrypt a2enmod headers #Activation of Mod headers a2enmod deflate #Activation of Mod deflate Setup the timezone : vi /etc/php5/apache2/php.ini [Date] ; Defines the default timezone used by the date functions date.timezone = Europe/Paris Java installation aptitude install sun-java6-jdk vi /etc/profile Append the following line : export JAVA_HOME=/usr/lib/jvm/java-6-sun reload your .profile : (command to type

DHCP server with ubuntu

first install the correct package : sudo aptitude install dhcp3-server then edit the configuration file : vim /etc/dhcp3/dhcpd.conf ddns-update-style none; # option definitions common to all supported networks... option domain-name " domain.tld " option domain-name-servers 80.10.246.3, 80.10.246.1, 80.10.246.129 ; default-lease-time 600; max-lease-time 7200; # If this DHCP server is the official DHCP server for the local # network, the authoritative directive should be uncommented. #authoritative; # Use this to send dhcp log messages to a different log file (you also # have to hack syslog.conf to complete the redirection). log-facility local7; # No service will be given on this subnet, but declaring it helps the # DHCP server to understand the network topology. # eth0 subnet configuration subnet 192.168.2.0 netmask 255.255.255.0 { range 192.168.2.100 192.168.2.200; option routers 192.168.2.254; option broadcast-address 192.168.2.255; } Replace domain.tld by your

Upgrade from kubuntu 8.10 to 9.04 with raid disk : no block devices found

Image
Well... I could have waited 15 more days to have the stable version of Ubuntu 9.04 available for upgrade... but no... It seems I wasn't aware i've so much time to loose. So I've upgraded my kubuntu 8.10 (64bit) to the 9.04 version. All went smoothly until I reboot where I get this nice message : no block devices found (4 times) Gave up waiting for root device. ALERT! /dev/md3 does not exist. dropping to a shell! Apparently the raid configuration has been dropped during the upgrade. I've filled a bug here : https://bugs.launchpad.net/ubuntu/+bug/358054 I don't know exactly what in my setup causes this, but it seems that it's a bug of the last kernel. Probably my raid setup. My computer is made of : P5N32-E Sli plus motherboard C2D 6250 4GB of RAM 2x 250GB SATA, RAID1 software for linux (sdc, sdd) 2x150GB Raptor SATA Raid0 for windows (fake raid from motherboard) (sda, sdb) To get my system back on line I just need to do this in the busybox shell : mdadm -As exit

Send mail through gmail smtp server with Exim4 - What to do when gmail account has been disabled

Image
To send mail from a machine using gmail smtp server see this tutorial : http://www.manu-j.com/blog/wordpress-exim4-ubuntu-gmail-smtp/75/ I've just ran into a problem with this config. I've created a gmail account just for this purpose because you need to set the gmail account password in exim4 configuration file on each machine. I didn't want to use my personnal gmail account for obvious reasons. As it's a technical account, I never log into it through http://gmail.com web interface. Which lead to the account beeing disabled by gmail. As a result, all mail that exim4 tryed to send gives this warning message in /var/log/exim4/mainlog : R=send_via_gmail T=gmail_smtp defer (-53): retry time not reached for any host To solve this issue, you need to Login to http://gmail.com with the account you use with exim4. It will ask you to login a second time with a captcha... do so login on all of your machine that use this technique and issue the following command : sudo exim -qff

Holidays...

Image
Hi, I'm in holdiays until the end of march, far far away from any computers ;) Thomas.

Gears on linux x64 ...

Image
gmail, google docs and google calendar now offers offline support with google Gears ! Great... but... Gears is not available for x64 linux... I've ask the google support for a release date of an official x64 build... but meanwhile, I've found (yes... google is my friend) this blog : http://nielspeen.com/blog/2009/02/google-gears-64-bit/ that gives a x64 build of gears that actually works ;) Great ! Btw, I can understand that one loves Yahoo! webmail which is great, but Microsoft Live mail... seriously... it's ugly, slow, so poor in functionality... why use it when you have access to an awesome webmail like gmail?? ;) Update : new version of the x64 version is available on niespeen blog ( 0.5.18.0 version (instead of the 0.5.16.0 version proposed by the firefox updater))

Limit the upload bandwidth of your apache webserver with mod_bw

Image
I've a server at home on a ADSL connection which has 100kBytes/s of upload and 1.2MBytes/s of download as bandwidth. If someone download at full speed some large file on my web server, my internet connection become unusable. To avoid this, I start to ask my friends to use a download manager to limit their download speed... but it's somewhat far too tricky for a lot of them... So I use mod_bw developed by Ivan Barrera http://www.ivn.cl/apache/ (sourceforge : http://bwmod.sourceforge.net/ ). Here is a quick way to limit the bandwidth used by Apache : Install & enable (on Ubuntu): sudo apt-get install libapache2-mod-bw sudo a2enmod bw Configure (your apache virtualhost conf file like /etc/apache2/sites-available/default) : <virtualhost *:80> #... other config stuf for the virtual host BandWidthModule On ForceBandWidthModule On BandWidth 192.168.0.0/24 0 BandWidth all 80000 </virtualhost> Explaination : line 1 : Activate the mod for the virtualhost. line 2 : Set a

How to solve GPG warning about apt/aptitude repository update

Image
When you add a repository in your /etc/apt/sources.list and run a apt-update you'll get the update of the newly added repository but also a warning about a GPG key like the following one : Hit http://ppa.launchpad.net intrepid/main Sources Hit http://fr.archive.ubuntu.com intrepid-proposed/universe Packages Hit http://ppa.launchpad.net intrepid/main Packages Fetched 309B in 0s (519B/s) Reading package lists... Done W: GPG error: http://ppa.launchpad.net intrepid Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY D702BF6B8C6C1EFD W: You may want to run apt-get update to correct these problems Running again apt-update won't solve the issue. This warning can be safely ignored, but I don't like to leave warning when there is a solution to get rid of it... because when something is going wrong, it would complicate to sort out what is safe to be ignored and what tells about a real issue. So, to get rid of this warning her

Thoughs about Facebook

Image
Today I've converted one of my friends to Facebook... This lead me to think about why I like Facebook so much and why I think it's awesome : Basic facts : It allows you to keep in touch with your acquaintance, see what's happening in their lives without actually spying them ;) Give updates about you in the same way. Use some useful apps like ' Birthday Calendar ' that help you not to forget you're friends birthday ;) Get in deeper touch with some friends of your friends that you find utterly interesting in a way far less obvious than match.com like website ;) You can be helped with some apps like ' Flirtable ' or ' Are YOU Interested ' Still on this friends and/or flirt side, when you go back from holidays and want to keep in touch, it's far easier to retrieve somebody with Facebook than exchanging email, or worse... postal address... And again, you can force your lover to put 'In relationship with you ' on their information page, so