• ETCD成员维护


    # For each machine
    TOKEN=my-etcd-token-1
    CLUSTER_STATE=new
    NAME_1=etcd-node-1
    NAME_2=etcd-node-2
    NAME_3=etcd-node-3
    HOST_1=10.240.0.13
    HOST_2=10.240.0.14
    HOST_3=10.240.0.15
    CLUSTER=${NAME_1}=http://${HOST_1}:2380,${NAME_2}=http://${HOST_2}:2380,${NAME_3}=http://${HOST_3}:2380
    
    # For node 1
    THIS_NAME=${NAME_1}
    THIS_IP=${HOST_1}
    etcd --data-dir=data.etcd --name ${THIS_NAME} 
    	--initial-advertise-peer-urls http://${THIS_IP}:2380 
    	--listen-peer-urls http://${THIS_IP}:2380 
    	--advertise-client-urls http://${THIS_IP}:2379 
    	--listen-client-urls http://${THIS_IP}:2379 
    	--initial-cluster ${CLUSTER} 
    	--initial-cluster-state ${CLUSTER_STATE} 
    	--initial-cluster-token ${TOKEN}
    
    # For node 2
    THIS_NAME=${NAME_2}
    THIS_IP=${HOST_2}
    etcd --data-dir=data.etcd --name ${THIS_NAME} 
    	--initial-advertise-peer-urls http://${THIS_IP}:2380 
    	--listen-peer-urls http://${THIS_IP}:2380 
    	--advertise-client-urls http://${THIS_IP}:2379 
    	--listen-client-urls http://${THIS_IP}:2379 
    	--initial-cluster ${CLUSTER} 
    	--initial-cluster-state ${CLUSTER_STATE} 
    	--initial-cluster-token ${TOKEN}
    
    # For node 3
    THIS_NAME=${NAME_3}
    THIS_IP=${HOST_3}
    etcd --data-dir=data.etcd --name ${THIS_NAME} 
    	--initial-advertise-peer-urls http://${THIS_IP}:2380 
    	--listen-peer-urls http://${THIS_IP}:2380 
    	--advertise-client-urls http://${THIS_IP}:2379 
    	--listen-client-urls http://${THIS_IP}:2379 
    	--initial-cluster ${CLUSTER} 
    	--initial-cluster-state ${CLUSTER_STATE} 
    	--initial-cluster-token ${TOKEN}
    

    Then replace a member with member remove and member add commands:

    # get member ID
    export ETCDCTL_API=3
    HOST_1=10.240.0.13
    HOST_2=10.240.0.14
    HOST_3=10.240.0.15
    etcdctl --endpoints=${HOST_1}:2379,${HOST_2}:2379,${HOST_3}:2379 member list
    
    # remove the member
    MEMBER_ID=278c654c9a6dfd3b
    etcdctl --endpoints=${HOST_1}:2379,${HOST_2}:2379,${HOST_3}:2379 
    	member remove ${MEMBER_ID}
    
    # add a new member (node 4)
    export ETCDCTL_API=3
    NAME_1=etcd-node-1
    NAME_2=etcd-node-2
    NAME_4=etcd-node-4
    HOST_1=10.240.0.13
    HOST_2=10.240.0.14
    HOST_4=10.240.0.16 # new member
    etcdctl --endpoints=${HOST_1}:2379,${HOST_2}:2379 
    	member add ${NAME_4} 
    	--peer-urls=http://${HOST_4}:2380
    

    Next, start the new member with --initial-cluster-state existing flag:

    # [WARNING] If the new member starts from the same disk space,
    # make sure to remove the data directory of the old member
    #
    # restart with 'existing' flag
    TOKEN=my-etcd-token-1
    CLUSTER_STATE=existing
    NAME_1=etcd-node-1
    NAME_2=etcd-node-2
    NAME_4=etcd-node-4
    HOST_1=10.240.0.13
    HOST_2=10.240.0.14
    HOST_4=10.240.0.16 # new member
    CLUSTER=${NAME_1}=http://${HOST_1}:2380,${NAME_2}=http://${HOST_2}:2380,${NAME_4}=http://${HOST_4}:2380
    
    THIS_NAME=${NAME_4}
    THIS_IP=${HOST_4}
    etcd --data-dir=data.etcd --name ${THIS_NAME} 
    	--initial-advertise-peer-urls http://${THIS_IP}:2380 
    	--listen-peer-urls http://${THIS_IP}:2380 
    	--advertise-client-urls http://${THIS_IP}:2379 
    	--listen-client-urls http://${THIS_IP}:2379 
    	--initial-cluster ${CLUSTER} 
    	--initial-cluster-state ${CLUSTER_STATE} 
    	--initial-cluster-token ${TOKEN}
  • 相关阅读:
    spoj 694 求一个字符串中不同子串的个数
    Qt for Android 开发大坑
    HDUOJ A Mathematical Curiosity 1017
    Node.js开发入门—HelloWorld再分析
    GTK入门学习:布局容器之固定布局
    彻底领悟javascript中的exec与match方法
    JQuery中attr属性和jQuery.data()学习笔记
    正则表达式-验证带千分号的,带任意位小数的数字类型
    JQuery EasyUI 动态改变表单项的验证守则
    JavaScript计算两个日期的时间差
  • 原文地址:https://www.cnblogs.com/justart/p/11670850.html
Copyright © 2020-2023  润新知