页面“Redis批量删除key”与“Golang”之间的差异

来自linux中国网wiki
(页面间的差异)
跳到导航 跳到搜索
 
 
第1行: 第1行:
[[category:ops]] [[category:redis]] 
 
  
[[Redis-bigkeys]]
+
=learn=
  
ulink
+
[https://zhuanlan.zhihu.com/p/82324723 谈谈 Golang, 以及我走的一些弯路]
[https://cloud.tencent.com/developer/article/1530197 Redis 高效删除大key]
 
=redis cluster 批量删除key=
 
  
== 正则匹配删除 之hello项目的版本==
+
[https://www.zhihu.com/question/23486344 怎么学习 Golang]
  
 +
https://studygolang.com/
 +
 +
=install=
 
<pre>
 
<pre>
  
redisloop-re.sh
+
从go 1.8开始,GOPATH环境变量现在有一个默认值,如果它没有被设置。 它在Unix上默认为$HOME/go,
#!/bin/bash
 
#Usage  模糊删除 key  key name 写在  rr 文件里 如  hello_user_*  #这个用法是  bash redisloop-re.sh
 
#for line  in  `cat $1`  #这个用法是  bash redisloop-re.sh  rr
 
for line  in  `cat rr`
 
#cat  $1
 
#cat  $1  | while read line
 
do
 
#echo $line
 
  
redis-cli  -c  -h 172.31.22.218 -p 7000  -a hellopass keys $line |xargs  -r -t -n1 redis-cli  -c  -h  172.31.22.218  -p 7000  -a hellopas  del
+
wget -c https://dl.google.com/go/go1.14.4.linux-amd64.tar.gz
redis-cli  -c  -h 172.31.22.218 -p 7001  -a hellopass keys $line | xargs  -r -t -n1 redis-cli  -c  -h 172.31.22.218  -p 7001  -a hellopass  del 
 
redis-cli  -c  -h 172.31.16.135 -p 7002  -a hellopas keys $line | xargs  -r -t -n1  redis-cli  -c  -h  172.31.16.135  -p 7002  -a hellopass del
 
redis-cli  -c  -h 172.31.16.135 -p 7003 -a hellopass keys  $line | xargs -r -t -n1  redis-cli -c  -h  172.31.16.135  -p 7003  -a hellopassw del
 
redis-cli  -c  -h 172.31.23.43 -p 7004 -a hellopassw  keys  $line | xargs  -r -t -n1 redis-cli  -c -h  172.31.23.43  -p 7004  -a hellopass  del
 
redis-cli  -c  -h 172.31.23.43 -p 7005  -a hellopassw keys  $line | xargs  -r -t -n1 redis-cli  -c  -h  172.31.23.43  -p 7005  -a hellopas  del
 
done
 
  
 +
tar -C /usr/local -xzf go$VERSION.$OS-$ARCH.tar.gz
  
 +
tar  -xvf go1.14.4.linux-amd64.tar.gz  -C /usr/local/
  
 +
#加入 添加到环境变量
 +
echo 'export PATH=$PATH:/usr/local/go/bin' >>/etc/profile  && source /etc/profile
  
done
+
vi /etc/profile
 +
export PATH=/usr/local/go/bin/:$PATH
 +
#export GOPATH=/root/go/  #(可选设置) 如果你用root运行
 +
export GOROOT=/usr/local/go/
 +
#export GOARCH=amd64
 +
#export GOOS=linux
 +
export GOTOOLS=$GOROOT/pkg/tool
 +
#export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
  
</pre>
+
#export PATH=$PATH:/usr/local/gobin
 +
 
 +
source /etc/profile
  
  
==在集群中删除多个指定的key ==
+
#export PATH=/usr/local/go/bin/:$PATH
 +
#export GOPATH=/root
  
<pre>
 
删除单个的 如下
 
cat redisloop.sh
 
#!/bin/bash
 
#模糊删除 key  在re.sh 那个脚本里面
 
# Usage  bash  redisloop.sh  你的文件  # 文件内容样子  del token_resp11916485
 
cat  $1  | while read line
 
do
 
  
redis-cli    -c -h    172.31.22.218  -p 7000 -a hellopass $line
+
#以前的文章
redis-cli    -c -h    172.31.22.218  -p 7001  -a hellopass  $line
+
#freebsd
redis-cli    -c  -h  172.31.16.135   -p 7002  -a hellopassw  $line 
+
  https://dl.google.com/go/go1.12.5.freebsd-amd64.tar.gz
redis-cli    -c  -h  172.31.16.135  -p 7003  -a hellopassw  $line
+
#linux
redis-cli    -c  -h  172.31.23.43  -p 7004  -a hellopassw  $line
+
  curl -o go1.13.6.linux-amd64.tar.gz   https://dl.google.com/go/go1.13.6.linux-amd64.tar.gz
redis-cli    -c  -h  172.31.23.43  -p 7005  -a hellopassw  $line
 
</pre>
 
  
  
 +
tar -C /usr/local -xzf go1.12.5.freebsd-amd64.tar.gz
  
<pre>
 
#pre
 
  
删除单个:del key
 
  
删除多个:redis-cli -a pass(密码) keys "WX_ACT_USER_KEY_*" | xargs redis-cli -a pass(密码) del
+
export PATH=$PATH:/usr/local/go/bin
  
 +
source /etc/profile  #如果修改的是/etc/profile
 +
source $HOME/.profile  #如果修改的是$HOME/.profile
  
 +
go version
  
#June 19 2020  有空结果一下原来的版本再优化一下
 
cat redis_del_key.sh
 
#!/bin/bash
 
# Usage
 
#redis_list=("host:post" "host:post")
 
  
redis_list=( "172.16.200.12:7003" "172.16.200.7:7004" "172.16.200.7:7005" "172.16.200.13:7000" "172.16.200.13:7001" "172.16.200.12:7002")
 
#redis_list=( "172.16.200.13:7000" "172.16.200.13:7001" "172.16.200.12:7002")
 
#redis_list=("172.16.200.7:7004")
 
password="3636password"
 
  
for info in ${redis_list[@]}
+
</pre>
    do
 
        echo "开始执行:$info" 
 
        ip=`echo $info | cut -d : -f 1`
 
        port=`echo $info | cut -d : -f 2`
 
  
      for  loop in  `cat key.txt`
 
        do
 
        #echo $loop  |xargs -t -n1 redis-cli -c  -h $ip -p $port -a $password -c del
 
        echo $loop  |xargs -t -n1 redis-cli -c  -h $ip -p $port -a $password -c keys
 
        done
 
  
    done
+
=ubuntu=
    echo "success done完成"
+
<pre>
 +
sudo add-apt-repository ppa:longsleep/golang-backports
 +
sudo apt update
 +
sudo apt install golang-go
  
# cat key.txt
+
</pre>
infnce:wonderfulCache
+
https://github.com/golang/go/wiki/Ubuntu
ext_info
+
=IDE=
  
 +
==goland==
 +
进入goland的bin目录下执行./goland.sh
  
 +
Goland常用快捷键
 +
文件相关快捷键:
 +
 +
CTRL+E,打开最近浏览过的文件。
 +
CTRL+SHIFT+E,打开最近更改的文件。
 +
CTRL+N,可以快速打开struct结构体。
 +
CTRL+SHIFT+N,可以快速打开文件。
 +
代码格式化:
 +
 +
CTRL+ALT+T,可以把代码包在一个块内,例如if{…}else{…}。
 +
CTRL+ALT+L,格式化代码。
 +
CTRL+空格,代码提示。
 +
CTRL+/,单行注释。CTRL+SHIFT+/,进行多行注释。
 +
CTRL+B,快速打开光标处的结构体或方法(跳转到定义处)。
 +
CTRL+“+/-”,可以将当前方法进行展开或折叠。
 +
查找和定位
 +
CTRL+R,替换文本。
 +
CTRL+F,查找文本。
 +
CTRL+SHIFT+F,进行全局查找。
 +
CTRL+G,快速定位到某行。
 +
代码编辑
 +
 +
ALT+Q,可以看到当前方法的声明。
 +
CTRL+Backspace,按单词进行删除。
 +
SHIFT+ENTER,可以向下插入新行,即使光标在当前行的中间。
 +
CTRL+X,删除当前光标所在行。
 +
CTRL+D,复制当前光标所在行。
 +
ALT+SHIFT+UP/DOWN,可以将光标所在行的代码上下移动。
 +
CTRL+SHIFT+U,可以将选中内容进行大小写转化。
  
#原来的版本
+
===linux下Goland如何设置桌面快捷方式 ===
 +
<pre>
 +
ln -s  /opt/goland/bin/goland.sh /usr/bin/goland #我是这种在 awesome有效
  
del hello_user_*
 
  
redis-cli keys
+
goland打开后点击任务栏:
  
 +
tools---->create desktop entry.
  
redis-cli keys "hello_user_*" | xargs redis-cli del
 
  
 +
#我的这个应该是没效果的
 +
cat /usr/share/applications/goland.desktop
 +
Version=1.0
 +
Type=Application
 +
Name=GoLand
 +
Icon=/opt/goland/bin/goland.png
 +
Exec="/opt/goland/bin/goland.sh" %f
 +
Comment=The Drive to Develop
 +
Categories=Development;IDE;
 +
Terminal=false
 +
StartupWMClass=jetbrains-goland
 +
</pre>
  
./redis-cli -h IP -p PORT -a PASSWORD keys 'key*' | xargs  ./redis-cli -h IP  -p PORT -a PASSWORD del
+
[https://zhuanlan.zhihu.com/p/63248860 GO教程:安装Goland开发工具]
  
redis-cli    -c  -h    172.31.22.218  -p 7000  -a pass keys 'hello_user_*'| xargs -i redis-cli    -c  -h    172.31.22.218  -p 7000  -a pass  del {}
+
[https://www.cnblogs.com/zhangguosheng1121/p/11448194.html go安装与goland破解永久版]
redis-cli    -c  -h    172.31.22.218  -p 7001  -a pass keys 'hello_user_*'| xargs -i redis-cli    -c  -h    172.31.22.218  -p 7001  -a pass del {}
 
  
redis-cli    -c  -h    172.31.16.135  -p 7002  -a pass keys 'hello_user_*'| xargs -i  redis-cli    -c  -h    172.31.16.135  -p 7002 -a pass  del {}
+
==emacs==
redis-cli    -c  -h    172.31.16.135  -p 7003  -a pass keys 'hello_user_*'| xargs  -i redis-cli    -c  -h    172.31.16.135  -p 7003 -a pass  del {}
 
  
redis-cli    -c  -h    172.31.23.43  -p 7004  -a pass keys 'hello_user_*'| xargs -i  redis-cli    -c  -h    172.31.23.43  -p 7004 -a pass  del {}
 
redis-cli    -c  -h    172.31.23.43  -p 7005  -a pass keys 'hello_user_*'| xargs -i  redis-cli    -c  -h    172.31.23.43  -p 7005 -a pass  del {}
 
  
 +
[https://blog.csdn.net/weishixianglian/article/details/104582423  golang快速入门[6.2<nowiki>]</nowiki>-集成开发环境-emacs详解]
 +
https://github.com/golang/go/wiki/IDEsAndTextEditorPlugins
  
 +
https://emacs-china.org/t/topic/6469
  
#!/bin/bash
+
https://stackoverflow.com/questions/1715464/emacs-mode-for-go#1715502
redis_comm=/usr/local/redis-5.0.3/bin/redis-cli
 
redis_ser01=192.168.50.175
 
redis_ser02=192.168.50.174
 
$redis_comm -c -h $redis_ser01  -p 7001 -a xxx  keys $1 | xargs -i $redis_comm -c -h $redis_ser01  -p 7001 -a xxx del {}
 
$redis_comm -c -h $redis_ser02  -p 7001 -a xxx  keys $1 | xargs -i $redis_comm -c -h $redis_ser02  -p 7001 -a xxx del {}
 
  
运行:
+
https://www.emacswiki.org/emacs/GoLangMode
  
./redis_del_key.sh 匹配的key*
+
[https://www.cnblogs.com/wang_yb/p/4923168.html Emacs中多个golang项目的配置方法 ]
  
err  
+
[https://studygolang.com/articles/6126 Emacs golang 配置 ]
  
-i  {} 都是一定要的
+
https://www.cnblogs.com/lienhua34/p/5838166.html
  
redis-cli -n 0 keys "test*" | xargs redis-cli -n 0 del
+
https://github.com/lienhua34/myemacs-conf
(error) CROSSSLOT Keys in request don't hash to the same slot
 
  
</pre>
+
https://github.com/syl20bnr/spacemacs/tree/master/layers/%2Blang/go
  
=del相关=
+
https://blog.yuantops.com/tech/emacs-config-go-dev-environ/
  
命令和DEL十分相似:删除指定的key(s),若key不存在则该key被跳过。但是,相比DEL会产生阻塞,该命令会在另一个线程中回收内存,因此它是非阻塞的。 这也是该命令名字的由来:仅将keys从keyspace元数据中删除,真正的删除会在后续异步操作。
+
https://dreamerjonson.com/2019/11/24/emacs-package-for-golang/index.html
http://www.redis.cn/commands/unlink.html
 
  
 +
https://github.com/dominikh/go-mode.el
  
[https://www.zybuluo.com/phper/note/609318 redis 中pipline,mset, mget使用对比]
+
https://github.com/alecthomas/gometalinter
  
[https://blog.csdn.net/wojiuguowei/article/details/85096609  redis del与unlink命令用法及实现]
+
https://www.cnblogs.com/cobbliu/p/4860600.html
  
[https://yq.aliyun.com/articles/743207 Redis:del/unlink 命令源码解析]
+
[https://www.cnblogs.com/ibgo/p/5207025.html Emacs golang 配置 ]
  
[https://www.cnblogs.com/0201zcr/p/9647787.html  redis批量删除key 远程批量删除key ]
 
  
 +
https://zhuanlan.zhihu.com/p/19902040
  
[https://www.cnblogs.com/kiko2014551511/p/11531584.html Redis批量删除key的命令]
+
https://github.com/lryong/emacs-golang-conf
  
[https://www.php.cn/redis/447726.html redis中批量删除key的方法]
+
https://chenyangguang.github.io/2018-11-27-ide/
  
 
=see also=
 
=see also=
[https://blog.csdn.net/xujiamin0022016/article/details/103020025?utm_medium=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.nonecase&depth_1-utm_source=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.nonecase  如何优雅地删除Redis大键]
+
https://golang.google.cn/doc/install#install
 
 
[https://blog.csdn.net/yangyangye/article/details/100523387  redis集群批量删除模糊key shell脚本]
 
 
 
[https://blog.csdn.net/yangyangye/article/details/100523387  redis集群批量删除模糊key shell脚本]
 
 
 
[https://www.cnblogs.com/feng0520/p/11067025.html  redis cluster集群批量删除中的key]
 
 
 
[https://my.oschina.net/u/1255588/blog/1563672 Redis集群批量删除key]
 
 
 
[https://www.cnblogs.com/0201zcr/p/9647787.html  redis批量删除key 远程批量删除key ]
 
 
 
[https://blog.csdn.net/zj20142213/article/details/80879744  redis集群批量删除指定的key]
 
 
 
https://blog.csdn.net/qq_36090419/article/details/80537684
 
 
 
[https://www.cnblogs.com/DreamDrive/p/5772198.html  Redis中的批量删除数据库中的Key]
 
  
[https://www.cnblogs.com/DreamDrive/p/5772198.html Redis中的批量删除数据库中的Key]
+
[[category:go]]

2020年9月14日 (一) 05:50的版本

learn

谈谈 Golang, 以及我走的一些弯路

怎么学习 Golang

https://studygolang.com/

install


从go 1.8开始,GOPATH环境变量现在有一个默认值,如果它没有被设置。 它在Unix上默认为$HOME/go,

wget -c https://dl.google.com/go/go1.14.4.linux-amd64.tar.gz

tar -C /usr/local -xzf go$VERSION.$OS-$ARCH.tar.gz

tar  -xvf go1.14.4.linux-amd64.tar.gz  -C /usr/local/

#加入 添加到环境变量
echo 'export PATH=$PATH:/usr/local/go/bin' >>/etc/profile  && source /etc/profile

vi /etc/profile
export PATH=/usr/local/go/bin/:$PATH
#export GOPATH=/root/go/  #(可选设置) 如果你用root运行 
export GOROOT=/usr/local/go/
#export GOARCH=amd64
#export GOOS=linux
export GOTOOLS=$GOROOT/pkg/tool
#export PATH=$PATH:$GOROOT/bin:$GOPATH/bin

#export PATH=$PATH:/usr/local/gobin

source /etc/profile


#export PATH=/usr/local/go/bin/:$PATH
#export GOPATH=/root


#以前的文章
#freebsd
 https://dl.google.com/go/go1.12.5.freebsd-amd64.tar.gz
#linux
 curl -o  go1.13.6.linux-amd64.tar.gz   https://dl.google.com/go/go1.13.6.linux-amd64.tar.gz


tar -C /usr/local -xzf go1.12.5.freebsd-amd64.tar.gz



export PATH=$PATH:/usr/local/go/bin

source /etc/profile  #如果修改的是/etc/profile
source $HOME/.profile   #如果修改的是$HOME/.profile

go version




ubuntu

sudo add-apt-repository ppa:longsleep/golang-backports
sudo apt update
sudo apt install golang-go

https://github.com/golang/go/wiki/Ubuntu

IDE

goland

进入goland的bin目录下执行./goland.sh

Goland常用快捷键 文件相关快捷键: ​ CTRL+E,打开最近浏览过的文件。 CTRL+SHIFT+E,打开最近更改的文件。 CTRL+N,可以快速打开struct结构体。 CTRL+SHIFT+N,可以快速打开文件。 代码格式化: ​ CTRL+ALT+T,可以把代码包在一个块内,例如if{…}else{…}。 CTRL+ALT+L,格式化代码。 CTRL+空格,代码提示。 CTRL+/,单行注释。CTRL+SHIFT+/,进行多行注释。 CTRL+B,快速打开光标处的结构体或方法(跳转到定义处)。 CTRL+“+/-”,可以将当前方法进行展开或折叠。 查找和定位 CTRL+R,替换文本。 CTRL+F,查找文本。 CTRL+SHIFT+F,进行全局查找。 CTRL+G,快速定位到某行。 代码编辑 ​ ALT+Q,可以看到当前方法的声明。 CTRL+Backspace,按单词进行删除。 SHIFT+ENTER,可以向下插入新行,即使光标在当前行的中间。 CTRL+X,删除当前光标所在行。 CTRL+D,复制当前光标所在行。 ALT+SHIFT+UP/DOWN,可以将光标所在行的代码上下移动。 CTRL+SHIFT+U,可以将选中内容进行大小写转化。

linux下Goland如何设置桌面快捷方式

 ln -s  /opt/goland/bin/goland.sh /usr/bin/goland #我是这种在 awesome有效 


goland打开后点击任务栏:

tools---->create desktop entry.


#我的这个应该是没效果的
cat /usr/share/applications/goland.desktop
Version=1.0
Type=Application
Name=GoLand
Icon=/opt/goland/bin/goland.png
Exec="/opt/goland/bin/goland.sh" %f
Comment=The Drive to Develop
Categories=Development;IDE;
Terminal=false
StartupWMClass=jetbrains-goland

GO教程:安装Goland开发工具

go安装与goland破解永久版

emacs

golang快速入门[6.2]-集成开发环境-emacs详解 https://github.com/golang/go/wiki/IDEsAndTextEditorPlugins

https://emacs-china.org/t/topic/6469

https://stackoverflow.com/questions/1715464/emacs-mode-for-go#1715502

https://www.emacswiki.org/emacs/GoLangMode

Emacs中多个golang项目的配置方法

Emacs golang 配置

https://www.cnblogs.com/lienhua34/p/5838166.html

https://github.com/lienhua34/myemacs-conf

https://github.com/syl20bnr/spacemacs/tree/master/layers/%2Blang/go

https://blog.yuantops.com/tech/emacs-config-go-dev-environ/

https://dreamerjonson.com/2019/11/24/emacs-package-for-golang/index.html

https://github.com/dominikh/go-mode.el

https://github.com/alecthomas/gometalinter

https://www.cnblogs.com/cobbliu/p/4860600.html

Emacs golang 配置


https://zhuanlan.zhihu.com/p/19902040

https://github.com/lryong/emacs-golang-conf

https://chenyangguang.github.io/2018-11-27-ide/

see also

https://golang.google.cn/doc/install#install