Fix MariaDB for ubuntu

In MariaDB we adjust the dependecies of what we install there as well
adding only what is appropriate for the install.

In Ansible we adjust some templates to all work around differences
between the different Linux families.

Change-Id: Ibc26e2f4d4a732630632d3ed27fb595b6fe019d2
Partially-Implements: blueprint install-from-ubuntu
This commit is contained in:
Sam Yaple 2015-08-20 14:32:34 +00:00
parent 91088e595f
commit 8f7ff27779
3 changed files with 14 additions and 53 deletions

View File

@ -1,3 +1,4 @@
{% set wsrep_driver = '/usr/lib/galera/libgalera_smm.so' if kolla_base_distro == 'ubuntu' else '/usr/lib64/galera/libgalera_smm.so' %}
[mysqld]
bind-address={{ hostvars[inventory_hostname]['ansible_' + api_interface]['ipv4']['address'] }}
port={{ mariadb_port }}
@ -13,7 +14,7 @@ wsrep_provider_options="gmcast.listen_addr=tcp://{{ hostvars[inventory_hostname]
wsrep_node_address={{ hostvars[inventory_hostname]['ansible_' + api_interface]['ipv4']['address'] }}:{{ mariadb_wsrep_port }}
wsrep_sst_receive_address={{ hostvars[inventory_hostname]['ansible_' + api_interface]['ipv4']['address'] }}:{{ mariadb_sst_port }}
wsrep_provider=/usr/lib64/galera/libgalera_smm.so
wsrep_provider={{ wsrep_driver }}
wsrep_cluster_name="{{ database_cluster_name }}"
wsrep_node_name={{ ansible_hostname }}
wsrep_sst_method=xtrabackup-v2

View File

@ -1,27 +1,5 @@
#!/bin/bash
function configure_files {
crudini --set $CFG mariadb bind-address "${DB_CLUSTER_BIND_ADDRESS}"
crudini --set $CFG mariadb binlog_format "ROW"
crudini --set $CFG mariadb character-set-server "utf8"
crudini --set $CFG mariadb collation-server "utf8_general_ci"
crudini --set $CFG mariadb datadir "/var/lib/mysql"
crudini --set $CFG mariadb default-storage-engine "innodb"
crudini --set $CFG mariadb init-connect "'SET NAMES utf8'"
crudini --set $CFG mariadb innodb_autoinc_lock_mode "2"
crudini --set $CFG mariadb innodb_file_per_table 1
crudini --set $CFG mariadb innodb_flush_log_at_trx_commit "2"
crudini --set $CFG mariadb innodb_locks_unsafe_for_binlog "1"
crudini --set $CFG mariadb innodb_log_file_size "100M"
crudini --set $CFG mariadb query_cache_size "0"
crudini --set $CFG mariadb query_cache_type "0"
crudini --set $CFG mariadb wsrep_cluster_address "gcomm://${DB_CLUSTER_NODES}"
crudini --set $CFG mariadb wsrep_cluster_name "${DB_CLUSTER_NAME}"
crudini --set $CFG mariadb wsrep_provider "/usr/lib64/galera/libgalera_smm.so"
crudini --set $CFG mariadb wsrep_sst_auth "'root:${DB_ROOT_PASSWORD}'"
crudini --set $CFG mariadb wsrep_sst_method "${DB_CLUSTER_WSREP_METHOD}"
}
function bootstrap_db {
mysqld_safe --wsrep-new-cluster &
@ -53,33 +31,7 @@ function bootstrap_db {
mysqladmin -p"${DB_ROOT_PASSWORD}" shutdown
}
function configure_db {
bootstrap_db
echo "GRANT ALL ON *.* TO 'root'@'%' IDENTIFIED BY '$DB_ROOT_PASSWORD' ;" > $DB_CLUSTER_INIT_SQL
if [ "$MARIADB_DATABASE" ]; then
echo "CREATE DATABASE IF NOT EXISTS $MARIADB_DATABASE ;" >> $DB_CLUSTER_INIT_SQL
fi
if [ "$MARIADB_USER" -a "$MARIADB_PASSWORD" ]; then
echo "CREATE USER '$MARIADB_USER'@'%' IDENTIFIED BY '$MARIADB_PASSWORD' ;" >> $DB_CLUSTER_INIT_SQL
if [ "$MARIADB_DATABASE" ]; then
echo "GRANT ALL ON $MARIADB_DATABASE.* TO '$MARIADB_USER'@'%' ;" >> $DB_CLUSTER_INIT_SQL
fi
fi
echo "FLUSH PRIVILEGES" >> $DB_CLUSTER_INIT_SQL
}
function populate_db {
mysql_install_db
chown -R mysql: /var/lib/mysql
}
function prepare_db {
populate_db
configure_db
configure_files
}

View File

@ -26,10 +26,18 @@ RUN yum install -y http://www.percona.com/redir/downloads/percona-release/redhat
{% elif base_distro in ['ubuntu', 'debian'] %}
RUN ["/bin/false"]
# TODO(sdake) when ubuntu support is implemented we will need a line
# && rm -rf /var/lib/mysql/
# At the end of this run statement we symlink two folders to match the folder
# structure of the RPM family for mysql configs. This allows us to not change
# the config-external.sh code
# TODO(SamYaple): Remove that symlink once config-external is updated
RUN apt-get install -y --no-install-recommends \
mariadb-galera-server \
percona-xtrabackup \
socat \
expect \
&& apt-get clean \
&& rm -rf /var/lib/mysql/* \
&& ln -s /etc/mysql/conf.d/ /etc/my.cnf.d
{% endif %}