当前位置:网站首页>【Redis】redis安装与客户端redis-cli的使用(批量操作)
【Redis】redis安装与客户端redis-cli的使用(批量操作)
2022-07-23 12:33:00 【InfoQ】
Part1在Centos中安装Redis
1安装步骤
mkdir /data/redis & cd /data/redis wget https://download.redis.io/releases/redis-6.0.9.tar.gz
tar xzf redis-6.0.9.tar.gz
cd redis-6.0.9
make
make test
redis-serverredis-clicp src/redis-server /usr/local/bin/
cp src/redis-cli /usr/local/bin/
cp src/redis-sentinel /usr/local/bin/
cd /data/redis/
创建一个6379的文件夹
mkdir 6379
将配置模板拷贝到6379中
cp redis-6.0.9/redis.conf 6379
cd 6379
mkdir log
mkdir run
vim /data/redis/6379/redis.conf
daemonize yes ## 后台运行
pidfile /data/redis/run/redis_6379.pid
logfile /data/redis/log/redis_6379.log
dir /data/redis/6379
/usr/local/bin/redis-server /data/redis/6379/redis.conf

/usr/local/bin/redis-cli
2安装可能出现的问题
make[3]: 进入目录“/data/redis/redis-6.0.9/deps/hiredis”
cc -std=c99 -pedantic -c -O3 -fPIC -Wall -W -Wstrict-prototypes -Wwrite-strings -Wno-missing-field-initializers -g -ggdb net.c
make[3]: cc:命令未找到
make[3]: *** [net.o] 错误 127
make[3]: 离开目录“/data/redis/redis-6.0.9/deps/hiredis”
make[2]: *** [hiredis] 错误
yum install gcc-c++make distcleanmakeserver.c: 在函数‘redisSetProcTitle’中:
server.c:5052:15: 错误:‘struct redisServer’没有名为‘cluster_enabled’的成员
if (server.cluster_enabled) server_mode = " [cluster]";
^
server.c:5053:20: 错误:‘struct redisServer’没有名为‘sentinel_mode’的成员
else if (server.sentinel_mode) server_mode = " [sentinel]";
^
server.c:5057:15: 错误:‘struct redisServer’没有名为‘bindaddr_count’的成员
server.bindaddr_count ? server.bindaddr[0] : "*",
^
server.c:5057:39: 错误:‘struct redisServer’没有名为‘bindaddr’的成员
server.bindaddr_count ? server.bindaddr[0] : "*",
^
server.c:5058:15: 错误:‘struct redisServer’没有名为‘port’的成员
server.port ? server.port : server.tls_port,
^
server.c:5058:29: 错误:‘struct redisServer’没有名为‘port’的成员
server.port ? server.port : server.tls_port,
^
server.c:5058:43: 错误:‘struct redisServer’没有名为‘tls_port’的成员
server.port ? server.port : server.tls_port,
yum -y install centos-release-scl && yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils && scl enable devtoolset-9 bash
make distcleanmakemakeIt's a good idea to run 'make test'make testYou need tcl 8.5 or newer in order to run the Redis testyum install -y tclPart2redis-cli,Redis命令行界面
3客户端回复结果作为其他的输出
/usr/local/bin/redis-cli/usr/local/bin/redis-cli incr mycounter > /tmp/output.txt
cat /tmp/output.txt

/usr/local/bin/redis-cli --no-raw incr mycounter > /tmp/output.txt
--raw4主机,端口,密码和数据库
/usr/local/bin/redis-cli -h localhost -p 6379 ping-a <password>/usr/local/bin/redis-cli -a myUnguessablePazzzzzword123 ping5统计
redis-cli -h IP地址 -p 端口 -a 密码 info keyspace
redis-cli keys "Abc*" | wc -l
6从其他程序获取内容当做redis的输入
/usr/local/bin/redis-cli -x set incrcount < /tmp/output.txtvim /tmp/commands.txtset foo 100
incr foo
append foo xxx
get foo
cat /tmp/commands.txt | /usr/local/bin/redis-cli
--rawredis-cli> /tmp/output.txt7连续运行相同的命令
-r <count>和-i <delay>

8随时间监视RSS内存大小
redis-cli -r -1 -i 1 INFO | grep rss_human
9批量操作
vim /tmp/commands.txt
cat /tmp/commands.txt | /usr/local/bin/redis-cli --pipe > /tmp/batchout.tx--pipe
10如何批量删除指定的数据
/usr/local/bin/redis-cli keys '1*' |xargs /usr/local/bin/redis-cli del11连续统计模式
--stat实时监控-i
12扫描大键
/usr/local/bin/redis-cli -x set bigkeyname < /tmp/commands.txtredis-cli --bigkeys
SCAN命令13获取按键列表
redis-cli --scan | head -10redis-cli --scan --pattern '*-11*'14监控Redis中的操作命令
redis-cli monito
|grep15RDB文件的远程备份
redis-cli --rdb /tmp/redisdump.rdb16执行LRU模拟
./redis-cli --lru-test 10000000
17如果批量删除 带\n后缀的key

-t-t 表示先打印命令,然后再执行。
redis-cli -a daimler1818 del lru:17288 lru:3818127getgetkeys 'lru:*'
\nget "lru:3717577\n"
/data/codis/codis/redis-cli -a password keys "lru*" |head -10 | xargs -I {} -t echo ' del "{}\n"' > /tmp/lrutest.txt
/data/codis/codis/redis-cli -a password keys "lru*"head -10xargs -I {} -t echo 'del "{}\n"'{}echo 'del "{}\n"'del "lru:3717577\n"> /tmp/lrutest.txtcat /tmp/lrutest.txt | ./redis-cli -a password -x
cat /tmp/lrutest.txt | ./redis-cli -a password --pipePart3参考文档
边栏推荐
- Practice code - day one
- Emgucv recording video
- Esp8266 nodemcu flash file system (spiffs)
- Transparent proxy server architecture of squid proxy service
- MySQL soul 16 ask, how many questions can you hold on to?
- 基于USB数据采集卡(DAQ)与IO模块的热电阻温度采集「建议收藏」
- lc marathon 7.23
- MySQL - master-slave replication
- Bean Validation起源篇----01
- Oralce中实现将指定列的指定内容替换为想要的内容
猜你喜欢

智慧民航新业态崭露头角,图扑数字孪生入局民航飞联网

Vinka推出高抗干扰VK36N系列触摸IC:VK36N1D,VK36N2P,VK36N3B,VK36N4I 使用便利

Esp8266 nodemcu flash file system (spiffs)

First hello of SOC_ World experiment

大端模式和小端模式的记忆方法
![[in simple terms] from self information to entropy, from relative entropy to cross entropy, nn Crossentropyloss, cross entropy loss function and softmax, multi label classification](/img/42/5419f0b3240142de87895439bd4297.png)
[in simple terms] from self information to entropy, from relative entropy to cross entropy, nn Crossentropyloss, cross entropy loss function and softmax, multi label classification

死锁、饥饿、死循环之间的区别

2022蓝帽杯初赛wp

vulnstack红日-4

将.calss文件转为.jar-idea篇
随机推荐
信箱通信-
Nport serial server principle, moxa serial server nport-5130 detailed configuration
Purpose of wsastartup function
Thermal resistance temperature acquisition based on USB data acquisition card (DAQ) and IO module "suggestions collection"
WSAStartup函数的用途
Niuke-top101-bm36
Esp8266 nodemcu flash file system (spiffs)
AC automata and fail tree
快递单证智能OCR识别,助力物流行业数字化升级
pytest接口自动化测试框架 | 如何获取帮助
知道为什么PCBA电路板会板翘吗?
The difference between deadlock, hunger and dead cycle
Go 接口:深入内部原理
机器狗背冲锋枪射击视频火了,网友瑟瑟发抖:stooooooooppppp!
死锁、饥饿、死循环之间的区别
基于USB数据采集卡(DAQ)与IO模块的热电阻温度采集「建议收藏」
The competition boss is in Huawei: network experts are from Stanford physics department, and some people "work as much as reading a doctoral degree"
CA数字证书
LeetCode之等式方程的可满足性
pytest接口自动化测试框架 | 控制测试用例执行