1

I'm attempting to install MariaDB Server 5.5 in a diskless image using Redhat Enterprise 7.8.

The problem I am running into is having a single diskless image with a single /etc/my.cnf being deployed to all the nodes, which then are all pointed to the same data directory on the shared NFS storage.

What I would like to do is somehow have the /etc/my.cnf determine which node it is on and write to a different directory on the shared storage (i.e. datadir = /sharednfs/output/node1,2,3,4/mariadb). Is this possible?

From what I researched it looks like the only way would be to setup a separate diskless image for each node. I'm unable to find any parameters in my.cnf that would allow a hostname variable or something of the sort.

mforsetti
  • 2,666
  • 2
  • 16
  • 20
Chad
  • 23
  • 4

2 Answers2

1

I was able to get it to work by creating an override file for the mariadb systemd service and adding

ExecStart=/usr/bin/mysqld_safe --defaults-file=/nfspath/%H_my.cnf --basedir=/usr

Just to clarify, the --defaults-file option has to be the first argument in the line, it would not work otherwise. Thank you again for both of your inputs!

Chad
  • 23
  • 4
0

I don't have a RHEL system handy, but assuming it is pretty close to centos7.

Sure seems like you could easily handle this by overriding mariadb.service unit somehow.

Perhaps add a ExecStartPre that adds a script that will replace the my.cnf with a symlink of /etc/my.cnf to something like /nfspath/$(hostname -f)_my.cnf.

Or perhaps there is a way to just override the ExecStart. I don't think $() is valid here, but if it was something like this. Perhaps run it via sh -c?

ExecStart=/usr/bin/mysqld_safe --basedir=/usr --defaults-file=/nfspath/$(hostname -f)_my.cnf
Zoredache
  • 130,897
  • 41
  • 276
  • 420
  • 1
    There's `%H` or `%l` if you need that, see [systemd.unit - Specifiers manual](https://www.freedesktop.org/software/systemd/man/systemd.unit.html#Specifiers). Just make sure that the unit file runs after systemd-hostnamed. – mforsetti Sep 17 '20 at 02:43
  • Fancy, I didn't know systemd had that feature. That should make it easy. You just have to override the ExecStart – Zoredache Sep 17 '20 at 21:28
  • Thank you Zoredache and mforsetti for your suggestions. – Chad Sep 18 '20 at 17:43