Im trying to setup a three node cluster and just installed the first node as per the documentation (on CentOS Linux release 8.1.1911 (Core)) and after restart Im getting the following error:
mysql-systemd: WARNING: mysql pid file /var/run/mysqld/mysqld.pid empty or not readable
I also granted permission to others to write to /var/run/mysqld but the error remains. Because I needed more space on the /var/lib/mysql I mounted this on a new partition but the error was showing up before that. Other than that I have just changed the IPs for the cluster in my.cnf.
Any suggestions are welcome!
I have tried to reproduce your issue:
- created partition
- mounted it
- install PXC-80
- started mysql (it was started successfully)
- stopped mysqld
- migrated /var/lib/mysql to the mounted partition
- modified my.cnf to use new location of data directory
- started successfully mysqld
Everything worked well.
Could you please confirm if my scenario is the same as yours or otherwise please correct my scenario
What I did is to mount the new partition on /var/lib/mysql with of course first stopping the service and moving the files out of that location and then putting them back on the partition. So I didnt need to change the my.cnf to set the new location. Today I plan to repeat the setup and see will the error repeat.
I have checked this setup and the same issue a faced once mysql user wasn’t able to write to this mounted partition.
So I suggest checking the permissions to write to the partition.
I did a fresh install and ran into another issue. After installation with:
# service mysql start
The service started without issues. After that I issued
# systemctl disable mysql.service
# systemctl enable mysql.service
Failed to enable unit: Unit file mysql.service does not exist.
Can not start it either with:
# service mysql start
Redirecting to /bin/systemctl start mysql.serviceFailed to start mysql.service: Unit mysql.service not found.
It seems disabling the service broke it. Im just not used at all with the systemd (my experience is mostly on Centos 6, not 7 or 8) and I dont know what went wrong.
I installed following exactly the documentation
As you have removed /etc/systemd/system/mysql.service - you have removed systemd configuration.
If talk in terms of Centos6 you have removed init script.
For systems which support systemd we provide only systemd configuration.
Ok, it turned out I need to reenable it with:
systemctl enable mysqld.service
And mysql.service is a symlink to that. It is to be noted that “disable mysql” works but “enable mysql” does not.
P.S. also Selinux must be disabled for the service to start when the datadir is changed to a different partition
One last note - may save someone time…
If you have changed the datadir, set the permissions correct for the mysql user to write, disabled (or properly configured) selinux, and you still are getting an error that Mysql cant write (create a test file) to the new location then perhaps the new location is under /home. In this case systemd has extra protection for the services to prevent them from accessing it and you need to set in /usr/lib/systemd/system/mysql.service :
Or just choose another location not involving /home /root or /run/user…
@kenashkov thanks for sharing this info! I would add some more info about this option (from https://www.freedesktop.org/software/systemd/man/systemd.exec.html):
ProtectHome= Takes a boolean argument or the special values “read-only” or “tmpfs”. If true, the directories /home, /root, and /run/user are made inaccessible and empty for processes invoked by this unit. If set to “read-only”, the three directories are made read-only instead. If set to “tmpfs”, temporary file systems are mounted on the three directories in read-only mode. The value “tmpfs” is useful to hide home directories not relevant to the processes invoked by the unit, while still allowing necessary directories to be made visible when listed in BindPaths= or BindReadOnlyPaths=.Setting this to “yes” is mostly equivalent to set the three directories in InaccessiblePaths=. Similarly, “read-only” is mostly equivalent to ReadOnlyPaths=, and “tmpfs” is mostly equivalent to TemporaryFileSystem= with “:ro”.
It is recommended to enable this setting for all long-running services (in particular network-facing ones), to ensure they cannot get access to private user data, unless the services actually require access to the user’s private data. This setting is implied if DynamicUser= is set. This setting cannot ensure protection in all cases. In general it has the same limitations as ReadOnlyPaths=, see below.
This option is only available for system services and is not supported for services running in per-user instances of the service manager.