etcd集群添加节点

本文内容纲要:etcd集群添加节点

查看当前集群节点信息

# etcdctl member list --write-out=table

+------------------+---------+--------------------+--------------------------------+-----------------------------------------------------+------------+

| ID | STATUS | NAME | PEER ADDRS | CLIENT ADDRS | IS LEARNER |

+------------------+---------+--------------------+--------------------------------+-----------------------------------------------------+------------+

| 44d8bc3300880bcd | started | sht-sgmhadoopdn-01 | http://sht-sgmhadoopdn-01:2380 | http://10.0.0.1:2379,http://sht-sgmhadoopdn-01:2379 | false |

| d446fbe3296eb85a | started | sht-sgmhadoopdn-03 | http://sht-sgmhadoopdn-03:2380 | http://10.0.0.1:2379,http://sht-sgmhadoopdn-02:2379 | false |

| e9136c1ad1754783 | started | sht-sgmhadoopdn-02 | http://sht-sgmhadoopdn-02:2380 | http://10.0.0.1:2379,http://sht-sgmhadoopdn-02:2379 | false |

+------------------+---------+--------------------+--------------------------------+-----------------------------------------------------+------------+

添加新节点sht-sgmhadoopdn-04(172.16.101.66)

添加集群节点对应hosts文件解析

# cat /etc/hosts

127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4

::1 localhost localhost.localdomain localhost6 localhost6.localdomain6

172.16.101.58 sht-sgmhadoopdn-01

172.16.101.59 sht-sgmhadoopdn-02

172.16.101.60 sht-sgmhadoopdn-03

172.16.101.66 sht-sgmhadoopdn-04

在现有集群接点添加新节点

# etcdctl member add sht-sgmhadoopdn-04 --peer-urls="http://sht-sgmhadoopdn-04:2380"

Member 7796493c3943f891 added to cluster 69bef0b9ccf44365

ETCD_NAME="sht-sgmhadoopdn-04"

ETCD_INITIAL_CLUSTER="sht-sgmhadoopdn-01=http://sht-sgmhadoopdn-01:2380,sht-sgmhadoopdn-04=http://sht-sgmhadoopdn-04:2380,sht-sgmhadoopdn-03=http://sht-sgmhadoopdn-03:2380,sht-sgmhadoopdn-02=http://sht-sgmhadoopdn-02:2380"

ETCD_INITIAL_ADVERTISE_PEER_URLS="http://sht-sgmhadoopdn-04:2380"

ETCD_INITIAL_CLUSTER_STATE="existing"

新节点的etcd配置文件必须包括以上输出内容

查看当前集群信息

# etcdctl member list --write-out=table

+------------------+-----------+--------------------+--------------------------------+-----------------------------------------------------+------------+

| ID | STATUS | NAME | PEER ADDRS | CLIENT ADDRS | IS LEARNER |

+------------------+-----------+--------------------+--------------------------------+-----------------------------------------------------+------------+

| 44d8bc3300880bcd | started | sht-sgmhadoopdn-01 | http://sht-sgmhadoopdn-01:2380 | http://10.0.0.1:2379,http://sht-sgmhadoopdn-01:2379 | false |

| 7796493c3943f891 | unstarted | | http://sht-sgmhadoopdn-04:2380 | | false |

| d446fbe3296eb85a | started | sht-sgmhadoopdn-03 | http://sht-sgmhadoopdn-03:2380 | http://10.0.0.1:2379,http://sht-sgmhadoopdn-02:2379 | false |

| e9136c1ad1754783 | started | sht-sgmhadoopdn-02 | http://sht-sgmhadoopdn-02:2380 | http://10.0.0.1:2379,http://sht-sgmhadoopdn-02:2379 | false |

+------------------+-----------+--------------------+--------------------------------+-----------------------------------------------------+------------+

新节点配置etcd

etcd系统服务文件

# cat /usr/lib/systemd/system/etcd.service

[Unit]

Description=etcd service

Documentation=https://github.com/etcd-io/etcd

After=network.target

After=network-online.target

Wants=network-online.target

[Service]

User=tnuser

Type=notify

EnvironmentFile=/usr/local/etcd/etcd.conf

WorkingDirectory=/usr/local/etcd

ExecStart=/usr/local/etcd/etcd

Restart=always

RestartSec=10s

LimitNOFILE=65536

[Install]

WantedBy=multi-user.target

etcd配置文件

# cat /usr/local/etcd/etcd.conf

ETCD_NAME="sht-sgmhadoopdn-04"

ETCD_DATA_DIR="/usr/local/etcd/data"

ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster-01"

ETCD_INITIAL_CLUSTER_STATE="existing"

ETCD_LISTEN_CLIENT_URLS="http://0.0.0.0:2379"

ETCD_ADVERTISE_CLIENT_URLS="http://sht-sgmhadoopdn-01:2379,http://10.0.0.1:2379"

ETCD_LISTEN_PEER_URLS="http://0.0.0.0:2380"

ETCD_INITIAL_ADVERTISE_PEER_URLS="http://sht-sgmhadoopdn-04:2380"

ETCD_INITIAL_CLUSTER="sht-sgmhadoopdn-01=http://sht-sgmhadoopdn-01:2380,sht-sgmhadoopdn-02=http://sht-sgmhadoopdn-02:2380,sht-sgmhadoopdn-03=http://sht-sgmhadoopdn-03:2380,sht-sgmhadoopdn-04=http://sht-sgmhadoopdn-04:2380"

ETCD_ENABLE_V2="true"

启动新节点

# systemctl start etcd

再次查看集群状态

# etcdctl member list --write-out=table

+------------------+---------+--------------------+--------------------------------+-----------------------------------------------------+------------+

| ID | STATUS | NAME | PEER ADDRS | CLIENT ADDRS | IS LEARNER |

+------------------+---------+--------------------+--------------------------------+-----------------------------------------------------+------------+

| 44d8bc3300880bcd | started | sht-sgmhadoopdn-01 | http://sht-sgmhadoopdn-01:2380 | http://10.0.0.1:2379,http://sht-sgmhadoopdn-01:2379 | false |

| 7796493c3943f891 | started | sht-sgmhadoopdn-04 | http://sht-sgmhadoopdn-04:2380 | http://10.0.0.1:2379,http://sht-sgmhadoopdn-01:2379 | false |

| d446fbe3296eb85a | started | sht-sgmhadoopdn-03 | http://sht-sgmhadoopdn-03:2380 | http://10.0.0.1:2379,http://sht-sgmhadoopdn-02:2379 | false |

| e9136c1ad1754783 | started | sht-sgmhadoopdn-02 | http://sht-sgmhadoopdn-02:2380 | http://10.0.0.1:2379,http://sht-sgmhadoopdn-02:2379 | false |

+------------------+---------+--------------------+--------------------------------+-----------------------------------------------------+------------+

将各节点etcd.conf配置文件的变量ETCD_INITIAL_CLUSTER添加新节点信息,然后依次重启。

本文内容总结:etcd集群添加节点

原文链接:https://www.cnblogs.com/ilifeilong/p/11625151.html

以上是 etcd集群添加节点 的全部内容, 来源链接: utcz.com/z/296998.html

回到顶部