KB10026 How to manually change the location of vProtect database

📚

Documentation

Installation guides, configuration steps, and product documentation.

Explore documentation →

🎧

Support

Create a support request or review your existing cases.

Go to support →

⬇️

Download trial

Download the product trial and try it out.

View downloads →

KB10026 How to manually change the location of vProtect database

KB ID: 10026

Product: vProtect

Version: not applicable

Published: 2021-02-26

Last modified: 2021-02-26

Problem

How to manually change the location of vProtect database from local hard drive to another hard drive

 

example:

The database is located in the default location and you would like to move it to a different disk or directory

Solution

 

Check the location of the database

mysql -u root -p

[root@vprotect /]# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 91
Server version: 10.4.18-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.


MariaDB [(none)]> select @@datadir;
+-----------------+
| @@datadir |
+-----------------+
| /var/lib/mysql/ |
+-----------------+
1 row in set (0.000 sec)
MariaDB [(none)]> exit

 

Prepare the new location for the database (in this case /Database)

lsblk

[root@vprotect /]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 80G 0 disk
├─sda1 8:1 0 600M 0 part /boot/efi
├─sda2 8:2 0 1G 0 part /boot
└─sda3 8:3 0 78.4G 0 part
├─cl-root 253:0 0 47.4G 0 lvm /
├─cl-swap 253:1 0 7.9G 0 lvm [SWAP]
└─cl-home 253:2 0 23.1G 0 lvm /home
sdb 8:16 0 500G 0 disk
└─sdb1 8:17 0 500G 0 part /vprotect_data
sdc 8:32 0 40G 0 disk
└─sdc1 8:33 0 40G 0 part /Database

[root@vprotect ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 3.8G 0 3.8G 0% /dev
tmpfs 3.8G 0 3.8G 0% /dev/shm
tmpfs 3.8G 8.7M 3.8G 1% /run
tmpfs 3.8G 0 3.8G 0% /sys/fs/cgroup
/dev/mapper/cl-root 48G 7.9G 40G 17% /
/dev/sda2 1014M 248M 767M 25% /boot
/dev/sda1 599M 6.9M 592M 2% /boot/efi
/dev/mapper/cl-home 24G 198M 23G 1% /home
tmpfs 777M 0 777M 0% /run/user/0
/dev/sdc1 40G 517M 40G 2% /Database

 

Stop vprotect-server and mariadb services

systemctl stop vprotect-server.service

[root@vprotect ~]# systemctl stop vprotect-server.service

[root@vprotect ~]# systemctl stop mariadb.service

[root@vprotect ~]# systemctl status vprotect-server.service

[root@vprotect ~]# systemctl status mariadb.service

...

Feb 26 13:58:48 vprotect systemd[1]: Stopped MariaDB 10.4.18 database server.

...

Feb 26 14:01:51 vprotect systemd[1]: Stopped vProtect Server.

Copy the database to the new location using rsync with "a" and "v" flags

rsync -av

[root@vprotect ~]# rsync -av /var/lib/mysql /Database

...

sent 207,798,673 bytes received 5,310 bytes 27,707,197.73 bytes/sec
total size is 207,728,475 speedup is 1.00

Redirect the location of database to the new directory

vim /etc/my.cnf

[root@vprotect ~]# vim /etc/my.cnf

[mysqld]
datadir=/Database/mysql
socket=/Database/mysql/mysql.sock

[client]
port=3306
socket=/Database/mysql/mysql.sock

Run database and vprotect-server services

systemctl stop vprotect-server.service

[root@vprotect ~]# systemctl start mariadb.service

[root@vprotect ~]# systemctl start vprotect-server.service

[root@vprotect ~]# systemctl status vprotect-server.service

[root@vprotect ~]# systemctl status mariadb.service

...

Feb 26 14:41:20 vprotect systemd[1]: Started MariaDB 10.4.18 database server.

...

Feb 26 14:43:00 vprotect api_start.sh[2986]: vProtect Server started

Check the location of the database

mysql -u root -p

[root@vprotect ~]# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 25
Server version: 10.4.18-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> select @@datadir;
+------------------+
| @@datadir |
+------------------+
| /Database/mysql/ |
+------------------+
1 row in set (0.000 sec)

MariaDB [(none)]> exit