List(列表) Redis 列表是简单的字符串列表,按照插入顺序排序。你可以添加一个元素到列表的头部(左边)或者尾部(右边) 格式: lpush name value 在 key 对应 list 的头部添加字符串元素 格式: rpush name value 在 key 对应 list 的尾部添加字符串元素 格式: lrem name index key 对应 list 中删除 count 个和 value 相同的元素 格式: llen name 返回 key 对应 list 的长度
Set(集合) 格式: sadd name value Redis的Set是string类型的无序集合。 集合是通过哈希表实现的,所以添加,删除,查找的复杂度都是O(1)。
zset(sorted set:有序集合) 格式: zadd name score value Redis zset 和 set 一样也是string类型元素的集合,且不允许重复的成员。 不同的是每个元素都会关联一个double类型的分数。redis正是通过分数来为集合中的成员进行从小到大的排序。 zset的成员是唯一的,但分数(score)却可以重复。
==================132redis启动================================================ 103398:C 08 Jan 201917:42:20.481 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo 103398:C 08 Jan 201917:42:20.481 # Redis version=5.0.2, bits=64, commit=00000000, modified=0, pid=103398, just started 103398:C 08 Jan 201917:42:20.481 # Configuration loaded 103399:M 08 Jan 201917:42:20.482 * Increased maximum number of open files to 10032 (it was originally set to 1024). 103399:M 08 Jan 201917:42:20.483 * Running mode=standalone, port=7000. 103399:M 08 Jan 201917:42:20.483 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128. 103399:M 08 Jan 2019 17:42:20.483 # Server initialized 103399:M 08 Jan 2019 17:42:20.483 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect. 103399:M 08 Jan 2019 17:42:20.483 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled. 103399:M 08 Jan 2019 17:42:20.483 * Ready to accept connections
==================133redis启动开始请求同步====================================== 103399:M 08 Jan 2019 17:44:56.213 * Replica 192.168.250.133:7001 asks for synchronization 103399:M 08 Jan 2019 17:44:56.213 * Full resync requested by replica 192.168.250.133:7001
# 主从复制 默认 RDB 持久化 103399:M 08 Jan 2019 17:44:56.213 * Starting BGSAVE for SYNC with target: disk 103399:M 08 Jan 2019 17:44:56.214 * Background saving started by pid 103768 103768:C 08 Jan 2019 17:44:56.216 * DB saved on disk 103768:C 08 Jan 2019 17:44:56.216 * RDB: 4 MB of memory used by copy-on-write 103399:M 08 Jan 2019 17:44:56.299 * Background saving terminated with success # 133 redis 数据同步成功 103399:M 08 Jan 2019 17:44:56.299 * Synchronization with replica 192.168.250.133:7001 succeeded ==================134redis启动开始请求同步======================================= 103399:M 08 Jan 2019 17:45:25.389 * Replica 192.168.250.134:7002 asks for synchronization 103399:M 08 Jan 2019 17:45:25.389 * Full resync requested by replica 192.168.250.134:7002
# 主从复制 默认 RDB 持久化 103399:M 08 Jan 2019 17:45:25.389 * Starting BGSAVE for SYNC with target: disk 103399:M 08 Jan 2019 17:45:25.390 * Background saving started by pid 103858 103858:C 08 Jan 2019 17:45:25.391 * DB saved on disk 103858:C 08 Jan 2019 17:45:25.392 * RDB: 4 MB of memory used by copy-on-write 103399:M 08 Jan 2019 17:45:25.402 * Background saving terminated with success # 133 redis 数据同步成功 103399:M 08 Jan 2019 17:45:25.402 * Synchronization with replica 192.168.250.134:7002 succeeded ==================134redis关闭日志=============================================== 103399:M 08 Jan 2019 17:51:13.850 # Connection with replica 192.168.250.134:7002 lost. ==================134redis重新启动日志============================================ 103399:M 08 Jan 2019 17:52:28.885 * Replica 192.168.250.134:7002 asks for synchronization 103399:M 08 Jan 2019 17:52:28.885 * Partial resynchronization request from 192.168.250.134:7002 accepted. Sending 588 bytes of backlog starting from offset 43.
==================132redis强制关闭================================================ 103399:M 08 Jan 2019 17:54:06.369 # User requested shutdown... 103399:M 08 Jan 2019 17:54:06.369 * Removing the pid file. 103399:M 08 Jan 2019 17:54:06.369 # Redis is now ready to exit, bye bye...
==================132redis 主服务器再次上线,同步数据以及连接slave服务器=============== 105223:M 08 Jan 2019 17:54:47.189 * Background saving terminated with success 105223:M 08 Jan 2019 17:54:47.189 * Synchronization with replica 192.168.250.133:7001 succeeded 105223:M 08 Jan 2019 17:54:47.807 * Replica 192.168.250.134:7002 asks for synchronization 105223:M 08 Jan 2019 17:54:47.807 * Partial resynchronization not accepted: Replication ID mismatch (Replica asked for 'd0ff33789382fccfe621d9ad03c26cc545bda3fa', my replication IDs are '00591a20c6cafe8f906632746d514e99213ee121' and '0000000000000000000000000000000000000000') 105223:M 08 Jan 2019 17:54:47.807 * Starting BGSAVE for SYNC with target: disk 105223:M 08 Jan 2019 17:54:47.808 * Background saving started by pid 105229 105229:C 08 Jan 2019 17:54:47.809 * DB saved on disk 105229:C 08 Jan 2019 17:54:47.809 * RDB: 4 MB of memory used by copy-on-write 105223:M 08 Jan 2019 17:54:47.894 * Background saving terminated with success 105223:M 08 Jan 2019 17:54:47.894 * Synchronization with replica 192.168.250.134:7002 succeeded