etcd集群开机启动
Posted Davygeek
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了etcd集群开机启动相关的知识,希望对你有一定的参考价值。
1. 安装最新版本
使用官方最新版本
https://github.com/coreos/etcd/releases
2. 更新配置文件
tee /etc/etcd/etcd.conf <<-‘EOF‘ ETCD_NAME=etcd03 ETCD_DATA_DIR="/var/lib/etcd/etcd03" ETCD_LISTEN_PEER_URLS="http://192.168.2.46:2380" ETCD_LISTEN_CLIENT_URLS="http://192.168.2.46:2379,http://127.0.0.1:2379" ETCD_INITIAL_ADVERTISE_PEER_URLS="http://192.168.2.46:2380" ETCD_ADVERTISE_CLIENT_URLS="http://192.168.2.46:2379" ETCD_INITIAL_CLUSTER_STATE="new" ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster1" ETCD_INITIAL_CLUSTER="etcd01=http://192.168.2.44:2380,etcd02=http://192.168.2.45:2380,etcd03=http://192.168.2.46:2380" EOF
tee /usr/lib/systemd/system/etcd.service <<-‘EOF‘ [Unit] Description=Etcd Server After=network.target After=network-online.target Wants=network-online.target [Service] Type=notify WorkingDirectory=/var/lib/etcd/ EnvironmentFile=-/etc/etcd/etcd.conf User=etcd # 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-cluster-token=\"${ETCD_INITIAL_CLUSTER_TOKEN}\" --initial-cluster=\"${ETCD_INITIAL_CLUSTER}\" --initial-cluster-state=\"${ETCD_INITIAL_CLUSTER_STATE}\" " Restart=on-failure LimitNOFILE=65536 [Install] WantedBy=multi-user.target EOF
3. 更新启动
systemctl daemon-reload
systemctl start etcd
systemctl enable etcd
4. 校验状态
etcdctl member list
etcdctl cluster-health
以上是关于etcd集群开机启动的主要内容,如果未能解决你的问题,请参考以下文章
记一次虚机强制断电 K8s 集群 etcd pod 挂掉快照丢失(没有备份)问题处理
记一次虚机强制断电 K8s 集群 etcd pod 挂掉快照丢失(没有备份)问题处理