当前位置: 首页 > news >正文

docker 部署单节点的etcd以及 常用使用命令

docker部署etcd

$ docker run -d --name etcd-server -p 2379:2379 -p 2380:2380 quay.io/coreos/etcd:v3.5.0 /usr/local/bin/etcd -name my-etcd-1 -advertise-client-urls http://0.0.0.0:2379 -listen-client-urls http://0.0.0.0:2379 -initial-advertise-peer-urls http://0.0.0.0:2380 -listen-peer-urls http://0.0.0.0:2380 -initial-cluster my-etcd-1=http://0.0.0.0:2380
Unable to find image 'quay.io/coreos/etcd:v3.5.0' locally
v3.5.0: Pulling from coreos/etcd
6022c6b01d76: Pull complete
1d97b1ec77fc: Pull complete
99ef4b690837: Pull complete
435b7bf0967c: Pull complete
17e4a5f7c1b5: Pull complete
5b0292999756: Pull complete
Digest: sha256:28759af54acd6924b2191dc1a1d096e2fa2e219717a21b9d8edf89717db3631b
Status: Downloaded newer image for quay.io/coreos/etcd:v3.5.0
ddcbe3db8e832a366d37a75f15ed35618e82928e79d31fe9e33f39627e97c114

验证 etcd 服务

可以使用 etcdctl 命令行工具验证 etcd 服务是否正常工作。

在主机上安装 etcdctl,安装方式如下:

macos:

$ brew install etcd

其他系统:

  1. 访问etcd的GitHub发布页面(https://github.com/etcd-io/etcd/releases)来找到你想要的版本。

  2. 下载对应版本的etcdctl二进制文件。

  3. 将下载的文件移动到你的PATH中的一个目录,例如/usr/local/bin

# 下载etcdctl,替换<version>为实际版本号
$ curl -L https://github.com/etcd-io/etcd/releases/download/v{version}/etcd-v{version}-darwin-amd64.tar.gz -o etcd-v{version}-darwin-amd64.tar.gz
# 解压缩
$ tar xzvf etcd-v{version}-darwin-amd64.tar.gz
# 将etcdctl移动到/usr/local/bin目录
$ sudo mv etcd-v{version}-darwin-amd64/etcdctl /usr/local/bin/
替换<version>为你想要安装的etcdctl版本。

验证: 

$ etcdctl --endpoints=http://localhost:2379 endpoint health --write-out="json"

如果返回 {"endpoint":"http://localhost:2379","health":"true"},表示 etcd 服务运行正常。

常用使用命令

  1. 存储键值对

    etcdctl --endpoints=http://localhost:2379 put mykey "myvalue"
    
  2. 读取键值对

    etcdctl --endpoints=http://localhost:2379 get mykey
    
  3. 列出所有键值对

    etcdctl --endpoints=http://localhost:2379 get --prefix ""
    
  4. 删除键值对

    etcdctl --endpoints=http://localhost:2379 del mykey
    
  5. 查看 etcd 集群状态

    etcdctl --endpoints=http://localhost:2379 endpoint status
    
  6. 备份 etcd 数据

    etcdctl --endpoints=http://localhost:2379 snapshot save backup.db
    
  7. 恢复 etcd 数据

    etcdctl snapshot restore backup.db --data-dir /path/to/etcd/data-dir
    

http://www.lryc.cn/news/468451.html

相关文章:

  • 华为开放式耳机测评,南卡 、华为、Cleer开放式耳机超深度横评
  • 【Power Query】List.Select 筛选列表
  • Spring--4
  • django celery 定时任务 Crontab 计划格式
  • 动态应用程序安全测试 (DAST) 工具 Fortify WebInspect
  • 深入解析东芝TB62261FTG,步进电机驱动方案
  • Vue 常用的狗钩子函数
  • 【机器学习基础】激活函数
  • nnMamba用于糖尿病视网膜病变检测测试
  • 【Spring MVC】创建项目和建立请求连接
  • 台达A2伺服
  • ReactOS系统中搜索给定长度的空间地址区间中的二叉树
  • Postgresql中和时间相关的字段类型及其适用场景
  • 储能蓝海:技术革新与成本骤降引爆市场
  • java抽象类和接口
  • 法治在沃刷积分-刷文章浏览数
  • 【深度学习实验七】 自动梯度计算
  • JAVA毕业设计192—基于Java+Springboot+vue的个人博客管理系统(源代码+数据库+万字论文+开题+任务书)
  • must be ‘pom‘ but is ‘jar‘解决思路
  • STM32启动文件浅析
  • h5页面与小程序页面互相跳转
  • 探索 JavaScript 事件机制(四):React 合成事件系统
  • openlayers 封装加载本地geojson数据 - vue3
  • 手机号码携号转网查询接口-在线手机号码携号转网查询-手机号码携号转网查询API
  • yolo目标检测和姿态识别和目标追踪
  • Docker搭建开源Web云桌面操作系统Puter和DaedalOS
  • FAQ-为什么交换机发给服务器的日志显示的时间少8小时
  • [表达式]真假计算
  • 记录一次线上环境svchost.exe antimalware service executable 进程占用CPU过高问题
  • Docker 部署 EMQX 一分钟极速部署