public
Created

Script to put mysqld on a ram disk in ubuntu 10.04. Runs on every hudson slave boot

  • Download Gist
ramdisk_mysql.sh
Shell
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
sudo cp -r /home/hudson/.ssh /root/;
sudo chown -R root:root /root/.ssh;
 
sudo service mysql stop;
sudo cp -pRL /var/lib/mysql /dev/shm/mysql;
sudo echo "[mysqld]
datadir = /dev/shm/mysql
" > /tmp/ramdisk.cnf;
sudo mv /tmp/ramdisk.cnf /etc/mysql/conf.d/ramdisk.cnf;
sudo echo "
# vim:syntax=apparmor
# Last Modified: Tue Jun 19 17:37:30 2007
#include <tunables/global>
 
/usr/sbin/mysqld {
#include <abstractions/base>
#include <abstractions/nameservice>
#include <abstractions/user-tmp>
#include <abstractions/mysql>
#include <abstractions/winbind>
 
capability dac_override,
capability sys_resource,
capability setgid,
capability setuid,
 
network tcp,
 
/etc/hosts.allow r,
/etc/hosts.deny r,
 
/etc/mysql/*.pem r,
/etc/mysql/conf.d/ r,
/etc/mysql/conf.d/* r,
/etc/mysql/my.cnf r,
/usr/sbin/mysqld mr,
/usr/share/mysql/** r,
/var/log/mysql.log rw,
/var/log/mysql.err rw,
/var/lib/mysql/ r,
/var/lib/mysql/** rwk,
/var/log/mysql/ r,
/var/log/mysql/* rw,
/var/run/mysqld/mysqld.pid w,
/var/run/mysqld/mysqld.sock w,
 
/sys/devices/system/cpu/ r,
/dev/shm/mysql/ r,
/dev/shm/mysql/** rwk,
}
" > /tmp/usr.sbin.mysqld;
sudo mv /tmp/usr.sbin.mysqld /etc/apparmor.d/usr.sbin.mysqld;
sudo service apparmor restart;
sudo service mysql start;

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.