我在做etcd 群集搭建,共三个几点,我使用同一台机器的不同的端口可以搭建成功,但用三台机器搭建时启动服务后报错'cluster ID mismatch',这三台都是云主机,相应的端口都已经开放了,可以互相访问, 详细报错日志如下:
```
Feb 20 20:33:13 VM-0-15-ubuntu etcd[26272]: request cluster ID mismatch (got 3652f05a66289861 want f633942361b97b7f)
Feb 20 20:33:13 VM-0-15-ubuntu etcd[26272]: request cluster ID mismatch (got 3652f05a66289861 want f633942361b97b7f)
Feb 20 20:33:13 VM-0-15-ubuntu etcd[26272]: request sent was ignored (cluster ID mismatch: peer[7a710abd2cc3d001]=3652f05a66289861, local=f633942361b97b7f)
Feb 20 20:33:13 VM-0-15-ubuntu etcd[26272]: request sent was ignored (cluster ID mismatch: peer[7a710abd2cc3d001]=3652f05a66289861, local=f633942361b97b7f)
Feb 20 20:33:13 VM-0-15-ubuntu etcd[26272]: request cluster ID mismatch (got 3652f05a66289861 want f633942361b97b7f)
Feb 20 20:33:13 VM-0-15-ubuntu etcd[26272]: request cluster ID mismatch (got 3652f05a66289861 want f633942361b97b7f)
Feb 20 20:33:13 VM-0-15-ubuntu etcd[26272]: request sent was ignored (cluster ID mismatch: peer[7a710abd2cc3d001]=3652f05a66289861, local=f633942361b97b7f)
Feb 20 20:33:13 VM-0-15-ubuntu etcd[26272]: request sent was ignored (cluster ID mismatch: peer[7a710abd2cc3d001]=3652f05a66289861, local=f633942361b97b7f)
Feb 20 20:33:13 VM-0-15-ubuntu etcd[26272]: request cluster ID mismatch (got 3652f05a66289861 want f633942361b97b7f)
Feb 20 20:33:13 VM-0-15-ubuntu etcd[26272]: request cluster ID mismatch (got 3652f05a66289861 want f633942361b97b7f)
```
**node1 :**
/etc/systemd/system/etcd.service 其他两台一样
```
[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=root
# set GOMAXPROCS to number of processors
ExecStart=/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-advertise-peer-urls=${ETCD_INITIAL_ADVERTISE_PEER_URLS} \
--initial-cluster-state=${ETCD_INITIAL_CLUSTER_STATE} \
--initial-cluster=${ETCD_INITIAL_CLUSTER}
Restart=on-failure
LimitNOFILE=65536
[Install]
WantedBy=multi-user.target
```
/etc/etcd/etcd.conf
```
ETCD_NAME="etcd-1"
ETCD_DATA_DIR="/var/lib/etcd/data"
ETCD_LISTEN_CLIENT_URLS="http://ip1:2379,http://localhost:2379"
ETCD_LISTEN_PEER_URLS="http://ip1:2380"
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://ip1:2380"
ETCD_ADVERTISE_CLIENT_URLS="http://ip1:2379,http://localhost:2379"
ETCD_INITIAL_CLUSTER="etcd-1=http://ip1:2380,etcd-2=http://ip2:2380,etcd-3=http://ip3:2380"
ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster-token"
ETCD_INITIAL_CLUSTER_STATE="new"
```
**node2:**
/etc/etcd/etcd.conf
```
ETCD_NAME="etcd-2"
ETCD_DATA_DIR="/var/lib/etcd/data"
ETCD_LISTEN_CLIENT_URLS="http://ip2:2379,http://localhost:2379"
ETCD_LISTEN_PEER_URLS="http://ip2:2380"
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://ip2:2380"
ETCD_ADVERTISE_CLIENT_URLS="http://ip2:2379,http://localhost:2379"
ETCD_INITIAL_CLUSTER="etcd-1=http://ip1:2380,etcd-2=http://ip2:2380,etcd-3=http://ip3:2380"
ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster-token"
ETCD_INITIAL_CLUSTER_STATE="new"
```
**node3:**
/etc/etcd/etcd.conf
```
ETCD_NAME="etcd-3"
ETCD_DATA_DIR="/var/lib/etcd/data"
ETCD_LISTEN_CLIENT_URLS="http://ip3:2379,http://localhost:2379"
ETCD_LISTEN_PEER_URLS="http://ip3:2380"
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://ip3:2380"
ETCD_ADVERTISE_CLIENT_URLS="http://ip3:2379,http://localhost:2379"
ETCD_INITIAL_CLUSTER="etcd-1=http://ip1:2380,etcd-2=http://ip2:2380,etcd-3=http://ip3:2380"
ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster-token"
ETCD_INITIAL_CLUSTER_STATE="new"
```
**启动命令:**
```
systemctl daemon-reload
systemctl enable etcd
systemctl start etcd
```
**我尝试删除data-dir文件夹,然后重建,重启服务,还是无效**
**帮我看下我哪里出错了**
etcd version is 3.3.18
system is ubuntu 16.04
有疑问加站长微信联系(非本文作者)