MathJax

SyntaxHighlighter

Highlight

Custom CSS

Thursday, August 14, 2008

Moving the MySQL data directory in Ubuntu

There are lots of guides on the internet that tell you how to move your data directory. Most of them fail to mention that for Ubuntu, AppArmor will render those directions useless in a silent way. If you've followed everything to the letter, and MySQL still refuses to start for some reason, tail /var/log/syslog. If you see something like this:

May 7 15:51:55 vcke-gl-linux mysqld_safe[5886]: started
May 7 15:51:55 vcke-gl-linux kernel: [ 82.391726] audit(1210139515.249:2): 
  type=1503 operation="inode_create" 
  requested_mask="w::" denied_mask="w::" 
  name="/mnt/fastdata/var/lib/mysql/vcke-gl-linux.lower-test" 
  pid=5888 profile="/usr/sbin/mysqld" namespace="default"
May 7 15:51:55 vcke-gl-linux mysqld[5890]: 080507 15:51:55 [Warning] Can't create test file
  /var/lib/mysql/vcke-gl-linux.lower-test
May 7 15:51:55 vcke-gl-linux kernel: [ 82.393387] audit(1210139515.259:3): 
  type=1503 operation="inode_create" 
  requested_mask="w::" denied_mask="w::" 
  name="/mnt/fastdata/var/lib/mysql/vcke-gl-linux.lower-test" 
  pid=5888 profile="/usr/sbin/mysqld" namespace="default"
May 7 15:51:55 vcke-gl-linux mysqld[5890]: 080507 15:51:55 [Warning] Can't create test file 
  /var/lib/mysql/vcke-gl-linux.lower-test
May 7 15:51:55 vcke-gl-linux kernel: [ 82.487247] audit(1210139515.349:4): 
  type=1503 operation="inode_create" 
  requested_mask="w::" denied_mask="w::" name="/mnt/fastdata/tmp/ib7jXL82" 
  pid=5888 profile="/usr/sbin/mysqld" namespace="default"

...then you'll know the problem applies to you. For security reasons, AppArmor will restrict MySQL to reading and writing from certain specified directories, listed in /etc/apparmor.d/usr.sbin/mysqld. If you edit that file and add the new data directory, you'll be golden. You might also need to change mysql's home directory in /etc/passwd, or create a symlink to the new home.

Tuesday, August 5, 2008

Installing IBM JDK 6.0 on Ubuntu

The IBM JDK offers performance benefits over Sun's JDK, which is especially useful when playing around with, say, the Scala interpreter. Installing it on Ubuntu can be a little tricky, but here's how you do it:

  1. Download the IBM JDK version 6 here.
  2. Install fakeroot and java-package with sudo apt-get install fakeroot java-package.
  3. Edit /usr/share/java-package/ibm-j2sdk.sh and add this on line 28:
    "ibm-java-sdk-6.0-1.0-linux-i386.tgz" ) # SUPPORTED
        j2se_version=1.6.0${revision}
        j2se_expected_min_size=82 # 85983232 bytes
        found=true
        ;;
    
  4. Navigate to the directory where the JDK was downloaded and execute fakeroot make-jpkg ibm-java-sdk-6.0-1.0-linux-i386.tgz.
  5. Install the debian package that was created.
  6. Type sudo update-alternatives --config java to choose to use the IBM JDK.

Note: Previously, I had always installed JDKs manually, but if you want to use the JDKs that come in the repositories, make sure to pick up libreadline-java and libjline-java to make it easier to work with the scala interative shell.