etcdクラスタ追加ノード

13577 ワード

現在のクラスタノード情報の表示
# 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は新しいノード情報を追加し、順次再起動します.