Media Wiki /var/www/includes/db/Database.php: DatabaseBase::factory no viable database extension found for type ‘mysql’

I just upgraded Ubuntu and unfortunately the MediaWiki installation broke. There was no debugging output on the screen (for obvious security reasons). So, I just had a blank page on the screen.

The first thing that I did was show the debugging output but editing the LocalSetting.php to enabling

$wgShowExceptionDetails = true;

After refreshing the page, the error appeared as

/var/www/includes/db/Database.php: DatabaseBase::factory no viable database extension found for type 'mysql'

It turns out the problem was php not connecting to MySQL properly.

sudo php5enmod mysql
sudo service apache2 restart

How to remove Ubuntu Landscape Client *

I have started to remove the Ubuntu / Cannonical Landscape Client from all my Ubuntu servers because otherwise it is just another service:

  1. Running in the background using power
  2. Potiential security hole with root permission
  3. I don’t actually use it

It is quite simple:

sudo apt-get remove landscape-client landscape-client-ui landscape-client-ui-install landscape-common

If Cannonical open sourced the service for Landscape then I would actually start using it but in the meantime…

Strange Conveyor User Ubuntu

I have just been looking at the processes on my laptop and noticed a python process running as a user called ‘conveyor’. I can’t remember adding a user or installing a program called conveyer. It turns out that it was a Makerbot process. So, a quick…

apt-get remove makerbot* 

…helped sort that out. Why Makerbot doesn’t make a user called Makerbot, I have no idea.

How to extend / increase a Windows Partition on KVM QEMU VM

We have a Windows 7 VM running on Ubuntu KVM. I needed to give the Windows 7 machine more disk space. This turns out to be really easy (when you know how).

Step 1 – Shutdown the VM

virsh shutdown hostname

Step 2 – Increase the qcow2 image
Find the qcow2 file of the VM and take a backup (just in case).

cp hostname.qcow2 hostname.qcow2.backup
qemu-img resize hostname.qcow2 +100GB

Step 3 – Start the VM
Now start the VM.

virsh start hostname

Step 4 – Extend the partition in Window
Windows has a really good partition management utility built into it. Search for “disk management”

window_7_vm_disk_resizing

Then select the partition, right click and choose extend partition. You should then follow the simple steps and you are done.

Let me know if you have any improvements to this.

How to change the banner image in Install4J

I am just making an installer for Windows, Mac and Linux using install4j. However, it isn’t clear from the docs how to change the banner image on the left hand side.

To set it on the Welcome screen, you need to go to Installer -> Welcome and select the “Images For Banner” property,

To change it on the Finish screen, you need to go to installer -> Finish and select the “Image for Banner” property.

bacula-dir mysqldump: Error 2013: Lost connection to MySQL server during query when dumping table

Our Bacula server has started failing when backing up its own database.  This is a standard job called BackupCatalog. It showed an error like so:

27-Feb 23:29 bacula-dir JobId 6545: shell command: run BeforeJob "/etc/bacula/scripts/<a href="http://make_catalog_backup.pl" target="_blank">make_<wbr />catalog_backup.pl</a> MyCatalog"
27-Feb 23:35 bacula-dir JobId 6545: BeforeJob: mysqldump: Error 2013: Lost connection to MySQL server during query when dumping table `File` at row: 2164125
27-Feb 23:35 bacula-dir JobId 6545: BeforeJob: mysqldump: Couldn't execute 'show table status like 'FileSet'': MySQL server has gone away (2006)
....

Reading the error, it would appear to be a mysqldump problem, rather than a Bacula configuration problem. The mysqldump process was running out of resources. This was because the mysql server wasn’t configured correctly and the server didn’t have enough memory or cpu. I run Bacula on a virtual server and it was therefore quite easy to give an extra two gigs of memory and some more CPU time.

However, to fix the mysql server configuration, I adjusted the following settings in MySQL. I did this by creating a file in the /etc/mysql/conf.d/ directory called bacula.cnf with the following settings and then restarted the server.

[mysqld]
wait_timeout = 86400
max_allowed_packet=32M
innodb_buffer_pool_size=1G

sudo service mysql restart

Install mysqltuner
You might have different mysql configuration issues and therefore have different configurations to change.  I would highly recommend mysqltuner to help you diagnose problem.  It is designed to analysis your MySQL server and recommend  options which could be changed based on your server usages.

Note: Your server needs to be running for over 24 hours before it’s recommendations are useful.  So, if you have just restarted the server, it probably won’t be very useful.

apt-get install mysqltuner

Then run:

mysqltuner

And you get a lovely report like so. Note:  The reports shown below is for server that has only been up for 15 minutes and the recommendations can’t really be trusted.

 >>  MySQLTuner 1.0.1 - Major Hayden <major@mhtx.net>
 >>  Bug reports, feature requests, and downloads at http://mysqltuner.com/
 >>  Run with '--help' for additional options and output filtering

-------- General Statistics --------------------------------------------------
[--] Skipped version check for MySQLTuner script
[OK] Currently running supported MySQL version 5.5.35-0ubuntu0.12.04.2
[OK] Operating on 64-bit architecture

-------- Storage Engine Statistics -------------------------------------------
[--] Status: -Archive -BDB -Federated +InnoDB -ISAM -NDBCluster 
[--] Data in InnoDB tables: 413M (Tables: 25)
[--] Data in PERFORMANCE_SCHEMA tables: 0B (Tables: 17)
[!!] Total fragmented tables: 25

-------- Performance Metrics -------------------------------------------------
[--] Up for: 15m 36s (24K q [26.087 qps], 56 conn, TX: 353K, RX: 4M)
[--] Reads / Writes: 0% / 100%
[--] Total buffers: 192.0M global + 2.7M per thread (151 max threads)
[OK] Maximum possible memory usage: 597.8M (10% of installed RAM)
[OK] Slow queries: 0% (0/24K)
[OK] Highest usage of available connections: 1% (3/151)
[OK] Key buffer size / total MyISAM indexes: 16.0M/98.0K
[!!] Key buffer hit rate: 80.0% (5 cached / 1 reads)
[!!] Query cache efficiency: 17.0% (29 cached / 171 selects)
[OK] Query cache prunes per day: 0
[OK] Sorts requiring temporary tables: 0% (0 temp sorts / 3 sorts)
[OK] Temporary tables created on disk: 19% (54 on disk / 275 total)
[OK] Thread cache hit rate: 94% (3 created / 56 connections)
[OK] Table cache hit rate: 24% (66 open / 273 opened)
[OK] Open file limit used: 4% (48/1K)
[OK] Table locks acquired immediately: 100% (24K immediate / 24K locks)
[!!] InnoDB data size / buffer pool: 413.7M/128.0M

-------- Recommendations -----------------------------------------------------
General recommendations:
    Run OPTIMIZE TABLE to defragment tables for better performance
    MySQL started within last 24 hours - recommendations may be inaccurate
    Enable the slow query log to troubleshoot bad queries
Variables to adjust:
    query_cache_limit (> 1M, or use smaller result sets)
    innodb_buffer_pool_size (>= 413M)

Top
I recommend using Top to diagnose the load problems on your server.  For me, it was clear from the basic numbers that the server was using alot of swap and lots of cpu.

SAR
Finally, I recommend used the excellent sysstat / sar tools to see the history of the CPU and the iowait on the server.

I hope this helps someone.