页面“Gogs搭建自己的git服务器”与“Redis批量删除key”之间的差异

来自linux中国网wiki
(页面间的差异)
跳到导航 跳到搜索
docker>Evan
 
 
第1行: 第1行:
 +
[[category:ops]] [[category:redis]] 
  
==官网==
+
[[Redis-bigkeys]]
[https://gogs.io/ https://gogs.io/]
+
=redis cluster 批量删除key=
 
 
== Docker for Gogs==
 
 
<pre>
 
<pre>
母机
+
#June 19 2020  有空结果一下原来的版本再优化一下
192.168.50.159
+
cat redis_del_key.sh
 +
#!/bin/bash
 +
# Usage
 +
#redis_list=("host:post" "host:post")
  
参考命令这里-d将容器跑到后台,不在当前终端输出
+
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")
#docker run --name=jenkins -it -u root -d -p 8080:8080 -p 50000:50000 -v /data/jenkins:/var/jenkins_home 3f08dc4f3f5d
+
#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"
  
# Pull image from Docker Hub.
+
for info in ${redis_list[@]}
$ docker pull gogs/gogs
+
    do
 +
        echo "开始执行:$info" 
 +
        ip=`echo $info | cut -d : -f 1`
 +
        port=`echo $info | cut -d : -f 2`
  
# Create local directory for volume. 物理机数据目录
+
      for loop in  `cat key.txt`
$ mkdir -p /var/gogs
+
        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
  
# Use `docker run` for the first time.
+
    done
$ docker run --name=gogs -p 10022:22 -p 10080:3000 -v /var/gogs:/data gogs/gogs
+
    echo "success done完成"
  
# Use `docker start` if you have stopped it. 以后启动用这个命令就行了
+
# cat key.txt
$ docker start gogs
+
infnce:wonderfulCache
 +
ext_info
  
docker exec -it gogs /bin/bash
 
  
http://192.168.50.159:10080/install
 
#用sqlite3 直接配置就行了,如果想要mysql 得自己搞一下喽 改为真实地址可以 pull push 但是不好看呢
 
  
 +
#原来的版本
  
域名 应用 URL 这些要改 为
+
del hello_user_*
192.168.50.159:10080
 
  
clone
+
redis-cli keys
  
git clone ssh://git@hostname:10022/username/myrepo.git
 
  
#注意 就是有很多地方 像新建的仓库地址显示为localhost 这个得改一下  还有 key 添加 无论在project 还是用户 哪里添加 都还是要密码 是glone 要指定用户名么
+
  redis-cli keys "hello_user_*" | xargs redis-cli del
  
</pre>
 
  
===参考===
+
./redis-cli -h IP -p PORT -a PASSWORD keys 'key*' | xargs  ./redis-cli -h IP  -p PORT -a PASSWORD del
https://github.com/gogs/gogs/tree/master/docker
 
  
[https://www.jianshu.com/p/4e43bda3e1f2 使用Docker搭建git服务Gogs]
+
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 {}
 +
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 {}
  
[https://www.blackglory.me/docker-deploy-nginx-and-gogs/ 使用Docker部署Nginx + Gogs快速搭建在线Git服务]
+
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 {}
 +
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 {}
  
[https://www.jianshu.com/p/75f2117a837c Docker部署(四):Gogs]
+
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://github.com/helm/charts/tree/master/incubator/gogs helm gogs]
 
  
== 下载二进制包 ==
 
  
 +
#!/bin/bash
 +
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 {}
  
== 数据库相关操作 ==
+
运行:
<pre>#不用创建库 mysql -uroot -pevan < scripts/mysql.sql
 
  
create user 'gogs'@'localhost' identified by 'evan';
+
./redis_del_key.sh 匹配的key*
create user 'gogs'@'127.0.0.1' identified by 'evan';
 
  grant all privileges on gogs.* to 'gogs'@'localhost' identified by "evan";
 
grant all privileges on gogs.* to 'gogs'@'127.0.0.1' identified by "evan";
 
flush privileges;
 
exit;
 
</pre>
 
  
== 创建git 用户 ==
+
err 
<pre>useradd git&nbsp;; passwd git&nbsp;</pre>
 
  
&nbsp;
+
-i  {} 都是一定要的
  
 +
redis-cli -n 0 keys "test*" | xargs redis-cli -n 0 del
 +
(error) CROSSSLOT Keys in request don't hash to the same slot
  
 +
</pre>
  
 +
=see also=
  
== 配置启动文件 ==
 
<pre>cp scripts/init/centos/gogs /etc/init.d/ </pre>
 
 
#GOGS_HOME=/data/gogs/gogs
 
<pre>sed -i 's#GOGS_HOME=/home/git/gogs#GOGS_HOME=/data/gogs/#' /etc/init.d/gogs&nbsp;
 
 
mkdir -p /data/gogs/log;
 
 
chmod +x /etc/init.d/gogs
 
chown -R git:git /data/gogs/;
 
 
/etc/init.d/gogs start </pre>
 
 
#./gogs web
 
 
 
 
 
 
== web 界面安装 ==
 
  mkdir -p /data/gogs-repositories &&&nbsp;chown -R git:git /data/gogs-repositories
 
 
[http://192.168.3.9:3000/install http://192.168.3.9:3000/install]<br/> ip:3000;
 
 
web 界面安装中要注意的&nbsp;
 
 
仓库根目录 &nbsp;/data/gogs-repositories
 
  
<br/> 服务器和其它服务设置 禁止用户自主注册&nbsp;<br/> 启用登录访问限制
+
[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://gogs.io/docs/intro/faqs 官方常见问题]
 
&nbsp;
 
  
&nbsp;
+
[https://blog.csdn.net/zj20142213/article/details/80879744  redis集群批量删除指定的key]
  
[[Category:Git]]
+
https://blog.csdn.net/qq_36090419/article/details/80537684

2020年6月22日 (一) 11:37的版本


Redis-bigkeys

redis cluster 批量删除key

#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[@]}
    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
    echo "success done完成"

# cat key.txt 
infnce:wonderfulCache
ext_info



#原来的版本

del hello_user_* 

redis-cli keys


 redis-cli keys "hello_user_*" | xargs redis-cli del


./redis-cli -h IP -p PORT -a PASSWORD keys 'key*' | xargs  ./redis-cli -h IP  -p PORT -a PASSWORD del

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 {}
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 {}
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 {}



#!/bin/bash
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 {}

运行:

./redis_del_key.sh  匹配的key*

err  

-i  {} 都是一定要的 

redis-cli -n 0 keys "test*" | xargs redis-cli -n 0 del
(error) CROSSSLOT Keys in request don't hash to the same slot

see also

redis集群批量删除模糊key shell脚本

redis cluster集群批量删除中的key

Redis集群批量删除key

redis集群批量删除指定的key

https://blog.csdn.net/qq_36090419/article/details/80537684