Mirexa

Wiki Cluster

Operating a cluster

Bootstrapping a three-node Mirexa cluster, adding and draining nodes, rebalancing on demand, reading cluster state, what to alert on, and the upgrade caveats.

This page is the operator's path through a Mirexa cluster: the material to prepare, the configuration each node needs, how to bring up three nodes, and the day-two operations — adding a node, draining one, rebalancing, reading what the cluster thinks of itself, and what to alert on. Everything here is done through the gRPC control API; mirexa-cli has no cluster commands. The concepts behind each step are on the other pages of this section.

Before you start

You need, for every node:

  1. A node id — an integer ≥ 1, unique, and stable for the node's life (its Raft state is keyed by it).

  2. Four addresses peers and clients can actually dial — not 0.0.0.0, not :8080. A node registers its listen addresses verbatim as the addresses it advertises; there is no separate advertise setting, so a wildcard would send redirected clients and peers to the wrong host.

    Key Used by
    network.addr Clients (the data address redirects name)
    control.addr Other nodes (seeds, registration, heartbeats) and operators
    cluster.raft_addr The Raft transport between members
    cluster.replication_addr Copies pulling from primaries (mutual TLS)
  3. Replication certificates from one offline cluster CA:

    bash
    mirexa-cli certs ca -dir ./pki
    
    bash
    mirexa-cli certs issue -dir ./pki -node-id 1 -hosts 10.0.0.1,node1.internal
    

    This writes ca.crt/ca.key and, per node, node-<id>.crt and node-<id>.key (mode 0600). -hosts must list every address peers dial the node's replication listener at. Keep ca.key offline. See mirexa-cli certs and TLS and certificates.

  4. A signing key and an admin token. Data-plane authentication is on by default, and a clustered node with no security.auth.trusted_keys is refused at config load (a single node would generate its own issuer; in a cluster each node would trust a different one). A control listener on a routable address is also refused unless control.admin_auth is on:

    bash
    mirexa-cli token keygen -name ops -dir ./keys
    
    bash
    mirexa-cli token issue -key ./keys/ops.key -perms ADMIN_CLUSTER -validity 1h > admin.token
    

    Every node lists the public key under security.auth.trusted_keys, and every node reads its own credential from cluster.admin_token_file, re-read before every request. A token lives at most an hour, so run something (a cron job, a sidecar) that re-issues the file well before it expires; a node whose token lapses can no longer heartbeat and will be fenced. See Authentication and tokens.

A cluster confined to one host can keep control.addr on loopback and leave admin auth off. The repository's own multi-node tests do exactly that. Its nodes still need the shared trusted_keys, or security.auth.enabled: false.

Configuration

The founding node (node 1). Values under partition, compression and the two marked cluster-wide only seed the cluster's agreed settings; afterwards the agreed values win and a differing YAML value is logged and ignored. Choose them before the first start — partition count, liveness timeout and replication factor can never be changed.

yaml
storage:
  data_dir: /var/lib/mirexa
network:
  addr: "10.0.0.1:8080"
observability:
  addr: "10.0.0.1:9100"
partition:
  count: 4096                       # cluster-wide, immutable
security:
  auth:
    trusted_keys:
      - name: ops
        public_key: "BASE64-OF-ops.pub"
control:
  enabled: true                     # required: a clustered node registers and heartbeats through it
  addr: "10.0.0.1:9090"
  admin_auth: true                  # required for a routable control.addr
cluster:
  enabled: true
  node_id: 1
  raft_addr: "10.0.0.1:7000"
  initial_members:
    1: "10.0.0.1:7000"              # bootstrap: this node founds the cluster
  liveness_timeout: 30s             # cluster-wide, immutable
  replication_factor: 3             # cluster-wide, immutable
  admin_token_file: /etc/mirexa/admin.token
  replication_addr: "10.0.0.1:7100"
  replication_cert_file: /etc/mirexa/pki/node-1.crt
  replication_key_file: /etc/mirexa/pki/node-1.key
  replication_ca_file: /etc/mirexa/pki/ca.crt
  strict_settings: true             # refuse to start rather than run on local values

A joining node (node 2) differs in its addresses, its id, and its membership: seeds instead of initial_members. Seeds are control addresses; one reachable seed is enough.

yaml
cluster:
  enabled: true
  node_id: 2
  raft_addr: "10.0.0.2:7000"
  seeds: ["10.0.0.1:9090"]
  admin_token_file: /etc/mirexa/admin.token
  replication_addr: "10.0.0.2:7100"
  replication_cert_file: /etc/mirexa/pki/node-2.crt
  replication_key_file: /etc/mirexa/pki/node-2.key
  replication_ca_file: /etc/mirexa/pki/ca.crt
  strict_settings: true

Never give a joining node an initial_members list. A node with a member list bootstraps a new, separate cluster of its own, which looks healthy and replicates nothing.

The full list of cluster.* keys is in the Configuration reference. Important ones not shown above: voters (3), max_concurrent_migrations (2), rebalance_auto (false), scrub_bytes_per_second (8 MiB/s), copy_read_max_staleness (5s), join_timeout (1m), settings_timeout (15s).

Bootstrapping three nodes

The tested path is one founder, then joiners:

  1. Start node 1. It bootstraps a one-voter group, seeds the cluster settings from its YAML, registers itself, and places every partition — all on itself, because it is the only ONLINE node. Wait until GetClusterStatus shows it as leader and mirexa_cluster_partitions_unassigned reads 0.
  2. Start nodes 2 and 3 with seeds pointing at node 1 (and at each other, once running). Each is admitted as a non-voter, catches up, starts, and registers ONLINE. The leader promotes them to voters once both are caught up — three voters, never two.
  3. Copies. With replication_factor: 3, the replication loop adds two copies of every partition, two × max_concurrent_migrations seeds at a time. Watch mirexa_cluster_copies_missing fall to 0.
  4. Spread the primaries. Every primary is still on node 1. Either set cluster.rebalance_auto: true, or read the plan and move partitions yourself (below). With in-sync copies everywhere, the rebalancer uses swaps, which move write load without copying data.

Bootstrapping three founders at once with identical initial_members is also supported by the configuration, but how evenly the first placement spreads in that case depends on which nodes have registered when the leader first places, and is unverified.

Talking to the control API

Use any gRPC client. With grpcurl and the schema from this repository (server reflection is off by default, control.reflection):

bash
grpcurl -plaintext -import-path proto -proto mirexa/control/v1/control.proto \
  -H "authorization: Bearer $(cat admin.token)" \
  10.0.0.1:9090 mirexa.control.v1.ClusterService/GetClusterStatus

Drop -plaintext and pass -cacert when control.use_tls is on (the control listener then uses the data plane's TLS certificate). Mutating calls sent to a follower are refused with FAILED_PRECONDITION and a NotLeader detail naming the leader's control address; send them there. The Control-plane gRPC API lists every RPC and message.

Reading the cluster's state

RPC Answers Consistency
GetClusterStatus Leader, term, voters and non-voters, commit/applied index, counts This node's local view — answers without a quorum
ListNodes / GetNode Registry records: addresses, status, incarnation Linearizable
ListPartitions (optionally by node) / GetPartition Directory entries: primary, copies, in-sync set, epoch, divergent Linearizable
ListPartitionHealth (impaired_only) serving / under_replicated / primary_down / unavailable, with failover candidates Linearizable
ListMigrations Each intent with its derived step Linearizable
ListDrains Per draining node: primaries, copies and migrations left Linearizable
GetRebalancePlan The latest plan and when it was computed The leader's last evaluation; ask the leader
GetClusterConfig The agreed settings and their version (empty before any are agreed)

The web dashboard shows a cluster view (totals and a per-node table) when dashboard.upstream_addrs lists the nodes.

Day-two operations

Adding a node

Configure it like node 2 above and start it. It joins as a non-voter, may be promoted to voter, and receives copies if partitions are short of the replication factor. It receives no primaries until something moves them: run the rebalancer or move partitions by hand.

Rebalancing on demand

bash
grpcurl ... mirexa.control.v1.ClusterService/GetRebalancePlan
bash
grpcurl ... -d '{"partition_id": 17, "target_node_id": 3}' \
  mirexa.control.v1.ClusterService/MigratePartition

MigratePartition returns at once; follow it with ListMigrations. Stop one with AbortMigration (same two fields) — it stops future steps and undoes nothing. A plan of FailedPrecondition means the leader cannot tell yet (a node has not reported, or write rates are still warming up); it is not a balanced cluster. See Moving partitions and rebalancing.

Draining and removing a node

bash
grpcurl ... -d '{"node_id": 3}' mirexa.control.v1.ClusterService/DrainNode

The cluster moves the node's primaries, then its copies, decommissions it, removes it from the voter set, and the process exits with status 0 on its own. Follow progress with ListDrains. A dead node can be drained too; its primaries are failed over and its copies re-created elsewhere. Afterwards, DeregisterNode removes its record and makes the id reusable. Budget about ⌈partitions ÷ max_concurrent_migrations⌉ × 6.6 s plus seed transfer time. See Joining, draining and decommissioning nodes.

Rolling restarts

Restart one node at a time and wait for it to be ONLINE and its copies back in sync before the next. A clean stop hands off first: it sheds new writes to its partitions, waits for in-flight writes, and waits up to network.shutdown_timeout (30 s) for its copies to receive everything it acknowledged. A node also waits up to that timeout for idle client connections to close, so plan the orchestrator's grace period above it. A node that stays down longer than the liveness timeout is fenced, and one liveness timeout later its partitions fail over.

Replacing a dead node

If a node will not return: its primaries fail over automatically to in-sync copies (about two liveness timeouts). Its copies are not re-created while it stays registered — they still count toward the replication factor. Drain it (DrainNode works on a node that is down) so its copies move, then deregister it. Partitions with no in-sync copy stay unavailable until the node returns.

What to alert on

Metric Alert when Meaning
mirexa_cluster_partitions_unavailable > 0 Data out of reach: no primary and no caught-up copy
mirexa_cluster_partitions_primary_down > 0 for longer than ~2 × liveness timeout Failover should have restored these
mirexa_cluster_partitions_under_replicated > 0 for long Redundancy lost
mirexa_cluster_copies_missing > 0 for long, or NaN Below the replication factor
mirexa_cluster_primary_lease_remaining_seconds 0 on a node holding primaries That node refuses its partitions
mirexa_raft_has_leader 0 The control plane cannot commit
sum(mirexa_raft_is_leader) ≠ 1 across the cluster No leader, or a reporting problem
mirexa_cluster_migrations_unsatisfiable > 0 A requested move will not happen
mirexa_cluster_migrations_in_flight not falling A migration is stuck
mirexa_replica_worst_lag_seconds approaching 2 × liveness timeout A copy is about to leave the in-sync set
mirexa_reconcile_rotten_chunks > 0 for long A rotten chunk no peer can repair
mirexa_replication_cert_expiry_timestamp_seconds within weeks of now Rotate the node certificate (SIGHUP)
mirexa_cluster_rebalance_moves_recommended > 0 with auto off A rebalance is waiting for you

Several of these read NaN, never zero, when a node cannot read its own control-plane state; alert on NaN too. Ready-made alert rules and dashboards live in the separate monitoring repository; see Monitoring and alerting and Metrics.

Upgrades

Mirexa refuses older on-disk and replicated formats rather than reading them with defaults, so an upgrade across a format change is not in place:

  • Control-plane snapshot — format version 12. An older snapshot is refused at startup, and a settings entry from an older build is refused as truncated. A cluster's raft/ directories do not survive an upgrade across a snapshot or command format change.
  • stream.idx — version 5; version 4 is refused.
  • Wire protocol — version 2, with no version-1 interoperation.
  • Replication schema — mirexa.replication.v1 changes additively only within v1.

No in-place or rolling upgrade path exists across such a change; an upgrade that changes one of these formats means a fresh cluster loaded from your source data (for example with mirexa-cli load). Check which formats changed before upgrading. See On-disk formats.

Known limitations to plan around

  • A cutover of a heavily written partition freezes its writes for as long as its copy lags — tens of seconds at hundreds of thousands of candles per second.
  • A completed migration frees no disk on its source: files are moved under quarantine/, and nothing deletes a quarantine.
  • A node with many streams takes a long time to stop cleanly (about 45 ms per stream with buffered data, measured 2026-10-20 on one laptop).
  • No zone or rack awareness in placement.
  • The replication factor, partition count and liveness timeout cannot be changed after bootstrap.

See Known limitations.

References

Source

Tests

Further reading

External

  • grpcurl — https://github.com/fullstorydev/grpcurl
  • Prometheus, "Alerting rules" — https://prometheus.io/docs/prometheus/latest/configuration/alerting_rules/