etcd 下载 :https://github.com/etcd-io/etcd/releases
1. etcd.service 服务管理程序
[Unit]
Description=Etcd Server
After=network.target
After=network-online.target
Wants=network-online.target
[Service]
Type=notify
EnvironmentFile=/opt/etcd/cfg/etcd.conf
ExecStart=/opt/etcd/bin/etcd \
--name=${ETCD_NAME} \
--data-dir=${ETCD_DATA_DIR} \
--listen-peer-urls=${ETCD_LISTEN_PEER_URLS} \
--listen-client-urls=${ETCD_LISTEN_CLIENT_URLS},http://127.0.0.1:2379 \
--advertise-client-urls=${ETCD_ADVERTISE_CLIENT_URLS} \
--initial-advertise-peer-urls=${ETCD_INITIAL_ADVERTISE_PEER_URLS} \
--initial-cluster=${ETCD_INITIAL_CLUSTER} \
--initial-cluster-token=${ETCD_INITIAL_CLUSTER_TOKEN} \
--initial-cluster-state=new \
--cert-file=/opt/etcd/ssl/server.pem \
--key-file=/opt/etcd/ssl/server-key.pem \
--peer-cert-file=/opt/etcd/ssl/server.pem \
--peer-key-file=/opt/etcd/ssl/server-key.pem \
--trusted-ca-file=/opt/etcd/ssl/ca.pem \
--peer-trusted-ca-file=/opt/etcd/ssl/ca.pem
Restart=on-failure
LimitNOFILE=65536
[Install]
WantedBy=multi-user.target
# 参数说明
ExecStart -- 启动程序时,去哪找程序可执行文件
2. etcd.conf 配置文件
#[Member]
ETCD_NAME="etcd-1"
ETCD_DATA_DIR="/var/lib/etcd/default.etcd"
ETCD_LISTEN_PEER_URLS="https://192.168.31.63:2380"
ETCD_LISTEN_CLIENT_URLS="https://192.168.31.63:2379"
#[Clustering]
ETCD_INITIAL_ADVERTISE_PEER_URLS="https://192.168.31.63:2380"
ETCD_ADVERTISE_CLIENT_URLS="https://192.168.31.63:2379"
ETCD_INITIAL_CLUSTER="etcd-1=https://192.168.31.61:2380,etcd-2=https://192.168.31.62:2380,etcd-3=https://192.168.31.63:2380"
ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster"
ETCD_INITIAL_CLUSTER_STATE="new"
Member -- 单节点
ETCD_NAME -- 标识符
ETCD_DATA_DIR -- 存储数据的位置
ETCD_LISTEN_PEER_URLS -- 与其他 etcd 互传数据所使用的 ip 地址和端口
ETCD_LISTEN_CLIENT_URLS -- 与 apiserver(客户端)互传数据所使用的 ip 地址和端口
Clustering -- 集群
ETCD_INITIAL_ADVERTISE_PEER_URLS -- 广播其他 etcd 我正在监听
ETCD_ADVERTISE_CLIENT_URLS -- 广播 apiserver(客户端)我正在监听
ETCD_INITIAL_CLUSTER -- 设置 etcd 集群成员
ETCD_INITIAL_CLUSTER_TOKEN -- 设置集群通信的令牌(需一致)
ETCD_INITIAL_CLUSTER_STATE -- 初始集群状态,new 为新建集群
3. 申请 ssl 证书
略
4. 验证部署是否成功
/opt/etcd/bin/etcdctl --ca-file=/opt/etcd/ssl/ca.pem --cert-file=/opt/etcd/ssl/server.pem --key-file=/opt/etcd/ssl/server-key.pem --endpoints="https://192.168.31.63:2379,https://192.168.31.65:2379,https://192.168.31.66:2379" cluster-health
网友评论