diff --git a/seaweed-block/docs/operations-manual.md b/seaweed-block/docs/operations-manual.md index ff732ff663..53cd6102a6 100644 --- a/seaweed-block/docs/operations-manual.md +++ b/seaweed-block/docs/operations-manual.md @@ -7,13 +7,17 @@ should not need them to finish a step. They are relative to the repository's `do The examples use one host, with everything on loopback. Where an address must change for several hosts, the step says so. For the Kubernetes alpha line, see the [Kubernetes quick start](quickstart-kubernetes.md). -**Two conventions:** +**Conventions:** - **Absolute paths under sudo.** Every command run with `sudo` names its binary by absolute path (`sudo /usr/local/bin/sw-block ...`). On RHEL and its rebuilds, sudo's `secure_path` does not include `/usr/local/bin`, so `sudo sw-block` answers `command not found`. Commands without sudo use the short name. - **Device names.** `/dev/` stands for a device name you read from `lsblk` on your host. Never copy a device name from an example. +- **Addresses.** `` and `` mean the private, mutually reachable addresses of your two hosts, read from + `ip -br addr` and checked against your network configuration. Replace these markers before running a command or + writing a file; they are not shell variables. `127.0.0.1` always means the host running that command. The + two-host procedure and each address's purpose are in [appendix B](#appendix-b-two-hosts-and-a-planned-move). Contents: @@ -33,6 +37,8 @@ Contents: Appendix A. [Build from source](#appendix-a-build-from-source) +Appendix B. [Two hosts and a planned move](#appendix-b-two-hosts-and-a-planned-move) + ## 0. Prerequisites This manual has been run end to end on Ubuntu 24.04 and on AlmaLinux 9 with SELinux enforcing. You need Linux with @@ -842,3 +848,157 @@ for b in blockmaster blockvolume sw-block; do go build -o $b ./cmd/$b; done ``` Then install them as in section 1, step 2. + +## Appendix B. Two hosts and a planned move + +This is the two-host variant of sections 0–5. A runs blockmaster, SeaweedFS and the initial holder (`s1`); B is +the move target (`s2`). Both use the same release and chunk store. The guest runs on A while A holds the volume, +then on B after the move. This procedure moves the block volume; it does not migrate a running guest application +or VM. Stop the application before unmounting and start it on B after checking its files. + +### Addresses and certificates, before starting services + +Install section 0's guest packages and section 1's binaries, user and units on **both** hosts. Install SeaweedFS +and run blockmaster only on A. Choose the private addresses before issuing certificates: + +| Marker or address | Where it comes from and where to use it | +|---|---| +| `:9180` | A's private interface; blockmaster listen address and every CLI/holder's `--master` | +| `:18888` | SeaweedFS filer gRPC on A; every `--chunk-filer` | +| `:9201`, `:9202` | s1's data/control addresses, in the spec and A's holder settings | +| `:9201`, `:9202` | s2's data/control addresses, in the spec, move command and B's holder settings | +| `127.0.0.1:9203` | Holder status/chunk control, read on A before the move and on B afterwards | +| `127.0.0.1:4420` | Guest NVMe/TCP on the current holder's host; never replace it with a node address | + +Use unused ports if these are occupied, changing every matching setting. Allow the control and SeaweedFS traffic +between the private hosts. SeaweedFS also advertises its master and volume-server addresses: both hosts must reach +those advertised addresses, not just the filer. In section 0's SeaweedFS unit, replace `-ip=127.0.0.1` with +`-ip=` before starting it. The example uses master 9333, filer HTTP 8888, filer gRPC 18888 and volume HTTP 8080; +confirm the actual listeners with `ss -ltn`. SeaweedFS traffic is not protected by blockmaster's mTLS: keep it on +the trusted private network. + +Issue certificates using [authenticate the control API](operator-guide.md#authenticate-the-control-api): a CA, +a master certificate whose SAN includes ``, node certificates with CN `s1` and `s2`, and a separate operator +certificate on each host (for example CN `ops-a` and `ops-b`). Add all four client certificates' SHA-256 fingerprints +to A's role file: `node s1`, `node s2`, `admin ops-a` and `admin ops-b`, respectively. Generate each private key on +its owning host and send only its CSR to the CA. Keep the CA signing key off the service hosts. + +Install the CA certificate, that host's node certificate/key and operator certificate/key under +`/etc/sw-block/tls/` as `ca.crt`, `node.crt`, `node.key`, `operator.crt`, `operator.key`. A additionally needs +`master.crt`, `master.key` and `roles`. Use root-owned files, group `sw-block`, mode 0640 for service keys and +mode 0750 for the directory. Keep the operator key readable only by its operator (root in the examples below). +The commands below run in a root shell (`sudo -i` first). On each host, export the operator credentials before CLI calls: + +```sh +export SW_BLOCK_TLS_CERT=/etc/sw-block/tls/operator.crt +export SW_BLOCK_TLS_KEY=/etc/sw-block/tls/operator.key +export SW_BLOCK_TLS_CA=/etc/sw-block/tls/ca.crt +``` + +An ordinary user's exported variables are not automatically passed through `sudo`. + +On A, section 2's spec must list **both** nodes, with data/control addresses from the table above. Keep v1's +4 GiB geometry and initial placement `s1/r1`. In `/etc/sw-block/blockmaster.env`, keep section 2's topology, +expected-slots and workspace settings, and replace the following two lines (literal addresses, no markers): + +```sh +SWB_MASTER_LISTEN=:9180 +SWB_MASTER_EXTRA_ARGS=--cluster-spec /etc/sw-block/cluster-spec.yaml --lifecycle-store /var/lib/sw-block-master/lifecycle --chunk-filer :18888 --chunk-path /swblock/chunks --tls-cert /etc/sw-block/tls/master.crt --tls-key /etc/sw-block/tls/master.key --tls-client-ca /etc/sw-block/tls/ca.crt --role-file /etc/sw-block/tls/roles --audit-log /var/lib/sw-block-master/audit.log +``` + +Then start blockmaster as in section 2. Check `cluster format-level` and `ops workspace show` with +`--master :9180`. A non-loopback listen without the complete mTLS configuration is refused. + +### Start the holder and guest on A + +`volume start` writes the instance settings but has no flags for the holder's mTLS credentials. Before its first +start, on **both** hosts add those flags to a per-instance systemd override. Run this from the release repository +installed in section 1; it copies the shipped `ExecStart` unchanged except for appending the three TLS flags. +The settings file's `--layout-id` and other extra arguments remain in use: + +```sh +mkdir -p /etc/systemd/system/sw-blockvolume@v1.service.d +test "$(grep -c '^ \$SWB_VOLUME_EXTRA_ARGS$' deploy/systemd/sw-blockvolume@.service)" = 1 && + { printf '[Service]\nExecStart=\n'; + sed -n '/^ExecStart=/,/^ \$SWB_VOLUME_EXTRA_ARGS$/p' deploy/systemd/sw-blockvolume@.service | + sed 's|^ \$SWB_VOLUME_EXTRA_ARGS$| $SWB_VOLUME_EXTRA_ARGS --master-tls-cert /etc/sw-block/tls/node.crt --master-tls-key /etc/sw-block/tls/node.key --master-ca /etc/sw-block/tls/ca.crt|'; + } > /etc/systemd/system/sw-blockvolume@v1.service.d/master-tls.conf +systemctl daemon-reload +``` + +The `test` must succeed; if it does not, inspect the shipped unit instead of starting with an empty override. +Keep this override aligned with the shipped `ExecStart` when upgrading the unit. + +On **A**, start v1 using section 3, with these explicit network addresses: + +```sh +/usr/local/bin/sw-block volume start v1 --master :9180 --server-id s1 --replica-id r1 \ + --data-addr :9201 --ctrl-addr :9202 --status-addr 127.0.0.1:9203 \ + --size 4GiB --nvme-listen 127.0.0.1:4420 --chunk-filer :18888 +``` + +Wait for Healthy, then attach the guest on **A** using section 3's loopback `nvme connect`, discover the device, +make its filesystem once and mount it. Write your test files; save their `sha256sum` output outside the volume +and copy that manifest to B. Take a snapshot as in section 5 on A. Commands needing the master/filer use +`--master :9180 --chunk-filer :18888`; commands using `--status-addr` run on the current holder's host. + +### Planned move A → B, with the guest following + +Prepare B's certificates, override, binary and guest packages **before** moving. B must have no stale local copy +of v1; do not copy A's WAL or settings file to B. Do not use `volume stop` between sealing and the revocation ACK. + +1. **On A**, check the files against the saved manifest, stop their writer, unmount `/mnt/v1` and disconnect the + guest with `nvme disconnect -n nqn.2026-05.io.seaweedfs:v1`. Leave the holder running. +2. **On A**, read the current replica `R` and epoch `E`, then seal. Copy the returned sealed HEAD generation `G`: + + ```sh + sw-block ops workspace show --master :9180 --volume v1 + sw-block ops chunk detach --plain --volume v1 --status-addr 127.0.0.1:9203 --timeout 120s + ``` + + Continue only after detach exits 0. `R`, `E` and `G` below are the values you just read, not literal arguments. +3. **On A**, revoke and repeat show until its recorded ACK matches **all three** values: + + ```sh + sw-block ops workspace revoke --master :9180 --volume v1 --replica R --epoch E --sealed-gen G + sw-block ops workspace show --master :9180 --volume v1 + ``` + + Require `recorded ACK: R@E HEAD generation G`. The holder exits 0 by itself; a signal stop skips the ACK. + Check `systemctl is-active sw-blockvolume@v1` reports inactive, then `systemctl disable sw-blockvolume@v1` + on A so it does not start there at boot. +4. **On A**, move authority, keeping one request id for all retries: + + ```sh + sw-block ops workspace move --clean --master :9180 --volume v1 --replica R --epoch E \ + --target-host s2 --target-data :9201 --target-ctrl :9202 --request-id move-v1-1 + ``` + + An unknown outcome is settled by the same command and request id. Do not start B until the move is issued. +5. **On B**, start the holder immediately (within the new epoch's 30-second lease): + + ```sh + /usr/local/bin/sw-block volume start v1 --master :9180 --server-id s2 --replica-id r1 \ + --data-addr :9201 --ctrl-addr :9202 --status-addr 127.0.0.1:9203 \ + --size 4GiB --nvme-listen 127.0.0.1:4420 --chunk-filer :18888 + ``` + + If that lease has already expired, the holder waits for the re-grant barrier. For this new format-level-1 + cluster, the barrier is the master's grant deadline plus configured clock skew: with defaults and no renewal + or master restart, 30 + 20 = 50 seconds after the move. A later renewal or master restart changes the relevant + deadline or restart floor. Follow the holder's typed re-grant retry/barrier answer; keep the same move request + id and target holder instead of issuing another move. The older format-level-0 horizon calculation in the + lifecycle page is not the rule for this level-1 cluster. +6. **On B**, require Healthy and check `ops workspace show --master :9180 --volume v1`: holder `r1` at + the new epoch and the issued `move-v1-1`. Connect NVMe using section 3's **loopback** command, discover B's + device and mount the existing filesystem at `/mnt/v1`. **Do not run mkfs again.** Check the copied SHA-256 + manifest against the mounted files before restarting their writer. A no longer has a connected guest. + +For iSCSI, use section 4's logout on A and section 3's loopback discovery/login on B instead of NVMe disconnect +and connect. The same seal, ACK and move sequence applies. Stop, snapshots and holder-status commands now run on B; +the master and filer remain on A. Keep the same volume size, replica id and chunk path throughout. + +For teardown, first stop and disconnect the guest on B, then stop/disable its holder. Check for active holders +on **both** hosts. Section 12's single-host removal block must not be run unchanged: remove only each host's own +units, override and local files after its services are inactive; remove blockmaster and the dedicated SeaweedFS +data only on A, after no holder on either host uses them.