Redis 官网
Windows 安装
-
Linux 安装
下载并安装
wget http://download.redis.io/releases/redis-6.0.8.tar.gztar xzf redis-6.0.8.tar.gzcd redis-6.0.8make
启动Redis(默认启动模式)
cd src./redis-server
Docker 安装
docker pull redisdocker run -itd --name redis-test -p 6379:6379 redis \bin\bashdocker exec -it containerID \bin\bashRedis 连接测试
redis-cli ping // pongset name hellochen-
Redis 性能测试
Usage: 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 SADDUsing this option the benchmark will expand the string __rand_int__inside an argument with a 12 digits number in the specified rangefrom 0 to keyspacelen-1. The substitution changes every time a commandis executed. Default tests use this to hit random keys in thespecified 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 testnames are the same as the ones produced as output.-I Idle mode. Just open N idle connections and wait.
$ redis-benchmark -n 10000 -q PING_INLINE: 16393.44 requests per second PING_BULK: 16393.44 requests per second SET: 15432.10 requests per second GET: 16313.21 requests per second INCR: 16556.29 requests per second LPUSH: 15220.70 requests per second RPUSH: 14471.78 requests per second LPOP: 15060.24 requests per second RPOP: 16129.03 requests per second SADD: 16339.87 requests per second SPOP: 15105.74 requests per second LPUSH (needed to benchmark LRANGE): 13736.26 requests per second LRANGE_100 (first 100 elements): 9652.51 requests per second LRANGE_300 (first 300 elements): 5238.34 requests per second LRANGE_500 (first 450 elements): 3759.40 requests per second LRANGE_600 (first 600 elements): 3608.81 requests per second MSET (10 keys): 13927.58 requests per secondRedis 远程连接配置
- 修改redis服务器的配置文件
本机安装的redis-4.0.14默认的配置文件 redis.conf 设置
绑定本机地址:bind 127.0.0.1
开启保护模式:protected-mode yes
此时连接,服务器是拒绝的
[root@hellochen redis]# ./redis-cli -h 192.168.100.109 -p 6379
Could not connect to Redis at 192.168.100.109:6379: Connection refused
Could not connect to Redis at 192.168.100.109:6379: Connection refused
not connected> eixt
- 配置文件比较大,我们通过ctrl + F 查找关键字修改为:
bind 0.0.0.0
protected-mode no
- 使用redis客户端连接
redis-cli -h 192.168.123.36
