Moving MySQL data from the default directory to a different directory/host
By default, MySQL uses /var
for its data storage. /var
directory should be mounted separately on a larger disk. Following are instructions on how to move the /var
directory onto a separate location in case of Unravel bundled MySQL and external MySQL.
Unravel bundled MySQL
Perform a slow shutdown of the MySQL server and ensure that it stops without errors.
Get DB root password from
/root/unravel.install.include
:$ grep 'DB_ROOT_PASSWORD' /root/unravel.install.include or $ grep 'DB_ROOT_PASSWORD' /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
Backup MySQL database folder. In the following case, steps are run to backup
/srv/unravel/db_data
folder.$ cd /srv/unravel $ tar cvf unravel_db_data.tar db_data/
Restore MySQL data directory to the custom path:
cp unravel_db_data.tar
</PATH/TO/NEW/LOCATION>
cd<NEW LOCATION>
tar xvf unravel_db_data.tarIn
/etc/my.cnf
, under the [mysqld] section, update the value ofdata_dir
with the new path;data_dir=
<new_path>
If the host has been moved, update the JDBC properties in
unravel.properties
file.
External MySQL
Note
MySQL user needs to have read/write access to the new path.
Perform a slow shutdown of the MySQL server and ensure 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
/var/lib/mysql/
folder. If you are not using default data path replace /var/lib/mysql/ with the correct path)// Backup /var/lib/mysql/ folder (if not using default data path replace /var/lib/mysql/ with the correct path) $ cd /var/lib $ tar cvf unravel_db_data.tar mysql/
Restore MySQL data directory to the custom path:
cp unravel_db_data.tar </PATH/TO/NEW/SERVER/LOCATION> cd <NEW LOCATION> tar xvf unravel_db_data.tar
Update
/etc/my.cnf
file with the new path of the data directory.If the host has been moved, update JDBC properties in
unravel.properties
file.Install JDBC Driver.
Caution
Enabling a slow shutdown can increase the time to stop MySQL.