• etcd: mac 环境部署


    部署etcd

    官网:https://etcd.io/docs/v3.5/install/
    release版本链接:https://github.com/etcd-io/etcd/releases/

    下载部署文件

    参考release版本链接中的说明,拼装相应版本的下载地址:

    wget https://github.com/etcd-io/etcd/releases/download/{ETCD_VER}/etcd-{ETCD_VER}-darwin-amd64.zip
    
    • 1

    如v3.5.12 版本:

    wget https://github.com/etcd-io/etcd/releases/download/v3.5.12/etcd-v3.5.12-darwin-amd64.zip
    
    • 1

    启动服务

    将zip包解压出来,进入目录查看文件。

    localhost:etcd xxx$ unzip etcd-v3.5.12-darwin-amd64.zip
    Archive:  etcd-v3.5.12-darwin-amd64.zip
       creating: etcd-v3.5.12-darwin-amd64/
      inflating: etcd-v3.5.12-darwin-amd64/README.md
      inflating: etcd-v3.5.12-darwin-amd64/READMEv2-etcdctl.md
      inflating: etcd-v3.5.12-darwin-amd64/etcdutl
      inflating: etcd-v3.5.12-darwin-amd64/etcdctl
       creating: etcd-v3.5.12-darwin-amd64/Documentation/
      inflating: etcd-v3.5.12-darwin-amd64/Documentation/README.md
       creating: etcd-v3.5.12-darwin-amd64/Documentation/dev-guide/
       creating: etcd-v3.5.12-darwin-amd64/Documentation/dev-guide/apispec/
       creating: etcd-v3.5.12-darwin-amd64/Documentation/dev-guide/apispec/swagger/
      inflating: etcd-v3.5.12-darwin-amd64/Documentation/dev-guide/apispec/swagger/v3election.swagger.json
      inflating: etcd-v3.5.12-darwin-amd64/Documentation/dev-guide/apispec/swagger/rpc.swagger.json
      inflating: etcd-v3.5.12-darwin-amd64/Documentation/dev-guide/apispec/swagger/v3lock.swagger.json
      inflating: etcd-v3.5.12-darwin-amd64/README-etcdutl.md
      inflating: etcd-v3.5.12-darwin-amd64/README-etcdctl.md
      inflating: etcd-v3.5.12-darwin-amd64/etcd
    localhost:etcd xxx$ cd etcd-v3.5.12-darwin-amd64
    localhost:etcd-v3.5.12-darwin-amd64 xxx$ ls -l
    total 123296
    drwxr-xr-x@ 4 zcy  staff       128  1 31 18:36 Documentation
    -rw-r--r--@ 1 zcy  staff     42066  1 31 18:36 README-etcdctl.md
    -rw-r--r--@ 1 zcy  staff      7359  1 31 18:36 README-etcdutl.md
    -rw-r--r--@ 1 zcy  staff      9394  1 31 18:36 README.md
    -rw-r--r--@ 1 zcy  staff      7896  1 31 18:36 READMEv2-etcdctl.md
    -rwxr-xr-x@ 1 zcy  staff  26570464  1 31 18:36 etcd
    -rwxr-xr-x@ 1 zcy  staff  19811888  1 31 18:36 etcdctl
    -rwxr-xr-x@ 1 zcy  staff  16669696  1 31 18:36 etcdutl
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29

    运行启动命令

    localhost:etcd-v3.5.12-darwin-amd64 xxx$ nohup ./etcd &
    [1] 53092
    localhost:etcd-v3.5.12-darwin-amd64 xxx$ appending output to nohup.out
    
    • 1
    • 2
    • 3

    命令行使用

    1. put
      localhost:etcd-v3.5.12-darwin-amd64 xxx$ ./etcdctl put name cloud
      OK
      
      • 1
      • 2
    2. get
      localhost:etcd-v3.5.12-darwin-amd64 xxx$ ./etcdctl get name
      name
      cloud
      
      • 1
      • 2
      • 3
    3. del
      localhost:etcd-v3.5.12-darwin-amd64 xxx$ ./etcdctl del name
      1
      
      • 1
      • 2
    4. watch
      先执行watch,此时命令行会挂起, 等待watch的信息返回
      localhost:etcd-v3.5.12-darwin-amd64 xxx$ ./etcdctl watch name
      
      
      • 1
      • 2
      另外再开一个命令行窗口,执行put 命令,watch窗口会显示put的信息
      新窗口:
      localhost:etcd-v3.5.12-darwin-amd64 xxx$ ./etcdctl put name cloud
      OK
      
      • 1
      • 2
      watch窗口:
      localhost:etcd-v3.5.12-darwin-amd64 xxx$ ./etcdctl watch name
      PUT
      name
      cloud
      
      
      • 1
      • 2
      • 3
      • 4
      • 5
      新窗口`再执行del命令:
      localhost:etcd-v3.5.12-darwin-amd64 xxx$ ./etcdctl del name
      1
      
      • 1
      • 2
      watch窗口也会显示del信息:
      localhost:etcd-v3.5.12-darwin-amd64 xxx$ ./etcdctl watch name
      PUT
      name
      cloud
      DELETE
      name
      
      
      • 1
      • 2
      • 3
      • 4
      • 5
      • 6
      • 7
    5. lease
      localhost:etcd-v3.5.12-darwin-amd64 xxx$ ./etcdctl lease grant 120
      lease 694d8dd00386a80a granted with TTL(120s)
      localhost:etcd-v3.5.12-darwin-amd64 xxx$ ./etcdctl put name cloud --	lease="694d8dd00386a80a"
      OK
      
      • 1
      • 2
      • 3
      • 4

    brew 安装etcd

    安装etcd

    brew install etcd
    
    • 1

    运行 etcd
    安装完后,会有相关提示,推荐使用 brew services 来管理这些应用。

    brew services 常用的操作:

    # 查看当前应用列表
    brew services list
    
    # 启动某个应用
    brew services start {serviceName}
    
    # 停止某个应用
    brew services stop {serviceName}
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    以etcd为例:

    #安装etcd 
    brew install etcd
    
    #启动etcd
    brew services start {serviceName}
    
    • 1
    • 2
    • 3
    • 4
    • 5
  • 相关阅读:
    C. Good String(暴力枚举)
    Apache Doris 2.1.0 版本发布:开箱盲测性能大幅优化,复杂查询性能提升 100%
    CMS 三色标记【JVM调优】
    PVL EDI 项目案例
    单例设计模式
    山西电力市场日前价格预测【2023-09-12】
    2022年03月 C/C++(七级)真题解析#中国电子学会#全国青少年软件编程等级考试
    学编程始于C语言,但只学C远远不够的!
    王道书 P149 T5(求树高) + 拓展(求某点的层次/深度)(二叉树链式存储实现)
    SpringBoot配置
  • 原文地址:https://blog.csdn.net/Mr_rain/article/details/136237987