-
Notifications
You must be signed in to change notification settings - Fork 327
etcd-website: Update migration process guidance with etcdctl v3.4 #1044
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
wendy-ha18
wants to merge
13
commits into
etcd-io:main
Choose a base branch
from
wendy-ha18:etcd-website-revise-how-to-migrate
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
57aa50b
etcd-website: Update migration process with etcdctl v3.4
wendy-ha18 a4b3754
etcd-website: fix lints failed
wendy-ha18 d52a79a
etcd-website: revise the set command for clearer
wendy-ha18 b5a7dcb
etcd-website: fix lint failed with order list
wendy-ha18 8434658
etcd-website: fix DCO Sign check failed
wendy-ha18 417a148
etcd-website: fix alerts panel
wendy-ha18 aef6bc4
etcd-website: fix lint failed
wendy-ha18 92050f3
etcd-website: add emoji warning
wendy-ha18 cbab8de
etcd-website fix: moving how to migrate to v3.4
wendy-ha18 08ccc45
etcd-website: fix: Remove how to migrate in v3.5, 3.6, 3.7 and update…
wendy-ha18 fcd421b
etcd-website: fix: Update more details for the process and bring GIF …
wendy-ha18 1fedbf5
etcd-website: fix: minor fix wording
wendy-ha18 9c0e066
etcd-webiste: fix: fix lint failed
wendy-ha18 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
--- | ||
title: How to migrate etcd from v2 to v3 | ||
description: etcd v2 to v3 migration guide | ||
weight: 1200 | ||
--- | ||
|
||
`migrate` to transform etcd v2 to v3 data. | ||
|
||
{{% alert color="warning" %}} | ||
⚠️ **Deprecated functionality:** | ||
|
||
The `etcdctl migrate` command was removed in etcd v3.5.0 ([pull/12971](https://github.com/etcd-io/etcd/pull/12971)). If your etcd cluster is already running v3.5 or higher, you can no longer migrate v2 data to v3 using this method. | ||
|
||
You **must use etcdctl v3.4 or earlier** to perform the migration (View note from [CHANGELOG-3.5](https://github.com/ahrtr/etcd/blob/main/CHANGELOG/CHANGELOG-3.5.md#etcdctl-v3-3)). However please take appropriate precautions when using it, as it is no longer officially supported or tested in recent releases. | ||
{{% /alert %}} | ||
|
||
## Pre-requisites | ||
|
||
Before migrating from etcd v2 to v3, ensure the following: | ||
|
||
- A currently running etcd v2 cluster. | ||
- The `etcdctl` CLI tool version <= v3.4. | ||
- Access to each etcd node and their data directories. | ||
- A working backup of your etcd data before performing the migration. | ||
|
||
## Migrate a cluster | ||
|
||
The following steps show how to migrate your etcd data from v2 to v3 using `etcdctl migrate`. | ||
|
||
### Variables and Flags Used | ||
|
||
- `--endpoints`: Specifies the etcd cluster endpoint(s). | ||
- `--output`: Output format (e.g., `"json"`). | ||
- `--data-dir`: Path to the data directory (default: `default.etcd`). View more at [etcd flags](https://etcd.io/docs/v3.6/op-guide/configuration/#member). | ||
- `--wal-dir`: The write-ahead log directory inside `data-dir` (default: `default.etcd/member/wal`). View more at [etcd flags](https://etcd.io/docs/v3.6/op-guide/configuration/#member). | ||
- `set`: Command to set a key-value pair in etcd v2 (View [READMEv2](https://github.com/etcd-io/etcd/blob/main/etcdctl/READMEv2.md#setting-key-values) for more details. In etcd v3, the equivalent command is `put` instead of `set`, see the [READMEv3](https://github.com/etcd-io/etcd/tree/main/etcdctl#key-value-commands)) for reference. | ||
- `get`: Command to retrieve a key-value pair (View [Read keys](https://etcd.io/docs/v3.6/dev-guide/interacting_v3/#read-keys)). | ||
|
||
### Migration Process | ||
|
||
- Step 1: Set up test key using v2 API | ||
|
||
```sh | ||
export ETCDCTL_API=2 | ||
etcdctl --endpoints=http://$ENDPOINT set foo bar | ||
etcdctl --endpoints=http://$ENDPOINT --output="json" get foo | ||
``` | ||
|
||
- Step 2: Stop each etcd node (one at a time) | ||
|
||
Before running the migration, stop your etcd node to ensure data consistency. | ||
|
||
- Step 3: Run the migration tool | ||
|
||
Switch to API v3 and use `etcdctl migrate` command to transform the v2 store. Please review the deprecation alert on top of the page, you must use etcdctl v3.4 or earlier to be able to perform this command. | ||
|
||
```sh | ||
export ETCDCTL_API=3 | ||
etcdctl --endpoints=http://$ENDPOINT migrate \ | ||
--data-dir="default.etcd" \ | ||
--wal-dir="default.etcd/member/wal" | ||
``` | ||
|
||
- Step 4: Restart etcd node after migrate | ||
|
||
Repeat steps 2–4 for each etcd node one at a time in your cluster. | ||
|
||
- Step 5: Confirm the data is accessible via v3 API | ||
|
||
```sh | ||
etcdctl --endpoints=$ENDPOINTS get /foo | ||
``` | ||
|
||
Summary full process: | ||
|
||
```shell | ||
# write key in etcd version 2 store | ||
export ETCDCTL_API=2 | ||
etcdctl --endpoints=http://$ENDPOINT set foo bar | ||
|
||
# read key in etcd v2 | ||
etcdctl --endpoints=$ENDPOINTS --output="json" get foo | ||
|
||
# stop etcd node to migrate, one by one | ||
|
||
# migrate v2 data | ||
export ETCDCTL_API=3 | ||
etcdctl --endpoints=$ENDPOINT migrate --data-dir="default.etcd" --wal-dir="default.etcd/member/wal" | ||
|
||
# restart etcd node after migrate, one by one | ||
|
||
# confirm that the key got migrated | ||
etcdctl --endpoints=$ENDPOINTS get /foo | ||
``` | ||
|
||
## Visual guide for reference | ||
|
||
 |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion to add "store" to the page title to avoid confusion.