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

Centos7 安装 Etcd

        Github上下载并解压安装包

wget https://github.com/coreos/etcd/releases/download/v3.4.10/etcd-v3.4.10-linux-amd64.tar.gz
tar xzvf etcd-v3.4.10-linux-amd64.tar.gz
mv etcd-v3.4.10-linux-amd64 /opt/etcd

        解压后是一些文档和两个二进制文件etcd和etcdctl。etcd是server端,etcdctl是客户端。

        测试环境,启动一个单节点的etcd服务,只需要运行etcd命令就行。

./etcd

配置信息

        为了可以使用系统命令运行etcd,将文件夹下的二进制文件复制到bin下

cp /opt/etcd/etcd* /usr/local/bin/

        设定etcd配置文件

mkdir -p /var/lib/etcd/
mkdir -p /opt/etcd/config/
chmod 700 /var/lib/etcd #注意修改权限,否则无法启动

        创建etcd配置文件

cat <<EOF | sudo tee /opt/etcd/config/etcd.conf
#节点名称
ETCD_NAME=$(hostname -s)
#数据存放位置
ETCD_DATA_DIR=/var/lib/etcd
EOF

        创建systemd配置文件

cat <<EOF | sudo tee /etc/systemd/system/etcd.service[Unit]
Description=Etcd Server
Documentation=https://github.com/coreos/etcd
After=network.target[Service]
User=root
Type=notify
EnvironmentFile=-/opt/etcd/config/etcd.conf
ExecStart=/opt/etcd/etcd
Restart=on-failure
RestartSec=10s
LimitNOFILE=40000[Install]
WantedBy=multi-user.target
EOF

        启动etcd

systemctl daemon-reload && systemctl enable etcd && systemctl start etcd

基本操作

etcdctl -h
NAME:etcdctl - A simple command line client for etcd3.USAGE:etcdctl [flags]VERSION:3.4.10API VERSION:3.4COMMANDS:alarm disarm		Disarms all alarmsalarm list		Lists all alarmsauth disable		Disables authenticationauth enable		Enables authenticationcheck datascale		Check the memory usage of holding data for different workloads on a given server endpoint.check perf		Check the performance of the etcd clustercompaction		Compacts the event history in etcddefrag			Defragments the storage of the etcd members with given endpointsdel			Removes the specified key or range of keys [key, range_end)elect			Observes and participates in leader electionendpoint hashkv		Prints the KV history hash for each endpoint in --endpointsendpoint health		Checks the healthiness of endpoints specified in `--endpoints` flagendpoint status		Prints out the status of endpoints specified in `--endpoints` flagget			Gets the key or a range of keyshelp			Help about any commandlease grant		Creates leaseslease keep-alive	Keeps leases alive (renew)lease list		List all active leaseslease revoke		Revokes leaseslease timetolive	Get lease informationlock			Acquires a named lockmake-mirror		Makes a mirror at the destination etcd clustermember add		Adds a member into the clustermember list		Lists all members in the clustermember promote		Promotes a non-voting member in the clustermember remove		Removes a member from the clustermember update		Updates a member in the clustermigrate			Migrates keys in a v2 store to a mvcc storemove-leader		Transfers leadership to another etcd cluster member.put			Puts the given key into the storerole add		Adds a new rolerole delete		Deletes a rolerole get		Gets detailed information of a rolerole grant-permission	Grants a key to a rolerole list		Lists all rolesrole revoke-permission	Revokes a key from a rolesnapshot restore	Restores an etcd member snapshot to an etcd directorysnapshot save		Stores an etcd node backend snapshot to a given filesnapshot status		Gets backend snapshot status of a given filetxn			Txn processes all the requests in one transactionuser add		Adds a new useruser delete		Deletes a useruser get		Gets detailed information of a useruser grant-role		Grants a role to a useruser list		Lists all usersuser passwd		Changes password of useruser revoke-role	Revokes a role from a userversion			Prints the version of etcdctlwatch			Watches events stream on keys or prefixesOPTIONS:--cacert=""				verify certificates of TLS-enabled secure servers using this CA bundle--cert=""					identify secure client using this TLS certificate file--command-timeout=5s			timeout for short running command (excluding dial timeout)--debug[=false]				enable client-side debug logging--dial-timeout=2s				dial timeout for client connections-d, --discovery-srv=""			domain name to query for SRV records describing cluster endpoints--discovery-srv-name=""			service name to query when using DNS discovery--endpoints=[127.0.0.1:2379]		gRPC endpoints-h, --help[=false]				help for etcdctl--hex[=false]				print byte strings as hex encoded strings--insecure-discovery[=true]		accept insecure SRV records describing cluster endpoints--insecure-skip-tls-verify[=false]	skip server certificate verification (CAUTION: this option should be enabled only for testing purposes)--insecure-transport[=true]		disable transport security for client connections--keepalive-time=2s			keepalive time for client connections--keepalive-timeout=6s			keepalive timeout for client connections--key=""					identify secure client using this TLS key file--password=""				password for authentication (if this option is used, --user option shouldn't include password)--user=""					username[:password] for authentication (prompt if password is not supplied)-w, --write-out="simple"			set the output format (fields, json, protobuf, simple, table)

        输入、查看、更新、删除k-v:

[root@localhost ~] etcdctl put /testkey "Hello world"
OK
[root@localhost ~] etcdctl get /testkey "Hello world"
/testkey
Hello world
[root@localhost ~] etcdctl put /testkey "Hello"
OK
[root@localhost ~] etcdctl get /testkey "Hello"
/testkey
Hello
[root@localhost ~] etcdctl del /testkey 
1

        获取json输出:

[root@localhost ~] etcdctl get key1 -w json
{"header":{"cluster_id":14841639068965178418,"member_id":10276657743932975437,"revision":6,"raft_term":2},"kvs":[{"key":"a2V5MQ==","create_revision":5,"mod_revision":5,"version":1,"value":"dmFsdWUx"}],"count":1}
[root@localhost ~] etcdctl get key1
key1
value1
[root@localhost ~] echo dmFsdWUx|base64 -d
value1[root@localhost ~]# 

        watch操作:在一个终端运行:

[root@localhost etcd] etcdctl watch key1
PUT
key1
valuex
PUT
key1
valuez

        在另一个终端:

[root@localhost ~] etcdctl put key1 valuex
OK
[root@localhost ~] etcdctl put key1 valuez
OK

        租约
        lease。etcd支持申请定时器,申请一个lease,会返回一个lease ID标识定时器。如果在put一个key的同时携带lease ID,就实现了一个自动过期的key。在etcd中,一个lease可以关联任意多的key,当lease过期后所有关联的key都将被自动删除。

#生成
[root@localhost etcd] etcdctl lease grant 300
lease 694d73749a9d0515 granted with TTL(300s)
#关联到key
[root@localhost etcd] etcdctl put key3 300 --lease=694d73749a9d0515
OK
#维持租约
[root@localhost etcd] etcdctl lease keep-alive 694d73749a9d0515
lease 694d73749a9d0515 keepalived with TTL(300)
#撤销租约
[root@localhost ~] etcdctl lease revoke 694d73749a9d0515
lease 694d73749a9d0515 revoked

相关文章:

Centos7 安装 Etcd

Github上下载并解压安装包 wget https://github.com/coreos/etcd/releases/download/v3.4.10/etcd-v3.4.10-linux-amd64.tar.gz tar xzvf etcd-v3.4.10-linux-amd64.tar.gz mv etcd-v3.4.10-linux-amd64 /opt/etcd解压后是一些文档和两个二进制文件etcd和etcdctl。etcd是serve…...

powerjob基于springboot2.1.6.RELEASE版本的问题研究

项目背景&#xff1a;基于第三代框架的集成问题&#xff0c;如果对于powerjob不熟悉的朋友&#xff0c;可以参考官方文档PowerJob 简介 语雀 关于语雀 23 日故障的公告 (qq.com) 简单插一句&#xff0c;针对语雀文档故障的心得&#xff0c;数据恢复&#xff0c;完整性&#…...

【AI视野·今日CV 计算机视觉论文速览 第270期】Wed, 18 Oct 2023

AI视野今日CS.CV 计算机视觉论文速览 Wed, 18 Oct 2023 Totally 60 papers &#x1f449;上期速览✈更多精彩请移步主页 Daily Computer Vision Papers 4K4D: Real-Time 4D View Synthesis at 4K Resolution Authors Zhen Xu, Sida Peng, Haotong Lin, Guangzhao He, Jiaming …...

uni-app小程序,uview-ui组件样式无法穿透修改的解决办法

1.首先设置以下选项.该选项的作用是让微信小程序允许样式穿透. 在需要改动的文件内加上 options: { styleIsolation: shared } 2.然后再使用vue的样式穿透写法. ::v-deep .类样式{} 或者 /deep/ .类样式{}...

Codeforces Round 515

Portal. C. Books Queries Portal. sol. D. Boxes Packing Portal. 把从左至右删物品转化为从右至左加物品。模拟即可。 #include <bits/stdc.h> using namespace std;const int maxn2e55; int a[maxn];int main() {int n,m,k;cin>>n>>m>>k;for(…...

Linux shell编程学习笔记15:定义数组、获取数组元素值和长度

一、 Linux shell 脚本编程中的数组概述 数组是一种常见的数据结构。跟大多数编程语言一样&#xff0c;大多数Linux shell脚本支持数组&#xff0c;但对数组的支持程度各不相同&#xff0c;比如数组的维度&#xff0c;是支持一维数组还是多维数组&#xff1f;再如&#xff0c;…...

k8s部署kafka,并使用zookeeper做注册中心

kafka在3.x版本后增加KRaft作为自己的注册中心&#xff0c;可以不依赖外部的zk&#xff1b;这里上一篇已经部署好了zk&#xff0c;kafka依然使用zk作为注册中心。 这里使用kafka是为集成zipkin收发微服务接口链路日志数据&#xff0c;只需要部署1个实列即可够用。 编写脚本yam…...

关于Nginx缓存

Nginx缓存 一般情况下系统用到的缓存有三种 服务端缓存&#xff1a; 缓存存在后端服务器&#xff0c;如redis代理缓存&#xff1a; 缓存存储在代理服务器或中间件&#xff0c;内容从后端服务器获取&#xff0c;保存在本地客户端缓存&#xff1a; 缓存在浏览器什么时候会出现3…...

为什么Open3D可视化TensorFlow张量速度超慢

问题描述 在使用Open3D可视化TensorFlow张量表示的点云时速度超慢 原因分析 可能是因为Open3D没有针对tf.Tensor做优化&#xff0c;也可能是tf.Tensor本身没有对张量的操作做优化&#xff0c;所以可能如果要在CPU中计算&#xff0c;numpy可能性能更好。 解决方案 open3d.u…...

使用element-UI Cascader组件,实现第一级单选选,第二级,第三级,子级可以多选

最近开发过程中&#xff0c;遇到需求测一个需求&#xff0c;就是级联选择器&#xff0c;需要多选&#xff1b;但是第一级是单选&#xff1b; 既要单选又要复选。参照网上内容&#xff0c;自己整理了一下功能实现&#xff1b; 如下图&#xff1a; 思路&#xff1a;1.把第一层的…...

防止消息丢失与消息重复——Kafka可靠性分析及优化实践

系列文章目录 上手第一关&#xff0c;手把手教你安装kafka与可视化工具kafka-eagle Kafka是什么&#xff0c;以及如何使用SpringBoot对接Kafka 架构必备能力——kafka的选型对比及应用场景 Kafka存取原理与实现分析&#xff0c;打破面试难关 防止消息丢失与消息重复——Kafka可…...

【Linux】Linux中Crontab(定时任务)命令详解及使用教程

文章目录 前言1.使用yum命令安装Crontab&#xff1a;2.查看Crontab状态&#xff1a;3.添加定时任务&#xff1a;4.查看任务列表&#xff1a;5.Crontab相关命令&#xff1a;6.部分脚本无法执行问题&#xff1a;7.Crontab默认调度任务&#xff1a;8.注意清理系统用户的邮件日志&a…...

计算机毕设 flink大数据淘宝用户行为数据实时分析与可视化

文章目录 0 前言1、环境准备1.1 flink 下载相关 jar 包1.2 生成 kafka 数据1.3 开发前的三个小 tip 2、flink-sql 客户端编写运行 sql2.1 创建 kafka 数据源表2.2 指标统计&#xff1a;每小时成交量2.2.1 创建 es 结果表&#xff0c; 存放每小时的成交量2.2.2 执行 sql &#x…...

8.2 矢量图层点要素单一符号使用一

文章目录 前言单一符号&#xff08;Single symbol&#xff09;渲染简单标记(Simple Marker)QGis代码实现 SVG标记&#xff08;SVG marker&#xff09;QGis代码实现 总结 前言 上一篇教程对矢量图层符号化做了一个整体介绍&#xff0c;并以点图层为例介绍了可以使用的渲染器&am…...

SQL企业微信群机器人消息推送

--参考资料地址 --微软官方地址: https://learn.microsoft.com/zh-cn/sql/relational-databases/system-stored-procedures/ole-automation-stored-procedures-transact-sql?view=sql-server-ver16 --腾讯官方地址:https://developer.work.weixin.qq.com/ --使…...

vscode远程连接ubuntu

修改环境变量&#xff0c;改使用git自带的ssh工具 openssh: C:\Windows\System32\OpenSSH\ssh.exeGit ssh: C:\Program Files\Git\usr\bin\ssh.exe vscode安装插件remote-ssh 重开软件&#xff0c;在左侧拓展入口下方&#xff0c;进入远程资源管理器 点击设置&#xff0c;进…...

Positive Technologies 在迪拜宣布与地区网络安全解决方案提供商开展合作

在中东最大的信息技术展 GITEX GLOBAL 2023 的间隙&#xff0c;Positive Technologies 同意与八家组织&#xff08;网络安全服务和解决方案提供商&#xff09;合作&#xff0c;在该地区开展合作&#xff0c;推广最先进的产品&#xff0c;并分享信息安全领域的经验。该公司强调了…...

Pyside6 QTextEdit

Pyside6 QTextEdit QTextEdit使用QTextEdit常用函数文本编辑类函数文本框格式设置函数设置文字颜色设置文字背景颜色设置文字格式设置文本框样式程序设置界面设置 QTextEdit信号textChanged信号 完整程序界面程序主程序 QTextEdit类提供了一个用于编辑和显示纯文本和富文本的组…...

Hadoop核心机制详细解析

Hadoop核心机制详细解析 Hadoop的核心机制是通过HDFS文件系统和MapReduce算法进行存储资源、内存和程序的有效利用与管理。在现实的实例中&#xff0c;通过Hadoop&#xff0c;可以轻易的将多台普通的或低性能的服务器组合成分布式的运算-存储集群&#xff0c;提供大数据量的存…...

Chromium源码由浅入深(一)

工作中需要对Chromium源码、尤其是源码中图形部分进行深入研究&#xff0c;所以借此机会边学习边写文章&#xff0c;分享一下我的实时学习研究Chromium源码的由浅入深的过程。 闲言少叙&#xff0c;书归正传。 通过命令行启动Chrome浏览器&#xff0c;命令及结果如下&#xf…...

【Python】 -- 趣味代码 - 小恐龙游戏

文章目录 文章目录 00 小恐龙游戏程序设计框架代码结构和功能游戏流程总结01 小恐龙游戏程序设计02 百度网盘地址00 小恐龙游戏程序设计框架 这段代码是一个基于 Pygame 的简易跑酷游戏的完整实现,玩家控制一个角色(龙)躲避障碍物(仙人掌和乌鸦)。以下是代码的详细介绍:…...

1.3 VSCode安装与环境配置

进入网址Visual Studio Code - Code Editing. Redefined下载.deb文件&#xff0c;然后打开终端&#xff0c;进入下载文件夹&#xff0c;键入命令 sudo dpkg -i code_1.100.3-1748872405_amd64.deb 在终端键入命令code即启动vscode 需要安装插件列表 1.Chinese简化 2.ros …...

Qwen3-Embedding-0.6B深度解析:多语言语义检索的轻量级利器

第一章 引言&#xff1a;语义表示的新时代挑战与Qwen3的破局之路 1.1 文本嵌入的核心价值与技术演进 在人工智能领域&#xff0c;文本嵌入技术如同连接自然语言与机器理解的“神经突触”——它将人类语言转化为计算机可计算的语义向量&#xff0c;支撑着搜索引擎、推荐系统、…...

【服务器压力测试】本地PC电脑作为服务器运行时出现卡顿和资源紧张(Windows/Linux)

要让本地PC电脑作为服务器运行时出现卡顿和资源紧张的情况&#xff0c;可以通过以下几种方式模拟或触发&#xff1a; 1. 增加CPU负载 运行大量计算密集型任务&#xff0c;例如&#xff1a; 使用多线程循环执行复杂计算&#xff08;如数学运算、加密解密等&#xff09;。运行图…...

Matlab | matlab常用命令总结

常用命令 一、 基础操作与环境二、 矩阵与数组操作(核心)三、 绘图与可视化四、 编程与控制流五、 符号计算 (Symbolic Math Toolbox)六、 文件与数据 I/O七、 常用函数类别重要提示这是一份 MATLAB 常用命令和功能的总结,涵盖了基础操作、矩阵运算、绘图、编程和文件处理等…...

OPenCV CUDA模块图像处理-----对图像执行 均值漂移滤波(Mean Shift Filtering)函数meanShiftFiltering()

操作系统&#xff1a;ubuntu22.04 OpenCV版本&#xff1a;OpenCV4.9 IDE:Visual Studio Code 编程语言&#xff1a;C11 算法描述 在 GPU 上对图像执行 均值漂移滤波&#xff08;Mean Shift Filtering&#xff09;&#xff0c;用于图像分割或平滑处理。 该函数将输入图像中的…...

GC1808高性能24位立体声音频ADC芯片解析

1. 芯片概述 GC1808是一款24位立体声音频模数转换器&#xff08;ADC&#xff09;&#xff0c;支持8kHz~96kHz采样率&#xff0c;集成Δ-Σ调制器、数字抗混叠滤波器和高通滤波器&#xff0c;适用于高保真音频采集场景。 2. 核心特性 高精度&#xff1a;24位分辨率&#xff0c…...

Linux 中如何提取压缩文件 ?

Linux 是一种流行的开源操作系统&#xff0c;它提供了许多工具来管理、压缩和解压缩文件。压缩文件有助于节省存储空间&#xff0c;使数据传输更快。本指南将向您展示如何在 Linux 中提取不同类型的压缩文件。 1. Unpacking ZIP Files ZIP 文件是非常常见的&#xff0c;要在 …...

【JavaSE】多线程基础学习笔记

多线程基础 -线程相关概念 程序&#xff08;Program&#xff09; 是为完成特定任务、用某种语言编写的一组指令的集合简单的说:就是我们写的代码 进程 进程是指运行中的程序&#xff0c;比如我们使用QQ&#xff0c;就启动了一个进程&#xff0c;操作系统就会为该进程分配内存…...

PHP 8.5 即将发布:管道操作符、强力调试

前不久&#xff0c;PHP宣布了即将在 2025 年 11 月 20 日 正式发布的 PHP 8.5&#xff01;作为 PHP 语言的又一次重要迭代&#xff0c;PHP 8.5 承诺带来一系列旨在提升代码可读性、健壮性以及开发者效率的改进。而更令人兴奋的是&#xff0c;借助强大的本地开发环境 ServBay&am…...