首页 > 其他分享 >etcd单节点扩容到3节点

etcd单节点扩容到3节点

时间:2023-07-19 17:46:34浏览次数:29  
标签:扩容 https key -- ca 10.38 etcd 节点

背景:k8s为基于kubeadm创建的,etcd为二进制方式部署 

1.准备二进制及service文件

在etcd节点etcdctl version 查看版本信息

修改systemd启动文件,查看文件位置

vim /etc/systemd/system/etcd.service

在--initial-cluster中添加新机器

[Unit]
Description=Etcd Server
After=network.target
After=network-online.target
Wants=network-online.target
Documentation=https://github.com/coreos

[Service]
Type=notify
WorkingDirectory=/var/lib/etcd

ExecStart=/usr/local/bin/etcd \
  --name=etcd-k8s-dev-master-1 \
  --cert-file=/etc/kubernetes/pki/etcd/server.crt \
  --key-file=/etc/kubernetes/pki/etcd/server.key \
  --peer-cert-file=/etc/kubernetes/pki/etcd/peer.crt \
  --peer-key-file=/etc/kubernetes/pki/etcd/peer.key \
  --trusted-ca-file=/etc/kubernetes/pki/etcd/ca.crt \
  --peer-trusted-ca-file=/etc/kubernetes/pki/etcd/ca.crt \
  --initial-advertise-peer-urls=https://10.38.0.212:2380 \
  --listen-peer-urls=https://10.38.0.212:2380 \
  --listen-client-urls=https://10.38.0.212:2379,http://127.0.0.1:2379 \
  --advertise-client-urls=https://10.38.0.212:2379 \
  --initial-cluster-token=etcd-cluster-token \
  --initial-cluster=etcd-k8s-dev-master-1=https://10.38.0.212:2380,etcd-k8s-dev-worker-1=https://10.38.0.245:2380,etcd-k8s-dev-master-2=https://10.38.0.175:2380 \
  --initial-cluster-state=new \
  --data-dir=/var/lib/etcd \
  --snapshot-count=50000 \
  --auto-compaction-retention=1 \
  --max-request-bytes=10485760 \
  --quota-backend-bytes=8589934592
Restart=always
RestartSec=15
LimitNOFILE=65536
OOMScoreAdjust=-999

[Install]
WantedBy=multi-user.target

将原来服务器的etcd和etcdctl,service发送到另外两台服务器上

scp -i OPS-DEV-hybridcloud.pem /usr/local/bin/etcd 10.38.0.175:/usr/local/bin/etcd

scp -i OPS-DEV-hybridcloud.pem /usr/local/bin/etcdctl 10.38.0.175:/usr/local/bin/etcdctl

scp -i OPS-DEV-hybridcloud.pem /etc/systemd/system/etcd.service 10.38.0.175:/etc/systemd/system/etcd.service

2.生成证书

安装cfssl,证书生成工具

在https://github.com/cloudflare/cfssl/releases中选择版本进行下载,比较早的版本已不可用,最好下载较新的版本

 

wget https://github.com/cloudflare/cfssl/releases/download/v1.6.3/cfssl_1.6.3_linux_amd64
wget https://github.com/cloudflare/cfssl/releases/download/v1.6.3/cfssljson_1.6.3_linux_amd64
chmod +x /usr/bin/cfssl*

 

编写json文件,用于生成证书

 

vim ca-config.json
{
  "signing": {
    "default": {
      "expiry": "876000h"
    },
    "profiles": {
      "server": {
         "expiry": "876000h",
         "usages": [
            "signing",
            "key encipherment",
            "server auth",
            "client auth"
        ]
      },
      "client": {
         "expiry": "876000h",
         "usages": [
            "signing",
            "key encipherment",
            "client auth"
        ]
      },
      "peer": {
         "expiry": "876000h",
         "usages": [
            "signing",
            "key encipherment",
            "server auth",
            "client auth"
        ]
      }
    }
  }
}
vim server-csr.json
{
    "CN": "etcd",
    "hosts": [
        "10.38.0.212",
        "10.38.0.245",
        "10.38.0.175"
    ],
    "key": {
        "algo": "rsa",
        "size": 2048
    },
    "names": [
        {
            "C": "CN",
            "L": "Beijing",
            "ST": "Beijing"
        }
    ]
}
vim client-csr.json
{
    "CN": "client",
    "key": {
        "algo": "rsa",
        "size": 2048
    }
}

生成证书

cfssl gencert -ca=ca.crt -ca-key=ca.key -config=ca-config.json -profile=server server-csr.json | cfssljson -bare server
cfssl gencert -ca=ca.crt -ca-key=ca.key -config=ca-config.json -profile=peer server-csr.json | cfssljson -bare peer
cfssl gencert -ca=ca.crt -ca-key=ca.key -config=ca-config.json -profile=client client-csr.json | cfssljson -bare client

将生成证书的.pem -key.pem改为 .crt .key

将证书传送给另外两个新节点

scp -r -i ~/OPS-DEV-hybridcloud.pem ../etcd 10.38.0.175:/etc/kubernetes/pki/etcd

修改两个节点上的service文件,修改本机的ip,还有initial-cluster-state=existing

[Unit]
Description=Etcd Server
After=network.target
After=network-online.target
Wants=network-online.target
Documentation=https://github.com/coreos

[Service]
Type=notify
WorkingDirectory=/var/lib/etcd

ExecStart=/usr/local/bin/etcd \
  --name=etcd-k8s-dev-worker-1 \
  --cert-file=/etc/kubernetes/pki/etcd/server.crt \
  --key-file=/etc/kubernetes/pki/etcd/server.key \
  --peer-cert-file=/etc/kubernetes/pki/etcd/peer.crt \
  --peer-key-file=/etc/kubernetes/pki/etcd/peer.key \
  --trusted-ca-file=/etc/kubernetes/pki/etcd/ca.crt \
  --peer-trusted-ca-file=/etc/kubernetes/pki/etcd/ca.crt \
  --initial-advertise-peer-urls=https://10.38.0.245:2380 \
  --listen-peer-urls=https://10.38.0.245:2380 \
  --listen-client-urls=https://10.38.0.245:2379,http://127.0.0.1:2379 \
  --advertise-client-urls=https://10.38.0.245:2379 \
  --initial-cluster-token=etcd-cluster-token \
  --initial-cluster=etcd-k8s-dev-master-1=https://10.38.0.212:2380,etcd-k8s-dev-worker-1=https://10.38.0.245:2380,etcd-k8s-dev-master-2=https://10.38.0.175:2380 \
  --initial-cluster-state=existing \
  --data-dir=/var/lib/etcd \
  --snapshot-count=50000 \
  --auto-compaction-retention=1 \
  --max-request-bytes=10485760 \
  --quota-backend-bytes=8589934592
Restart=always
RestartSec=15
LimitNOFILE=65536
OOMScoreAdjust=-999

[Install]
WantedBy=multi-user.target

etcd备份,若没问题不用恢复,若加入有问题可通过快照进行恢复

etcdctl snapshot save /data/etcd$(date +%Y%m%d_%H%M%S)_snapshot.db

 

标签:扩容,https,key,--,ca,10.38,etcd,节点
From: https://www.cnblogs.com/xiaoxiaomuyuyu/p/17566302.html

相关文章

  • Redis群集配置搭建以及节点添加删除
    一、Redis群集 1、Redis群集的作用优势  1)Redis群集的作用  防止单节点故障数据丢失 增加访问并发量 2)优势  可靠性强  稳定性强 加快处理速度 实时故障修复2、Redis群集原理和Redis群集角色类型 1)redis群集原理  Redis数据存储在卡槽中 卡槽范......
  • Doris-BE节点集体挂掉问题排查
    背景7月14版本上线,7月16日doris集群BE节点短时间内陆续挂掉,暂时重启解决,7月17日周一上班,BE节点开始反复挂掉影响使用问题定位:1、查看dorisBE节点日志be.out日志如下所示,由第7行(doris::PlanFragmentExecutor)可看出是因为sql执行引发的问题,需要进一步的通过CoreDump来定位到触......
  • kubeasz K8S测试环境删除多余 node 节点
    kubeaszK8S测试环境删除多余node节点背景:公司之前存在3套test环境,有1套环境部署的生产环境老系统,目前生产环境已经完成了新老系统切换,不在需要老系统test环境,需要进行回收1|查看节点列表使用kubectl命令来查看当前集群中的节点列表,以确认要删除的节点的名称。kub......
  • mongodb一主一从添加一个从节点
    环境:OS:Centos7mongodb:4.4.22拓扑结构:192.168.1.107primary192.168.1.104secondary新增节点:192.168.1.108secondary 1.新增的节点安装mongodb目录结构保持与现有的一致,同时将密钥拷贝到新节点的相应目录下mongo.cnf配置文件可以拷贝主库的过来,然后修改相应的ip即可......
  • VMware ESXi给虚拟机扩容
       一、查看现状df-Thlsblkfdisk-l二、增加容量重启虚拟机三、新建分区#创建分区命令fdisk/dev/sda再输入p新增分区输入:n回车(默认为主分区primary)分区号,起始扇区,结束扇区都默认(回车)设置分区格式输入:t分区号默认(回车)Hex代码为8e(8e代表LinuxLVM......
  • docker分布式存储之哈希槽3主3从redis集群配置+主从扩容缩容
    创建开启六台redis容器systemctlrestartdockerdockerpullredis:6.0.8根据需求下载redis的镜像版本配置3主3从开启六台redis容器分别用node-1~node-6来区分dockerrun-d--nameredis-node-1--nethost--privileged=true-v/tmp/redis/share/redis-node......
  • 泛微OA节点后附加操作-update数据
    1.礼品领用申请流程,到人力资源部备案节点,由人力资源部填写“实际使用数量”,在该节点后减少对应礼品的库存数量。2.节点后附加操作2.1新建DML接口动作2.2填写信息3.DML语句updateuf_jczlsetkcsl=kcsl-'{?d.sjsl}'whereid='{?d.lpmc}'......
  • mongodb副本集(PSA模式)修改节点信息
    环境:OS:Centos7mongodb:4.4.22 我们在副本集扩容的情况下,新加入节点一般设置priority和votes都为0,待新节点数据同步完成后再进行修改:主库上执行新增新的节点:myrepl:PRIMARY>rs.add({host:"192.168.1.107:29001",priority:0,votes:0})待同步完成后查看副本集配置 ......
  • [Linux][报错解决] 搭建有固定ip的节点
    Linux环境:CentOS8+VMware目标:令节点有固定可访问的ip地址,为以后搭建多节点环境铺垫过程:查看并确定宿主机和linux系统的ip地址,修改ens160/ens33文件中的参数,使系统ip固定使用dhclient给linux系统分配一个ip系统刚开始默认没有ip(ifconfig后ens160/33没有inet一项),这时候需要dhc......
  • mongodb4.4.22主从(副本集附仲裁节点)部署带认证模式
    环境:OS:CentOS7DB:4.4.22机器角色:192.168.1.102:29001主192.168.1.104:29001从192.168.1.105:29001仲裁节点 1.下载相应的版本https://www.mongodb.com/download-center/community我这里下载的是mongodb-linux-x86_64-rhel70-4.4.22.tgz 2.创建安装目录192.168.1.102......