安装部分
二进制方式部署ETCD高可用集群
[root@etcd-01 ~]
[root@etcd-01 ~]
- 操作成功即为安装成功(也可以查看都有什么内容);可以查看版本
[root@etcd-01 ~]
etcdctl version: 3.5.5
API version: 3.5
- 将组件分发至其他节点(因为内容一样,所以没必要在下载一次),注意如果使用节点名要提前做好hosts解析
[root@etcd-01 ~]
[root@etcd-01 ~]
生成证书
- 本例使用cfssl工具生成证书,所以下载cfssl工具
[root@etcd-01 ~]
[root@etcd-01 ~]
[root@etcd-01 ~]
[root@etcd-01 ~]
Version: 1.6.2
Runtime: go1.18
[root@etcd-01 ~]
[root@etcd-02 ~]
[root@etcd-03 ~]
[root@etcd-01 ~]
{
"signing": {
"default": {
"expiry": "876000h"
},
"profiles": {
"etcd": {
"usages": [
"signing",
"key encipherment",
"server auth",
"client auth"
],
"expiry": "876000h"
}
}
}
}
[root@etcd-01 ~]
{
"CN": "etcd",
"key": {
"algo": "rsa",
"size": 2048
},
"names": [
{
"C": "CN",
"ST": "Beijing",
"L": "Beijing",
"O": "etcd",
"OU": "Etcd Security"
}
],
"ca": {
"expiry": "876000h"
}
}
[root@etcd-01 ~]
[root@etcd-01 ~]
etcd-ca.csr etcd-ca-key.pem etcd-ca.pem
[root@etcd-01 ~]
{
"CN": "etcd",
"key": {
"algo": "rsa",
"size": 2048
},
"names": [
{
"C": "CN",
"ST": "Beijing",
"L": "Beijing",
"O": "etcd",
"OU": "Etcd Security"
}
]
}
[root@etcd-01 ~]
[root@etcd-01 ~]
etcd-ca.csr etcd-ca-key.pem etcd-ca.pem etcd.csr etcd-key.pem etcd.pem
[root@etcd-01 ssl]
[root@etcd-01 ssl]
ETCD配置
[root@etcd-01 ~]
name: 'etcd-01'
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://192.168.10.3:2380'
listen-client-urls: 'https://192.168.10.3:2379,http://127.0.0.1:2379'
max-snapshots: 3
max-wals: 5
cors:
initial-advertise-peer-urls: 'https://192.168.10.3:2380'
advertise-client-urls: 'https://192.168.10.3:2379'
discovery:
discovery-fallback: 'proxy'
discovery-proxy:
discovery-srv:
initial-cluster: 'etcd-01=https://192.168.10.3:2380,etcd-02=https://192.168.10.4:2380,etcd-03=https://192.168.10.5:2380'
initial-cluster-token: 'etcd-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: '/etc/etcd/ssl/etcd.pem'
key-file: '/etc/etcd/ssl/etcd-key.pem'
client-cert-auth: true
trusted-ca-file: '/etc/etcd/ssl/etcd-ca.pem'
auto-tls: true
peer-transport-security:
cert-file: '/etc/etcd/ssl/etcd.pem'
key-file: '/etc/etcd/ssl/etcd-key.pem'
peer-client-cert-auth: true
trusted-ca-file: '/etc/etcd/ssl/etcd-ca.pem'
auto-tls: true
debug: false
log-package-levels:
log-outputs: [default]
force-new-cluster: false
[root@etcd-01 ~]
[Unit]
Description=Etcd Service
Documentation=https://coreos.com/etcd/docs/latest/
After=network.target
[Service]
Type=notify
ExecStart=/usr/local/bin/etcd --config-file=/etc/etcd/etcd.config.yml
Restart=on-failure
RestartSec=10
LimitNOFILE=65536
[Install]
WantedBy=multi-user.target
Alias=etcd3.service
- 其他两个节点配置一样,复制即可
- 所有启动etcd服务
systemctl daemon-reload
systemctl enable --now etcd
[root@etcd-01 ~]
[root@etcd-01 ~]
+-------------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------+
| ENDPOINT | ID | VERSION | DB SIZE | IS LEADER | IS LEARNER | RAFT TERM | RAFT INDEX | RAFT APPLIED INDEX | ERRORS |
+-------------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------+
| 192.168.10.5:2379 | 4ee1cc1544fd02a3 | 3.5.5 | 20 kB | false | false | 2 | 9 | 9 | |
| 192.168.10.4:2379 | 2af255134b508f21 | 3.5.5 | 20 kB | false | false | 2 | 9 | 9 | |
| 192.168.10.3:2379 | 86ef4da6f07b0d20 | 3.5.5 | 20 kB | true | false | 2 | 9 | 9 | |
+-------------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------+
到这里二进制部署etcd集群就结束了!
|