etcd集群部署
硬件:4台 8c16G ssd 1T
软件版本: etcd 3.4.15
部署
wget https://github.com/etcd-io/etcd/releases/download/v3.4.15/etcd-v3.4.15-linux-amd64.tar.gz
tar xf etcd-v3.4.15-linux-amd64.tar.gz
mv etcd-v3.4.15-linux-amd64 /usr/local/etcd/etcd
配置
etcd1
cd /usr/local/etcd/etcd/
mkdir conf
cat > conf/etcd.yaml << EOF
name: etcd-1
data-dir: /usr/local/etcd/data
listen-client-urls: http://192.168.0.16:2379,http://127.0.0.1:2379
advertise-client-urls: http://192.168.0.16:2379,http://127.0.0.1:2379
listen-peer-urls: http://192.168.0.16:2380
initial-advertise-peer-urls: http://192.168.0.16:2380
initial-cluster: etcd-1=http://192.168.0.16:2380,etcd-2=http://192.168.0.17:2380,etcd-3=http://192.168.0.18:2380,etcd-4=http://192.168.0.20:2380
initial-cluster-token: etcd-cluster-token4444444
initial-cluster-state: new
EOF
mkdir /usr/local/etcd/etcd/data
mkdir /usr/local/etcd/etcd/wal
etcd2
cd /usr/local/etcd/etcd/
mkdir conf
cat > conf/etcd.yaml << EOF
name: etcd-2
data-dir: /usr/local/etcd/data
listen-client-urls: http://192.168.0.17:2379,http://127.0.0.1:2379
advertise-client-urls: http://192.168.0.17:2379,http://127.0.0.1:2379
listen-peer-urls: http://192.168.0.17:2380
initial-advertise-peer-urls: http://192.168.0.17:2380
initial-cluster: etcd-1=http://192.168.0.16:2380,etcd-2=http://192.168.0.17:2380,etcd-3=http://192.168.0.18:2380,etcd-4=http://192.168.0.20:2380
initial-cluster-token: etcd-cluster-token4444444
initial-cluster-state: new
EOF
mkdir /usr/local/etcd/etcd/data
mkdir /usr/local/etcd/etcd/wal
etcd3
cd /usr/local/etcd/etcd/
mkdir conf
cat > conf/etcd.yaml << EOF
name: etcd-3
data-dir: /usr/local/etcd/data
listen-client-urls: http://192.168.0.18:2379,http://127.0.0.1:2379
advertise-client-urls: http://192.168.0.18:2379,http://127.0.0.1:2379
listen-peer-urls: http://192.168.0.18:2380
initial-advertise-peer-urls: http://192.168.0.18:2380
initial-cluster: etcd-1=http://192.168.0.16:2380,etcd-2=http://192.168.0.17:2380,etcd-3=http://192.168.0.18:2380,etcd-4=http://192.168.0.20:2380
initial-cluster-token: etcd-cluster-token4444444
initial-cluster-state: new
EOF
mkdir /usr/local/etcd/etcd/data
mkdir /usr/local/etcd/etcd/wal
etcd4
cd /usr/local/etcd/etcd/
mkdir conf
cat > conf/etcd.yaml << EOF
name: etcd-4
data-dir: /usr/local/etcd/data
listen-client-urls: http://192.168.0.20:2379,http://127.0.0.1:2379
advertise-client-urls: http://192.168.0.20:2379,http://127.0.0.1:2379
listen-peer-urls: http://192.168.0.20:2380
initial-advertise-peer-urls: http://192.168.0.20:2380
initial-cluster: etcd-1=http://192.168.0.16:2380,etcd-2=http://192.168.0.17:2380,etcd-3=http://192.168.0.18:2380,etcd-4=http://192.168.0.20:2380
initial-cluster-token: etcd-cluster-token4444444
initial-cluster-state: new
EOF
mkdir /usr/local/etcd/etcd/data
mkdir /usr/local/etcd/etcd/wal
启动
cat > /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=/usr/local/etcd/
# User=root
# set GOMAXPROCS to number of processors
ExecStart=/bin/bash -c "/usr/local/etcd/etcd --config-file /usr/local/etcd/conf/etcd.yaml"
Restart=on-failure
LimitNOFILE=65536
[Install]
WantedBy=multi-user.target
EOF
chmod 755 /usr/lib/systemd/system/etcd.service
chmod /usr/local/etcd/data
systemctl daemon-reload
systemctl restart etcd
systemctl enable etcd