Mysql and moving the data directory.

Associate
Joined
10 Nov 2004
Posts
2,237
Location
Expat in Singapore
Hi,

I am building a mysql server and have a second set of disks for the database data area. The disks are partitioned and mounted on the fs as /database.

I then followed one of the many guides on moving the data;

Code:
service mysqld stop
cp -rv /var/lib/mysql /database
chown -R mysql:mysql/database
vi /etc/my.cnf
paste;

[mysqld]
 user = mysql
 datadir = /database/mysql
 port = 3306
 socket = /var/lib/mysql/mysql.sock
 pid-file = /var/run/mysqld/mysqld.pid
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

:wq (save and exit)

service mysqld start

Now when trying to start I get the following in the log files;

120217 06:52:08 mysqld_safe Starting mysqld daemon with databases from /database/mysql
120217 6:52:08 [Warning] Can't create test file /database/mysql/localhost.lower-test
120217 6:52:08 [Warning] Can't create test file /database/mysql/localhost.lower-test
/usr/libexec/mysqld: Can't change dir to '/database/mysql/' (Errcode: 13)
120217 6:52:08 [ERROR] Aborting
120217 6:52:08 [Note] /usr/libexec/mysqld: Shutdown complete
120217 06:52:08 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended

I suspect that maybe selinux is causing issues again but am open to other suggestions.

What is the best way to resolve ?

Thanks
RB
 
Thanks for that. I will give it a go tonight.

I tried starting mysql using the

service mysql start

But got the 'unrecognized service' error (was running it as root).

Will try again as mysql and see if that works.

RB
 
Ok,

Did lots of testing over the weekend and still not working.

Have tried the following...

Setting SELinux to permissive and checking the /var/log/audit/audit.log. A number of SELinux messages came up.

Installed and used audit2why to generate custom rules and then load them in tot he kernal as modules. Repeated until no messages appeared in the audit log. Still mysql daemon will not start. Turned off SELinux completely and rebooted. Still would not start. Uninstalled and linked the /var/lib/mysql to the mount point for the second array then installed. Still will not start. Removed mysql and mysql-server and then mounted the second array on /var/lib/mysql and installed again. Still will not start up.

If I install mysql and mysql server to the standard location with no links or custom mounts etc it works fine. It is getting ti to startup with the data area being somewhere else that seems to be causing a big problem.

Any other suggestions most welcome. I really didn't expect there to be such an issue with this.

RB
 
Thanks for the suggestions guys.

I will give the cp a go and see how that works out.

I will also take a good read through the troubleshooting guide. It looks very helpful.

Probably also worth noting that the database engine is InnoDB.

I have currently resorted to clearing Mysql from the server and mounting the drives on the /var/lib/mysql directory, where the datafiles are usually created, and then intend to install Mysql and see if it installs correctly. I would much rather have them in a separate clearly visible mount point but this is more of a proof of concept at the moment to make sure I can at least get something working.

Of course, it never rains but pours.... It now seems that the Intel 82574L nic chipset is having issues with CentOS 6.2. The Nic based on the 82579LMseems fine so now I have to 'down' one of the nics or I keep getting 'network unreachable' some times. That is for another thread though which I should go and start now.

Thanks for the suggestions, I shall report back with any new error messages and results.

RB
 
Small update on this.

I mounted the array on /vat/lib/mysql and made sure owner and group were mysql and it installed and started.

I then turned on SELinux again and it ran fine (audit2allow must have worked I guess).

Next step would be to remount the array on the mount point I want, edit the config file to point there and then see if mysql will start.

Some progress at last.

The problem with the network port only seems to come up if one or more of the ports is set to DHCP. Setting both to a static IP and they are fine. The people I am building these two servers for have static addresses so no real problem there. I shall of course make them aware and make a note in the documention I will be supplying.

RB
 
Back
Top Bottom