[MDEV-17637] New systemd-aware script to re-create datadir Created: 2018-11-07  Updated: 2021-05-03  Resolved: 2021-05-03

Status: Closed
Project: MariaDB Server
Component/s: Packaging
Fix Version/s: N/A

Type: Task Priority: Major
Reporter: Juan Assignee: Juan
Resolution: Won't Do Votes: 0
Labels: documentation, need_feedback, systemd

Issue Links:
Relates
relates to MDEV-15844 Add umask and umask_dir as server var... Needs Feedback
relates to MDEV-16415 Make UMASK and UMASK_DEV configurable... Closed
relates to MDEV-17640 UMASK_DIR configuration for mysql_ins... Closed
relates to MDEV-19010 run mysql_install_db automatically Open
relates to MDEV-19126 Add UMASK as a configuration paramete... Closed

 Description   

When creating the data directories with the mysql_install_db script, UMASK settings in /etc/systemd/system/mariadb.service.d/ are ignored.

Setting UMASK in the environment works correctly, but setting /etc/systemd/system/mariadb.service.d/ as instructed in https://mariadb.com/kb/en/library/specifying-permissions-for-schema-data-directories-and-tables/ has no effect on the mysql_install_db script.

Note that UMASK settings are respected by the server itself. This is only an issue when invoking mysql_install_db manually on systemd distributions.



 Comments   
Comment by Elena Stepanova [ 2018-11-07 ]

Do you mean the case when mysql_install_db script is invoked manually, or when it is run via server installation, or when it is run via service startup?

Comment by Juan [ 2018-11-07 ]

This is with mysql_install_db invoked manually on systemd.

Comment by Elena Stepanova [ 2018-11-07 ]

What does it mean, "manually on systemd"? Could you provide the exact command line that is run, please?

Given the update on the description, apparently it means "on systemd-enabled distributions". But if mysql_install_db is started manually, why would it know anything about systemd configuration?

Comment by Juan [ 2018-11-07 ]

On systemd: Meaning on CentOS 7+, where systemd, and not upstart, manages services.

Command line:

~# mysql_install_db

"why would it know anything about systemd configuration?" - Shall I ask the customer why he expects the product's installation to respect the product's configuration?

Comment by Juan [ 2018-11-07 ]

As I understand it, the customer is having an issue because they are trying to use a scripted install and have a specific error caused by the lack of uniformity in the application of the UMASK_DIR.

The same as mysql_install_db is expected to crawl through the cnf files to find the datadir, and expected to read the environment variable UMASK_DIR, it should be able to see the same information when it is declared instead in /etc/systemd/system/mariadb.service.d/

It would be odd to expect mysql_install_db to know nothing about the mysql service, the service for which it is creating and populating a datadir.

Comment by Elena Stepanova [ 2018-11-07 ]

It is not creating the datadir for the service. It creates the datadir for MariaDB server. It has nothing to do with the systemd service.
mysql_install_db is not expected to crawl through all config files on a machine, either. It is supposed to read very specific sections of a specific set of MariaDB cnf files.

Moreover, if you choose to invoke mysqld manually, without the service, it won't be reading systemd configuration either. It will only read its own config files, as it's supposed to.

Comment by Valerii Kravchuk [ 2018-11-08 ]

I think we just need new script, let's say mysql_new_instance, that is aware of systemd configuration files, something like galera_new_cluster (maybe also based on mysqld --initialize feature like the one we see in upstream MySQL).

I see no point in any change of behavior for existing mysql_install_db.

Comment by Juan [ 2018-11-08 ]

Confirmed that mysql_install_db does not read the UMASK and UMASK_DIR definitions in upstart either (in /etc/init.d/mysql.server), so it's not a question of something that worked properly in prior versions.

Comment by Elena Stepanova [ 2018-11-09 ]

Converted to a feature request based on valerii's comment above.

The fact that mysql_install_db isn't aware of an init script is irrelevant. It is not a regression, and neither is it a bug, that it is not aware of any wrappers that might or might not be optionally used to call it, as well as mysqld itself and any other MariaDB binaries.

Please note that there is also MDEV-17640, which is a separate but related matter.

Comment by Sergei Golubchik [ 2019-02-08 ]

I don't see it as something that needs fixing at all. Files in /etc/systemd/system/mariadb.service.d/ affect mariadb when started via systemd and do not affect mariadb when not started via systemd. This is what one would expect and this is what actually happens.

Comment by Juan [ 2019-02-08 ]

I can let the user know that engineering feels mysql_install_db does not need to support server UMASK settings, but it seems legitimate that a client would expect mysql_install_db to work in this scenario.
My take is that since the functional requirement to have the server use a specific permissions mask when managing files would obviously apply to a utility that creates those files for that server, maybe the service configuration is not the ideal place for UMASK. If it were a global variable, it would be a much more seamless management experience for the server administrator.

Comment by Sergei Golubchik [ 2019-03-08 ]

May be. Or may be mysqld --initialize mode could be implemented.

Comment by Jacob Moorman (Inactive) [ 2019-04-12 ]

Juan: In review of the referenced page, https://mariadb.com/kb/en/library/specifying-permissions-for-schema-data-directories-and-tables/ whose parent is "Starting and Stopping MariaDB", it appears that this content is wholly about the MariaDB Server process and not about the installation process of MariaDB Server.

It is likely that some other page or pages need to incorporate information about file and directory permissions, but I believe the note added to this page two months ago is now covering a completely separate product step, and should be reverted. I don't believe that this specific page should be extended to cover these other cases, but that we should identify in the page specific to mysql_install_db how umask is set.

Does this approach raise concerns? If not, I will revert your change at bottom of page and add umask information on the pages for mysql_install_db

Generated at Thu Feb 08 08:37:58 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.