Article ID: 111149, created on Apr 18, 2011, last review on Oct 23, 2014

  • Applies to:
  • Plesk Expand


Parallels Plesk Expand sometimes responds very slowly on operations in Control Panel.


MySQLdatabase (/var/lib/mysql/ibdata1) is very large and Expand is slow on some operations.


Most of the space in the database is taken up by log records for CMail/CDNS synchronizations and task logs, which are stored in the database. In order to conserve space, the database needs to be shrunk and Expand settings on a number of stored log entries adjusted.

The best way to shrink the database and avoid fragmentation of InnoDB data is to re-create MySQL data storage from scratch.

1.Stop Expand:

/etc/init.d/expand stop
/etc/init.d/sw-cp-server stop

2.Create a working directory and go there:

mkdir /root/db_backup
cd /root/db_backup

3.Save all tables except for large ones with tasks and logs:

/usr/local/expand/sbin/expandmysql -Ns -e"SHOW TABLES" | grep -vE 'cdns_attempt|cdns_activity_log$|cmail_attempt|cmail_activity_log|tm_action|tm_task' | while read tbl ; do
     echo === $tbl ;
     mysqldump -uexpand -p`cat /usr/local/expand/etc/.expand.shadow` --quote-names --add-drop-table --extended-insert expand $tbl > $tbl.sql

4.Save the structure of previously omitted tables:

for tbl in cdns_attempt cdns_activity_log cmail_attempt cmail_activity_log tm_action ; do
     mysqldump -uexpand -p`cat /usr/local/expand/etc/.expand.shadow` --quote-names --add-drop-table --no-data expand $tbl > $tbl.sql

5.Save only periodic tasks from tm_task:

mysqldump -uexpand -p`cat /usr/local/expand/etc/.expand.shadow` --quote-names --add-drop-table --where="period <> 0" expand tm_task > tm_task.sql

6.Backup the MySQL database:

mysqldump -uexpand -p`cat /usr/local/expand/etc/.expand.shadow` --databases mysql > /root/mysql.sql

7.Re-initialize MySQL data storage from scratch:

/etc/init.d/mysqld stop
 mv /var/lib/mysql /var/lib/
 mkdir /var/lib/mysql
 chown -R mysql:mysql /var/lib/mysql
 /etc/init.d/mysqld start

8.Restore the MySQL database and create the Expand database:

cat /root/mysql.sql | mysql
 mysql -e"CREATE DATABASE expand"

9.Restart MySQL to apply the new security settings:

/etc/init.d/mysqld restart

10.Prepare the header file for import. It is required to disable the foreign keys check:

echo "SET FOREIGN_KEY_CHECKS=0;" > 00_disable_fkeys

11.Import all tables:

for tbl in *.sql ; do
 echo === $tbl ;
     cat 00_disable_fkeys $tbl | /usr/local/expand/sbin/expandmysql

12.Reduce "max_activity_logs" and "keep_attempts" parameters in "expand.conf":

sed -i~ -e '/keep_attempts/{s/=.*/= 2/}' -e '/max_activity_logs/{s/=.*/= 200/}' /usr/local/expand/conf/expand.conf

13.Start Expand:

/etc/init.d/sw-cp-server start
/etc/init.d/expand start

8760abb54be64bdc3c8805b6572624e8 56797cefb1efc9130f7c48a7d1db0f0c

Email subscription for changes to this article
Save as PDF