美文网首页
Etcd集群搭建与性能测试和调优

Etcd集群搭建与性能测试和调优

作者: CaiGuangyin | 来源:发表于2021-04-01 17:24 被阅读0次

    搭建脚本如下:

    #!/bin/bash
    
    docker ps -a | grep etcd | grep -v k8s
    docker rm -f etcd
    
    ETCD_VERSION=3.3.10
    TOKEN=my-etcd-token
    CLUSTER_STATE=new
    NAME_1=etcd-node-0
    NAME_2=etcd-node-1
    NAME_3=etcd-node-2
    HOST_1=192.168.74.36
    HOST_2=192.168.74.36
    HOST_3=192.168.74.36
    CLUSTER=${NAME_1}=http://${HOST_1}:23801,${NAME_2}=http://${HOST_2}:23802,${NAME_3}=http://${HOST_3}:23803
    
    # 对于节点1
    THIS_NAME=${NAME_1}
    THIS_IP=${HOST_1}
    sudo docker run -d --net=host --name ${THIS_NAME} k8s.gcr.io/etcd:${ETCD_VERSION} \
        /usr/local/bin/etcd \
        --data-dir=data.etcd --name ${THIS_NAME} \
        --initial-advertise-peer-urls http://${THIS_IP}:23801 --listen-peer-urls http://${THIS_IP}:23801 \
        --advertise-client-urls http://${THIS_IP}:23791 --listen-client-urls http://${THIS_IP}:23791 \
        --initial-cluster ${CLUSTER} \
        --initial-cluster-state ${CLUSTER_STATE} --initial-cluster-token ${TOKEN}
    
    # 对于节点2
    THIS_NAME=${NAME_2}
    THIS_IP=${HOST_2}
    sudo docker run -d --net=host --name ${THIS_NAME} k8s.gcr.io/etcd:${ETCD_VERSION} \
        /usr/local/bin/etcd \
        --data-dir=data.etcd --name ${THIS_NAME} \
        --initial-advertise-peer-urls http://${THIS_IP}:23802 --listen-peer-urls http://${THIS_IP}:23802 \
        --advertise-client-urls http://${THIS_IP}:23792 --listen-client-urls http://${THIS_IP}:23792 \
        --initial-cluster ${CLUSTER} \
        --initial-cluster-state ${CLUSTER_STATE} --initial-cluster-token ${TOKEN}
    
    # 对于节点3
    THIS_NAME=${NAME_3}
    THIS_IP=${HOST_3}
    sudo docker run -d --net=host --name ${THIS_NAME} k8s.gcr.io/etcd:${ETCD_VERSION} \
        /usr/local/bin/etcd \
        --data-dir=data.etcd --name ${THIS_NAME} \
        --initial-advertise-peer-urls http://${THIS_IP}:23803 --listen-peer-urls http://${THIS_IP}:23803 \
        --advertise-client-urls http://${THIS_IP}:23793 --listen-client-urls http://${THIS_IP}:23793 \
        --initial-cluster ${CLUSTER} \
        --initial-cluster-state ${CLUSTER_STATE} --initial-cluster-token ${TOKEN}
    

    性能测试与调优参考以下博客:
    https://www.jianshu.com/p/f31ef5e7bdd0

    相关文章

      网友评论

          本文标题:Etcd集群搭建与性能测试和调优

          本文链接:https://www.haomeiwen.com/subject/kjotkltx.html