1

I know use etcdctl get /key to get the /key

I make the key from golang below .

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 revision:29 raft_term:2

time.Sleep(10 * time.Minute)

Its success to make the key from clientv3. But I try to get it frometcdctl` there is nothing .

➜  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) ✗

Where did I wrong ?

Hot to fix it .

Mrj
  • 59
  • 2
  • 8

0 Answers0