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.
If you're using Unravel bundled MySQL, see Move a Bundled MySQL.
If you're using an external MySQL, see Move an External MySQL.
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.
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.
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 }
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;
Stop
unravel_db
daemon./etc/init.d/unravel_db stop
Back up MySQL database folder
/srv/unravel/db_data
.cd /srv/unravel # tar cvf unravel_db_data.tar db_data/
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
cdnew-db-location
# tar xvf unravel_db_data.tarUpdate
unravel.install.include
and the MySQL.cnf
file:In
/root/unravel.install.include
set DB_DATADIR tonew-db-location
.In
/usr/local/unravel/mysql/unravel_mysql.cnf
set bothinnodb_data_home_dir
andinnodb_log_group_home_dir
tonew-db-location
.
Moving an external MySQL
Note
The MySQL user must have read/write access to the new path.
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.
Run the following commands to set MySQL clean shutdown.
mysql -uroot -p mysql> SET GLOBAL innodb_fast_shutdown=0;
Stop MySQL daemon.
service mysqld stop
Backup MySQL database folder /var/lib/mysql.
cd /var/lib # tar cvf unravel_db_data.tar mysql/
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
cdnew-db-location
tar xvf unravel_db_data.tarUpdate MySQL cnf file.
In
/etc/my.cnf
set DB_DATADIR tonew-db-location
.