etcd集群部署
安装包:etcd-v3.3.10-linux-amd64.tar.gz
解压:
tar xvf etcd-v3.3.10-linux-amd64.tar.gz cd etcd-v3.3.10-linux-amd64
编辑etcd配置文件:
vim /opt/kubernetes/cfg/etcd #[Member] ETCD_NAME="etcd01" ETCD_DATA_DIR="/var/lib/etcd/default.etcd" ETCD_LISTEN_PEER_URLS="https://10.50.182.65:2380" ETCD_LISTEN_CLIENT_URLS="https://10.50.182.65:2379" #[Clustering] ETCD_INITIAL_ADVERTISE_PEER_URLS="https://10.50.182.65:2380" ETCD_ADVERTISE_CLIENT_URLS="https://10.50.182.65:2379" ETCD_INITIAL_CLUSTER="etcd01=https://10.50.182.65:2380,etcd02=https://10.50.182.66:2380,etcd03=https://10.50.182.67:2380" ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster" ETCD_INITIAL_CLUSTER_STATE="new"
将etcd配置到系统环境中
vim /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/kubernetes/cfg/etcd ExecStart=/opt/kubernetes/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} --initial-cluster-state=new --cert-file=/opt/kubernetes/ssl/server.pem --key-file=/opt/kubernetes/ssl/server-key.pem --peer-cert-file=/opt/kubernetes/ssl/server.pem --peer-key-file=/opt/kubernetes/ssl/server-key.pem --trusted-ca-file=/opt/kubernetes/ssl/ca.pem --peer-trusted-ca-file=/opt/kubernetes/ssl/ca.pem Restart=on-failure LimitNOFILE=65536 [Install] WantedBy=multi-user.target
启动etcd服务日志在/var/log/messages:
systemctl start etcd
systemctl enable etcd
systemctl status etcd -l
此时master上面etcd配置完毕,我们将其配置拷贝到其他2台机器上面,命令自己调整:
scp -rf -P 10022 jyapp@10.50.182.65:/opt/kubernetes /opt/
在master02和master03上启动etcd
测试etcd:
cd /opt/kubernetes/ssl /opt/kubernetes/bin/etcdctl --ca-file=ca.pem --cert-file=server.pem --key-file=server-key.pem --endpoints="https://10.50.182.65:2379,https://10.50.182.66:2379,https://10.50.182.67:2379" cluster-health