как показать etcd ключи и значения из etcdctl? - PullRequest
0 голосов
/ 11 октября 2018

Я знаю, используйте etcdctl get /key, чтобы получить /key

Я делаю ключ от Голанга ниже.

cli, err := clientv3.New(clientv3.Config{
    Endpoints:   []string{"localhost:2379"},
    DialTimeout: 5 * time.Second,
})
if err != nil {
    panic(err)
}
defer cli.Close()

ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
resp, err := cli.Put(ctx, "sample_key", "sample_value")
defer cancel()
if err != nil {
    fmt.Println(ctx)
}
fmt.Println(resp.Header)

// cluster_id: 14841639068965178418 member_id: 10276657743932975437 ревизия: 29 raft_term: 2

time.Sleep(10 * time.Minute)

Это s success to make the key from clientv3. But I try to get it from etcdctl` ничего нет.

➜  etcd-v3.3.9-darwin-amd64 git:(master) ✗ ./etcdctl ls /
➜  etcd-v3.3.9-darwin-amd64 git:(master) ✗ ./etcdctl ls /
➜  etcd-v3.3.9-darwin-amd64 git:(master) ✗ ./etcdctl get /sample_key
Error:  100: Key not found (/sample_key) [5]
➜  etcd-v3.3.9-darwin-amd64 git:(master) ✗ ./etcdctl get sample_key
Error:  100: Key not found (/sample_key) [5]
➜  etcd-v3.3.9-darwin-amd64 git:(master) ✗

Где я ошибся?

Горячий, чтобы исправить это.

...