欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

etcd安装使用(转)

程序员文章站 2022-07-13 22:20:34
...

etcd下载链接:

https://github.com/etcd-io/etcd/releases


安装

下载etcdv3包

1
2复制代码
cd /usr/local/src/ 
wget https://github.com/coreos/etcd/releases/download/v3.2.15/etcd-v3.2.15-linux-amd64.tar.gz复制代码

注:etcd版本号不一样。

解压

1
2复制代码
tar -zxvf etcd-v3.2.15-linux-amd64.tar.gzmv 
etcd-v3.2.15-linux-amd64 etcd复制代码

添加v3环境变量

将代码路径加入环境变量中,并使用etcdv3的api接口

1
2
3复制代码
vim /etc/profileexport 
PATH=/usr/local/src/etcd:$PATHexport 
ETCDCTL_API=3复制代码

生效 source /etc/profile

简易启动local standlone cluster

参考:coreos.com/etcd/docs/l…

切换到:/usr/local/src/etc 目录直接启动etcd服务进程

1
2
3
4
5
6
7
8
9复制代码
[email protected]:/usr/local/src/etcd# ./etcd&[1] 
19228
[email protected]:/usr/local/src/etcd# 2018-03-07 13:40:16.719105 I | etcdmain: etcd Version: 3.2.15
2018-03-07 13:40:16.719217 I | etcdmain: Git SHA: 1b3ac99e8
2018-03-07 13:40:16.719235 I | etcdmain: Go Version: go1.8.5
2018-03-07 13:40:16.719244 I | etcdmain: Go OS/Arch: linux/amd64
2018-03-07 13:40:16.719254 I | etcdmain: setting maximum number of CPUs to 4, total number of available CPUs is 4
2018-03-07 13:40:16.719274 W | etcdmain: no data-dir provided, using default data-dir ./default.etcd
2018-03-07 13:40:16.719422 N | etcdmain: the server is already initialized as复制代码

判别是否启动成功

查看 2379 和 2380 两个端口服务都已经启动成功

etcdctl操作etcd存储

额外说明:etcdctl get “” –from-key 是查看所有数据

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复制代码
[email protected]:~# etcdctl  del f
1
[email protected]:~# etcdctl get "" --from-key
fo
xxx
foo
bar
[email protected]:~# etcdctl  put q qq
OK
[email protected]:~# etcdctl get "" --from-key
fo
xxx
foo
bar
q
qq
[email protected]:~# etcdctl  put q qqq
OK
[email protected]:~# etcdctl get "" --from-key
fo
xxx
foo
bar
q
qqq复制代码


转载于:https://juejin.im/post/5c7f2853e51d452bfa4d6ee1