Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Guide to the use of redis (1)

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Guidelines for using redis

A brief introduction to Redis

When redis unfolds, it looks like remote directory server. Redis is an open source, memory-based data structure storage that can be used as a database, cache system, or message queue. It supports data structures such as string, list (array), hashes (associative array), collection, ordered collection, bitmaps (bitmap), hyperloglogs, spatial index, which is very powerful. Redis has built-in replication capabilities, support for lua scripts, LRU algorithms, transactions, persistent storage and support for high availability (sentinel,redis cluster). The following is a summary of the characteristics of redis:

II. Redis installation

Because redis is very powerful and widely used, it has been included in the epel warehouse, so we only need to point the yum warehouse to the epel warehouse. So the installation here is very simple, directly yum install-y redis. Note that what I have installed here is the redis3.2 version, and the official latest version is redis4. The download and installation method is very simple. If you have any ideas, please poke the website.

Https://redis.io/download

III. Detailed explanation of the configuration file

Usually for software packages installed by rpm, we can view the configuration files related to the program with the following command

[root@mysql ~] # rpm-ql redis/etc/logrotate.d/redis/etc/redis-sentinel.conf # Monitoring (Sentinel) configuration file / etc/redis.conf # main configuration file / etc/systemd/system/redis-sentinel.service.d/etc/systemd/system/redis-sentinel.service.d/limit.conf/etc/systemd/system/redis.service .d / etc/systemd/system/redis.service.d/limit.conf/usr/bin/redis-benchmark/usr/bin/redis-check-aof/usr/bin/redis-check-rdb/usr/bin/redis-cli # redis client program / usr/bin/redis-sentinel/usr/bin/redis-server # redis server program / usr/bin/redis -shutdown/usr/lib/systemd/system/redis-sentinel.service/usr/lib/systemd/system/redis.service/usr/lib/tmpfiles.d/redis.conf/usr/share/doc/redis-3.2.3/usr/share/doc/redis-3.2.3/00-RELEASENOTES/usr/share/doc/redis-3.2.3/BUGS/usr/share/doc/redis-3.2.3/CONTRIBUTING/usr/share/doc/redis-3.2.3/MANIFESTO / usr/share/doc/redis-3.2.3/README.md/usr/share/licenses/redis-3.2.3/usr/share/licenses/redis-3.2.3/COPYING/var/lib/redis/var/log/redis # redis log file directory / var/run/redis [root@mysql ~] # grep'^ # #'/ etc/redis.conf # # INCLUDES # NETWORK # # # GENERAL # SNAPSHOTTING # # REPLICATION # # SECURITY # LIMITS # # # # APPEND ONLY MODE # LUA SCRIPTING # # # REDIS CLUSTER # SLOW LOG # # LATENCY MONITOR # EVENT NOTIFICATION # # ADVANCED CONFIG # #

Below grep, you can see which configuration segments are in the main redis configuration file.

You can also use the following command to see which services have been turned on in the main configuration file.

[root@mysql2 ~] # cat / etc/redis.conf | grep-v'#'| sed'/ ^ $/ d' bind 0.0.0.0protected-mode noport 6379tcp-backlog 511timeout 0tcp-keepalive 300daemonize nosupervised nopidfile / var/run/redis/redis.pidloglevel noticelogfile / var/log/redis/redis.logdatabases 16save 900 1save 300 10save 60 10000stop-writes-on-bgsave-error yesrdbcompression yesrdbchecksum yesdbfilename dump.rdbdir / var/lib/redisslave-serve-stale-data yesslave-read-only yesrepl-diskless-sync norepl-diskless-sync- Delay 5repl-disable-tcp-nodelay noslave-priority 100appendonly noappendfilename "appendonly.aof" appendfsync everysecno-appendfsync-on-rewrite noauto-aof-rewrite-percentage 100auto-aof-rewrite-min-size 64mbaof-load-truncated yeslua-time-limit 5000 cluster-enabled yes cluster-config-file nodes-6379.conf cluster-node-timeout 15000slowlog-log-slower-than 10000slowlog-max-len 128latency-monitor-threshold 0notify-keyspace-events "" hash-max-ziplist-entries 512hash-max-ziplist-value 64list-max-ziplist-size-2list- Compress-depth 0set-max-intset-entries 512zset-max-ziplist-entries 128zset-max-ziplist-value 64hll-sparse-max-bytes 3000activerehashing yesclient-output-buffer-limit normal 00 0client-output-buffer-limit slave 256mb 64mb 60client-output-buffer-limit pubsub 32mb 8mb 60hz 10aof-rewrite-incremental-fsync yes

Next, analyze the contents of each configuration segment of the main configuration file / etc/redis.conf

3.1Configuration segment of INCLUDES

If you have a better configuration template, please put it in this configuration section

# include / path/to/local.conf# include / path/to/other.conf

3.2. Network configuration segment

Network configuration items:

"bind 127.0.0." allows clients connected to redis IPprotected-mode no# security mode port 637" port tcp-backlog 51 "backup queue timeout" client idle, the timeout for closing the client connection. 0 means that the tcp-keepalive 30 persistent connection timeout is not closed.

3.3. Common configuration segment

# # GENERAL # # daemonize no#. By default, redis does not run supervised no# in daemon mode. Whether to enable super supervision of pidfile / var/run/redis/redis.pidpid file path loglevel notice# day Log level logfile / var/log/redis/redis.log# specifies the log file path databases sets the number of databases

3.4. Snapshot configuration segment

RDB (brushing the data in memory to disk), RDB takes snapshots of memory and constantly snapshots and exports data. Disadvantages: easy to lose data.

Save 9001 # 900s one key change make a snapshot save 300 10 keys change in 300 seconds make a snapshot save 60 10000 # 60 seconds make a snapshot stop-writes-on-bgsave-error yes# default if there is a problem during RDB snapshots persistence, set this parameter Redis does not allow users to perform any update operations rdbcompression yes# uses LZF to compress strings and objects when exporting .RDB database files. If you want to save some CPU resources, you can set it to no, but the amount of data may be large. The check value of crc64 is written at the end of the file during the rdbchecksum yes#RDB snapshot making process. This may well ensure the correctness of the data. The cost is the performance degradation of dbfilename dump.rdb# snapshot filename dir. / # snapshot path

3.5. Master-slave configuration related segments

For configuration items related to master-slave configuration, a Master can have multiple slave hosts and support chained replication; Master synchronizes data to slave hosts in a non-blocking manner.

Slaveof # is used to create a slave server # masterauth # master server authentication password slave-serve-stale-data yes#. When slave loses its connection to master, or when replication is still being processed, slave will behave in the following two ways: yes indicates that slave continues to respond to client requests, even though the data is different. No indicates that slave will return "SYNC with master in progreee" error message; slave-read-only yes# slave server read-only repl-diskless-sync no a new slave node or a slave node that has failed to synchronize with the master node for a long time needs to re-communicate with the master node and needs to do "full synchronization". At this time, there are two style synchronization methods: Disk-backend: the master node creates a new snapshot file on disk, and then sends it to the slave node. Diskless: the master section takes up the newly created snapshot and sends it directly to the slave node through the network socket file; in order to achieve parallel replication, it is usually necessary to delay for a period of time before the replication starts Repl-diskless-sync-delay slave based on network socket synchronization latency repl-ping-slave-period 10#ping slave server interval # repl-timeout 6 master-slave replication timeout repl-disable-tcp-nodelay no# defaults to no, when yes is selected, master will send a small amount of tcp packets to slave, which has a negative impact on delay slave data acceptance time and 40 milliseconds delay In the case of high traffic or a large number of intermediate nodes between master slave, it is recommended to change the maximum memory of the yes# repl-backlog-size 1mb# backup team # repl-backlog-ttl 360 backup queue ttl duration slave-priority 10 "when the master service is down, the lower the priority slave, the more likely it is to become a master candidate # min-slaves-to-write 3 # at least when the slave node is online The master node is allowed to write data # min-slaves-max-lag 10 # how long does the slave node lag behind the master node at most # slave-announce-ip 5.5.5.5 # the IP# slave-announce-port 1234 # of the server claims the port of the server

3.6. Security-related configuration segment

# Security related # requirepass foobared# whether to set password, requirepass + password # rename-command CONFIG "" # rename or disable certain commands

3.7. limit configuration segment

# maxclients 1000 clients concurrency # maxmemory # memory limit Expiration deletes key# maxclients 10000 maximum number of concurrent connections # maxmemory Max available memory # maxmemory-policy noeviction memory obsolescence Strategy # volatile-lru-> remove the key with an expire set using an LRU algorithm obsolete keys with expiration based on LRU algorithm # allkeys-lru-> remove any key according to the LRU algorithm obsolete all keys based on LRU algorithm # volatile-random-> remove a random key with an expire set Random elimination of # allkeys-random-> remove a random key Any key randomly eliminates all keys # volatile-ttl-> remove the key with the nearest expire time (minor TTL) based on TTL duration # noeviction-> don't expire at all, just return an error on write operations never eliminates Once the memory is exhausted, the default error is: # maxmemory-policy noeviction recommends how does volatile-lru,volatile-ttl determine the elimination of memory? -- > quantitative sampling # maxmemory-samples 5

3.8. AOF mode configuration segment

AOF, or APPEND ONLY MODE, means to append files only. The data in rdis memory is synchronized to disk asynchronously by default. If downtime occurs, some data will be lost. AOF is also a way of data persistence, which can improve the reliability of data. AOF mode records each write to the end of the specified file to achieve storage persistence; when redis restarts, the database can be rebuilt in memory by re-executing the commands in the file. By default, fsync () is used to write disk data, resulting in a power outage, or up to 1 second of data is lost in the event of an internal error in Redis. AOF and RDB persistence methods can be enabled at the same time without conflict. If you start AOF mode, Redis will write the data written each time to the appendonly.aof file after receiving. Redis reads the data from this file into memory each time it starts.

Does appendonly no# record persistence log appendfilename "appendonly.aof" # AOF file appendfsync everysec# writes once per second # fsync () requests the operating system to write data to disk immediately redis supports the following three modes: no:redis does not perform active synchronization, but OS does; everysec: once per second; always: once per statement, slow but safe Whether no-appendfsync-on-rewrite no# does not call fsync during aof rewriting in the background. Default is no, which means calling. Rewriting AOF will be triggered only when the above two conditions of auto-aof-rewrite-percentage 100auto-aof-rewrite-min-size 64mb# are met at the same time. Compared with the last aof file size, its growth is more than 100%, and if the size is not less than 64MB, AOF; aof-load-truncated yes# redis can load truncated AOF files at startup, which is enabled by default; otherwise, it may fail to start Note: the persistence mechanism itself cannot replace backup; backup strategy should be formulated to back up redis libraries regularly.

3.9. LUA script configuration section

Lua-time-limit 5000#lua script execution time limit

3.10. Redis cluster configuration segment

Whether cluster-enabled yes# enables cluster cluster-config-file nodes-6379.conf# cluster profile cluster-node-timeout 1500 cluster node communication timeout

3.11. Slow start log configuration segment

The slow start log is used to record queries that exceed the specified time, but it is important to note that the run time does not include various Icano times.

For example: connect the client, send response data, and so on.

Slowlog-log-slower-than 10000slowlog-max-len 12cm slow query log length, this length is unlimited, the unit is subtle, as long as there is enough memory, you can release memory through SLOWLOG RESET.

3.12. Delay monitoring configuration segment

Latency-monitor-threshold 0

3.13. Event notification configuration segment

Notify-keyspace-events ""

3.14. Redis advanced configuration segment

Configure advanced options for redis

The maximum entrieshash-max-ziplist-value that each corresponding hash can store. When there is a large amount of data, it is suitable for hash coding but requires more memory. The upper limit of the number of elements cannot exceed the given limit. List-max-ziplist-entries 512list-max-ziplist-value 6 codes are similar to hashes, saving a lot of space by coding in another way when there are fewer list data elements. Set-max-intset-entries 512#set is encoded as a string of 64-bit unsigned integer numbers. This parameter limits the maximum limit for this encoding to be used in this case. Zset-max-ziplist-entries 128zset-max-ziplist-value 6 is similar to hashes,lists, but sorted sets also uses a special coding method to save space. This kind of encoding is only suitable for ordered sequences whose length and elements meet the above restrictions. Hll-sparse-max-bytes 3000activerehashing yesclient-output-buffer-limit normal 00 0client-output-buffer-limit slave 256mb 64mb 60client-output-buffer-limit pubsub 32mb 8mb 60hz 10aof-rewrite-incremental-fsync yes# when the child process rewrites the AOF file, when the following option is turned on, the AOF file will be synchronized every 32 megabytes of data, which helps avoid write latency to disk.

IV. Introduction to the usage of redis

4.1.The redis command options

Use the redis-cli-h command to view the usage of redis client commands. The use of the option is actually very simple, and it should be easy to get rid of English.

[root@mysql ~] # redis-cli-hredis-cli 3.2.3Usage: redis-cli [OPTIONS] [cmd [arg [arg...]-h Server hostname (default: 127.0.0.1). -p Server port (default: 6379). -s Server socket (overrides hostname and port). -a Password to use when connecting to the server. -r Execute specified command N times. -I When-r is used, waits seconds per command. It is possible to specify sub-second times like-I 0.1. -n Database number. -x Read last argument from STDIN. -d Multi-bulk delimiter in for raw formatting (default:\ n). -c Enable cluster mode (follow-ASK and-MOVED redirections) -raw Use raw formatting for replies (default when STDOUT is not a tty). -- no-raw Force formatted output even when STDOUT is not a tty. -- csv Output in CSV format. -- stat Print rolling stats about server: mem, clients,...-- latency Enter a special mode continuously sampling latency. -latency-history Like-latency but tracking latency changes over time. Default time interval is 15 sec. Change it using-I. -- latency-dist Shows latency as a spectrum, requires xterm 256 colors. Default time interval is 1 sec. Change it using-I. -- lru-test Simulate a cache workload with an 80-20 distribution. -- slave Simulate a slave showing commands received from the master. -- rdb Transfer an RDB dump from remote server to local file. -- pipe Transfer raw Redis protocol from stdin to server. -- pipe-timeout In-- pipe mode, abort with error if after sending all data. No reply is received within seconds. Default timeout: 30. Use 0 to wait forever. -- bigkeys Sample Redis keys looking for big keys. -- scan List all keys using the SCAN command. -pattern Useful with-scan to specify a SCAN pattern. -- intrinsic-latency Run a test to measure intrinsic system latency. The test will run for the specified amount of seconds. -- eval Send an EVAL command using the Lua script at. -ldb Used with-eval enable the Redis Lua debugger. -- ldb-sync-mode Like-- ldb but uses the synchronous Lua debugger, in this mode the server is blocked and script changes are are not rolled back from the server memory. -- help Output this help and exit. -- version Output version and exit. Examples: cat / etc/passwd | redis-cli-x set mypasswd redis-cli get mypasswd redis-cli-r 100 lpush mylist x redis-cli-r 100-I 1 info | grep used_memory_human: redis-cli-- eval myscript.lua key1 key2, arg1 arg2 arg3 redis-cli-- scan-- pattern'*: 12345 cycles'

The operation of some simple commands

Connect the redis server

[root@mysql ~] # redis-cli 127.0.0.1 purl 6379 >

Select the first database

127.0.0.1 6379 > select 1 OK

Select the 15th database

127.0.0.1 select 6379 [1] > 15 OK127.0.0.1:6379 [15] >

Select the 17th library and report an error. Redis defaults to 16 libraries.

127.0.0.1 ERR invalid DB index 6379 [15] > select 17 (error)

Select the default library

127.0.0.1 select 6379 [15] > 0 OK

Use help to check the use of transaction, of course, you can press the tab key to see the use of other commands

127.0.1 EXEC 6379 > help @ transactions DISCARD-summary: Discard all commands issued after MULTI since: 2.0.0 EXEC-summary: Execute all commands issued after MULTI since: 1.2.0 MULTI-summary: Mark the start of a transaction block since: 1.2.0 UNWATCH-summary: Forget about all watched keys since: 2.2.0 WATCH key [key...] Summary: Watch the given keys to determine execution of the MULTI/EXEC block since: 2.2.0

Press tab to switch to view different options

127.0.0.1 6379 > help @

When entering a command, it will automatically prompt for the following content, which is quite convenient.

127.0.0.1 PX milliseconds 6379 > set key value [EX seconds] [PX milliseconds] [NX | XX]

4.2.The redis data type

1.string string

Redis String is the most commonly used data type, and ordinary key/value storage can be classified as this type.

Foo- > bar key-value relationship # View string string related operation command help @ string # set the key value 127.0.0.1 string 6379 > SET testkey 'tom'OK# get the key value 127.0.0.1 string 6379 > get testkey "tom" # append key value Add the following values: 127.0.0.1 integer > append testkey 'neo' (integer) delete key 127.0.0.1 integer > del testkey (integer) get key 127.0.0.1 integer 6379 > get testkey (nil) # set multiple keys 127.0.0.1 > mset name' tom' age 12OK# get multiple keys 127.0.0.1 > mget name age1) "tom" 2) "12" # setting value 127.0 .0.1 get counts 6379 > set counts 1 OK# get the value 127.0.0.1 get counts "1" # minus one operation 127.0.0.1 get counts 6379 > decr counts (integer) 0127.0.0.1 get counts 6379 > get counts "0" # add one operation 127.0.0.1integer 6379 > incr counts (integer) 1127.0.1lug 6379 > incr counts (integer) acquisition value 127.0.0.1 get counts "2"

2.list list

The redis list type is actually a two-way linked list in which each child element is of type string, which means that even if you have thousands of elements in the list, the time complexity of adding a new element to the beginning or end of the list is O (1).

# View list list related operation command help @ listl:leftr:right# append a value 127.0.0.1 listl:leftr:right# 6379 > lpush mylist 'monday' (integer) to the list to view the elements in the list by index and view the element [0] That is, the first element 127.0.0.1integer 6379 > lindex mylist 0 "monday" # append a value of 127.0.0.1 sunday' 6379 > lpush mylist 'sunday' (integer) to the list to view the elements in the list by index > lindex mylist 0 "sunday" # Look at the second element 127.0.0.1 lindex mylist 1 "monday" # append a value 127.0.0.1 rpush mylist 'tuesday' (integer) 3127.0.0.1 integer > lindex mylist 2 "tuesday" # delete a value 127.0.0.1 from the right side of the list > rpop mylist "Tuesday" 127.0.0.16379 > lindex mylist 2 (nil) # get the length of the list : 6379 > llen mylist (integer) 2127.0.0.1 lpop mylist "sunday" 127.0.0.1 lpop mylist 6379 > llen mylist (integer) 1

3. Hash

Redis hash is a mapping table of field and value of type string.

# check the hash type related operation command help @ hash# to set the hash key value to stu1 and the field id The value is 1127.0.0.1hash 6379 > hset stu1 id 1 (integer) setting another hash data 127.0.0.1 hash 6379 > hset stu1 name 'tom' (integer) 1127.0.0.1 hash 6379 > hset stu1 age 12 (integer) gets all the values in the hash field 127.0.0.1tom' 6379 > hmget stu1 id name age 1) "1" 2) "tom" 3) "12" # gets all the values in hash 127.0.0 .1id 6379 > hvals stu11) "1" 2) "tom" 3) "12" # get all fields in hash 127.0.0.1 hash > hkeys stu11) "id" 2) "name" 3) "age" # get all fields and corresponding values in hash 127.0.0.1 hash 6379 > hgetall stu11) "id" 2) "1" 3) "name" 4) "tom" 5) "age" 6) "12"

4 set set

The set of redis is an unordered collection of type string.

# View the set data type related operation command 127.0.0.1 students 6379 > help @ set# to add multiple members 127.0.0.1 to the students collection > sadd students' tom' 'sam'' lili' (integer) "to add multiple members to the teachers collection 127.0.1 > sadd teachers' sam' 'jerry' (integer)" move the' lili' from the students collection to the teachers collection 127.0.0. 1tom 6379 > smove students teachers' lili' (integer) receiver gets all the members in the set 127.0.0.1 integer 6379 > smembers students1) "tom" 2) "jerry" 127.0.0.1 integer 6379 > smembers teachers1) "lili" 2) "sam" 3) "jerry" # gets the intersection of the two sets 127.0.0.1 > sinter students teachers1) "jerry" # gets the union of the two sets 127.0.0.1: 6379 > sunion students teachers1) "lili" 2) "tom" 3) "sam" 4) those members in the "jerry" # students collection there is no 127.0.0.1sam 6379 > sdiff students teachers1) "tom" # and the opposite 127.0.0.1sam 6379 > sdiff teachers students1) "lili" 2) "sam" # randomly delete a member in the collection 127.0.0.1sam 6379 > spop students1 1) "tom" "# Delete a member 127.0.0.1 integer 6379 > srem students' tom' (integer) 0

5 sorted set ordered set

The sorted set of redis is an ordered collection of string types.

# get ordered collection data type related operation command usage 127.0.0.1 jerry' 6379 > help @ sorted_set# add members of the stus collection 127.0.0.1 jerry' 6379 > zadd stus 1 'tom' 2' jerry' 3 'lucy' (integer) "sequentially add members of the teas collection 127.0.0.1 jerry' 6379 > zadd teas 1' sam' 2 'jerry' 3' lili' (integer) The number of 127.0.0.1zrank teas jerry 6379 > zcard teas (integer) Ibid. 127.0.0.1ZCARD stus (integer) > zrank teas jerry (integer) gets the index 127.0.0.1 > zrank teas jerry (integer).) "jerry" 2) "lucy" # obtains the corresponding value 127.0.1 > ZRANGEBYSCORE stus 1 in the ordered set by fraction. 2) "tom" 2) "jerry" # add an ordered set 127.0.0.1 lili' 6379 > ZADD ecscores 67 'tom' 33' lili' 89 'michael' 55' sam' (integer) score to obtain the corresponding value 127.0.0.1 lili' 6379 > ZRANGEBYSCORE ecscores 44901) "sam" 2) "tom" 3) "michael"

4.3.Using redis client / server commands

Client-side command

# get the client name Default is empty 127.0.0.1 CLIENT GETNAME 6379 > CLIENT GETNAME (nil) # set client name 127.0.0.1 CLIENT SETNAME 'mysql'OK# set client name 127.0.0.1 CLIENT GETNAME "mysql" # list client 127.0.0.1 mysql'OK# 6379 > CLIENT list id=6 addr=127.0.0.1:55374 fd=5 name= age=1619 idle=1619 flags=N db=0 sub=0 psub=0 multiid=7 addr=127.0.0.1:55376 fd=6 name=mysql age=579 idle=0 flags=N db=0 sub=0 psub=0 mul# temporarily Stop client 127.0.0.1 CLIENT REPLY 6379 > CLIENT PAUSE# kill client 127.0.0.1 CLIENT REPLY

Server-side command

# info command is very important to obtain detailed information on the server side You can view almost all kinds of detailed information 127.0.0.1 redis_version:3.2.3redis_git_sha1:00000000redis_git_dirty:0redis_build_id:672aed6eb816ad6credis_mode:standaloneos:Linux 6379 > info # Server server information redis_version:3.2.3redis_git_sha1:00000000redis_git_dirty:0redis_build_id:672aed6eb816ad6credis_mode:standaloneos:Linux 3.10.0-514.el7.x86_64 x86_64arch_bits:64multiplexing_api:epollgcc_version:4.8.5process_id:9087run_id:4788b467cdf1f8055eca00ef6bbe57b55ef20bdetcp_port:6379uptime_in_seconds:12596uptime_in_days : 0hz:10lru_clock:6928199executable:/usr/bin/redis-serverconfig_# Clients client information connected_clients:2client_longest_output_list:0client_biggest_input_buf:0blocked_clients:0# Memory memory information used_memory:834424used_memory_human:814.87Kused_memory_rss:6094848used_memory_rss_human:5.81Mused_memory_peak:834424used_memory_peak_human:814.87Ktotal_system_memory:1023938560 # Total memory total_system_memory _ human:976.50Mused_memory_lua:37888used_memory_lua_human:37.00Kmaxmemory:0 # memory unlimited maxmemory_human:0Bmaxmemory_policy:noevictionmem_fragmentation_ratio:7.30mem_allocator:jemalloc-3.6.0# Persistence persistence related information loading:0rdb_changes_since_last_save:0rdb_bgsave_in_progress:0rdb_last_save_time:1500090506rdb_last_bgsave_status:okrdb_last_ Bgsave_time_sec:0rdb_current_bgsave_time_sec:-1aof_enabled:0aof_rewrite_in_progress:0aof_rewrite_scheduled:0aof_last_rewrite_time_sec:-1aof_current_rewrite_time_sec:-1aof_last_bgrewrite_status:okaof_last_write_status:ok# Stats Statistics Information It's important, total_connections_received:6 total_commands_processed:82instantaneous_ops_per_sec:0total_net_input_bytes:3065total_net_output_bytes:35815120instantaneous_input_kbps:0.00instantaneous_output_kbps:0.00rejected_connections:0sync_full:0sync_partial_ok:0sync_partial_err:0expired_keys:0evicted_keys:0keyspace_hits:42keyspace_misses:1pubsub_channels:0pubsub_patterns:0latest_fork_usec:852migrate_cached_sockets:0# Replication # Master-slave replication related information role:masterconnected_slaves:0master_repl_offset:0repl_backlog_active:0repl_backlog_size:1048576repl_backlog_first_byte_offset:0repl_backlog_histlen:0# CPU related used_cpu_sys:8.24 kernel space used_cpu_user:4.10 user space used_cpu_sys_children:0.01used_cpu_user_children:0.00# Cluster information cluster_enabled:0# Keyspace db0:keys=10 Expires=0 Avg_ttl=0 key expiration time ttl127.0.0.1:6379 > info memory# Memory memory information # display CPU information 127.0.0.1 CPU message > info CPU# CPUused_cpu_sys:8.56used_cpu_user:4.16used_cpu_sys_children:0.01used_cpu_user_children:0.0# shutdown command 127.0.0.1 info memory# Memory 6379 > SHUTDOWN [NOSAVE | SAVE] # confi command to configure server attributes 127.0.0.1 : 6379 > CONFIG SET127.0.0.1:6379 > CONFIG GET 127.0.0.1 CONFIG REWRITE 6379 > CONFIG RESETSTAT

The use of redis will be introduced here for the time being, and next time we will introduce the application of redis.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report