本项目中常用redis命令

1, 安装开关及问题


如果是自己在本机上使用现在已经可以了,因为我这是局域网内提供给大家使用的所以还需要最后的配置。


当时修改开发的配置文件后,启动项目报错。


 打开cmd 然后使用 telnet ip 端口 来ping 配置的redis(要保证redis已启动),发现无法ping通。


这是因为在redis.conf中有个配置 bind 127.0.0.1 这个是默认只有本机访问,把这个注释掉就好了,注释以后查看redis进程就变为下面这样:
直接用yum 安装的, 注释掉/etc/redis/6379.conf文件里的 bind 127.0.0.1




后端模式启动


   修改redis.conf配置文件, daemonize yes 以后端模式启动。推荐!


   打开redis.conf,使用命令 :/ daemonize 快速查找到daemonize然后修改。


vi /etc/redis/redis.conf
仅修改: daemonize yes (no-->yes)




//启动
redis-server /etc/redis/6379.conf




Redis服务查看、开启、关闭
1、通过ps -ef|grep redis命令查看Redis进程;
2、开启Redis服务操作通过/etc/init.d/redis_6379 start命令,也可通过(service redis_6379 start);
3、关闭Redis服务操作通过/etc/init.d/redis_6379 stop命令,也可通过(service redis_6379 stop);




root      52410      1  0 17:39 ?        00:00:00 /usr/local/bin/redis-server *:6379
这个*号就表示允许其它用户访问了。然后在用打开本机的 cmd使用 telnet ip 端口 就能ping通了。






ResponseError: DENIED Redis is running in protected mode because protected mode is enabled, 
no bind address was specified, no authentication password is requested to clients. 
In this mode connections are only accepted from the loopback interface. If you want to connect from external computers to Redis you may adopt one of the following solutions: 
1) Just disable protected mode sending the command 'CONFIG SET protected-mode no' from the loopback interface by connecting to Redis from the same host the server is running, 
however MAKE SURE Redis is not publicly accessible from internet if you do so. Use CONFIG REWRITE to make this change permanent. 
2) Alternatively you can just disable the protected mode by editing the Redis configuration file, and setting the protected mode option to 'no', and then restarting the server. 
3) If you started the server manually just for testing, restart it with the '--protected-mode no' option. 4) Setup a bind address or an authentication password. 
NOTE: You only need to do one of the above things in order for the server to start accepting connections from the outside.



2, 命令
keys *


ZRANGE camera_52 0 -1 WITHSCORES //查看抓拍
hgetall 100 // 查看识别


127.0.0.1:6379> get captured_face_id
"99"


//考勤
127.0.0.1:6379> lrange "attend_2017-11-24_56" 0 8
1) "{\"listId\":1,\"ts\":1511538621,\"personKey\":\"123456789\",\"imageId\":71}"
2) "{\"listId\":1,\"ts\":1511538626,\"personKey\":\"123456789\",\"imageId\":71}"


//
lrange "38_1515567704_1515657704" 0 8
127.0.0.1:6379> lrange "38_1515567704_1515657704" 0 8
1) "{\"roi\": \"2018-1-10/38/faceROI/2018-1-10-15h54m39s237571-1.jpg\", \"imgKey\": \"1_1\", \"ts\": 1515570879}"
2) "{\"roi\": \"2018-1-10/38/faceROI/2018-1-10-15h54m47s723644-2.jpg\", \"imgKey\": \"2_1\", \"ts\": 1515570887}"
3) "{\"roi\": \"2018-1-10/38/faceROI/2018-1-10-15h54m55s905241-3.jpg\", \"imgKey\": \"3_1\", \"ts\": 1515570895}"
4) "{\"roi\": \"2018-1-10/38/faceROI/2018-1-10-15h54m57s716994-3.jpg\", \"imgKey\": \"3_2\", \"ts\": 1515570897}"
5) "{\"roi\": \"2018-1-10/38/faceROI/2018-1-10-15h54m59s561406-3.jpg\", \"imgKey\": \"3_3\", \"ts\": 1515570899}"
6) "{\"roi\": \"2018-1-10/38/faceROI/2018-1-10-15h55m01s159654-4.jpg\", \"imgKey\": \"4_1\", \"ts\": 1515570901}"
7) "{\"roi\": \"2018-1-10/38/faceROI/2018-1-10-15h55m03s012581-4.jpg\", \"imgKey\": \"4_2\", \"ts\": 1515570903}"
8) "{\"roi\": \"2018-1-10/38/faceROI/2018-1-10-15h55m07s240985-5.jpg\", \"imgKey\": \"5_1\", \"ts\": 1515570907}"
9) "{\"roi\": \"2018-1-10/38/faceROI/2018-1-10-15h55m08s063172-5.jpg\", \"imgKey\": \"5_2\", \"ts\": 1515570908}"




清空 
flushall 




收录 
127.0.0.1:6379> KEYS *
1) "lwctest"
2) "myIDID"
127.0.0.1:6379> ZRANGEBYSCORE myIDID 1513745864522 1513745867539
(empty list or set)
127.0.0.1:6379> ZRANGE myIDID 0 -1 WITHSCORES
 1) "1513746169724"
 2) "1513746169724"
 3) "1513746170728"
 4) "1513746170728"
 5) "1513746171733"
 6) "1513746171733"
 7) "1513746172738"
 8) "1513746172738"
 9) "1513746173743"
10) "1513746173743"
127.0.0.1:6379> ZRANGEBYSCORE myIDID 1513746169724 1513746173743
1) "1513746169724"
2) "1513746170728"
3) "1513746171733"
4) "1513746172738"
5) "1513746173743"
127.0.0.1:6379> 





猜你喜欢

转载自blog.csdn.net/weixin_40592935/article/details/80436320