etcd集群部署
下载
cd /usr/local/src/
version=v3.4.27
wget https://github.com/etcd-io/etcd/releases/download/"$version"/etcd-"$version"-linux-amd64.tar.gz
部署
tar xf etcd-v3.4.27-linux-amd64.tar.gz -C /opt/
ln -s /opt/etcd-v3.4.27-linux-amd64/ /opt/etcd
ln -s /opt/etcd/etcdctl /usr/local/bin/etcdctl
ln -s /opt/etcd/etcd /usr/local/bin/etcd
验证
etcd -version
WARNING: Package "github.com/golang/protobuf/protoc-gen-go/generator" is deprecated.
A future release of golang/protobuf will delete this package,
which has long been excluded from the compatibility promise.
etcd Version: 3.4.27
Git SHA: c92fb80f3
Go Version: go1.19.10
Go OS/Arch: linux/amd64
配置启动文件
cat /usr/lib/systemd/system/etcd.service
[Unit]
Description=Etcd Server
After=network.target
After=network-online.target
Wants=network-online.target
[Service]
Type=notify
EnvironmentFile=/opt/etcd/etcd.conf
ExecStart=/usr/local/bin/etcd
Restart=on-failure
LimitNOFILE=65536
[Install]
WantedBy=multi-user.target
配置文件
cat /opt/etcd/etcd.conf
ETCD_NAME="etcd01"
ETCD_DATA_DIR="/data/etcd/default.etcd"
ETCD_LISTEN_PEER_URLS="http://172.22.225.210:32380"
ETCD_LISTEN_CLIENT_URLS="http://172.22.225.210:32379,http://127.0.0.1:32379"
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://172.22.225.210:32380"
ETCD_ADVERTISE_CLIENT_URLS="http://172.22.225.210:32379"
ETCD_INITIAL_CLUSTER="etcd01=http://172.22.225.210:32380,etcd02=http://172.16.233.181:32380,etcd03=http://172.22.225.211:32380"
ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster"
ETCD_INITIAL_CLUSTER_STATE="new"
数据目录
mkdir /data/etcd/
启动
systemctl enable etcd
systemctl start etcd
systemctl status etcd
验证集群
etcdctl --endpoints http://172.22.225.210:2379 endpoint status --cluster -w table
Etcdkeeper部署
下载
cd /usr/local/src/
wget https://github.com/evildecay/etcdkeeper/releases/download/v0.7.6/etcdkeeper-v0.7.6-linux_x86_64.zip
unzip etcdkeeper-v0.7.6-linux_x86_64.zip -d /opt
chmod a+x /opt/etcdkeeper/etcdkeeper
启动文件
cat /lib/systemd/system/etcdkeeper.service
[Unit]
Description=etcdkeeper service
After=network.target
[Service]
Type=simple
ExecStart=/opt/etcdkeeper/etcdkeeper -h 172.22.225.210 -p 8100
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
PrivateTmp=true
[Install]
WantedBy=multi-user.target