Re: "primary" Condition for drbd?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2024-06-13 16:08:03, Lennart Poettering wrote:

Youre are assuming that people know what drbd is and does, and what
"primary" or "secondary" means in the context. I certainly have no
clue.


You are  right, sorry about that.

drbd is a scheme to mirror a block device via network, providing
a virtual block device (a "resource"). Each host providing the
resource has a local replica, holding the data and some meta
information. Usually all replicas of a resource have the same
size. It is fine to have several resources in parallel on the
involved hosts.

There are 2 modes of a drbd replica: In primary mode the host
performs all read and write operations, similar to other local
block devices. It forwards all write operations on block level
to all secondary replicas (write through).

In secondary mode a replica must not be used. It just receives
the changes from the primary and updates the local block dev
accordingly.

If the replicas of a resource are in sync and if the primary
replica is not mounted, activated or "used somehow", then the
primary replica can be set to secondary mode, and another replica
can take over, becoming the new primary for the resource. This
can be done to shut down a host, for example. On the next reboot
the replicas are synced again, even if the secondary stays
secondary.

Usually there are just 2 replicas forming a resource: 1 primary
and 1 secondary. (Newer drbd implementations support n>2. This
new mode is not included in the kernel yet.)

I would like to run several systemd services making use of the
resource only, if the local replica is in primary mode. This
could be mounting the storage, running a database in an LXC
container, and configuring a dedicated IP address, for example.
For the transition to secondary mode of the replica these
services have to be stopped in the right sequence again. Usual-
ly this is done with pacemaker, as Andrei mentioned, but it
should be possible to describe the dependencies between the
units without pacemaker. They are all local, and running
services on remote systems is not systemd's business.

Problem is, systemd provides several conditionals to check if
a block device exists, if a power supply is attached, if a
block device has been mounted, etc., but there is no condi-
tional to check if a replica stored on a real block device is
in primary mode.

Does systemd allow to run a program to evaluate a custom
condition in a unit file? Maybe I am too blind to see, but
I haven't found it mentioned on https://www.freedesktop.org/\
software/systemd/man/latest/systemd.unit.html.

There's ExecCondition=. But what would you use it for?

ExecCondition= is intended for quick checks.


Not documented on https://www.freedesktop.org/software/systemd/man/latest/systemd.unit.html,
as it seems.


I have no idea what this all means, but I have the suspicion you
actually want a generator, i.e. a plugin to systemd that adds some
deps depending on external configuration files.

i.e. implement this stuff:

https://www.freedesktop.org/software/systemd/man/latest/systemd.generator.html


I will check.


Regards
Harri



[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux