• Please be aware: Kaspersky Anti-Virus has been deprecated
    With the upgrade to Plesk Obsidian 18.0.64, "Kaspersky Anti-Virus for Servers" will be automatically removed from the servers it is installed on. We recommend that you migrate to Sophos Anti-Virus for Servers.
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

Question MySQL on another path (same server diffent raid)

Filmica

New Pleskian
Hello,
please I would have a suggestion about a new next plesk installation, because I'm newbie.
I explain my question.
I've a server metal with 3 raid systems on it, 1 Raid-0 for the S.O. and 2 Raid-5 as storage.
Is there a method to change the default MySQL path during the installation via terminal, for example, from disk sda to disk sdb?
Because seems that after I have installed the server, the paths cannot be altered without removing and reinstalling the server instance.
Thank you in advance for any kindle reply.
Best
Mike
 
So you would like your MySQL databases to reside on one of the RAID-5 arrays, instead of the RAID-0 on which they are now?

Can you please post how is your server partitioned?

Code:
parted -l
df -h
 
Thank you for your reply.
Yes, correct. I would like that my MySQL database to reside in one of the RAID-5 array instead of the RAID-0.

Code:
parted -l
returns me:

Model: IBM ServeRAID M5015 (scsi)
Disk /dev/sda: 747GB
Sector size (logical/physical): 512B/512B
Partition Table: loop
Disk Flags:

Number  Start  End    Size   File system  Flags
 1      0.00B  747GB  747GB  ext4


Model: IBM ServeRAID M5015 (scsi)
Disk /dev/sdb: 1245GB
Sector size (logical/physical): 512B/512B
Partition Table: loop
Disk Flags:

Number  Start  End     Size    File system  Flags
 1      0.00B  1245GB  1245GB  ext4


Model: IBM ServeRAID M5015 (scsi)
Disk /dev/sdc: 119GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start   End    Size   File system  Name  Flags
 1      1049kB  538MB  537MB  fat32              boot, esp
 2      538MB   119GB  118GB  ext4

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

df -h

Filesystem      Size  Used Avail Use% Mounted on
udev             63G     0   63G   0% /dev
tmpfs            13G  1.5M   13G   1% /run
/dev/sdc2       109G   16G   88G  15% /
tmpfs            63G     0   63G   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs            63G     0   63G   0% /sys/fs/cgroup
/dev/sdb        1.2T   77M  1.1T   1% /media/webB
/dev/sda        684G   73M  649G   1% /media/webA
/dev/sdc1       511M  6.1M  505M   2% /boot/efi
/dev/loop2       89M   89M     0 100% /snap/core/7396
/dev/loop1       90M   90M     0 100% /snap/core/7713
tmpfs            13G     0   13G   0% /run/user/1000
 
In short, default MySQL path can't be changed during the Plesk installation, but there are other ways to achieve what you want.

First, you could mount a partition (doesn't have to be the entire RAID array) from one of the RAID-5 arrays as /var/lib/mysql. This would be a sound choice.

Second, you could change the server configuration to look for MySQL databases in another directory. But I believe Plesk is reluctant to support changing the MySQL data location on linux because this was known to cause various issues in the past.

Third, you could change /var/lib/mysql to be a symlink to another directory. This approach would require more research, I'd look for Plesk related issues reported in the past.

BTW, which OS (and version) are you using? Do you have AppArmor or SELinux active?

How did you plan to use /media/webA and /media/webB?

How about /var/www/vhosts and /var/qmail, is it OK if they stay on RAID-0 array? The former location contains web site files, the latter contains email contents.
 
Ok I think to have understood the problem.
The OS is Ubuntu 18.04 LTS with AppArmor.
My initial idea was to use RAID-0 array only for SO and /media/webB for hosting service and /media/webA for backups. The same with /var/www/vhosts and /var/qmail, I would stay into the /media/webB with all account folders. But at this point, maybe, the best solutions is to use only the RAID-5 arrays for SO and backups (/media/webB for SO and /var/www/vhosts and /var/qmail; /media/webA for backups) in my opinion.
 
hello,

you can (re-)define path for DB files in MySQL/MariaDB config file. It should be something like:

[mysqld]
#
# * Basic Settings
#
datadir = /var/lib/mysql



to change mysql data location you should
1. stop all services that can try reach DB.
2. stop mysql server
3. copy existing data with all permissions to the new path, something like
rsync -av /var/lib/mysql/ /media/webA/mysql/

change datadir in config to "datadir = /media/webA/mysql"; save changes
4. start mysql server

if you have everything done correctly - mysql will be started successfully and you will be able to connect to it.
in mysql you can check current datadir by the command
> show variables like '%datadir%';
+---------------+-----------------+
| Variable_name | Value |
+---------------+-----------------+
| datadir | /var/lib/mysql/ |
+---------------+-----------------+

5. start all services that were stopped at step (1), or simply reboot the server
 
Hi Nik,

The above steps are not enough for latest Plesk Obsidian Version 18.0.62 which is running on AlmaLinux 8.10. With a normal server which is not having plesk panel, above steps are enough. But with latest panel, the above steps are not enough. With the above steps, mysql service will come up, but plesk panel will start throwing database errors. The database connections via websites will also wont work. Plesk panel still looks for /var/lib/mysql/mysql.sock. file hence the issues. I have followed the below steps and was able to make this working.

In my case i was trying to move data directory from "/var/lib/mysql" to "/home/MYSQL_DATA/" as root partion was not having enough space and databases in the server was fast growing. I had 8TB partition for /home/.

1. Take necessary backups of mysql databases so that if some thing goes wrong, we can restore data using the same. You can refer below link


Stop Mysql / Mariadb service. In mycase it was mariadb.

service mariadb stop

2. Copy mysql data directory to new location
cp -pr /var/lib/mysql /home/MYSQL_DATA/
chown -R mysql.mysql /home/MYSQL_DATA/

4. Move existing /var/lib/mysql

mv /var/lib/mysql /var/lib/mysql _bak

5. Edit my.cnf loaded, update the below parameter, Important note:- socket=/var/lib/mysql/mysql.sock this should remain unchanged. In normal procedure
socket paramer can also be changed.

datadir=/home/MYSQL_DATA/

6. Recrate /var/lib/mysql as plesk looks for the same and changing the path to the socket can cause the Plesk to crash. Just folder is enough, we just it for creation of socket file during start process of service.

mkdir /var/lib/mysql

7. Update the system demon configuration file for mysql / mariadb service. We have to update ExecStart parameter with new data directory path.

edit file /usr/lib/systemd/system/mariadb.service
ExecStart=/usr/libexec/mysqld --basedir=/usr $MYSQLD_OPTS $_WSREP_NEW_CLUSTER
To
ExecStart=/usr/libexec/mysqld --datadir=/home/MYSQL_DATA/mysql --basedir=/usr $MYSQLD_OPTS $_WSREP_NEW_CLUSTER
systemctl daemon-reload

8. Create a backup of /etc/passwd and change mysql users home directory.

mysql:x:27:27:MariaDB Server:/home/MYSQL_DATA:/sbin/nologin

9. Update /etc/psa/psa.conf with a path to the new mysql directory, so that plesk understands the new path. Change MYSQL_VAR_D from /var/lib/mysql to below. Important note:- socket MYSQL_SOCKET should remain unchanged.

MYSQL_VAR_D /home/MYSQL_DATA/mysql

10. For Almal linux, SeLinux should be disabled.

11. Start the Mysql / Mariadb service.

service mariadb restart

I was able to make the mysql data directory move with the above step of steps. All worked perfect.
 
Back
Top