In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
This article shows how to use commands commonly used in shell in Redis. Command examples are concise and easy to understand if you encounter this question in your daily work. I hope you can find a solution to your questions through this article.
Redis-cli
There are many options for redis-cli. In addition to the commonly used-h,-p,-a, here are some of the most commonly used options. To see all the options, you can use redis-cli-- help.
-- version to view the redis version
# redis-cli-- versionredis-cli 5.0.5
You can see that my current version is 5.0.5
-rmaine Musi
R is the abbreviation of repeat, which means to repeat several times. I is an acronym for interval, indicating how long the interval is.
For example, execute the ping command three times, every other second.
# redis-cli-r 3-I 1 ping
In addition, we introduce an api info memory of redis, which is used to count redis memory usage.
# redis-cli info memory# Memoryused_memory:878984used_memory_human:858.38Kused_memory_rss:3796992used_memory_rss_human:3.62M...
Statistical redis memory information
After introducing the above knowledge, and combined with the basics of shell, you can write a script to count the memory consumption of redis.
The shell script is as follows to get memory information every 5 seconds for a total of 6 times.
#! / bin/bashmemorys= `redis-cli-r 6-I 5 info memory | grep used_memory:\ | awk-F:'{print int ($2)} '`total=0for memory in $memorysdo echo $memory total=$ ((memory+total)) doneecho "avg:" $((total/6))
One thing to note is that in the awk line, you need to use int to convert to a numeric type, otherwise the increment in the loop will make an error, and you must make sure that the variable memory is of numeric type. The execution result of the script is as follows:
#. / bin/redis-used-memory.sh 883480883504883504883504883504883504avg:883500
Output 6 requested data respectively, and then print out the average value.
-- rdb saves the rdb file locally
With this option and with scheduled tasks, we can back up Redis data on a regular basis.
# redis-cli-- rdb/ data/redis/rdb/dump.rdbSYNC sent to master, writing 721 bytes to'/ data/redis/rdb/dump.rdb'Transfer finished with success.
If the redis contains important data, it is recommended to back up the data regularly to prevent too much loss after the data is lost.
Redis-benchmark
Redis has benchmarking tools that we can use to test the performance of redis. Here are a few common options. To know more about the use of options, use redis-benchmark-- help to see more information.
-c (clients)
Represents the number of concurrency of the client. The default is 50. 0.
-n (requests)
Represents the total number of client requests, with a default value of 100000.
For example, there are 100 clients and the total number of requests is 10000.
# redis-benchmark-c 100-n 10000
-Q
Only request data per second is displayed
Redis-benchmark-c 100-n 10000-Q PING_INLINE: 98039.22 requests per secondPING_BULK: 102040.82 requests per secondSET: 94339.62 requests per secondGET: 99009.90 requests per second.
You can see the performance of commands such as set, get, and so on per second.
-t
Benchmark the specified commands, for example, I just want to see how get and set perform:
# redis-benchmark-t get,set-qSET: 98911.96 requests per secondGET: 100200.40 requests per second
These are the common ways to use shell commands in Redis, which are more comprehensive, and I believe there are quite a few tools that we may see or use in our daily work. Through this article, I hope you can gain more.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.