Redis 入门概述(续)

一、redis默认安装目录下一些服务

usr/local/bin  默认安装目录

Redis 入门概述(续)_第1张图片

其中包含以下服务:

1、Redis-benchmark

性能测试工具,可以在自己本子运行,看看自己本子性能如何,是从缓存的角度来测试,更加的狠
[root@bogon bin]# redis-benchmark 
====== PING_INLINE ======
  100000 requests completed in 0.72 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1

99.58% <= 1 milliseconds
99.66% <= 2 milliseconds
99.71% <= 3 milliseconds
99.76% <= 6 milliseconds
99.80% <= 10 milliseconds
99.85% <= 12 milliseconds
99.91% <= 13 milliseconds
99.95% <= 16 milliseconds
100.00% <= 16 milliseconds
138696.25 requests per second

====== PING_BULK ======
  100000 requests completed in 0.62 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1

99.94% <= 1 milliseconds
100.00% <= 1 milliseconds
161550.89 requests per second

====== SET ======
  100000 requests completed in 0.68 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1

99.29% <= 1 milliseconds
99.70% <= 2 milliseconds
99.84% <= 3 milliseconds
99.90% <= 12 milliseconds
99.94% <= 13 milliseconds
99.95% <= 15 milliseconds
100.00% <= 15 milliseconds
147275.41 requests per second

====== GET ======
  100000 requests completed in 0.64 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1

99.59% <= 1 milliseconds
99.85% <= 2 milliseconds
99.90% <= 3 milliseconds
99.95% <= 4 milliseconds
100.00% <= 4 milliseconds
157232.70 requests per second

====== INCR ======
  100000 requests completed in 0.64 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1

99.77% <= 1 milliseconds
99.92% <= 2 milliseconds
100.00% <= 2 milliseconds
156739.81 requests per second

====== LPUSH ======
  100000 requests completed in 0.78 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1

99.51% <= 1 milliseconds
99.94% <= 2 milliseconds
100.00% <= 2 milliseconds
127877.23 requests per second

====== LPOP ======
  100000 requests completed in 0.63 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1

99.48% <= 1 milliseconds
99.67% <= 2 milliseconds
99.77% <= 3 milliseconds
99.94% <= 4 milliseconds
99.95% <= 5 milliseconds
99.95% <= 6 milliseconds
99.99% <= 7 milliseconds
100.00% <= 7 milliseconds
157977.88 requests per second

====== SADD ======
  100000 requests completed in 0.63 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1

99.62% <= 1 milliseconds
100.00% <= 1 milliseconds
157977.88 requests per second

====== SPOP ======
  100000 requests completed in 0.66 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1

99.65% <= 1 milliseconds
99.84% <= 2 milliseconds
100.00% <= 2 milliseconds
151057.41 requests per second

====== LPUSH (needed to benchmark LRANGE) ======
  100000 requests completed in 0.58 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1

99.71% <= 1 milliseconds
99.86% <= 2 milliseconds
100.00% <= 3 milliseconds
100.00% <= 3 milliseconds
173611.12 requests per second

====== LRANGE_100 (first 100 elements) ======
  100000 requests completed in 0.61 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1

99.87% <= 1 milliseconds
99.95% <= 2 milliseconds
99.99% <= 3 milliseconds
100.00% <= 3 milliseconds
165289.25 requests per second

====== LRANGE_300 (first 300 elements) ======
  100000 requests completed in 0.68 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1

99.61% <= 1 milliseconds
99.81% <= 2 milliseconds
99.95% <= 3 milliseconds
100.00% <= 3 milliseconds
147275.41 requests per second

====== LRANGE_500 (first 450 elements) ======
  100000 requests completed in 0.72 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1

99.72% <= 1 milliseconds
99.80% <= 2 milliseconds
99.86% <= 3 milliseconds
99.91% <= 4 milliseconds
99.93% <= 7 milliseconds
99.96% <= 8 milliseconds
99.97% <= 116 milliseconds
99.99% <= 117 milliseconds
100.00% <= 117 milliseconds
138504.16 requests per second

====== LRANGE_600 (first 600 elements) ======
  100000 requests completed in 0.66 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1

99.52% <= 1 milliseconds
99.80% <= 2 milliseconds
99.80% <= 3 milliseconds
99.85% <= 12 milliseconds
99.86% <= 13 milliseconds
99.90% <= 15 milliseconds
100.00% <= 15 milliseconds
151285.92 requests per second

====== MSET (10 keys) ======
  100000 requests completed in 0.71 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1

99.61% <= 1 milliseconds
99.87% <= 2 milliseconds
99.92% <= 3 milliseconds
99.95% <= 4 milliseconds
99.98% <= 5 milliseconds
100.00% <= 5 milliseconds
139860.14 requests per second

2、Redis-check-aof:

修复有问题的AOF文件

Appendonly.aof文件不能够随便更改

Redis 入门概述(续)_第2张图片

当更改之后会出现以下错误:

[root@bogon bin]# redis-server /usr/local/redis/redis-aof.conf 
[root@bogon bin]# redis-cli 
Could not connect to Redis at 127.0.0.1:6379: Connection refused

使用 redis 自带工具进行修复

Redis 入门概述(续)_第3张图片

3、Redis-check-dump

修复有问题的dump.rdb文件

4、Redis-cli

客户端,操作入口

5、Redis-sentinel

redis集群使用(哨兵服务)

6、Redis-server

Redis服务器启动命令

二、连通性测试

输入ping 输出 pong

[root@bogon bin]# redis-cli 
127.0.0.1:6379> ping
PONG
127.0.0.1:6379>

三、关闭 redis 服务

1、单实例关闭

redis-cli shutdown

2、多实例关闭,指定端口关闭(还创建了其他例如:6380,6381等端口实例时)

redis-cli -p 6379 shutdown

四、Redis启动后其他基础知识

1、单进程

单进程模型来处理客户端的请求。对读写等事件的响应
是通过对epoll函数的包装来做到的。Redis的实际处理速度完全依靠主进程的执行效率
Epoll是Linux内核为处理大批量文件描述符而作了改进的epoll,是Linux下多路复用IO接口select/poll的增强版本,它能显著提高程序在大量并发连接中只有少量活跃的情况下的系统CPU利用率。

2、默认库

默认16个数据库(在redis.conf 配置文件中配置),类似数组下表从零开始,初始默认使用零号库

设置数据库的数量,默认数据库为0

可以使用命令SELECT 在连接上指定数据库id切换链接的数据库

databases 16

查看当前数据库的key的数量

Dbsize   

清空当前库

Flushdb

通杀全部库(16个数据库)

Flushall

3、统一密码管理

16个库都是同样密码,要么都OK要么一个也连接不上

设置密码

127.0.0.1:6379> config get requirepass
1) "requirepass"
2) ""
127.0.0.1:6379> config set requirepass "123456"

再次访问显示错误没有认证

127.0.0.1:6379> get k1
(error) NOAUTH Authentication required.

认证

127.0.0.1:6379> auth 123456
OK
127.0.0.1:6379> get k1
"helloworld"

为了方便之后的操作,不需要一直都认证不设置密码

127.0.0.1:6379> config set requirepass ""
OK

4、Redis索引都是从零开始

5、默认端口是6379

你可能感兴趣的:(nosql)