adding mysql flavor (untested)

This commit is contained in:
Devananda van der Veen 2012-11-12 16:49:27 -08:00
parent 823e18fda2
commit ffab3354ca
11 changed files with 175 additions and 0 deletions

3
flavours/mysql/README.md Normal file
View File

@ -0,0 +1,3 @@
Sets up a MySQL server install in the image.
TODO: auto-tune settings based on host resources or metadata service.

View File

@ -0,0 +1,5 @@
#!/bin/bash
set -e
set -o xtrace
sed -i -r 's/^\s*#(net\.ipv4\.ip_forward=1.*)/\1/' /etc/sysctl.conf
echo 1 > /proc/sys/net/ipv4/ip_forward

View File

@ -0,0 +1,11 @@
#!/bin/bash
ntpfile=`mktemp`
cat << EOF > $ntpfile
server ntp.ubuntu.com iburst
server 127.127.1.0
fudge 127.127.1.0 stratum 10
EOF
mv /etc/ntp.conf /etc/ntp.conf.orig
mv $ntpfile /etc/ntp.conf
service ntp restart

View File

@ -0,0 +1,24 @@
#!/bin/bash
set -e
set -o xtrace
# get MYSQL_PASS and HOST_IP
source $(dirname $0)/defaults
service mysql stop || true
MYSQL_BOOTSTRAP="/usr/sbin/mysqld --bootstrap --user=mysql --skip-grant-tables"
sqltfile=`mktemp`
cat <<EOF > $sqltfile
USE mysql;
UPDATE user SET password=PASSWORD("$MYSQL_PASS") WHERE user='root';
EOF
$MYSQL_BOOTSTRAP < $sqltfile
rm -f $sqltfile
CNF=/etc/mysql/my.cnf
cp -f $(dirname $0)/my.cnf $CNF
sed -i "s/^bind-address=.*/bind-address=$HOST_IP/" $CNF
service mysql start

View File

@ -0,0 +1,15 @@
set -e
MYSQL_PASS=${MYSQL_PASS:-password}
# HOST_IP
# Find the interface used for the default route
HOST_IP_IFACE=${HOST_IP_IFACE:-$(ip route | sed -n '/^default/{ s/.*dev \(\w\+\)\s\+.*/\1/; p; }')}
# Search for an IP unless an explicit is set by ``HOST_IP`` environment variable
HOST_IP=`LC_ALL=C ip -f inet addr show ${HOST_IP_IFACE} | awk '/inet/ {split($2,parts,"/"); print parts[1]}'`
# XXX: get all these from metadata service eventually
IB_BUF_POOL=100M
IB_LOG_FILE_SIZE=10M

View File

@ -0,0 +1,63 @@
[mysql]
port = 3306
socket = /var/lib/mysql/data/mysql.sock
[mysqld]
# GENERAL #
user = mysql
default_storage_engine = InnoDB
socket = /var/lib/mysql/data/mysql.sock
pid_file = /var/lib/mysql/data/mysql.pid
bind-address = 0.0.0.0
# MyISAM #
key_buffer_size = 32M
myisam_recover = FORCE,BACKUP
# SAFETY #
max_allowed_packet = 16M
max_connect_errors = 1000000
skip_name_resolve
sql_mode = STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_AUTO_VALUE_ON_ZERO,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE,ONLY_FULL_GROUP_BY
sysdate_is_now = 1
innodb = FORCE
innodb_strict_mode = 1
# DATA STORAGE #
datadir = /var/lib/mysql/data/
# CACHES AND LIMITS #
tmp_table_size = 32M
max_heap_table_size = 32M
query_cache_type = 0
query_cache_size = 0
max_connections = 500
thread_cache_size = 50
open_files_limit = 65535
table_definition_cache = 4096
table_open_cache = 4096
# INNODB #
innodb_flush_method = O_DIRECT
innodb_log_files_in_group = 2
innodb_log_file_size = 64M
innodb_flush_log_at_trx_commit = 2
innodb_file_per_table = 1
innodb_buffer_pool_size = 592M
# TODO
# innodb_read_io_threads
# innodb_write_io_threads
# LOGGING #
log_error = /var/lib/mysql/data/mysql-error.log
log_queries_not_using_indexes = 1
slow_query_log = 1
slow_query_log_file = /var/lib/mysql/data/mysql-slow.log
server_id = 1
log_bin = /var/lib/mysql/data/mysql-bin
expire_logs_days = 7
max_binlog_size = 100M
binlog_format = ROW

View File

@ -0,0 +1,9 @@
#!/bin/sh
# Install controller base requiered packages
set -e
set -o xtrace
#DEBIAN_FRONTEND=noninteractive apt-get -y install sysstat mytop percona-toolkit percona-server-server-5.5 percona-server-client-5.5
DEBIAN_FRONTEND=noninteractive apt-get -y install sysstat mytop percona-toolkit mysql-server-5.5 mysql-client-5.5

View File

@ -0,0 +1,12 @@
#!/bin/bash
# Add the stack user we recommend folk use.
set -e
set -o xtrace
useradd -G admin -m stack -s /bin/bash
passwd stack <<EOF
stack
stack
EOF

View File

@ -0,0 +1,7 @@
#!/bin/bash
# Install the haveged daemon so ssh config on startup isn't glacial.
set -e
set -o xtrace
apt-get -y install haveged

View File

@ -0,0 +1,10 @@
#!/bin/sh
# Build iscsi modules with installed kernel
set -e
set -o xtrace
apt-get clean

View File

@ -0,0 +1,16 @@
#!/bin/sh
set -e
set -o xtrace
# add Percona GPG key
#gpg --keyserver hkp://keys.gnupg.net --recv-keys 1C4CBDCDCD2EFD2A
#gpg -a --export CD2EFD2A | apt-key add -
# add Percona repo
# XXX: autodetect distribution when Percona supports Quantal
#VER='precise'
#cat <<EOL > /etc/apt/sources.list.d/percona
#deb http://repo.percona.com/apt $VER main
#deb-src http://repo.percona.com/apt $VER main
#EOL