摘要:
使用go初步調用etcd package main import ( "context" "go.etcd.io/etcd/clientv3" "time" ) func main() { config := clientv3.Config{ Endpoints: []string{"106.12.72.181:23791", "106.1... 阅读全文
摘要:
package main import ( "context" "flag" "fmt" "github.com/gorilla/mux" uuid "github.com/satori/go.uuid" "goetcd/util" "log" "net/http" "os" "os/signal" "str... 阅读全文
摘要:
下载etcd代码然后拷贝到服务器 来自为知笔记(Wiz) 阅读全文
摘要:
docker run -d --name etcd1 --network etcdnet --ip 172.25.0.101 -p 23791:2379 -e ETCDCTL_API=3 -v /root/etcd:/etcd etcd:my etcd --config-file /etcd/conf/etcd.yml curl http://localhost:2... 阅读全文
摘要:
优雅的启动服务和退出 package main import ( "fmt" "github.com/gorilla/mux" "goetcd/util" "log" "net/http" "os" "os/signal" "strconv" "syscall" ) func main() { router :=... 阅读全文
摘要:
如上存放一些服务的key到etcd中,商品有两个,主要是为了负载均衡的key func NewService() *Service { config := clientv3.Config{ Endpoints: []string{"106.12.72.181:23791", "106.12.72.181:23792"}, DialTimeout... 阅读全文
摘要:
/go # etcdctl lease grant 200 //设置一个200秒过期的租约 lease 08e86eea8129eb12 granted with TTL(200s) /go # etcdctl lease timetolive 08e86eea8129eb12 //查看该租约的剩余到期时间 lease 08e86eea8129eb12 granted with TTL(2... 阅读全文
摘要:
因为是在windows上编译的代码,在linux上不可执行,所以需要交叉编译 package main import ( "flag" "gopkg.in/ini.v1" "log" "net/http" "strconv" ) func main() { port := flag.Int("p", 8080, "服务端口") fl... 阅读全文
摘要:
![image-20191209191301618](C:\Users\AneroKissinger\AppData\Roaming\Typora\typora-user-images\image-20191209191301618.png root@instance-emh5jlpa:~# etcdctl put /user/101/name xiahualou OK root@insta... 阅读全文
摘要:
package main import ( "github.com/gin-gonic/gin" "net/http" ) type Topic struct { TopicID int } func main() { m := make(map[string]interface{}) m["username"] = "jerry" rout... 阅读全文