Use iniset for changing my.conf and avoid deprecated config options
The mysql config file is using INI format so use the iniset function to manipulate it. This change also rearranges the config updates a bit allowing us to make mulitple changes in a single sudo call. This reduces the number of required process forks, and the number of times the 'functions' file needs to be sourced a bit. The "log-slow-queries" option is deprecated since mysql 5.1.29 and got removed with 5.6.x. Use the newer slow-query-log-file/slow-query-log settings instead. They are available since 5.1.12. This fixes a problem with running devstack with mysql-5.6, which is e.g. part of openSUSE 13.1. Change-Id: Iea28bf05c664b5387d51dae1a63a780344623596
This commit is contained in:
parent
4b49e37240
commit
0526bb8222
@ -83,36 +83,28 @@ function configure_database_mysql {
|
||||
|
||||
# Now update ``my.cnf`` for some local needs and restart the mysql service
|
||||
|
||||
# Change ‘bind-address’ from localhost (127.0.0.1) to any (0.0.0.0)
|
||||
sudo sed -i '/^bind-address/s/127.0.0.1/0.0.0.0/g' $MY_CONF
|
||||
# Change ‘bind-address’ from localhost (127.0.0.1) to any (0.0.0.0) and
|
||||
# set default db type to InnoDB
|
||||
sudo bash -c "source $TOP_DIR/functions && \
|
||||
iniset $MY_CONF mysqld bind-address 0.0.0.0 && \
|
||||
iniset $MY_CONF mysqld default-storage-engine InnoDB"
|
||||
|
||||
# Set default db type to InnoDB
|
||||
if sudo grep -q "default-storage-engine" $MY_CONF; then
|
||||
# Change it
|
||||
sudo bash -c "source $TOP_DIR/functions; iniset $MY_CONF mysqld default-storage-engine InnoDB"
|
||||
else
|
||||
# Add it
|
||||
sudo sed -i -e "/^\[mysqld\]/ a \
|
||||
default-storage-engine = InnoDB" $MY_CONF
|
||||
fi
|
||||
|
||||
if [[ "$DATABASE_QUERY_LOGGING" == "True" ]]; then
|
||||
echo_summary "Enabling MySQL query logging"
|
||||
|
||||
# Turn on slow query log
|
||||
sudo sed -i '/log.slow.queries/d' $MY_CONF
|
||||
sudo sed -i -e "/^\[mysqld\]/ a \
|
||||
log-slow-queries = /var/log/mysql/mysql-slow.log" $MY_CONF
|
||||
sudo sed -e '/log.slow.queries/d' \
|
||||
-e '/long.query.time/d' \
|
||||
-e '/log.queries.not.using.indexes/d' \
|
||||
-i $MY_CONF
|
||||
|
||||
# Log all queries (any query taking longer than 0 seconds)
|
||||
sudo sed -i '/long.query.time/d' $MY_CONF
|
||||
sudo sed -i -e "/^\[mysqld\]/ a \
|
||||
long-query-time = 0" $MY_CONF
|
||||
|
||||
# Log all non-indexed queries
|
||||
sudo sed -i '/log.queries.not.using.indexes/d' $MY_CONF
|
||||
sudo sed -i -e "/^\[mysqld\]/ a \
|
||||
log-queries-not-using-indexes" $MY_CONF
|
||||
# Turn on slow query log, log all queries (any query taking longer than
|
||||
# 0 seconds) and log all non-indexed queries
|
||||
sudo bash -c "source $TOP_DIR/functions && \
|
||||
iniset $MY_CONF mysqld slow-query-log 1 && \
|
||||
iniset $MY_CONF mysqld slow-query-log-file /var/log/mysql/mysql-slow.log && \
|
||||
iniset $MY_CONF mysqld long-query-time 0 && \
|
||||
iniset $MY_CONF mysqld log-queries-not-using-indexes 1"
|
||||
|
||||
fi
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user