1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498
| 1.下载etcd的软件包 wget https://github.com/etcd-io/etcd/releases/download/v3.6.10/etcd-v3.6.10-linux-amd64.tar.gz
2 解压etcd的二进制程序包到PATH环境变量路径 [root@k8s-cluster241 ~]# tar -xf etcd-v3.6.10-linux-amd64.tar.gz -C /usr/local/bin etcd-v3.6.10-linux-amd64/etcd{,utl,ctl} --strip-components=1 [root@k8s-cluster241 ~]# [root@k8s-cluster241 ~]# ll /usr/local/bin/etcd* -rwxr-xr-x 1 lkl lkl 26607800 Apr 2 02:30 /usr/local/bin/etcd* -rwxr-xr-x 1 lkl lkl 17469624 Apr 2 02:30 /usr/local/bin/etcdctl* -rwxr-xr-x 1 lkl lkl 17617080 Apr 2 02:30 /usr/local/bin/etcdutl* [root@k8s-cluster241 ~]# [root@k8s-cluster241 ~]# etcdctl version etcdctl version: 3.6.10 API version: 3.6 [root@k8s-cluster241 ~]#
3 将软件包下发到所有节点 [root@k8s-cluster241 ~]# scp /usr/local/bin/etcd* k8s-cluster242:/usr/local/bin
[root@k8s-cluster241 ~]# scp /usr/local/bin/etcd* k8s-cluster243:/usr/local/bin
4.安装cfssl证书管理工具 [root@k8s-cluster241 ~]# wget http://192.168.14.253/Resources/Prometheus/softwares/Etcd/k8s-cfssl-v1.6.5.zip
[root@k8s-cluster241 ~]# unzip k8s-cfssl-v1.6.5.zip
[root@k8s-cluster241 ~]# rename -v "s/_1.6.5_linux_amd64//g" cfssl*
[root@k8s-cluster241 ~]# mv cfssl* /usr/local/bin/ [root@k8s-cluster241 ~]#
[root@k8s-cluster241 ~]# chmod +x /usr/local/bin/cfssl* [root@k8s-cluster241 ~]# [root@k8s-cluster241 ~]# ll /usr/local/bin/cfssl* -rwxr-xr-x 1 root root 11890840 Jun 15 2024 /usr/local/bin/cfssl* -rwxr-xr-x 1 root root 8413336 Jun 15 2024 /usr/local/bin/cfssl-certinfo* -rwxr-xr-x 1 root root 6205592 Jun 15 2024 /usr/local/bin/cfssljson* [root@k8s-cluster241 ~]# [root@k8s-cluster241 ~]#
5.创建证书存储目录 [root@k8s-cluster241 ~]# mkdir -pv /k8s/{pki,certs}/etcd mkdir: created directory '/k8s' mkdir: created directory '/k8s/pki' mkdir: created directory '/k8s/pki/etcd' mkdir: created directory '/k8s/certs' mkdir: created directory '/k8s/certs/etcd' [root@k8s-cluster241 ~]# [root@k8s-cluster241 ~]# tree /k8s/ /k8s/ ├── certs │ └── etcd └── pki └── etcd
4 directories, 0 files [root@k8s-cluster241 ~]#
6.生成证书的CSR文件: 证书签发请求文件,配置了一些域名,公司,单位 [root@k8s-cluster241 ~]# cd /k8s/pki/etcd/ [root@k8s-cluster241 etcd]# [root@k8s-cluster241 etcd]# cat > etcd-ca-csr.json <<EOF { "CN": "etcd", "key": { "algo": "rsa", "size": 2048 }, "names": [ { "C": "CN", "ST": "Beijing", "L": "Beijing", "O": "etcd", "OU": "Etcd Security" } ], "ca": { "expiry": "876000h" } } EOF
7. 生成etcd CA证书和CA证书的key [root@k8s-cluster241 etcd]# cfssl gencert -initca etcd-ca-csr.json | cfssljson -bare /k8s/certs/etcd/etcd-ca [root@k8s-cluster241 etcd]# [root@k8s-cluster241 etcd]# ll /k8s/certs/etcd/etcd-ca* -rw-r--r-- 1 root root 1050 May 4 11:09 /k8s/certs/etcd/etcd-ca.csr -rw------- 1 root root 1679 May 4 11:09 /k8s/certs/etcd/etcd-ca-key.pem -rw-r--r-- 1 root root 1318 May 4 11:09 /k8s/certs/etcd/etcd-ca.pem [root@k8s-cluster241 etcd]#
8. 生成etcd证书的有效期为100年 [root@k8s-cluster241 etcd]# cat > ca-config.json <<EOF { "signing": { "default": { "expiry": "876000h" }, "profiles": { "kubernetes": { "usages": [ "signing", "key encipherment", "server auth", "client auth" ], "expiry": "876000h" } } } } EOF
9.生成证书的CSR文件: 证书签发请求文件,配置了一些域名,公司,单位 [root@k8s-cluster241 etcd]# cat > etcd-csr.json <<EOF { "CN": "etcd", "key": { "algo": "rsa", "size": 2048 }, "names": [ { "C": "CN", "ST": "Beijing", "L": "Beijing", "O": "etcd", "OU": "Etcd Security" } ] } EOF
10.基于自建的ectd ca证书生成etcd的证书 [root@k8s-cluster241 etcd]# cfssl gencert \ -ca=/k8s/certs/etcd/etcd-ca.pem \ -ca-key=/k8s/certs/etcd/etcd-ca-key.pem \ -config=ca-config.json \ --hostname=127.0.0.1,k8s-cluster241,k8s-cluster242,k8s-cluster243,10.0.0.241,10.0.0.242,10.0.0.243 \ --profile=kubernetes \ etcd-csr.json | cfssljson -bare /k8s/certs/etcd/etcd-server
[root@k8s-cluster241 etcd]# ll /k8s/certs/etcd/etcd-server* -rw-r--r-- 1 root root 1139 May 4 11:12 /k8s/certs/etcd/etcd-server.csr -rw------- 1 root root 1679 May 4 11:12 /k8s/certs/etcd/etcd-server-key.pem -rw-r--r-- 1 root root 1472 May 4 11:12 /k8s/certs/etcd/etcd-server.pem [root@k8s-cluster241 etcd]#
11.将etcd证书同步到其他两个master节点 [root@k8s-cluster241 etcd]# tree /k8s/ /k8s/ ├── certs │ └── etcd │ ├── etcd-ca.csr │ ├── etcd-ca-key.pem │ ├── etcd-ca.pem │ ├── etcd-server.csr │ ├── etcd-server-key.pem │ └── etcd-server.pem └── pki └── etcd ├── ca-config.json ├── etcd-ca-csr.json └── etcd-csr.json
4 directories, 9 files [root@k8s-cluster241 etcd]# [root@k8s-cluster241 etcd]# [root@k8s-cluster241 etcd]# data_rsync.sh /k8s/ ===== rsyncing k8s-cluster242: k8s ===== 命令执行成功! ===== rsyncing k8s-cluster243: k8s ===== 命令执行成功! [root@k8s-cluster241 etcd]#
12.k8s-cluster241节点的配置文件 [root@k8s-cluster241 ~]# mkdir -pv /k8s/softwares/etcd mkdir: created directory '/k8s/softwares' mkdir: created directory '/k8s/softwares/etcd' [root@k8s-cluster241 ~]# [root@k8s-cluster241 ~]# cat > /k8s/softwares/etcd/etcd.config.yml <<'EOF' name: 'k8s-cluster241' data-dir: /var/lib/etcd wal-dir: /var/lib/etcd/wal snapshot-count: 5000 heartbeat-interval: 100 election-timeout: 1000 quota-backend-bytes: 0 listen-peer-urls: 'https://10.0.0.241:2380' listen-client-urls: 'https://10.0.0.241:2379,http://127.0.0.1:2379' max-snapshots: 3 max-wals: 5 cors: initial-advertise-peer-urls: 'https://10.0.0.241:2380' advertise-client-urls: 'https://10.0.0.241:2379' discovery: discovery-fallback: 'proxy' discovery-proxy: discovery-srv: initial-cluster: 'k8s-cluster241=https://10.0.0.241:2380,k8s-cluster242=https://10.0.0.242:2380,k8s-cluster243=https://10.0.0.243:2380' initial-cluster-token: 'etcd-k8s-cluster' initial-cluster-state: 'new' strict-reconfig-check: false enable-v2: true enable-pprof: true proxy: 'off' proxy-failure-wait: 5000 proxy-refresh-interval: 30000 proxy-dial-timeout: 1000 proxy-write-timeout: 5000 proxy-read-timeout: 0 client-transport-security: cert-file: '/k8s/certs/etcd/etcd-server.pem' key-file: '/k8s/certs/etcd/etcd-server-key.pem' client-cert-auth: true trusted-ca-file: '/k8s/certs/etcd/etcd-ca.pem' auto-tls: true peer-transport-security: cert-file: '/k8s/certs/etcd/etcd-server.pem' key-file: '/k8s/certs/etcd/etcd-server-key.pem' peer-client-cert-auth: true trusted-ca-file: '/k8s/certs/etcd/etcd-ca.pem' auto-tls: true debug: false log-package-levels: log-outputs: [default] force-new-cluster: false EOF
13.k8s-cluster242节点的配置文件 [root@k8s-cluster242 ~]# mkdir -pv /k8s/softwares/etcd mkdir: created directory '/k8s/softwares' mkdir: created directory '/k8s/softwares/etcd' [root@k8s-cluster242 ~]# [root@k8s-cluster242 ~]# cat > /k8s/softwares/etcd/etcd.config.yml <<'EOF' name: 'k8s-cluster242' data-dir: /var/lib/etcd wal-dir: /var/lib/etcd/wal snapshot-count: 5000 heartbeat-interval: 100 election-timeout: 1000 quota-backend-bytes: 0 listen-peer-urls: 'https://10.0.0.242:2380' listen-client-urls: 'https://10.0.0.242:2379,http://127.0.0.1:2379' max-snapshots: 3 max-wals: 5 cors: initial-advertise-peer-urls: 'https://10.0.0.242:2380' advertise-client-urls: 'https://10.0.0.242:2379' discovery: discovery-fallback: 'proxy' discovery-proxy: discovery-srv: initial-cluster: 'k8s-cluster241=https://10.0.0.241:2380,k8s-cluster242=https://10.0.0.242:2380,k8s-cluster243=https://10.0.0.243:2380' initial-cluster-token: 'etcd-k8s-cluster' initial-cluster-state: 'new' strict-reconfig-check: false enable-v2: true enable-pprof: true proxy: 'off' proxy-failure-wait: 5000 proxy-refresh-interval: 30000 proxy-dial-timeout: 1000 proxy-write-timeout: 5000 proxy-read-timeout: 0 client-transport-security: cert-file: '/k8s/certs/etcd/etcd-server.pem' key-file: '/k8s/certs/etcd/etcd-server-key.pem' client-cert-auth: true trusted-ca-file: '/k8s/certs/etcd/etcd-ca.pem' auto-tls: true peer-transport-security: cert-file: '/k8s/certs/etcd/etcd-server.pem' key-file: '/k8s/certs/etcd/etcd-server-key.pem' peer-client-cert-auth: true trusted-ca-file: '/k8s/certs/etcd/etcd-ca.pem' auto-tls: true debug: false log-package-levels: log-outputs: [default] force-new-cluster: false EOF
14.k8s-cluster243节点的配置文件 [root@k8s-cluster243 ~]# mkdir -pv /k8s/softwares/etcd mkdir: created directory '/k8s/softwares' mkdir: created directory '/k8s/softwares/etcd' [root@k8s-cluster243 ~]# [root@k8s-cluster243 ~]# cat > /k8s/softwares/etcd/etcd.config.yml <<'EOF' name: 'k8s-cluster243' data-dir: /var/lib/etcd wal-dir: /var/lib/etcd/wal snapshot-count: 5000 heartbeat-interval: 100 election-timeout: 1000 quota-backend-bytes: 0 listen-peer-urls: 'https://10.0.0.243:2380' listen-client-urls: 'https://10.0.0.243:2379,http://127.0.0.1:2379' max-snapshots: 3 max-wals: 5 cors: initial-advertise-peer-urls: 'https://10.0.0.243:2380' advertise-client-urls: 'https://10.0.0.243:2379' discovery: discovery-fallback: 'proxy' discovery-proxy: discovery-srv: initial-cluster: 'k8s-cluster241=https://10.0.0.241:2380,k8s-cluster242=https://10.0.0.242:2380,k8s-cluster243=https://10.0.0.243:2380' initial-cluster-token: 'etcd-k8s-cluster' initial-cluster-state: 'new' strict-reconfig-check: false enable-v2: true enable-pprof: true proxy: 'off' proxy-failure-wait: 5000 proxy-refresh-interval: 30000 proxy-dial-timeout: 1000 proxy-write-timeout: 5000 proxy-read-timeout: 0 client-transport-security: cert-file: '/k8s/certs/etcd/etcd-server.pem' key-file: '/k8s/certs/etcd/etcd-server-key.pem' client-cert-auth: true trusted-ca-file: '/k8s/certs/etcd/etcd-ca.pem' auto-tls: true peer-transport-security: cert-file: '/k8s/certs/etcd/etcd-server.pem' key-file: '/k8s/certs/etcd/etcd-server-key.pem' peer-client-cert-auth: true trusted-ca-file: '/k8s/certs/etcd/etcd-ca.pem' auto-tls: true debug: false log-package-levels: log-outputs: [default] force-new-cluster: false EOF
15.所有节点编写etcd启动脚本 cat > /usr/lib/systemd/system/etcd.service <<'EOF' [Unit] Description=Jason Yin's Etcd Service Documentation=https://coreos.com/etcd/docs/latest/ After=network.target
[Service] Type=notify ExecStart=/usr/local/bin/etcd --config-file=/k8s/softwares/etcd/etcd.config.yml Restart=on-failure RestartSec=10 LimitNOFILE=65536
[Install] WantedBy=multi-user.target Alias=etcd3.service EOF
16.所有节点启动etcd集群 systemctl daemon-reload && systemctl enable --now etcd systemctl status etcd
17.查看etcd集群状态 [root@k8s-cluster241 ~]# etcdctl --endpoints="https://10.0.0.241:2379,https://10.0.0.242:2379,https://10.0.0.243:2379" --cacert=/k8s/certs/etcd/etcd-ca.pem --cert=/k8s/certs/etcd/etcd-server.pem --key=/k8s/certs/etcd/etcd-server-key.pem endpoint status --write-out=table +-------------------------+------------------+---------+-----------------+---------+--------+-----------------------+--------+-----------+------------+-----------+------------+--------------------+--------+--------------------------+-------------------+ | ENDPOINT | ID | VERSION | STORAGE VERSION | DB SIZE | IN USE | PERCENTAGE NOT IN USE | QUOTA | IS LEADER | IS LEARNER | RAFT TERM | RAFT INDEX | RAFT APPLIED INDEX | ERRORS | DOWNGRADE TARGET VERSION | DOWNGRADE ENABLED | +-------------------------+------------------+---------+-----------------+---------+--------+-----------------------+--------+-----------+------------+-----------+------------+--------------------+--------+--------------------------+-------------------+ | https://10.0.0.241:2379 | 566d563f3c9274ed | 3.6.10 | 3.6.0 | 20 kB | 16 kB | 20% | 2.1 GB | true | false | 2 | 9 | 9 | | | false | | https://10.0.0.242:2379 | b83b69ba7d246b29 | 3.6.10 | 3.6.0 | 20 kB | 16 kB | 20% | 2.1 GB | false | false | 2 | 9 | 9 | | | false | | https://10.0.0.243:2379 | 47b70f9ecb1f200 | 3.6.10 | 3.6.0 | 20 kB | 16 kB | 20% | 2.1 GB | false | false | 2 | 9 | 9 | | | false | +-------------------------+------------------+---------+-----------------+---------+--------+-----------------------+--------+-----------+------------+-----------+------------+--------------------+--------+--------------------------+-------------------+ [root@k8s-cluster241 ~]#
18.验证etcd高可用集群 18.1 停止leader节点 [root@k8s-cluster241 ~]# ss -ntl | egrep "2379|2380" LISTEN 0 16384 10.0.0.241:2379 0.0.0.0:* LISTEN 0 16384 10.0.0.241:2380 0.0.0.0:* LISTEN 0 16384 127.0.0.1:2379 0.0.0.0:* [root@k8s-cluster241 ~]# [root@k8s-cluster241 ~]# systemctl stop etcd [root@k8s-cluster241 ~]# [root@k8s-cluster241 ~]# ss -ntl | egrep "2379|2380" [root@k8s-cluster241 ~]#
18.2 查看现有集群环境,发现新leader诞生 [root@k8s-cluster241 ~]# etcdctl --endpoints="https://10.0.0.241:2379,https://10.0.0.242:2379,https://10.0.0.243:2379" --cacert=/k8s/certs/etcd/etcd-ca.pem --cert=/k8s/certs/etcd/etcd-server.pem --key=/k8s/certs/etcd/etcd-server-key.pem endpoint status --write-out=table {"level":"warn","ts":"2026-05-04T11:19:26.883598+0800","logger":"etcd-client","caller":"v3@v3.6.10/retry_interceptor.go:68","msg":"retrying of unary invoker failed","target":"etcd-endpoints://0xc00033e5a0/10.0.0.241:2379","peer":"Peer{Addr: <nil>, LocalAddr: <nil>, AuthInfo: <nil>}","method":"/etcdserverpb.Maintenance/Status","attempt":0,"error":"rpc error: code = DeadlineExceeded desc = latest balancer error: connection error: desc = \"transport: Error while dialing: dial tcp 10.0.0.241:2379: connect: connection refused\""} Failed to get the status of endpoint https://10.0.0.241:2379 (context deadline exceeded) +-------------------------+------------------+---------+-----------------+---------+--------+-----------------------+--------+-----------+------------+-----------+------------+--------------------+--------+--------------------------+-------------------+ | ENDPOINT | ID | VERSION | STORAGE VERSION | DB SIZE | IN USE | PERCENTAGE NOT IN USE | QUOTA | IS LEADER | IS LEARNER | RAFT TERM | RAFT INDEX | RAFT APPLIED INDEX | ERRORS | DOWNGRADE TARGET VERSION | DOWNGRADE ENABLED | +-------------------------+------------------+---------+-----------------+---------+--------+-----------------------+--------+-----------+------------+-----------+------------+--------------------+--------+--------------------------+-------------------+ | https://10.0.0.242:2379 | b83b69ba7d246b29 | 3.6.10 | 3.6.0 | 20 kB | 16 kB | 20% | 2.1 GB | true | false | 3 | 10 | 10 | | | false | | https://10.0.0.243:2379 | 47b70f9ecb1f200 | 3.6.10 | 3.6.0 | 20 kB | 16 kB | 20% | 2.1 GB | false | false | 3 | 10 | 10 | | | false | +-------------------------+------------------+---------+-----------------+---------+--------+-----------------------+--------+-----------+------------+-----------+------------+--------------------+--------+--------------------------+-------------------+ [root@k8s-cluster241 ~]#
18.3 再将之前的leader起来 [root@k8s-cluster241 ~]# ss -ntl | egrep "2379|2380" [root@k8s-cluster241 ~]# [root@k8s-cluster241 ~]# systemctl start etcd [root@k8s-cluster241 ~]# [root@k8s-cluster241 ~]# ss -ntl | egrep "2379|2380" LISTEN 0 16384 10.0.0.241:2379 0.0.0.0:* LISTEN 0 16384 10.0.0.241:2380 0.0.0.0:* LISTEN 0 16384 127.0.0.1:2379 0.0.0.0:* [root@k8s-cluster241 ~]# [root@k8s-cluster241 ~]# etcdctl --endpoints="https://10.0.0.241:2379,https://10.0.0.242:2379,https://10.0.0.243:2379" --cacert=/k8s/certs/etcd/etcd-ca.pem --cert=/k8s/certs/etcd/etcd-server.pem --key=/k8s/certs/etcd/etcd-server-key.pem endpoint status --write-out=table +-------------------------+------------------+---------+-----------------+---------+--------+-----------------------+--------+-----------+------------+-----------+------------+--------------------+--------+--------------------------+-------------------+ | ENDPOINT | ID | VERSION | STORAGE VERSION | DB SIZE | IN USE | PERCENTAGE NOT IN USE | QUOTA | IS LEADER | IS LEARNER | RAFT TERM | RAFT INDEX | RAFT APPLIED INDEX | ERRORS | DOWNGRADE TARGET VERSION | DOWNGRADE ENABLED | +-------------------------+------------------+---------+-----------------+---------+--------+-----------------------+--------+-----------+------------+-----------+------------+--------------------+--------+--------------------------+-------------------+ | https://10.0.0.241:2379 | 566d563f3c9274ed | 3.6.10 | 3.6.0 | 25 kB | 25 kB | 0% | 2.1 GB | false | false | 3 | 11 | 11 | | | false | | https://10.0.0.242:2379 | b83b69ba7d246b29 | 3.6.10 | 3.6.0 | 20 kB | 16 kB | 20% | 2.1 GB | true | false | 3 | 11 | 11 | | | false | | https://10.0.0.243:2379 | 47b70f9ecb1f200 | 3.6.10 | 3.6.0 | 20 kB | 16 kB | 20% | 2.1 GB | false | false | 3 | 11 | 11 | | | false | +-------------------------+------------------+---------+-----------------+---------+--------+-----------------------+--------+-----------+------------+-----------+------------+--------------------+--------+--------------------------+-------------------+ [root@k8s-cluster241 ~]#
19.添加别名 19.1 添加别名 [root@k8s-cluster241 ~]# vim ~/.bashrc ... alias etcdctl='etcdctl --endpoints="10.0.0.241:2379,10.0.0.242:2379,10.0.0.243:2379" --cacert=/k8s/certs/etcd/etcd-ca.pem --cert=/k8s/certs/etcd/etcd-server.pem --key=/k8s/certs/etcd/etcd-server-key.pem '
... [root@k8s-cluster241 ~]# source ~/.bashrc [root@k8s-cluster241 ~]# [root@k8s-cluster241 ~]# etcdctl endpoint status --write-out=table +-----------------+------------------+---------+-----------------+---------+--------+-----------------------+--------+-----------+------------+-----------+------------+--------------------+--------+--------------------------+-------------------+ | ENDPOINT | ID | VERSION | STORAGE VERSION | DB SIZE | IN USE | PERCENTAGE NOT IN USE | QUOTA | IS LEADER | IS LEARNER | RAFT TERM | RAFT INDEX | RAFT APPLIED INDEX | ERRORS | DOWNGRADE TARGET VERSION | DOWNGRADE ENABLED | +-----------------+------------------+---------+-----------------+---------+--------+-----------------------+--------+-----------+------------+-----------+------------+--------------------+--------+--------------------------+-------------------+ | 10.0.0.241:2379 | 566d563f3c9274ed | 3.6.10 | 3.6.0 | 25 kB | 25 kB | 0% | 2.1 GB | false | false | 3 | 11 | 11 | | | false | | 10.0.0.242:2379 | b83b69ba7d246b29 | 3.6.10 | 3.6.0 | 20 kB | 16 kB | 20% | 2.1 GB | true | false | 3 | 11 | 11 | | | false | | 10.0.0.243:2379 | 47b70f9ecb1f200 | 3.6.10 | 3.6.0 | 20 kB | 16 kB | 20% | 2.1 GB | false | false | 3 | 11 | 11 | | | false | +-----------------+------------------+---------+-----------------+---------+--------+-----------------------+--------+-----------+------------+-----------+------------+--------------------+--------+--------------------------+-------------------+ [root@k8s-cluster241 ~]#
[root@k8s-cluster241 ~]# data_rsync.sh ~/.bashrc ===== rsyncing k8s-cluster242: .bashrc ===== 命令执行成功! ===== rsyncing k8s-cluster243: .bashrc ===== 命令执行成功! [root@k8s-cluster241 ~]#
19.2 测试验证 【需要断开重连】 [root@k8s-cluster242 ~]# etcdctl endpoint status --write-out=table +-----------------+------------------+---------+-----------------+---------+--------+-----------------------+--------+-----------+------------+-----------+------------+--------------------+--------+--------------------------+-------------------+ | ENDPOINT | ID | VERSION | STORAGE VERSION | DB SIZE | IN USE | PERCENTAGE NOT IN USE | QUOTA | IS LEADER | IS LEARNER | RAFT TERM | RAFT INDEX | RAFT APPLIED INDEX | ERRORS | DOWNGRADE TARGET VERSION | DOWNGRADE ENABLED | +-----------------+------------------+---------+-----------------+---------+--------+-----------------------+--------+-----------+------------+-----------+------------+--------------------+--------+--------------------------+-------------------+ | 10.0.0.241:2379 | 566d563f3c9274ed | 3.6.10 | 3.6.0 | 25 kB | 25 kB | 0% | 2.1 GB | false | false | 3 | 11 | 11 | | | false | | 10.0.0.242:2379 | b83b69ba7d246b29 | 3.6.10 | 3.6.0 | 20 kB | 16 kB | 20% | 2.1 GB | true | false | 3 | 11 | 11 | | | false | | 10.0.0.243:2379 | 47b70f9ecb1f200 | 3.6.10 | 3.6.0 | 20 kB | 16 kB | 20% | 2.1 GB | false | false | 3 | 11 | 11 | | | false | +-----------------+------------------+---------+-----------------+---------+--------+-----------------------+--------+-----------+------------+-----------+------------+--------------------+--------+--------------------------+-------------------+ [root@k8s-cluster242 ~]#
[root@k8s-cluster243 ~]# etcdctl endpoint status -w table +-----------------+------------------+---------+-----------------+---------+--------+-----------------------+--------+-----------+------------+-----------+------------+--------------------+--------+--------------------------+-------------------+ | ENDPOINT | ID | VERSION | STORAGE VERSION | DB SIZE | IN USE | PERCENTAGE NOT IN USE | QUOTA | IS LEADER | IS LEARNER | RAFT TERM | RAFT INDEX | RAFT APPLIED INDEX | ERRORS | DOWNGRADE TARGET VERSION | DOWNGRADE ENABLED | +-----------------+------------------+---------+-----------------+---------+--------+-----------------------+--------+-----------+------------+-----------+------------+--------------------+--------+--------------------------+-------------------+ | 10.0.0.241:2379 | 566d563f3c9274ed | 3.6.10 | 3.6.0 | 25 kB | 25 kB | 0% | 2.1 GB | false | false | 3 | 11 | 11 | | | false | | 10.0.0.242:2379 | b83b69ba7d246b29 | 3.6.10 | 3.6.0 | 20 kB | 16 kB | 20% | 2.1 GB | true | false | 3 | 11 | 11 | | | false | | 10.0.0.243:2379 | 47b70f9ecb1f200 | 3.6.10 | 3.6.0 | 20 kB | 16 kB | 20% | 2.1 GB | false | false | 3 | 11 | 11 | | | false | +-----------------+------------------+---------+-----------------+---------+--------+-----------------------+--------+-----------+------------+-----------+------------+--------------------+--------+--------------------------+-------------------+ [root@k8s-cluster243 ~]#
|