127.0.0.1:6379> CONFIG GET requirepass1) "requirepass"2) ""
配置密码之后,就需要进行认证
127.0.0.1:6379> CONFIG GET requirepass(error) NOAUTH Authentication required.127.0.0.1:6379> AUTH foobared #认证OK127.0.0.1:6379> CONFIG GET requirepass1) "requirepass"2) "foobared"
11、Redis持久化
Redis持久有两种方式:Snapshotting(快照),Append-only file(AOF)
Snapshotting(快照)
1、将存储在内存的数据以快照的方式写入二进制文件中,如默认dump.rdb中Append-only file(AOF)
2、save 900 1
#900秒内如果超过1个Key被修改,则启动快照保存 3、save 300 10
#300秒内如果超过10个Key被修改,则启动快照保存 4、save 60 10000
#60秒内如果超过10000个Key被修改,则启动快照保存
1、使用AOF持久时,服务会将每个收到的写命令通过write函数追加到文件中(appendonly.aof)12、Redis 性能测试
2、AOF持久化存储方式参数说明
appendonly yes
#开启AOF持久化存储方式 appendfsync always
#收到写命令后就立即写入磁盘,效率最差,效果最好 appendfsync everysec
#每秒写入磁盘一次,效率与效果居中 appendfsync no
#完全依赖OS,效率最佳,效果没法保证
自带相关测试工具
[root@test ~]# redis-benchmark --helpUsage: redis-benchmark [-h <host>] [-p <port>] [-c <clients>] [-n <requests]> [-k <boolean>] -h <hostname> Server hostname (default 127.0.0.1) -p <port> Server port (default 6379) -s <socket> Server socket (overrides host and port) -a <password> Password for Redis Auth -c <clients> Number of parallel connections (default 50) -n <requests> Total number of requests (default 100000) -d <size> Data size of SET/GET value in bytes (default 2) -dbnum <db> SELECT the specified db number (default 0) -k <boolean> 1=keep alive 0=reconnect (default 1) -r <keyspacelen> Use random keys for SET/GET/INCR, random values for SADD Using this option the benchmark will expand the string __rand_int__ inside an argument with a 12 digits number in the specified range from 0 to keyspacelen-1. The substitution changes every time a command is executed. Default tests use this to hit random keys in the specified range. -P <numreq> Pipeline <numreq> requests. Default 1 (no pipeline). -q Quiet. Just show query/sec values --csv Output in CSV format -l Loop. Run the tests forever -t <tests> Only run the comma separated list of tests. The test names are the same as the ones produced as output. -I Idle mode. Just open N idle connections and wait.Examples: Run the benchmark with the default configuration against 127.0.0.1:6379: $ redis-benchmarkUse 20 parallel clients, for a total of 100k requests, against 192.168.1.1: $ redis-benchmark -h 192.168.1.1 -p 6379 -n 100000 -c 20 Fill 127.0.0.1:6379 with about 1 million keys only using the SET test: $ redis-benchmark -t set -n 1000000 -r 100000000 Benchmark 127.0.0.1:6379 for a few commands producing CSV output: $ redis-benchmark -t ping,set,get -n 100000 --csv Benchmark a specific command line: $ redis-benchmark -r 10000 -n 10000 eval 'return redis.call("ping")' 0 Fill a list with 10000 random elements: $ redis-benchmark -r 10000 -n 10000 lpush mylist __rand_int__ On user specified command lines __rand_int__ is replaced with a random integer with a range of values selected by the -r option.
实际测试同时执行100万的请求[root@test ~]# redis-benchmark -n 1000000 -qPING_INLINE: 152578.58 requests per secondPING_BULK: 150308.14 requests per secondSET: 143266.47 requests per secondGET: 148632.58 requests per secondINCR: 145857.64 requests per secondLPUSH: 143781.45 requests per secondLPOP: 147819.66 requests per secondSADD: 138350.86 requests per secondSPOP: 134282.27 requests per secondLPUSH (needed to benchmark LRANGE): 141302.81 requests per secondLRANGE_100 (first 100 elements): 146756.67 requests per secondLRANGE_300 (first 300 elements): 148104.27 requests per secondLRANGE_500 (first 450 elements): 152671.75 requests per secondLRANGE_600 (first 600 elements): 148104.27 requests per secondMSET (10 keys): 132731.62 requests per second
推荐阅读
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 十一 网络编程懒人入门:一文读懂什么是IPv6
- 如何快速处理网络故障,一文了解网络故障排查方法
- 新车如何快速除味除甲醛?活性炭包和车载空气净化器到底有没有用
- 每天杯茶七个生活妙方让你年轻10岁,四大步骤教你如何简易而快速的冲泡百合花茶
- 牙疼快速止疼药中药
- 让你快速入门国际象棋 国际象棋入门
- 怎么让网站内容快速被蜘蛛抓取收录?
- 一篇文章读懂redis
- 5分钟快速搭建FTP服务器的图文教程
- excel2016怎么快速输入当前日期与时间?