那些年你错过的Redis

本文介绍了Redis的启动与连接、性能测试,详细讲解了Redis的基本知识,包括Redis-key的操作,如字符串、列表、集合、哈希和有序集合等数据类型的常用命令,以及特殊数据类型的地理空间、Hyperloglog和位存储的应用。
摘要由CSDN通过智能技术生成

1.启动服务,连接

通过指定的配置文件启动服务 

[root@iZbp12fj4dxm8z5uofcvshZ ~]# cd /usr/local/bin
[root@iZbp12fj4dxm8z5uofcvshZ bin]# ls
chardetect         cloud-init      easy_install      jemalloc-config  jsondiff     jsonschema        luajit-2.0.4  redis-benchmark  redis-cli
chen_redis_config  cloud-init-per  easy_install-3.6  jemalloc.sh      jsonpatch    libmcrypt-config  mcrypt        redis-check-aof  redis-sentinel
cloud-id           dump.rdb        easy_install-3.8  jeprof           jsonpointer  luajit            mdecrypt      redis-check-rdb  redis-server
[root@iZbp12fj4dxm8z5uofcvshZ bin]# redis-server chen_redis_config/redis.conf 
2998:C 29 Nov 2021 19:19:39.453 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
2998:C 29 Nov 2021 19:19:39.453 # Redis version=5.0.8, bits=64, commit=00000000, modified=0, pid=2998, just started
2998:C 29 Nov 2021 19:19:39.453 # Configuration loaded

使用redis客户端进行连接、测试,默认端口号是6379,这里我修改成了自己的端口号

[root@iZbp12fj4dxm8z5uofcvshZ bin]# redis-cli -p 2021
127.0.0.1:2021> ping
(error) NOAUTH Authentication required.
127.0.0.1:2021> auth 526260 
OK
127.0.0.1:2021> ping
PONG
127.0.0.1:2021> keys * 
(empty list or set)
127.0.0.1:2021> set name zhangsan
OK
127.0.0.1:2021> keys *
1) "name"

查看redis的进程是否开启

[root@iZbp12fj4dxm8z5uofcvshZ ~]# ps -ef|grep redis
root      1653     1  0 19:12 ?        00:00:03 redis-server *:2021
root      7928  2206  0 19:52 pts/1    00:00:00 redis-cli -p 2021
root      8559  8496  0 19:56 pts/0    00:00:00 grep --color=auto redis

关闭redis服务

127.0.0.1:2021> shutdown 
not connected> exit
[root@iZbp12fj4dxm8z5uofcvshZ bin]# 

再次查看进程是否存在

[root@iZbp12fj4dxm8z5uofcvshZ ~]# ps -ef|grep redis
root      8816  8496  0 19:58 pts/0    00:00:00 grep --color=auto redis
[root@iZbp12fj4dxm8z5uofcvshZ ~]# 

2. redis性能测试

使用redis-benchmark工具(官方自带的性能测试工具)

100个并发连接,100000次请求,每次写入3个字节

[root@iZbp12fj4dxm8z5uofcvshZ ~]# redis-benchmark -h localhost -p 2021 -c 100 -n 100000
====== PING_INLINE ======
  100000 requests completed in 2.16 seconds
  100 parallel clients
  3 bytes payload
  keep alive: 1

11.54% <= 1 milliseconds
94.56% <= 2 milliseconds
99.36% <= 3 m
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小馒头爱学Java

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值