1**This is the documentation for etcd2 releases. Read [etcd3 doc][v3-docs] for etcd3 releases.**
2
3[v3-docs]: ../docs.md#documentation
4
5
6# Upgrade etcd from 2.1 to 2.2
7
8In the general case, upgrading from etcd 2.1 to 2.2 can be a zero-downtime, rolling upgrade:
9
10 - one by one, stop the etcd v2.1 processes and replace them with etcd v2.2 processes
11 - after you are running all v2.2 processes, new features in v2.2 are available to the cluster
12
13Before [starting an upgrade](#upgrade-procedure), read through the rest of this guide to prepare.
14
15## Upgrade Checklists
16
17### Upgrade Requirement
18
19To upgrade an existing etcd deployment to 2.2, you must be running 2.1. If you’re running a version of etcd before 2.1, you must upgrade to [2.1][v2.1] before upgrading to 2.2.
20
21Also, to ensure a smooth rolling upgrade, your running cluster must be healthy. You can check the health of the cluster by using `etcdctl cluster-health` command.
22
23### Preparedness
24
25Before upgrading etcd, always test the services relying on etcd in a staging environment before deploying the upgrade to the production environment.
26
27You might also want to [backup the data directory][backup-datastore] for a potential [downgrade].
28
29### Mixed Versions
30
31While upgrading, an etcd cluster supports mixed versions of etcd members. The cluster is only considered upgraded once all its members are upgraded to 2.2.
32
33Internally, etcd members negotiate with each other to determine the overall etcd cluster version, which controls the reported cluster version and the supported features.
34
35### Limitations
36
37If you have a data size larger than 100MB you should contact us before upgrading, so we can make sure the upgrades work smoothly.
38
39Every etcd 2.2 member will do health checking across the cluster periodically. etcd 2.1 member does not support health checking. During the upgrade, etcd 2.2 member will log warning about the unhealthy state of etcd 2.1 member. You can ignore the warning.
40
41### Downgrade
42
43If all members have been upgraded to v2.2, the cluster will be upgraded to v2.2, and downgrade is **not possible**. If any member is still v2.1, the cluster will remain in v2.1, and you can go back to use v2.1 binary.
44
45Please [backup the data directory][backup-datastore] of all etcd members if you want to downgrade the cluster, even if it is upgraded.
46
47### Upgrade Procedure
48
49In the example, we upgrade a three member v2.1 cluster running on local machine.
50
51#### 1. Check upgrade requirements.
52
53```
54$ etcdctl cluster-health
55member 6e3bd23ae5f1eae0 is healthy: got healthy result from http://localhost:22379
56member 924e2e83e93f2560 is healthy: got healthy result from http://localhost:32379
57member a8266ecf031671f3 is healthy: got healthy result from http://localhost:12379
58cluster is healthy
59
60$ curl http://localhost:4001/version
61{"etcdserver":"2.1.x","etcdcluster":"2.1.0"}
62```
63
64#### 2. Stop the existing etcd process
65
66You will see similar error logging from other etcd processes in your cluster. This is normal, since you just shut down a member and the connection is broken.
67
68```
692015/09/2 09:48:35 etcdserver: failed to reach the peerURL(http://localhost:12380) of member a8266ecf031671f3 (Get http://localhost:12380/version: dial tcp [::1]:12380: getsockopt: connection refused)
702015/09/2 09:48:35 etcdserver: cannot get the version of member a8266ecf031671f3 (Get http://localhost:12380/version: dial tcp [::1]:12380: getsockopt: connection refused)
712015/09/2 09:48:35 rafthttp: failed to write a8266ecf031671f3 on stream Message (write tcp 127.0.0.1:32380->127.0.0.1:64394: write: broken pipe)
722015/09/2 09:48:35 rafthttp: failed to write a8266ecf031671f3 on pipeline (dial tcp [::1]:12380: getsockopt: connection refused)
732015/09/2 09:48:40 etcdserver: failed to reach the peerURL(http://localhost:7001) of member a8266ecf031671f3 (Get http://localhost:7001/version: dial tcp [::1]:12380: getsockopt: connection refused)
742015/09/2 09:48:40 etcdserver: cannot get the version of member a8266ecf031671f3 (Get http://localhost:12380/version: dial tcp [::1]:12380: getsockopt: connection refused)
752015/09/2 09:48:40 rafthttp: failed to heartbeat a8266ecf031671f3 on stream MsgApp v2 (write tcp 127.0.0.1:32380->127.0.0.1:64393: write: broken pipe)
76```
77
78You will see logging output like this from ungraded member due to a mixed version cluster. You can ignore this while upgrading.
79
80```
812015/09/2 09:48:45 etcdserver: the etcd version 2.1.2+git is not up-to-date
822015/09/2 09:48:45 etcdserver: member a8266ecf031671f3 has a higher version &{2.2.0-rc.0+git 2.1.0}
83```
84
85You will also see logging output like this from the newly upgraded member, since etcd 2.1 member does not support health checking. You can ignore this while upgrading.
86
87```
882015-09-02 09:55:42.691384 W | rafthttp: the connection to peer 6e3bd23ae5f1eae0 is unhealthy
892015-09-02 09:55:42.705626 W | rafthttp: the connection to peer 924e2e83e93f2560 is unhealthy
90
91```
92
93[Backup your data directory][backup-datastore] for data safety.
94
95```
96$ etcdctl backup \
97      --data-dir /var/lib/etcd \
98      --backup-dir /tmp/etcd_backup
99```
100
101#### 3. Drop-in etcd v2.2 binary and start the new etcd process
102
103Now, you can start the etcd v2.2 binary with the previous configuration.
104You will see the etcd start and publish its information to the cluster.
105
106```
1072015-09-02 09:56:46.117609 I | etcdserver: published {Name:infra2 ClientURLs:[http://localhost:22380]} to cluster e9c7614f68f35fb2
108```
109
110You could verify the cluster becomes healthy.
111
112```
113$ etcdctl cluster-health
114member 6e3bd23ae5f1eae0 is healthy: got healthy result from http://localhost:22379
115member 924e2e83e93f2560 is healthy: got healthy result from http://localhost:32379
116member a8266ecf031671f3 is healthy: got healthy result from http://localhost:12379
117cluster is healthy
118```
119
120#### 4. Repeat step 2 to step 3 for all other members
121
122#### 5. Finish
123
124When all members are upgraded, you will see the cluster is upgraded to 2.2 successfully:
125
126```
1272015-09-02 09:56:54.896848 N | etcdserver: updated the cluster version from 2.1 to 2.2
128```
129
130```
131$ curl http://127.0.0.1:4001/version
132{"etcdserver":"2.2.x","etcdcluster":"2.2.0"}
133```
134
135[backup-datastore]: admin_guide.md#backing-up-the-datastore
136[downgrade]: #downgrade
137[v2.1]: https://github.com/coreos/etcd/releases/tag/v2.1.2
138