美文网首页
k8s-etcd集群搭建

k8s-etcd集群搭建

作者: 平头哥2 | 来源:发表于2019-12-23 15:20 被阅读0次

    部署etcd集群

    文章照抄

    https://www.cnblogs.com/jasonboren/p/11483898.html

    1. 先拉取etcd二进制压缩包

    [root@localhost ~]# cd
    [root@localhost ~]# wget wget https://github.com/coreos/etcd/releases/download/v3.3.2/etcd-v3.3.2-linux-amd64.tar.gz
    # 解压压缩包
    [root@localhost ~]# tar zxvf etcd-v3.3.2-linux-amd64.tar.gz
    
    # 建立一个文件,分别存放bin文件,cfg配置文件,ssl验证文件
    [root@localhost ~]# mkdir -p /opt/kubernetes/{bin,cfg,ssl}
    # 然后将etcd,etcdctl移动到bin目录下
    [root@localhost ~]# mv ~/etcd-v3.3.2-linux-amd64/etcd* /opt/kubernetes/bin/
    # 移动pem到ssl下
    [root@localhost ~]# mv /root/ssl/*pem /opt/kubernetes/ssl/
    

    创建 etcd 配置文件

    #[Member]
    #节点名字
    ETCD_NAME="etcd01"
    #数据目录
    ETCD_DATA_DIR="/var/lib/etcd/default.etcd" 
    #当前节点的ip地址
    ETCD_LISTEN_PEER_URLS="https://192.168.10.155:2380" 
    ETCD_LISTEN_CLIENT_URLS="https://192.168.10.155:2379"
    
    #[Clustering]
    ETCD_INITIAL_ADVERTISE_PEER_URLS="https://192.168.10.155:2380"
    ETCD_ADVERTISE_CLIENT_URLS="https://192.168.10.155:2379"
    #集群所有的节点的ip地址
    ETCD_INITIAL_CLUSTER="etcd01=https://192.168.10.155:2380,etcd02=https://192.168.10.158:2380,etcd03=https://192.168.10.157:2380" 
    ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster"
    ETCD_INITIAL_CLUSTER_STATE="new"
    

    创建 etcd.service 文件

    vi /usr/lib/systemd/system/etcd.service
    # 内容为
    [Unit]
    Description=Etcd Server
    After=network.target
    After=network-online.target
    Wants=network-online.target
    
    [Service]
    Type=notify
    EnvironmentFile=-/opt/kubernetes/cfg/etcd
    ExecStart=/opt/kubernetes/bin/etcd \
    --name=${ETCD_NAME} \
    --data-dir=${ETCD_DATA_DIR} \
    --listen-peer-urls=${ETCD_LISTEN_PEER_URLS} \
    --listen-client-urls=${ETCD_LISTEN_CLIENT_URLS},http://127.0.0.1:2379 \
    --advertise-client-urls=${ETCD_ADVERTISE_CLIENT_URLS} \
    --initial-advertise-peer-urls=${ETCD_INITIAL_ADVERTISE_PEER_URLS} \
    --initial-cluster=${ETCD_INITIAL_CLUSTER} \
    --initial-cluster-token=${ETCD_INITIAL_CLUSTER} \
    --initial-cluster-state=new \
    --cert-file=/opt/kubernetes/ssl/server.pem \
    --key-file=/opt/kubernetes/ssl/server-key.pem \
    --peer-cert-file=/opt/kubernetes/ssl/server.pem \
    --peer-key-file=/opt/kubernetes/ssl/server-key.pem \
    --trusted-ca-file=/opt/kubernetes/ssl/ca.pem \
    --peer-trusted-ca-file=/opt/kubernetes/ssl/ca.pem
    Restart=on-failure
    LimitNOFILE=65536
    
    [Install]
    WantedBy=multi-user.target
    

    启动etcd

    systemctl daemon-reload
    systemctl start etcd
    systemctl enable etcd 
    

    node01和node02 做相同的操作,记得修改etcd配置文件的ip和节点名字

    相关文章

      网友评论

          本文标题:k8s-etcd集群搭建

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