Ubuntu 安装 etcd 与 etcd-cpp-apiv3

目录

[安装 etcd](#安装 etcd)

[安装 etcd-cpp-apiv3](#安装 etcd-cpp-apiv3)


安装 etcd

bash 复制代码
sudo apt update
sudo apt install etcd-server
sudo apt install -y etcd-client

在 /etc/default/etcd 配置文件中配置,下面示例是单个服务器内进程之间交换信息且只有一个etcd节点。

bash 复制代码
#节点名称,默认为 "default"
ETCD_NAME="etcd1"
#数据目录,默认为 "${name}.etcd"
ETCD_DATA_DIR="/var/lib/etcd/default.etcd"
#用于客户端连接的 URL。
ETCD_LISTEN_CLIENT_URLS="http://127.0.0.1:2379"
#用于客户端访问的公开,也就是提供服务的 URL
ETCD_ADVERTISE_CLIENT_URLS="http://127.0.0.1:2379"
#用于集群节点间通信的 URL
#心跳间隔时间-毫秒
ETCD_HEARTBEAT_INTERVAL=100
#选举超时时间-毫秒
ETCD_ELECTION_TIMEOUT=1000

启动 etcd 服务进程

bash 复制代码
sudo systemctl start etcd
sudo systemctl enable etcd //设置开机自启

尝试向 etcd 服务进程存储键值对

bash 复制代码
etcdctl put mykey "this is awesome"

如果报错,则 sudo vi /etc/profile 在末尾声明环境变量 ETCDCTL_API=3 以确定 etcd 版本。

bash 复制代码
export ETCDCTL_API=3
bash 复制代码
source /etc/profile
etcdctl put mykey "this is awesome"

安装 etcd-cpp-apiv3

bash 复制代码
sudo apt-get install libboost-all-dev libssl-dev
sudo apt-get install libprotobuf-dev protobuf-compiler-grpc
sudo apt-get install libgrpc-dev libgrpc++-dev 
sudo apt-get install libcpprest-dev
bash 复制代码
git clone https://github.com/etcd-cpp-apiv3/etcd-cpp-apiv3.git
cd etcd-cpp-apiv3
mkdir build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=/usr
make -j$(nproc) && sudo make install
相关推荐
wyiyiyi4 小时前
【Web后端】Django、flask及其场景——以构建系统原型为例
前端·数据库·后端·python·django·flask
天宇_任4 小时前
Mysql数据库迁移到GaussDB注意事项
数据库·mysql·gaussdb
xiep14383335107 小时前
Ubuntu 安装带证书的 etcd 集群
数据库·etcd
40kuai7 小时前
kubernetes中数据存储etcd
容器·kubernetes·etcd
Java小白程序员8 小时前
Spring Framework:Java 开发的基石与 Spring 生态的起点
java·数据库·spring
老虎06278 小时前
数据库基础—SQL语句总结及在开发时
数据库·sql·oracle
爱掘金的土拨鼠10 小时前
国产化dm数据库锁表解锁
数据库
庖丁解java10 小时前
N个Utils
数据库
Mr. zhihao11 小时前
SQL LEFT JOIN 与 WHERE 条件的隐藏坑
数据库·sql
2301_7930868711 小时前
Redis 04 Reactor
数据库·redis·缓存