1. 程式人生 > >etcd集群開機啟動

etcd集群開機啟動

number url ble log emc 開機啟動 http res wan

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集群開機啟動