美文网首页
etcd部署

etcd部署

作者: 这货不是王马勺 | 来源:发表于2024-03-14 13:54 被阅读0次

    下载

    官网:

    https://etcd.io/docs/v3.5/install/
    

    github下载地址:

    https://github.com/etcd-io/etcd/releases/tag/v3.5.11
    

    下载对应的包即可,一般用linux_amd64的

    单实例部署

    上传压缩包,解压后进入目录(看看etcd是不是在bin子目录下)
    直接前台启动

    ./etcd
    

    后台启动etcd,日志文件输出到/tmp/etcd.log

    nohup ./etcd >/tmp/etcd.log 2>&1 &
    

    查看etcd版本

    ./etcd -version
    

    将etcd和etcdctl复制到/usr/local/bin目录,系统可直接调用etcd和etcdctl,也可以配置环境变量指向bin目录
    然后使用etcdctl客户端测试(默认监听localhost)

    etcdctl put name wwj
    etcdctl get name
    etcdctl get name --endpoints=localhost:2379
    

    单节点多实例部署

    etcd server 默认使用 2380 端口监听集群中其他 server 的请求,但是如果在同一台机器上
    有多个 etcd server 都在同一个端口上监听,那么会导致端口冲突 。作为示例,我们分别让 3 个 etcd server 监听在 12380 、 22380 、 32380 端口上 。
    (服务之间的监听默认是2380,客户端连接默认是2379)
    我们可以通过进程管理工具goreman,快速创建、停止本地的多节点etcd集群。
    依赖go环境,安装goreman:

    go install github.com/mattn/goreman@latest
    goreman help
    

    编写local-cluster-profile文件

    #etcd1: 
    etcd ‐‐name infra1 ‐‐listen‐client‐urls http://127.0.0.1:12379 ‐‐advertise‐client‐urls http://127.0.0.1:12379 ‐‐listen‐peer‐urls http://127.0.0.1:12380 ‐‐initial‐advertise‐peer‐urls http://127.0.0.1:12380 ‐‐initial‐cluster‐token etcd‐cluster‐1 ‐‐initial‐cluster 'infra1=http://127.0.0.1:12380,infra2=http://127.0.0.1:22380,infra3=http://127.0.0.1:32380' ‐‐initial‐cluster‐state new
    #etcd2: 
    etcd ‐‐name infra2 ‐‐listen‐client‐urls http://127.0.0.1:22379 ‐‐advertise‐client‐urls http://127.0.0.1:22379 ‐‐listen‐peer‐urls http://127.0.0.1:22380 ‐‐initial‐advertise‐peer‐urls http://127.0.0.1:22380 ‐‐initial‐cluster‐token etcd‐cluster‐1 ‐‐initial‐cluster 'infra1=http://127.0.0.1:12380,infra2=http://127.0.0.1:22380,infra3=http://127.0.0.1:32380' ‐‐initial‐cluster‐state new
    #etcd3: 
    etcd ‐‐name infra3 ‐‐listen‐client‐urls http://127.0.0.1:32379 ‐‐advertise‐client‐urls http://127.0.0.1:32379 ‐‐listen‐peer‐urls http://127.0.0.1:32380 ‐‐initial‐advertise‐peer‐urls http://127.0.0.1:32380 ‐‐initial‐cluster‐token etcd‐cluster‐1 ‐‐initial‐cluster 'infra1=http://127.0.0.1:12380,infra2=http://127.0.0.1:22380,infra3=http://127.0.0.1:32380' ‐‐initial‐cluster‐state new
    

    参考:

    https://www.bilibili.com/video/BV1Q84y167hF/?p=3&spm_id_from=pageDriver&vd_source=adbe4dade12efbb9aa6895c308f74a54
    

    相关文章

      网友评论

          本文标题:etcd部署

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