沉淀再出发:redis的安装和使用
一、前言
下面让我们看看Redis这个键值对内存数据库的使用方法和相关注意事项。
二、Redis的安装和使用
2.1、Redis的定义
REmote DIctionary Server(Redis) 是一个由Salvatore Sanfilippo写的key-value存储系统。Redis是一个开源的使用ANSI C语言编写、遵守BSD协议、支持网络、可基于内存亦可持久化的日志型、Key-Value数据库,并提供多种语言的API。它通常被称为数据结构服务器,因为值(value)可以是字符串(String), 哈希(Map), 列表(list), 集合(sets) 和 有序集合(sorted sets)等类型。
2.2、Redis的安装
在windows中访问网址https://github.com/MicrosoftArchive/redis/releases,下载安装即可(可以安装msi的,可以安装zip的)。在安装的时候选择设置环境变量,如果是直接解压的可以自己设置,这样Redis就安装完毕了。
我们测试一下(这里如果我们的目录不是切换到安装目录,后面的文件应该加上路径,并且可以省略后面的文件,系统默认会去寻找):
redis-server.exe redis.windows.conf
打开服务器之后,我们在新打开一个cmd作为客户端,连接到服务器,并且测试,发现正常运行:
redis-cli.exe -h 127.0.0.1 -p 6379
2.3、Redis 配置
格式:CONFIG GET CONFIG_SETTING_NAME
比如:CONFIG GET loglevel
使用 * 号获取所有配置项:CONFIG GET *
127.0.0.1:6379> CONFIG GET * 1) "dbfilename" 2) "dump.rdb" 3) "requirepass" 4) "" 5) "masterauth" 6) "" 7) "unixsocket" 8) "" 9) "logfile" 10) "" 11) "pidfile" 12) "" 13) "maxmemory" 14) "0" 15) "maxmemory-samples" 16) "5" 17) "timeout" 18) "0" 19) "auto-aof-rewrite-percentage" 20) "100" 21) "auto-aof-rewrite-min-size" 22) "67108864" 23) "hash-max-ziplist-entries" 24) "512" 25) "hash-max-ziplist-value" 26) "64" 27) "list-max-ziplist-size" 28) "-2" 29) "list-compress-depth" 30) "0" 31) "set-max-intset-entries" 32) "512" 33) "zset-max-ziplist-entries" 34) "128" 35) "zset-max-ziplist-value" 36) "64" 37) "hll-sparse-max-bytes" 38) "3000" 39) "lua-time-limit" 40) "5000" 41) "slowlog-log-slower-than" 42) "10000" 43) "latency-monitor-threshold" 44) "0" 45) "slowlog-max-len" 46) "128" 47) "port" 48) "6379" 49) "tcp-backlog" 50) "511" 51) "databases" 52) "16" 53) "repl-ping-slave-period" 54) "10" 55) "repl-timeout" 56) "60" 57) "repl-backlog-size" 58) "1048576" 59) "repl-backlog-ttl" 60) "3600" 61) "maxclients" 62) "10000" 63) "watchdog-period" 64) "0" 65) "slave-priority" 66) "100" 67) "min-slaves-to-write" 68) "0" 69) "min-slaves-max-lag" 70) "10" 71) "hz" 72) "10" 73) "cluster-node-timeout" 74) "15000" 75) "cluster-migration-barrier" 76) "1" 77) "cluster-slave-validity-factor" 78) "10" 79) "repl-diskless-sync-delay" 80) "5" 81) "tcp-keepalive" 82) "0" 83) "cluster-require-full-coverage" 84) "yes" 85) "no-appendfsync-on-rewrite" 86) "no" 87) "slave-serve-stale-data" 88) "yes" 89) "slave-read-only" 90) "yes" 91) "stop-writes-on-bgsave-error" 92) "yes" 93) "daemonize" 94) "no" 95) "rdbcompression" 96) "yes" 97) "rdbchecksum" 98) "yes" 99) "activerehashing" 100) "yes" 101) "protected-mode" 102) "yes" 103) "repl-disable-tcp-nodelay" 104) "no" 105) "repl-diskless-sync" 106) "no" 107) "aof-rewrite-incremental-fsync" 108) "yes" 109) "aof-load-truncated" 110) "yes" 111) "maxmemory-policy" 112) "noeviction" 113) "loglevel" 114) "notice" 115) "supervised" 116) "no" 117) "appendfsync" 118) "everysec" 119) "appendonly" 120) "no" 121) "dir" 122) "D:\\software_setup\\redis_setup" 123) "save" 124) "jd 900 jd 300 jd 60" 125) "client-output-buffer-limit" 126) "normal 0 0 0 slave 268435456 67108864 60 pubsub 33554432 8388608 60" 127) "unixsocketperm" 128) "0" 129) "slaveof" 130) "" 131) "notify-keyspace-events" 132) "" 133) "bind" 134) "127.0.0.1"