etcd 集群部署(静态配置)

论坛 期权论坛 脚本     
已经匿名di用户   2022-5-29 19:21   1206   0

前言

ETCD使用RAFT协议保证各个节点之间的状态一致。根据RAFT算法原理,节点数目越多,会降低集群的写性能。这是因为每一次写操作,需要集群中大多数节点将日志落盘成功后,Leader节点才能将修改内部状态机,并返回将结果返回给客户端。

也就是说在等同配置下,节点数越少,集群性能越好。显然,只部署1个节点是没什么意义的。通常,按照需求将集群节点部署为3,5,7,9个节点。

etcd有三种集群化启动的配置方案,分别为静态配置启动、etcd自身服务发现、通过DNS进行服务发现。

环境介绍

主机名IPetcd版本
node1192.168.49.1353.3.13
node2192.168.49.1363.3.13
node3192.168.49.1383.3.13

单节点安装

参考 https://www.cnblogs.com/mldblue/articles/10975280.html

配置

  1. 首先写配置文件(建议从网上下载example configure

  2. 在集群机器执行如下命令

    [root@node1 ~]# mkdir /etc/etcd/
    [root@node1 ~]# vim /etc/etcd/etcd.conf
    [root@node1 ~]# mkdir /opt/etcd_data
  3. node1 配置文件示例,node2、node3修改节点名称和集群内节点通信所用端口和客户端连接的端口。

    name: 'node1'
    data-dir: "/opt/etcd_data"
    wal-dir:
    snapshot-count: 10000
    heartbeat-interval: 100
    election-timeout: 1000
    quota-backend-bytes: 0
    listen-peer-urls: http://192.168.49.135:2380
    listen-client-urls: http://localhost:2379,http://192.168.49.135:2379
    max-snapshots: 5
    max-wals: 5
    cors:
    initial-advertise-peer-urls: http://192.168.49.135:2380
    advertise-client-urls: http://192.168.49.135:2379
    discovery:
    discovery-fallback: 'proxy'
    discovery-proxy:
    discovery-srv:
    initial-cluster: "node1=http://192.168.49.135:2380,node2=http://192.168.49.136:2380,node3=http://192.168.49.138:2380"
    initial-cluster-token: 'etcd-cluster'
    initial-cluster-state: 'new'
    strict-reconfig-check: false
    enable-v2: true
    enable-pprof: true
    proxy: 'off'
    proxy-failure-wait: 5000
    proxy-refresh-interval: 30000
    proxy-dial-timeout: 1000
    proxy-write-timeout: 5000
    proxy-read-timeout: 0
    client-transport-security:
      cert-file:
      key-file:
      client-cert-auth: false
      trusted-ca-file:
      auto-tls: false
    peer-transport-security:
      cert-file:
      key-file:
      client-cert-auth: false
      trusted-ca-file:
      auto-tls: false
    debug: false
    logger: zap
    log-outputs: [stderr]
    force-new-cluster: false
    auto-compaction-mode: periodic
    auto-compaction-retention: "1"
    

启动

  1. 启动

    [root@node1 etcd-v3.3.13-linux-amd64]# etcd --config-file /etc/etcd/etcd.conf

测试

  1. 查看集群成员

    [root@node2 ~]# etcdctl member list
    8816eaa680e63c73: name=node3 peerURLs=http://192.168.49.138:2380 clientURLs=http://192.168.49.138:2379 isLeader=false
    a3d1fb0d28ed2953: name=node2 peerURLs=http://192.168.49.136:2380 clientURLs=http://192.168.49.136:2379 isLeader=false
    cf5538a4dab95927: name=node1 peerURLs=http://192.168.49.135:2380 clientURLs=http://192.168.49.135:2379 isLeader=true

参考
https://www.cnblogs.com/softidea/p/6517959.html
https://blog.csdn.net/bbwangj/article/details/82584988
https://blog.csdn.net/fnatic_/article/details/84307332

转载于:https://www.cnblogs.com/mldblue/articles/10980910.html

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:81
帖子:4969
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP