博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ubuntu redis 安装 &基本命令
阅读量:6891 次
发布时间:2019-06-27

本文共 2644 字,大约阅读时间需要 8 分钟。

参考资料: redis命令参考: 安装:sudo apt-get install redis-server 安装完成后,Redis服务器会自动启动,我们检查Redis服务器程序 检查服务器进程:ps -aux|grep redis 检查Redis服务器状态:netstat -nlt|grep 6379 通过启动命令检查Redis服务器状态:sudo /etc/init.d/redis-server status 安装Redis服务器,会自动地一起安装Redis命令行客户端程序

 重启Redis服务器:sudo /etc/init.d/redis-server restart

配置文件:/etc/redis/redis.conf

先关闭再重启
[root@localhost src]# redis-cli  #开始客户端连接127.0.0.1:6379> auth 123456 #auth 密码登录OK127.0.0.1:6379> shutdown save    #shutdown 关闭服务  savenot connected> exit              # not connected 表示连接已经失去, exit 退出[root@localhost src]# [root@loca [root@localhost src]# ps -ef | grep redis-   # ps 查找进程 redis-server 真的关闭了root      2782  2508  0 05:57 pts/0    00:00:00 grep --color=auto redis-[root@localhost src]# redis-server ../redis.conf  #重启--------------------- 作者:1990_super 来源:CSDN 原文:https://blog.csdn.net/runbat/article/details/79248527 版权声明:本文为博主原创文章,转载请附上博文链接!
from redis import StrictRedis# 使用默认方式连接到数据库redis = StrictRedis(host='localhost', port=6379, db=0)# 使用url方式连接到数据库redis = StrictRedis.from_url('redis://@localhost:6379/1')
from redis import StrictRedis,ConnectionPool# 使用默认方式连接到数据库pool = ConnectionPool(host='localhost', port=6379, db=0)redis = StrictRedis(connection_pool=pool)# 使用url方式连接到数据库pool = ConnectionPool.from_url('redis://@localhost:6379/1')redis = StrictRedis(connection_pool=pool)
redis://[:password]@host:port/db    # TCP连接rediss://[:password]@host:port/db   # Redis TCP+SSL 连接unix://[:password]@/path/to/socket.sock?db=db    # Redis Unix Socket 连接

 

redis-load -h   # 获取帮助信息< redis_data.json redis-load -u redis://@localhost:6379  # 将json数据导入数据库中
redis-dump -h  # 获取帮助信息redis-dump -u redis://@localhost:6379 -d 1 > ./redis.data.jl  # 导出到json文件redis-dump -u redis://@localhost:6379 -f adsl:* > ./redis.data.jl  # 导出adsl开头的数据

 =======================

打印出所有[与pattern相匹配的]活跃频道:PUBSUB CHANNELS [pattern]    活跃频道指的是那些至少有一个订阅者的频道

订阅频道的订阅者数量:PUBSUB NUMSUB channel1 channel2
返回客户端订阅的所有模式的数量总和:PUBSUB NUMPAT

# client-1 订阅 news.* 和 discount.* 两个模式client-1> PSUBSCRIBE news.* discount.*Reading messages... (press Ctrl-C to quit)1) "psubscribe"2) "news.*"3) (integer) 11) "psubscribe"2) "discount.*"3) (integer) 2# client-2 订阅 tweet.* 一个模式client-2> PSUBSCRIBE tweet.*Reading messages... (press Ctrl-C to quit)1) "psubscribe"2) "tweet.*"3) (integer) 1# client-3 返回当前订阅模式的数量为 3client-3> PUBSUB NUMPAT(integer) 3# 注意,当有多个客户端订阅相同的模式时,相同的订阅也被计算在 PUBSUB NUMPAT 之内# 比如说,再新建一个客户端 client-4 ,让它也订阅 news.* 频道client-4> PSUBSCRIBE news.*Reading messages... (press Ctrl-C to quit)1) "psubscribe"2) "news.*"3) (integer) 1# 这时再计算被订阅模式的数量,就会得到数量为 4client-3> PUBSUB NUMPAT(integer) 4

 

 

 

 

 
 

转载于:https://www.cnblogs.com/testzcy/p/10962612.html

你可能感兴趣的文章
《转》精巧好用的DelayQueue
查看>>
Mongoose的模糊查询
查看>>
C#汉语转拼音,日文转假名
查看>>
[导入]WAP常见问题问答大全---七、关于WAP浏览器的常见问答
查看>>
无法使用此电子邮件地址。请选择其他电子邮件地址
查看>>
对接微信支付使用HMAC-SHA256使用签名算法实现方式
查看>>
Jenkins这种构建工具,一般都是内部使用,所以外部基本上不能访问
查看>>
php 慢配置文件
查看>>
mq和redis安装
查看>>
c# 字符串是否含有中文
查看>>
Bootstrap3基础 栅格系统 列中有行,行中有列
查看>>
按时间排序,查询不同类别各一个
查看>>
Docker swarm结合Openresty部署rabbitmq集群
查看>>
ArrayList、LinkedList、 Vector、Map 用法比较
查看>>
[Bzoj4818]序列计数(矩阵乘法+DP)
查看>>
HDU3535 AreYouBusy
查看>>
c 从txt中读取数据
查看>>
洛谷——P1154 奶牛分厩
查看>>
15:银行利息
查看>>
python安装大型包时出现错误Unable to find vcvarsall.bat
查看>>