etcd v3.3.20单机版安装
环境:CentOS 7.6 x86
软件包:etcd-v3.3.20-linux-amd64.tar.gz、etcdkeeper-v0.7.6-linux_x86_64.zip
一、安装etcd
1、下载并解压
cd /HHB/
wget 'https://github.com/etcd-io/etcd/releases/download/v3.3.20/etcd-v3.3.20-linux-amd64.tar.gz'
tar xf etcd-v3.3.20-linux-amd64.tar.gz
2、指向软连接
cd /HHB/
ln -s etcd-v3.3.20-linux-amd64 etcd
3、修改权限
cd /HHB/etcd
chown root:root etcd etcdctl
chmod 755 etcd etcdctl
4、拷贝可执行文件到指定目录
cd /HHB/etcd
cp etcd etcdctl /usr/bin/
5、编写服务启动文件
vim /lib/systemd/system/etcd.service
[Unit]
Description=Etcd Server
After=network.target
After=network-online.target
Wants=network-online.target
[Service]
Type=notify
WorkingDirectory=/HHB/etcd/etcd_12380
EnvironmentFile=-/HHB/etcd/etcd_12380/etcd.conf
User=root
# set GOMAXPROCS to number of processors
ExecStart=/bin/bash -c "GOMAXPROCS=$(nproc) /usr/bin/etcd --name=\"${ETCD_NAME}\" --data-dir=\"${ETCD_DATA_DIR}\" --listen-client-urls=\"${ETCD_LISTEN_CLIENT_URLS}\" --listen-peer-urls=\"${ETCD_LISTEN_PEER_URLS}\" --advertise-client-urls=\"${ETCD_ADVERTISE_CLIENT_URLS}\" --initial-advertise-peer-urls=\"${ETCD_INITIAL_ADVERTISE_PEER_URLS}\" --initial-cluster=\"${ETCD_INITIAL_CLUSTER}\" --initial-cluster-state=\"${ETCD_INITIAL_CLUSTER_STATE}\""
Restart=on-failure
LimitNOFILE=65536
[Install]
WantedBy=multi-user.target
二、配置etcd
1、创建配置文件
cd /HHB/etcd
mkdir -p etcd_12380/{log,data}
2、编写配置文件
cd etcd_12380/
vim etcd.conf
ETCD_NAME="node-01"
ETCD_DATA_DIR="/HHB/etcd/etcd_12380/data"
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://192.168.0.14:12380"
ETCD_LISTEN_PEER_URLS="http://192.168.0.14:12380"
ETCD_LISTEN_CLIENT_URLS="http://192.168.0.14:12379"
ETCD_ADVERTISE_CLIENT_URLS="http://192.168.0.14:12379"
ETCD_INITIAL_CLUSTER_TOKEN="HHB"
ETCD_INITIAL_CLUSTER="node-01=http://192.168.0.14:12380"
ETCD_INITIAL_CLUSTER_STATE="new"
3、修改/etc/profile文件并加载
vim /etc/profile
在末行插入
# etcd-v3.3.20
export ETCDCTL_API=3
source /etc/profile
三、启动测试etcd
1、重新加载服务配置文件并启动查看状态
systemctl daemon-reload
systemctl start etcd
systemctl status etcd
2、检查etcd集群情况(单机版可忽略)
ENDPOINTS=192.168.0.14:12379
etcdctl --endpoints=$ENDPOINTS --write-out=table member list
etcdctl --endpoints=$ENDPOINTS --write-out=table endpoint status
etcdctl --endpoints=$ENDPOINTS --write-out=table endpoint health
四、安装etcdkeeper
1、下载并解压安装包
cd /HHB/
wget https://github.com/evildecay/etcdkeeper/releases/download/v0.7.6/etcdkeeper-v0.7.6-linux_x86_64.zip --no-check-certificate
unzip etcdkeeper-v0.7.6-linux_x86_64.zip
2、改名&指软连接
mv etcdkeeper etcdkeeper.0.7.6
ln -s etcdkeeper.0.7.6 etcdkeeper
3、修改权限
cd /HHB/etcdkeeper/
chmod +x etcdkeeper
4、编写服务启动文件
vim /lib/systemd/system/etcdkeeper.service
[Unit]
Description=etcdkeeper service
After=network.target
[Service]
Type=simple
ExecStart=/HHB/etcdkeeper/etcdkeeper -p 8800 #指定访问端口
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
PrivateTmp=true
[Install]
WantedBy=multi-user.target
五、启动测试etcdkeeper
1、重新加载服务配置文件并启动查看状态
systemctl daemon-reload
systemctl start etcdkeeper.service
systemctl status etcdkeeper.service
2、通过web界面登录查看
http://127.0.0.1:8800/etcdkeeper/
六、备份还原etcd数据…
ETCDCTL_API=3 etcdctl snapshot restore test1654692299-etcd-snapshot.db \
> --name node-1 \
> --initial-cluster node-1=http://192.168.0.14:12380 \
> --initial-cluster-token HHB \
> --data-dir=/HHB/etcd/etcd_12380/data \
> --initial-advertise-peer-urls http://192.168.0.14:12380
未完待续。。。