当前位置: 首页 > news >正文

阿坝州网站制作seo刷关键词排名优化

阿坝州网站制作,seo刷关键词排名优化,蕲春做网站,logo设计大师这里将使用etcdctl命令行工具来进行演示&#xff0c; 1、使用put命令向etcd写入kv对 使用etcdctl put命令来设置键值对。put命令接受两个参数&#xff1a;键和值 使用方法&#xff1a; NAME:put - Puts the given key into the storeUSAGE:etcdctl put [options] <key&g…

这里将使用etcdctl命令行工具来进行演示,

1、使用put命令向etcd写入kv对

使用etcdctl put命令来设置键值对。put命令接受两个参数:键和值

使用方法:

NAME:put - Puts the given key into the storeUSAGE:etcdctl put [options] <key> <value> (<value> can also be given from stdin) [flags]DESCRIPTION:Puts the given key into the store.When <value> begins with '-', <value> is interpreted as a flag.Insert '--' for workaround:$ put <key> -- <value>$ put -- <key> <value>If <value> isn't given as a command line argument and '--ignore-value' is not specified,this command tries to read the value from standard input.If <lease> isn't given as a command line argument and '--ignore-lease' is not specified,this command tries to read the value from standard input.For example,$ cat file | put <key>will store the content of the file to <key>.OPTIONS:-h, --help[=false]            help for put--ignore-lease[=false]    updates the key using its current lease--ignore-value[=false]    updates the key using its current value--lease="0"               lease ID (in hexadecimal) to attach to the key--prev-kv[=false]         return the previous key-value pair before modification

示例:

# 写入一个键为foo 值为 hello world数据
[root@localhost etcd]# ./etcdctl put foo "hello world"
OK
# 使用put命令需要注意的事项为,当需要插入以“-”开通的值时,将被解释为一个标志,需要先插入--标志来解决该问题
[root@localhost etcd]# ./etcdctl put key3 -- -pzh
OK
[root@localhost etcd]# ./etcdctl get key3
key3
-pzh
2、使用get命令从etcd中读取kv对

使用get 命令来获取键对应的值,put命令接受一个参数:键

使用方法:

[root@localhost etcd]# ./etcdctl get --help
NAME:get - Gets the key or a range of keysUSAGE:etcdctl get [options] <key> [range_end] [flags]OPTIONS:--consistency="l"                 Linearizable(l) or Serializable(s)--count-only[=false]              Get only the count--from-key[=false]                Get keys that are greater than or equal to the given key using byte compare-h, --help[=false]                    help for get--keys-only[=false]               Get only the keys--limit=0                         Maximum number of results--order=""                        Order of results; ASCEND or DESCEND (ASCEND by default)--prefix[=false]                  Get keys with matching prefix--print-value-only[=false]        Only write values when using the "simple" output format--rev=0                           Specify the kv revision--sort-by=""                      Sort target; CREATE, KEY, MODIFY, VALUE, or VERSION

示例:

# 获取key为foo的值
[root@localhost etcd]# ./etcdctl get foo
foo
hello world
# 获取前缀为key的所有键 
[root@localhost etcd]# ./etcdctl get key --prefix
key1
v9
key2
v1
3、使用del命令从etcd中删除KV对
# 删除键foo
[root@localhost etcd]# ./etcdctl del foo
# 先新增以前缀为key开头的五个键,key1~key5
[root@localhost etcd]# ./etcdctl put key1 v1
OK
[root@localhost etcd]# ./etcdctl put key2 v2
OK
[root@localhost etcd]# ./etcdctl put key3 v3
OK
[root@localhost etcd]# ./etcdctl put key4 v4
OK
[root@localhost etcd]# ./etcdctl put key5 v5
OK
# 按前缀匹配的方式删除所有的key
[root@localhost etcd]# ./etcdctl del --prefix key
5
4、查看ctcd的数据版本
# 查看
[root@localhost etcd]# ./etcdctl get foo -w fields
# 发送响应的集群id
"ClusterID" : 14841639068965178418  
# 响应请求的节点ID
"MemberID" : 10276657743932975437
# 创建key时集群中当前全局数据版本号
"Revision" : 53
# 请求时当前raft主节点的任期号
"RaftTerm" : 10
# 查看的键
"Key" : "foo"
# 当前key创建时候的全局版本号值
"CreateRevision" : 32
# 当前key修改时候的全局版本号值
"ModRevision" : 32
# key的数据版本号
"Version" : 1
# key当前对应的值
"Value" : "v1"
# 使用的租约对应的id,如果没有使用则该值为0
"Lease" : 0
"More" : false
"Count" : 1
5、监控key
  • 使用方法:
# watch的用法参考如下
[root@localhost etcd]# ./etcdctl watch --help
NAME:watch - Watches events stream on keys or prefixesUSAGE:etcdctl watch [options] [key or prefix] [range_end] [--] [exec-command arg1 arg2 ...] [flags]OPTIONS:-h, --help[=false]            help for watch-i, --interactive[=false]     Interactive mode--prefix[=false]          Watch on a prefix if prefix is set--prev-kv[=false]         get the previous key-value pair before the event happens--rev=0                   Revision to start watching
  • 监控单个key
# 在第一个客户端输入如下指令:
[root@localhost etcd]# ./etcdctl watch  foo
PUT
foo
v2
PUT
foo
v3
PUT
foo
v3
# 在第二客户端输入监控命令
[root@localhost etcd]# ./etcdctl watch foo
PUT
foo
v2
PUT
foo
v3
PUT
foo
v3# 其他端口对foo这个键进行操作
[root@localhost etcd]# ./etcdctl put foo v2
OK
[root@localhost etcd]# ./etcdctl put foo v3
OK
[root@localhost etcd]# ./etcdctl put foo v3
OK
  • 监控多个key
# 监控以foo开头的所有键,只要是foo
[root@localhost etcd]# ./etcdctl watch foo --prefix
PUT
foo1
muiltvalue
PUT
foo2
muiltwatch
PUT
foo3
v3
DELETE
foo3
# 另外一个客户端进行put、del操作
[root@localhost etcd]# ./etcdctl put foo1 muiltvalue
OK
[root@localhost etcd]# ./etcdctl put foo2 muiltwatch
OK
[root@localhost etcd]# ./etcdctl put foo3 v3
OK
[root@localhost etcd]# ./etcdctl del foo4
0
[root@localhost etcd]# ./etcdctl del foo3
1

如果删除一个不存在的key时不会唤醒watch的客户端。

6、使用etcd来实现锁

go的代码示例:

package mainimport ("context""fmt"clientv3 "go.etcd.io/etcd/client/v3""go.etcd.io/etcd/client/v3/concurrency""log""time"
)func main() {// 初始化etcd客户端cli, err := clientv3.New(clientv3.Config{Endpoints:   []string{"192.168.188.101:2379"}, // 替换为你的etcd集群地址DialTimeout: 5 * time.Second,})if err != nil {log.Fatal(err)}defer cli.Close()// 创建一个上下文ctx, cancel := context.WithTimeout(context.Background(), 1000*time.Second)defer cancel()// 创建一个新的sessionsession, err := concurrency.NewSession(cli)if err != nil {log.Fatal(err)}defer session.Close()// 使用session创建锁mutualTxn := concurrency.NewMutex(session, "mutex")// 尝试获取锁err = mutualTxn.Lock(ctx)if err != nil {log.Fatal(err)}fmt.Println("Lock acquired")// 模拟一些工作time.Sleep(2 * time.Second)// 释放锁err = mutualTxn.Unlock(ctx)if err != nil {log.Fatal(err)}fmt.Println("Lock released")}
http://www.tj-hxxt.cn/news/13363.html

相关文章:

  • 校园网站建设方案12月10日新闻
  • 衡阳建设学校网站国内最新消息
  • 网站建设轮播大图百度推广登陆
  • 网站打不开被拦截怎么办关键词诊断优化全部关键词
  • 做一个公司网站流程 由ui设计爱站网挖掘工具
  • 宁波seo网络推广推荐公众号专业关键词优化平台
  • 网上那么多色图网站怎么做的win7一键优化工具
  • 公司免费网站域名友情链接交换
  • wordpress whatnew佛山百度seo代理
  • 长沙网站开发智能最新域名查询ip
  • 做视觉影像网站用什么软件系统合肥网络seo
  • 娄底哪里学习网站建设和seo网络推广竞价外包
  • 制作企业网站多少钱查询关键词
  • 电商网站模板今天最火的新闻头条
  • 学校安全教育网站建设网络推广员是干嘛的
  • 电脑建网站网站seo哪家好
  • 前端网站做多语言游戏推广员每天做什么
  • 国外好的做电视包装的网站网站营销策略
  • 化妆品网站建设可行性报告抖音seo点击软件排名
  • 免费申请注册网站公司推广策划方案
  • 日本人做的摇滚网站网络运营商
  • 网站建设期末试卷seo企业顾问
  • 企业网站报价模板沈阳网站关键字优化
  • 虚拟商城网站网站查询ip地址查询
  • 网站建设公司中心seo是哪个英文的简写
  • 网站仿站是啥公司网站推广
  • 企业管理咨询服务合同模板搜索引擎优化免费
  • 专业做婚纱摄影网站店铺运营
  • 个人做网站赚钱么网络营销首先要
  • 成都住房与城乡建设委员会网站简述网络营销的含义