Aug 25

We’re running MySQL on our low power home server system to support both our home monitoring system based on thermd and TNG Genealogy, a PHP-based web site application.  Since the internal solid state device (SSD) that acts as the hard drive for the home server has limited capacity (8 GB), I wanted to modify the MySQL configuration to maintain the databases on our QNAP NAS server.  Doing so provides us with lots of storage space and automatic backups via our multi-disk backup scheme. The only downside of the approach might be increased latency of database operations due to the use of NFS to access the database files.

Figuring out how to modify the configuration of MySQL to stop using /var/lib/mysql/ and to use a newly mounted share was easy.  After creating a mysql account and group on the NAS server and forcing the ids to be the same as used on the home server system, I tried to start MySQL.  However, I ran into a permissions problem:

Aug 25 22:21:14 home-server mysqld_safe[24585]: started
Aug 25 22:21:14 home-server kernel: [645095.493657] audit(1251256874.809:14): type=1503 operation="inode_create" requested_mask="w::" denied_mask="w::" name="/mnt/network-disk/database/home-server.lower-test" pid=24587 profile="/usr/sbin/mysqld" namespace="default"
Aug 25 22:21:14 home-server mysqld[24588]: 090825 22:21:14 [Warning] Can't create test file /mnt/network-disk/database/home-server.lower-test
Aug 25 22:21:14 home-server kernel: [645095.497234] audit(1251256874.809:15): type=1503 operation="inode_create" requested_mask="w::" denied_mask="w::" name="/mnt/network-disk/database/home-server.lower-test" pid=24587 profile="/usr/sbin/mysqld" namespace="default"
Aug 25 22:21:14 home-server mysqld[24588]: 090825 22:21:14 [Warning] Can't create test file /mnt/network-disk/database/home-server.lower-test
Aug 25 22:21:14 home-server kernel: [645095.586722] audit(1251256874.899:16): type=1503 operation="inode_permission" requested_mask="rw::" denied_mask="rw::" name="/mnt/network-disk/database/ibdata1" pid=24587 profile="/usr/sbin/mysqld" namespace="default"
Aug 25 22:21:14 home-server mysqld[24588]: 090825 22:21:14  InnoDB: Operating system error number 13 in a file operation.
Aug 25 22:21:14 home-server mysqld[24588]: InnoDB: The error means mysqld does not have the access rights to
Aug 25 22:21:14 home-server mysqld[24588]: InnoDB: the directory.
Aug 25 22:21:14 home-server mysqld[24588]: InnoDB: File name ./ibdata1
Aug 25 22:21:14 home-server mysqld[24588]: InnoDB: File operation call: 'open'.
Aug 25 22:21:14 home-server mysqld[24588]: InnoDB: Cannot continue operation.
Aug 25 22:21:14 home-server mysqld_safe[24595]: ended

Although all of the filesystem ownership and permissions were set properly, MySQL wouldn’t start.  It turns out that there’s an “apparmor” facility in Ubuntu that has a specific profile or configuration for MySQL.  This profile specifies the files that MySQL can access.  The standard path of /var/lib/mysql/ was present, but obviously the path of my new database share was not.  Once I modified the config file under /etc/apparmor.d/ and restarted apparmor, I was able to start MySQL.

Tagged with:
preload preload preload