The native libcephfs backend is the only transfer path. The rsync transport, the mounted-filesystem access and its helpers (mount check, path resolution below a mount, mount claim, quota and hardlink repair through the mount) are removed, together with the rsync lab test and the client image that only added rsync. The claim and release tests now exercise the native claim through a local test file system with real flock locks. BREAKING CHANGE: "backend": "rsync" and the endpoint field "mount" are rejected. "backend" is optional and only accepts "native"; jobs created with "native" resume without it. Journals of rsync jobs cannot be resumed. Builds without the build tag ceph only support doctor and status. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
232 lines
8.8 KiB
Markdown
232 lines
8.8 KiB
Markdown
# CephMig: migrate CephFS subvolumes between Ceph clusters
|
|
|
|
A Go tool that copies a CephFS subvolume, including its snapshots, POSIX ACLs,
|
|
xattrs, quotas and timestamps, from one Ceph cluster to another while the
|
|
application keeps running.
|
|
|
|
## Description
|
|
|
|
**Why?** A subvolume has to move to a new cluster with only a short write
|
|
stop. The target size is up to 200 TB and more than 200 million files. A
|
|
plain copy is not enough: snapshots, hardlinks and Ceph metadata must be
|
|
preserved, and an interrupted run must be resumable.
|
|
|
|
**How?** CephMig works in rounds. Each round transfers a consistent source
|
|
snapshot, verifies the target and creates a snapshot of the same name there.
|
|
A journal on local disk records every step. For the last round, all writers
|
|
are stopped briefly.
|
|
|
|
The copier talks to both clusters directly through libcephfs. It needs no
|
|
kernel or FUSE mount. After the initial transfer it uses snapdiff and, where
|
|
possible, blockdiff.
|
|
|
|
**Status:** prototype. The features are verified in the local lab. Load
|
|
tests at the target size and a production cutover are still missing.
|
|
|
|
> **Documented deviations:** native snapshot IDs and snapshot creation times
|
|
> are assigned anew at the target. CephMig takes mtime, atime,
|
|
> ctime and birth time (btime) of every file from the source; the ctime is
|
|
> never lower than the mtime. The original snapshot creation times are kept
|
|
> in the journal.
|
|
> Details: [docs/migration.md](docs/migration.md).
|
|
|
|
## Installation
|
|
|
|
Requirements:
|
|
|
|
- Linux, Go 1.25 or later and GNU Make
|
|
- for the copier and the lab: Docker Engine with Docker Compose and
|
|
`/dev/fuse` on the Docker host
|
|
- for the lab: up to 12 GiB RAM for the containers and about 8 GiB of disk
|
|
space for the two OSDs, plus space for the images
|
|
|
|
Get the source and build it:
|
|
|
|
```sh
|
|
git clone ssh://git@git.zb-server.de:30022/Sebi/CephfsMig.git
|
|
cd CephfsMig
|
|
make doctor # checks Go, Docker and Docker Compose
|
|
make build # builds bin/cephmig without libcephfs (doctor and status only)
|
|
make check # go vet, Go tests and a syntax check of the test scripts
|
|
```
|
|
|
|
The copier needs CGO and the libcephfs headers (build tag `ceph`), so it is
|
|
built in a container. The build also runs the Go tests with the race
|
|
detector:
|
|
|
|
```sh
|
|
make dev-native-build # builds the image cephmig-native:dev
|
|
```
|
|
|
|
## Usage
|
|
|
|
```text
|
|
cephmig doctor
|
|
cephmig inspect --config FILE
|
|
cephmig sync --config FILE --state FILE
|
|
cephmig finalize --config FILE --state FILE --writers-stopped
|
|
cephmig cleanup --config FILE --state FILE
|
|
cephmig status --state FILE
|
|
```
|
|
|
|
| Command | Effect |
|
|
|------------|----------------------------------------------------------------------|
|
|
| `inspect` | checks source and target without changing anything |
|
|
| `sync` | transfers the current state; can be repeated any number of times |
|
|
| `finalize` | last round after the write stop, then ready for cutover |
|
|
| `cleanup` | deletes the snapshots cephmig created and its claim on the target |
|
|
| `status` | prints the journal |
|
|
|
|
All results are written to standard output as JSON. The state file belongs
|
|
on local disk.
|
|
|
|
Steps of a migration:
|
|
|
|
1. Check source, target, permissions and capacity with `inspect`.
|
|
2. Make the initial copy with `sync` while the application keeps running.
|
|
3. Repeat `sync` to catch up with changes.
|
|
4. Stop all writing applications, then run `finalize --writers-stopped`.
|
|
5. Switch the clients to the target and release the applications.
|
|
6. Once the cutover is checked, remove the migration snapshots with `cleanup`.
|
|
|
|
A file system snapshot does not make a database application-consistent. The
|
|
write stop must cover all clients.
|
|
|
|
```mermaid
|
|
sequenceDiagram
|
|
actor Op as Operator
|
|
participant M as cephmig
|
|
participant S as Source cluster
|
|
participant T as Target cluster
|
|
|
|
Op->>M: inspect
|
|
M->>S: check subvolume
|
|
M->>T: check subvolume
|
|
loop sync, repeated while the application runs
|
|
Op->>M: sync
|
|
M->>S: create round snapshot
|
|
M->>T: copy changes, verify
|
|
M->>T: create round snapshot
|
|
M->>S: remove previous round snapshot
|
|
M->>T: remove previous round snapshot
|
|
end
|
|
Note over Op,S: stop all writers
|
|
Op->>M: finalize --writers-stopped
|
|
M->>S: create final snapshot
|
|
M->>T: copy, full verification, create final snapshot
|
|
M-->>Op: ready-for-cutover
|
|
Note over Op,T: switch clients to the target
|
|
Op->>M: cleanup
|
|
M->>S: remove final snapshot
|
|
M->>T: remove final snapshot
|
|
```
|
|
|
|
The detailed sequence is in [docs/migration.md](docs/migration.md#workflow-in-detail).
|
|
|
|
Intermediate `sync` rounds skip subtrees whose recursive change time
|
|
(`ceph.dir.rctime`) did not change, so a round reads only the changed parts.
|
|
`finalize` always reads everything.
|
|
|
|
Each round creates a snapshot `cephmig-<job>-<round>` at source and target;
|
|
`sync` deletes the older ones as soon as a newer round is complete. Users of
|
|
the subvolume therefore see at most one such snapshot during the migration,
|
|
and none after `cleanup`. Application snapshots are never deleted.
|
|
|
|
The configuration is a JSON file, here
|
|
[dev/migration.example.json](dev/migration.example.json) from the lab:
|
|
|
|
```json
|
|
{
|
|
"backend": "native",
|
|
"source": {
|
|
"config": "/clusters/source/ceph.conf",
|
|
"keyring": "/clusters/source/ceph.client.admin.keyring",
|
|
"filesystem": "cephfs",
|
|
"group": "migration",
|
|
"subvolume": "demo"
|
|
},
|
|
"target": {
|
|
"config": "/clusters/target/ceph.conf",
|
|
"keyring": "/clusters/target/ceph.client.admin.keyring",
|
|
"filesystem": "cephfs",
|
|
"group": "migration",
|
|
"subvolume": "demo"
|
|
},
|
|
"bandwidth_kib": 0
|
|
}
|
|
```
|
|
|
|
Optional fields are `user` (Ceph client identity, e.g. `client.migration`),
|
|
`workers` (0 to 64; 0 selects the default) and `full_scan` (`true` makes
|
|
every round read all metadata instead of skipping unchanged subtrees).
|
|
`backend` may be omitted; its only value is `native`.
|
|
|
|
## Examples
|
|
|
|
The lab starts two independent Ceph clusters (Ceph 21.2.0) in Docker and runs
|
|
the migration between them:
|
|
|
|
```sh
|
|
make dev-up # start the clusters
|
|
make dev-status # state of both clusters
|
|
make dev-smoke # smoke test: snapshot, ACLs, xattrs, hardlinks, quotas
|
|
make dev-native-test # native functional test
|
|
docker compose -f dev/compose.yaml exec native cephmig-native inspect \
|
|
--config /lab/migration.example.json
|
|
make dev-down # stop; the data is kept
|
|
```
|
|
|
|
More tests:
|
|
|
|
| Target | Content |
|
|
|----------------------------|-----------------------------------------------------------|
|
|
| `make dev-smallfiles-test` | 10,000 small files (`FILES=2000` limits the number) |
|
|
| `make dev-million-start` | one million files with four snapshot states |
|
|
| `make dev-restart-check` | restart of the lab; FSIDs and data are preserved |
|
|
|
|
Results of documented runs: [docs/smallfiles-local.md](docs/smallfiles-local.md)
|
|
and [docs/million-local.md](docs/million-local.md).
|
|
|
|
## Project structure
|
|
|
|
```text
|
|
.
|
|
├── cmd/
|
|
│ ├── cephmig/ command-line program
|
|
│ └── nativeprobe/ diagnostic tool for the libcephfs binding
|
|
├── internal/
|
|
│ ├── migration/ migration workflow, journal and native transfer
|
|
│ ├── storage/ file system interface of the native copier
|
|
│ └── cephfsnative/ CGO binding to libcephfs (build tag ceph)
|
|
├── dev/ lab: Compose files, Dockerfiles, test scripts
|
|
├── docs/ detailed documentation and measurements
|
|
└── Makefile build, check and lab targets
|
|
```
|
|
|
|
## Documentation
|
|
|
|
- [docs/migration.md](docs/migration.md): commands, limits and evidence
|
|
- [docs/lab.md](docs/lab.md): the lab in detail, Ceph version, known warnings
|
|
- [docs/raw-transfer.md](docs/raw-transfer.md): direct RADOS import and limits of the native implementation
|
|
- [docs/verify-concept.md](docs/verify-concept.md): concept for a full content verification after the cutover
|
|
- API documentation of the Go packages: `go doc -all ./internal/migration`
|
|
|
|
## Contributing
|
|
|
|
- Go code follows [Effective Go](https://go.dev/doc/effective_go) and is
|
|
formatted with `gofmt`. Exported identifiers have doc comments.
|
|
- Run `make check` before every commit.
|
|
- Commit messages follow [Conventional Commits 1.0.0](https://www.conventionalcommits.org/en/v1.0.0/),
|
|
for example `feat(migration): add bandwidth limit` or
|
|
`fix(native): retry on EEXIST`. Breaking changes are marked with `!` and a
|
|
`BREAKING CHANGE:` footer.
|
|
|
|
## License
|
|
|
|
No license has been chosen yet. Without a license, all rights are reserved.
|
|
|
|
## Contact
|
|
|
|
Sebastian Unterschütz. Please report questions and bugs as issues in the
|
|
repository [Sebi/CephfsMig](https://git.zb-server.de/Sebi/CephfsMig).
|