[MDEV-26317] Distributed mariadb.service Systed service file prevents start with default datadir Created: 2021-08-06  Updated: 2022-03-08  Resolved: 2022-01-07

Status: Closed
Project: MariaDB Server
Component/s: Packaging
Affects Version/s: 10.6.2, 10.2.39, 10.3.30, 10.4.20, 10.5.11
Fix Version/s: 10.3.33, 10.4.23, 10.5.14, 10.6.6, 10.7.2

Type: Bug Priority: Major
Reporter: Hartmut Holzgraefe Assignee: Daniel Black
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Problem/Incident
is caused by MDEV-10298 Improve systemd service hardening Closed
Relates
relates to MDEV-25177 Better indication of refusing to star... Closed

 Description   

When using our -systemd- binary tarballs the distributed mysqld.service systemd service file has

ProtectSystem=full

set since MDEV-10298. As this leads to everything under /usr being read-only, but the binary tarball builds having the data dir set up under /usr/local/mariadb-.../data by default.

So trying to bring the MariaDB server up using default settings, according to our instructions in

https://mariadb.com/kb/en/installing-mariadb-binary-tarball

leads to "funny" errors like:

2021-08-06 10:44:49 0 [ERROR] mysqld: File '/usr/local/mariadb-10.4.18-linux-systemd-x86_64/data/aria_log_control' not found (Errcode: 30 "Read-only file system")

while starting the server manually works just fine.

So I'd suggest to add

ReadWritePaths=/usr/local/mysql/data

to the bundled mariadb.service file. As /usr/local/mysql/data is a symlink, and SystemD resolves this link to the actual data directory, this should work across all releases without requiring per-release adjustments.

A more complete fix would be to allow both the symlink and the actual versioned path, like e.g.:

ReadWritePaths=/usr/local/mysql/data /usr/local/mariadb-10.4.18-linux-systemd-x86_64/data/



 Comments   
Comment by Hartmut Holzgraefe [ 2021-08-06 ]

Unfortunately the ReadWritePaths approach only works with CentOS 8, not with CentOS 7 ...

Comment by Hartmut Holzgraefe [ 2021-08-06 ]

pre Systemd 231 the setting name is ReadWriteDirectories, not ReadWritePaths

As CentOS 7 / RHEL 7 come with SystenD 219 the older ReadWriteDirectories is needed there

Comment by Tuukka Pasanen [ 2021-08-23 ]

hholzgra did I understand correctly that you are using binary tar-ball not DEB or RPM installation with read-only /usr and you use MariaDB-systemd to launch you instance?

Comment by Daniel Black [ 2021-09-01 ]

> using binary tar-ball not DEB or RPM installation

yes.

> with read-only /usr

No, ProtectSystem=full makes /usr read only.

> and you use MariaDB-systemd to launch you instance?

Yes the systemd service file is used to start the service.

Comment by Tuukka Pasanen [ 2021-12-03 ]

hholzgra Could you test Pull Request does it work around this problem?

Comment by Tuukka Pasanen [ 2021-12-20 ]

This PR has been merged

Comment by Vicențiu Ciorbaru [ 2021-12-20 ]

illuusio The PR https://github.com/MariaDB/server/pull/1949 is still open. Where exactly has this been merged? What branch?

Also, when fixing a bug in a version (say 10.3), the Fix Version you need to fill out in JIRA is 10.[34567].<next-upcoming-point-release>. Basically, you need to mark which upcoming versions will have the bug fixed, so that it's easy to figure out which version has it.

Comment by Tuukka Pasanen [ 2021-12-20 ]

cvicentiu I tried but it just said that it doesn't fit in to regex..

Comment by Sergei Golubchik [ 2021-12-20 ]

doesn't seem to be merged anywhere

Comment by Tuukka Pasanen [ 2021-12-20 ]

serg Sorry my bad.. I just looked GIthub very straigly it was approved not merged!.. I re-open if I can

Comment by Tuukka Pasanen [ 2021-12-20 ]

This just Approved not merged.

Comment by Hartmut Holzgraefe [ 2022-01-07 ]

Just by coincidence I ran into the same yesterday (didn't even really remember I had encountered it before, and especially not that I created this ticked), and for now updated the KB entries on tarball installation and on systemD to mention this problem and how to deal with it with a simple extra systemd service include file:

https://mariadb.com/kb/en/installing-mariadb-binary-tarballs/#auto-start-of-mysqld

https://mariadb.com/kb/en/systemd/#configuring-the-data-directory

Generated at Thu Feb 08 09:44:23 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.