The hastmon.conf
file is used by both
hastmon(8)
daemon and
hastmonctl(8)
control utility. Configuration file is designed in a way that exactly the same
file can be (and should be) used on all nodes. Every line starting with # is
treated as comment and ignored.
General syntax of the hastmon.conf
file is following:
# Global section
control <addr>
listen <addr>
timeout <seconds>
attempts <number>
heartbeat_interval <seconds>
complaint_count <number>
complaint_interval <seconds>
exec <path>
role_on_start <role>
key {
algorithm <name>
secret <string>
}
on <node> {
# Node section
control <addr>
listen <addr>
priority <number>
attempts <number>
heartbeat_interval <seconds>
complaint_count <number>
complaint_interval <seconds>
role_on_start <role>
}
on <node> {
# Node section
control <addr>
listen <addr>
priority <number>
attempts <number>
heartbeat_interval <seconds>
complaint_count <number>
complaint_interval <seconds>
role_on_start <role>
}
resource <name> {
# Resource section
exec <path>
timeout <seconds>
attempts <number>
heartbeat_interval <seconds>
complaint_count <number>
complaint_interval <seconds>
role_on_start <role>
key {
algorithm <name>
secret <string>
}
on <node> {
# Resource-node section
# Required
exec <path>
# Required
remote <addr>
priority <number>
attempts <number>
heartbeat_interval <seconds>
complaint_count <number>
complaint_interval <seconds>
role_on_start <role>
}
on <node> {
# Resource-node section
# Required
exec <path>
# Required
remote <addr>
priority <number>
attempts <number>
heartbeat_interval <seconds>
complaint_count <number>
complaint_interval <seconds>
role_on_start <role>
}
}
Most of the various available configuration parameters are
optional. If parameter is not defined in the particular section, it will be
inherited from the parent section. For example, if the
listen
parameter is not defined in the node section,
it will be inherited from the global section. If the global section does not
define the listen
parameter at all, the default
value will be used.
The ⟨node⟩ argument can be replaced either by a full hostname as
obtained by
gethostname(3),
only first part of the hostname, or (on FreeBSD) by node's UUID as found in
the kern.hostuuid
sysctl(8)
variable.
The following statements are available:
attempts
⟨number⟩
-
Nubber of attempt to start resource before giving up. The
default value is 3.
complaint_count
⟨number⟩
-
Number of complaints secondary should receive before
initiating failovering. The default value is
5.
complaint_interval
⟨seconds⟩
-
Conplaint's life time in seconds. Complaints older this
interval are expired and not taken into consideration. The default value
is 60.
control
⟨addr⟩
-
Address for communication with
hastmonctl(8).
Each of the following examples defines the same control address:
uds:///var/run/hastmonctl
unix:///var/run/hastmonctl
/var/run/hastmonctl
The default value is
uds:///var/run/hastmonctl.
listen
statement.
exec
⟨path⟩
-
Execute the given program on various events and to check
resource status. Below is the list of currently implemented events and
arguments the given program is executed with:
<path>
start <resource>
-
Executed on primary node to start resource.
<path>
stop <resource>
-
Executed on both primary and secondary nodes to stop
resource.
<path>
status <resource>
-
Executed on both primary and secondary nodes to check
resource status.
The script should return 0 as an exit status if the
resource is running and is OK, 1 if the resource is not running and
some other value if the resource is in unknown state.
<path>
role <resource> <oldrole> <newrole>
-
Executed on both primary and secondary nodes when resource
role is changed.
<path>
connect <resource>
-
Executed on both primary and secondary nodes when
connection for the given resource between the nodes is
established.
<path>
disconnect <resource>
-
Executed on both primary and secondary nodes when
connection for the given resource between the nodes is lost.
The ⟨path⟩ argument should contain full path to
executable program. If the given program exits with code different than
0, hastmon
will log it as
an error.
The ⟨resource⟩ argument is resource name from
the configuration file.
The ⟨oldrole⟩ argument is previous resource role
(before the change). It can be one of: init,
secondary, primary,
watchdog.
The ⟨newrole⟩ argument is current resource role
(after the change). It can be one of: init,
secondary, primary,
watchdog.
friends
⟨addr ...⟩
-
List of addresses (separated by space) of hosts that can
connect to the node. Format is the same as for the
heartbeat_interval
⟨seconds⟩
-
Interval between heartbeats (checks) in seconds. The default
value is 10.
key
-
Secret used for node authentication. If not specified host
access is controlled only by remote
and
friends
settings.
algorithm
⟨name⟩
-
Signature algorithm being used (MD5, SHA1, SHA256,
RIPEMD160).
secret
⟨string⟩
-
Actual authentication key.
listen
⟨addr⟩
-
Address to listen on in form of:
protocol://protocol-specific-address
Each of the following examples defines the same listen
address:
0.0.0.0
0.0.0.0:8458
tcp://0.0.0.0
tcp://0.0.0.0:8458
tcp4://0.0.0.0
tcp4://0.0.0.0:8458
The default value is
tcp4://0.0.0.0:8458.
priority
⟨number⟩
-
Node's priority (the lower number the higher priority).
Priority is used when several primaries are started (e.g. after previous
primary died) to negotiate who will be primary and who has to switch to
secondary. The default value is 100.
remote
⟨addr ...⟩
-
Addresses of the remote hastmon
daemons (separated by space). Format is the same as for the
listen
statement. When operating as a primary
node these addresses will be used to connect to the secondary nodes.
When operating as a secondary node only connections from these addresses
will be accepted. When operating as a watchdog node these addresses will
be used to check resource status on the nodes and send complaints. + .Pp
+ A special value of + .Va none + can be used when the remote address is
not yet known (eg. the other node is not + set up yet).
role_on_start
⟨role⟩
-
Role a resource should be set on
hastmon
start. It can be one of:
init, secondary,
primary, watchdog. The
default role is init.
timeout
⟨seconds⟩
-
Connection timeout in seconds. The default value is
5.
- /usr/local/etc/hastmon.conf
- The default
hastmon.conf
configuration file.
- /var/run/hastmonctl
- Control socket used by the
hastctl(8)
control utility to communicate with the
hastmon(8)
daemon.
The example configuration file can look as follows:
# host1 and host2 run hast resource. Watchdog is run on host3.
resource hast {
exec /usr/local/etc/rc.d/hast
on host1 {
friends tcp4://host3
remote tcp4://host2
priority 1
}
on host2 {
friends tcp4://host3
remote tcp4://host1
priority 2
}
on host3 {
remote tcp4://host1 tcp4://host2
}
}
# host1, host2 and host3 run mail resource.
# Watchdog is run on host4 and host5.
resource mail {
friends tcp4://10.0.0.4 tcp4://10.0.0.5
exec /usr/local/etc/rc.d/mail
on host1 {
remote tcp4://10.0.0.2 tcp4://10.0.0.3
priority 1
}
on host2 {
remote tcp4://10.0.0.1 tcp4://10.0.0.3
priority 2
}
on host3 {
remote tcp4://10.0.0.1 tcp4://10.0.0.2
priority 3
}
on host4 {
remote tcp4://10.0.0.1 tcp4://10.0.0.2 tcp4://10.0.0.3
}
on host5 {
remote tcp4://10.0.0.1 tcp4://10.0.0.2 tcp4://10.0.0.3
}
}