Home

Moving MySQL to a custom location

Important

Applicable only to Unravel v4.3.x or before.

Depending on your deployment, follow the steps in one of the sections below.

Note

Whichever move you perform, you must do a slow shutdown (https://dev.mysql.com/doc/refman/8.0/en/glossary.html#glos_slow_shutdown) which increases the time to stop MySQL.

If you need to move MySQL to another host, you need to install MySQL first on the new host. For instructions, see here.

Moving a bundled MySQL

Note

The daemon user must have read/write access to the new path.

  1. Perform a slow shutdown (https://dev.mysql.com/doc/refman/8.0/en/glossary.html#glos_slow_shutdown) of the MySQL server and make sure that it stops without errors.

    1. Get DB root password from /root/unravel.install.include or /root/unravel.install.include.prev.

      The example below uses *.include.

      grep 'DB_ROOT_PASSWORD' { /root/unravel.install.include | /root/unravel.install.include.prev }
    2. Run the following commands to set MySQL clean shutdown.

      /usr/local/unravel/mysql/bin/mysql -uroot --port=3316 --host=127.0.0.1 -p mysql> SET GLOBAL innodb_fast_shutdown=0;
    3. Stop unravel_db daemon.

      /etc/init.d/unravel_db stop
  2. Back up MySQL database folder /srv/unravel/db_data.

    cd /srv/unravel # tar cvf unravel_db_data.tar db_data/ 
  3. Restore MySQL datadir to the custom path. Replace new-db-location with the fully qualified path to the directory you want to place MySQL database.

    cp unravel_db_data.tar new-db-location
    cd new-db-location # tar xvf unravel_db_data.tar
  4. Update unravel.install.include and the MySQL .cnf file:

    1. In /root/unravel.install.include set DB_DATADIR to new-db-location.

    2. In /usr/local/unravel/mysql/unravel_mysql.cnf set both innodb_data_home_dir and innodb_log_group_home_dir to new-db-location .

Moving an external MySQL

Note

The MySQL user must have read/write access to the new path.

  1. Perform a slow shutdown (https://dev.mysql.com/doc/refman/8.0/en/glossary.html#glos_slow_shutdown) of the MySQL server and make sure that it stops without errors.

    1. Run the following commands to set MySQL clean shutdown.

      mysql -uroot -p mysql> SET GLOBAL innodb_fast_shutdown=0;
    2. Stop MySQL daemon.

      service mysqld stop
  2. Backup MySQL database folder /var/lib/mysql.

    cd /var/lib # tar cvf unravel_db_data.tar mysql/ 
  3. Restore MySQL datadir to the custom path. Replace new-db-location with the fully qualified path to the directory you want to place MySQL data base.

    cp unravel_db_data.tar new-db-location
    cd new-db-location
    tar xvf unravel_db_data.tar
  4. Update MySQL cnf file.

    • In /etc/my.cnf set DB_DATADIR to new-db-location.