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
| ... | ... |
@@ -83,36 +83,28 @@ function configure_database_mysql {
|
| 83 | 83 |
|
| 84 | 84 |
# Now update ``my.cnf`` for some local needs and restart the mysql service |
| 85 | 85 |
|
| 86 |
- # Change ‘bind-address’ from localhost (127.0.0.1) to any (0.0.0.0) |
|
| 87 |
- sudo sed -i '/^bind-address/s/127.0.0.1/0.0.0.0/g' $MY_CONF |
|
| 86 |
+ # Change ‘bind-address’ from localhost (127.0.0.1) to any (0.0.0.0) and |
|
| 87 |
+ # set default db type to InnoDB |
|
| 88 |
+ sudo bash -c "source $TOP_DIR/functions && \ |
|
| 89 |
+ iniset $MY_CONF mysqld bind-address 0.0.0.0 && \ |
|
| 90 |
+ iniset $MY_CONF mysqld default-storage-engine InnoDB" |
|
| 88 | 91 |
|
| 89 |
- # Set default db type to InnoDB |
|
| 90 |
- if sudo grep -q "default-storage-engine" $MY_CONF; then |
|
| 91 |
- # Change it |
|
| 92 |
- sudo bash -c "source $TOP_DIR/functions; iniset $MY_CONF mysqld default-storage-engine InnoDB" |
|
| 93 |
- else |
|
| 94 |
- # Add it |
|
| 95 |
- sudo sed -i -e "/^\[mysqld\]/ a \ |
|
| 96 |
-default-storage-engine = InnoDB" $MY_CONF |
|
| 97 |
- fi |
|
| 98 | 92 |
|
| 99 | 93 |
if [[ "$DATABASE_QUERY_LOGGING" == "True" ]]; then |
| 100 | 94 |
echo_summary "Enabling MySQL query logging" |
| 101 | 95 |
|
| 102 |
- # Turn on slow query log |
|
| 103 |
- sudo sed -i '/log.slow.queries/d' $MY_CONF |
|
| 104 |
- sudo sed -i -e "/^\[mysqld\]/ a \ |
|
| 105 |
- log-slow-queries = /var/log/mysql/mysql-slow.log" $MY_CONF |
|
| 106 |
- |
|
| 107 |
- # Log all queries (any query taking longer than 0 seconds) |
|
| 108 |
- sudo sed -i '/long.query.time/d' $MY_CONF |
|
| 109 |
- sudo sed -i -e "/^\[mysqld\]/ a \ |
|
| 110 |
- long-query-time = 0" $MY_CONF |
|
| 111 |
- |
|
| 112 |
- # Log all non-indexed queries |
|
| 113 |
- sudo sed -i '/log.queries.not.using.indexes/d' $MY_CONF |
|
| 114 |
- sudo sed -i -e "/^\[mysqld\]/ a \ |
|
| 115 |
- log-queries-not-using-indexes" $MY_CONF |
|
| 96 |
+ sudo sed -e '/log.slow.queries/d' \ |
|
| 97 |
+ -e '/long.query.time/d' \ |
|
| 98 |
+ -e '/log.queries.not.using.indexes/d' \ |
|
| 99 |
+ -i $MY_CONF |
|
| 100 |
+ |
|
| 101 |
+ # Turn on slow query log, log all queries (any query taking longer than |
|
| 102 |
+ # 0 seconds) and log all non-indexed queries |
|
| 103 |
+ sudo bash -c "source $TOP_DIR/functions && \ |
|
| 104 |
+ iniset $MY_CONF mysqld slow-query-log 1 && \ |
|
| 105 |
+ iniset $MY_CONF mysqld slow-query-log-file /var/log/mysql/mysql-slow.log && \ |
|
| 106 |
+ iniset $MY_CONF mysqld long-query-time 0 && \ |
|
| 107 |
+ iniset $MY_CONF mysqld log-queries-not-using-indexes 1" |
|
| 116 | 108 |
|
| 117 | 109 |
fi |
| 118 | 110 |
|