From 72534d6eba250b95d4d7d8c843904e83a647aa55 Mon Sep 17 00:00:00 2001 From: Clint Byrum Date: Thu, 21 Mar 2013 16:20:32 -0700 Subject: [PATCH] Refactor mysql element to do less in first-boot.d We didn't need to do most of this anyway, we just needed to configure mysql before we installed the packages in the image. Some of the other things were half-baked ideas which will come in later changes to add os-refresh-config and os-config-applier support to the element. Change-Id: Ib1b66a8b3b70fac10f3f826b1efd414c67f9bfc6 --- elements/mysql/first-boot.d/50-mysql | 29 ------------------- elements/mysql/first-boot.d/defaults | 15 ---------- elements/mysql/install.d/10-mysql | 3 +- .../mysql/{first-boot.d => install.d}/my.cnf | 4 ++- 4 files changed, 5 insertions(+), 46 deletions(-) delete mode 100755 elements/mysql/first-boot.d/50-mysql delete mode 100644 elements/mysql/first-boot.d/defaults rename elements/mysql/{first-boot.d => install.d}/my.cnf (94%) diff --git a/elements/mysql/first-boot.d/50-mysql b/elements/mysql/first-boot.d/50-mysql deleted file mode 100755 index 1f188571..00000000 --- a/elements/mysql/first-boot.d/50-mysql +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash -set -uex - -CNF=/etc/mysql/my.cnf -cp -f $(dirname $0)/my.cnf $CNF -sed -i "s/^bind-address=.*/bind-address=0.0.0.0/" $CNF - -D_SYS_MAINT="--defaults-file=/etc/mysql/debian.cnf" - -# Since we will be clearing out ib_*, make sure there aren't any innodb tables. -if mysqladmin $D_SYS_MAINT ping ; then - innodb_tables=$(mysql $D_SYS_MAINT -N -e "SELECT count(*) FROM information_schema.TABLES WHERE ENGINE LIKE 'InnoDB'") - if [ -n "$innodb_tables" -a $innodb_tables -gt 0 ] ; then - echo Found $innodb_tables InnoDB tables. Any existing data may be lost. ABORT! - exit 1 - fi - service mysql stop -fi - - -# The new my.cnf may not jive with default innodb sizes, so just backup and clear out ib files -if [ -n "$(ls /var/lib/mysql/ib_*)" ] ; then - BACKUP_DIR=/var/backups/mysql-$(date +%Y%m%d%H%M%S) - mkdir -p $BACKUP_DIR - chmod 700 $BACKUP_DIR - mv -f /var/lib/mysql/ib_* $BACKUP_DIR -fi - -service mysql start diff --git a/elements/mysql/first-boot.d/defaults b/elements/mysql/first-boot.d/defaults deleted file mode 100644 index 2c497d00..00000000 --- a/elements/mysql/first-boot.d/defaults +++ /dev/null @@ -1,15 +0,0 @@ -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 - diff --git a/elements/mysql/install.d/10-mysql b/elements/mysql/install.d/10-mysql index 4f7f6e58..4bb3d474 100755 --- a/elements/mysql/install.d/10-mysql +++ b/elements/mysql/install.d/10-mysql @@ -5,5 +5,6 @@ set -e set -o xtrace -#install-packages sysstat mytop percona-toolkit percona-server-server-5.5 percona-server-client-5.5 +install -D -m 0644 -o root -g root $(dirname $0)/my.cnf /etc/mysql/my.cnf + install-packages sysstat mytop percona-toolkit mysql-server-5.5 mysql-client-5.5 diff --git a/elements/mysql/first-boot.d/my.cnf b/elements/mysql/install.d/my.cnf similarity index 94% rename from elements/mysql/first-boot.d/my.cnf rename to elements/mysql/install.d/my.cnf index 6ca4bd4b..f47947e4 100644 --- a/elements/mysql/first-boot.d/my.cnf +++ b/elements/mysql/install.d/my.cnf @@ -56,8 +56,10 @@ log_queries_not_using_indexes = 1 slow_query_log = 1 slow_query_log_file = /var/log/mysql/mysql-slow.log -server_id = 1 +# server_id set in /etc/mysql/conf.d/server_id.cnf +# server_id = 1 log_bin = /var/lib/mysql/mysql-bin expire_logs_days = 7 max_binlog_size = 100M binlog_format = ROW +!includedir /etc/mysql/conf.d/