CrushMFT Documentation

Operating#

  • Start, stop and status.
    • Linux: ./crushbalance_init.sh start|stop|restart|status (or systemctl … under systemd, Install on Linux).
    • Windows: net start|stop "CrushBalance Server".
    • A stop unbinds every listener at once, lets open connections finish for at most 3 seconds, resets the rest, saves the GeoIP cache and the sticky pins, and exits after about 4 seconds.
    • Only one CrushBalance can use a prefs directory: a second one exits with code 6 ("another CrushBalance (pid …, started …) is using …").
  • Monitoring with /healthz. GET https://<host>:8090/healthz needs no login (the admin address allowlist still applies). It answers 200 ok when CrushBalance is licensed, not in safe mode or stopping, every enabled and usable listener is bound, and every bound listener has at least one routable endpoint; otherwise 503 degraded. For example curl --cacert admin.pem https://balancer:8090/healthz (or -k with the generated certificate).
  • Prometheus /metrics. Off by default (404). Settings › Server › Prometheus metrics › Generate token shows a bearer token once; only its hash is stored. Scrape https://<host>:8090/metrics with Authorization: Bearer <token>; the scraper must be allowed by admin_allowed_ips. Rotate or turn it off in the same place. A Prometheus job:
    - job_name: crushbalance
      scheme: https
      authorization:
        type: Bearer
        credentials_file: /etc/prometheus/crushbalance.token
      tls_config:
        ca_file: /etc/prometheus/crushbalance-admin-ca.pem
      static_configs:
        - targets: ['balancer.example.com:8090']
    
    Labels carry listener and endpoint ids, never names.
  • Logs. CrushBalanceServer.log in the working directory (log_file), rotated at log_max_size_mb (50 MiB) into log_max_files (9) archives. Each line is yyyy/MM/dd_HH:mm:ss:SSS|CATEGORY|LEVEL|message.
    • log_level (default info) sets every category; log_categories overrides single ones, for example conn=warn,health=debug. Both apply at once (Settings › Logging). Categories: server, config, conn, route, health, tls, http, proxy, security, admin, geoip, license, and audit (always info).
    • conn writes one line per closed connection. At high connection rates set conn=warn, so the audit lines in the same file are not rotated away quickly.
    • The Logs page shows a live tail of the newest 5,000 lines, with level, category and text filters; its Audit mode shows the newest 1,000 audit entries.
  • Backups and restore.
    • Every new version of prefs.XML that loads as a CrushBalance 27 file (a save, or a hand edit, also one with errors) is copied to backup/prefs-<yyyyMMdd-HHmmss-SSS>.XML (the newest 50 are kept), so the newest backup is always the current configuration, hand edits included.
    • From the UI: System › Backups › Restore. It keeps the current admin password, metrics token and registration; the replaced version stays available as a backup.
    • By hand: copy a backup file over prefs.XML. CrushBalance applies it within about 2 seconds, exactly as it is, credentials included.
    • Backups hold encrypted passwords; restoring them needs the same crushbalance.key.
  • Hand edits and -check-config.
    • CrushBalance checks prefs.XML every 2 seconds (and hashes it every 60 s) and applies a changed file without a restart. Comments are removed at the next save.
    • The file is XML 1.0. A file whose declaration names another version (<?xml version="1.1"?>) is refused like a file that is not well-formed: PREFS_PARSE, "the XML declaration must say version="1.0"" (at startup that means safe mode).
    • Validate first: java -jar CrushBalance.jar -check-config (or -check-config <file> for a copy). It prints every finding as [ERROR] path: message and a summary, and exits 0, or 3 on an error. It never writes.
    • A file with errors still loads, with the notice "Configuration errors" (System › Configuration issues): only the faulty part is affected. At startup a listener with an error is not started, an endpoint with an error is not used, a rule list with an error denies everyone, and a global key with an error takes its default; on a reload the previous definition of that part stays in force.
    • A file that cannot be parsed while CrushBalance runs: the running configuration is kept, a banner reports it, and UI saves are refused (409) until you fix it or overwrite it from the UI (the invalid file is then kept as backup/…-invalid.XML).
  • Safe mode and how to leave it. If at startup prefs.XML cannot be parsed, is damaged, or was written by a newer CrushBalance, it is not modified, and CrushBalance starts in safe mode:
    • no listener is bound, but the process keeps running (systemd does not loop);
    • the admin UI accepts the admin password of the newest valid backup and shows the reason, with the line and column, the backups, and the configuration log;
    • leave it by restoring a backup in the UI (refused with "would lock out" if that backup's admin_allowed_ips excludes your address), by fixing the file by hand (CrushBalance re-checks it every 2 seconds and starts normally once it is valid), or by copying a backup over prefs.XML;
    • java -jar CrushBalance.jar -check-config prints the details;
    • without any valid backup the admin shows only a notice page: "CrushBalance is in safe mode: prefs.XML cannot be used. Run "java -jar CrushBalance.jar -check-config" on the server for details." Fix or replace the file; deleting it starts a new, empty configuration (setup again).
  • Sticky pins across restarts. Every live pin (client address and CrushAuth cookie) is saved to sticky-pins.dat every 60 seconds when pins changed and at shutdown, and restored at startup, so clients return to the same backend after a restart. The file holds hashed keys only, never an address or a cookie. Pins idle longer than the listener's sticky_ttl are dropped, downtime included. A crash loses at most 60 seconds of pin changes.
  • The key file and moving to another host. crushbalance.key encrypts the passwords in prefs.XML (keystore, probe and GeoIP passwords), derives the passwords of the generated certificates and keys the pin file.
    • Back it up together with the prefs directory.
    • To move to another host, copy prefs.XML and crushbalance.key (the generated certificates and sticky-pins.dat are optional).
    • Without the original key, encrypted values cannot be decrypted (notice "Secrets cannot be decrypted"; restore the original key file, or enter the passwords again), generated certificates are regenerated (new fingerprint), and the pin file is ignored. The licence and the admin password are not affected.
  • Certificate renewal. Replace the keystore file (listener tls_keystore or admin_keystore); CrushBalance checks it every 60 seconds and uses the new certificate for new connections. Expiry warnings appear 30, 7 and 1 days ahead (listeners) and from 30 days ahead (admin). With certbot, a deploy hook can build the PKCS12 file:
    openssl pkcs12 -export -in "$RENEWED_LINEAGE/fullchain.pem" -inkey "$RENEWED_LINEAGE/privkey.pem" \
      -name crushbalance -passout file:/etc/crushbalance/web.p12.pass -out /etc/crushbalance/web.p12.new \
      && chmod 600 /etc/crushbalance/web.p12.new && mv /etc/crushbalance/web.p12.new /etc/crushbalance/web.p12
    
    The password in the pass file must equal the listener's keystore password (one password for the keystore and its key). When CrushBalance runs as a non-root user (Install on Linux), also chown crushbalance: /etc/crushbalance/web.p12.new before the mv, so the service user can read the file. Generated certificates renew themselves 30 days before they expire. A listener that was not started because its keystore was unusable starts at the next save, hand edit or restart.