Linux redis как посмотреть

Как найти логи Redis в Ubuntu

Логи очень важны при поиске и устранении ошибок в Redis.

В стандартной установке Redis (при помощи apt-get) в Ubuntu 14.04 логи хранятся в /var/log/redis/redis-server.log.

Чтобы просмотреть последние 10 строк:

sudo tail /var/log/redis/redis-server.log

При установке Redis из исходного кода логи помещаются в /var/log/redis_6379.log. Чтобы просмотреть последние 10 строк:

sudo tail /var/log/redis_6379.log

Архив логов

Redis архивирует устаревшие логи. Чтобы просмотреть список логов, помещённых в архив:

Можно разархивировать старый лог:

sudo gunzip /var/log/redis/redis-server.log.1.gz

А затем просмотреть последние 10 строк этого файла:

sudo tail /var/log/redis/redis-server.log.1

Поиск логов

Если логи не находятся в указанных выше каталогах, попробуйте найти файлы при помощи команды find в каталоге /var/logs.

Можно также выполнить поиск по системе. Это может занять некоторое время, если в системе много файлов. Также эта операция может вернуть несколько ошибок привилегий. Общесистемный поиск логов вернёт все файлы, чьё название содержит слово redis, в том числе и установочные файлы.

find / -path /sys -prune -o -path /proc -prune -o -name *redis*

Определение места хранения логов

Место хранения логов настраивается в конфигурационном файле redis.conf (/etc/redis/redis.conf).

sudo nano /etc/redis/redis.conf

Чтобы изменить имя лог-файла или выбрать другой каталог для его хранения, отредактируйте путь.

Логи в Ubuntu 15.04

Также можно проверить логи Redis, собранные с помощью systemd. Для этого существует команда journalctl.

Примечание: системы Ubuntu 15.04+ используют systemd, хотя Ubuntu 14.04 по умолчанию использует Upstart.

Больше о настройках и логах Redis можно узнать в статье «Настройка кластера Redis на Ubuntu 14.04».

Источник

MONITOR

Available since: 1.0.0 Time complexity: ACL categories: @admin , @slow , @dangerous , MONITOR is a debugging command that streams back every command processed by the Redis server. It can help in understanding what is happening to the database. This command can both be used via redis-cli and via telnet . The ability to see all the requests processed by the server is useful in order to spot bugs in an application both when using Redis as a database and as a distributed caching system.

$ redis-cli monitor 1339518083.107412 [0 127.0.0.1:60866] "keys" "*" 1339518087.877697 [0 127.0.0.1:60866] "dbsize" 1339518090.420270 [0 127.0.0.1:60866] "set" "x" "6" 1339518096.506257 [0 127.0.0.1:60866] "get" "x" 1339518099.363765 [0 127.0.0.1:60866] "eval" "return redis.call('set','x','7')" "0" 1339518100.363799 [0 lua] "set" "x" "7" 1339518100.544926 [0 127.0.0.1:60866] "del" "x" 
$ telnet localhost 6379 Trying 127.0.0.1. Connected to localhost. Escape character is '^]'. MONITOR +OK +1339518083.107412 [0 127.0.0.1:60866] "keys" "*" +1339518087.877697 [0 127.0.0.1:60866] "dbsize" +1339518090.420270 [0 127.0.0.1:60866] "set" "x" "6" +1339518096.506257 [0 127.0.0.1:60866] "get" "x" +1339518099.363765 [0 127.0.0.1:60866] "del" "x" +1339518100.544926 [0 127.0.0.1:60866] "get" "x" QUIT +OK Connection closed by foreign host. 

Commands not logged by MONITOR

Because of security concerns, no administrative commands are logged by MONITOR ‘s output and sensitive data is redacted in the command AUTH . Furthermore, the command QUIT is also not logged.

Читайте также:  Linux script file name

Cost of running MONITOR

Because MONITOR streams back all commands, its use comes at a cost. The following (totally unscientific) benchmark numbers illustrate what the cost of running MONITOR can be. Benchmark result without MONITOR running:

$ src/redis-benchmark -c 10 -n 100000 -q PING_INLINE: 101936.80 requests per second PING_BULK: 102880.66 requests per second SET: 95419.85 requests per second GET: 104275.29 requests per second INCR: 93283.58 requests per second 
$ src/redis-benchmark -c 10 -n 100000 -q PING_INLINE: 58479.53 requests per second PING_BULK: 59136.61 requests per second SET: 41823.50 requests per second GET: 45330.91 requests per second INCR: 41771.09 requests per second 

In this particular case, running a single MONITOR client can reduce the throughput by more than 50%. Running more MONITOR clients will reduce throughput even more.

Return

Behavior change history

  • >= 6.0.0 : AUTH excluded from the command’s output.
  • >= 6.2.0 : » RESET can be called to exit monitor mode.
  • >= 6.2.4 : » AUTH , HELLO , EVAL , EVAL_RO , EVALSHA and EVALSHA_RO included in the command’s output.

This is a community website sponsored by Redis Ltd. © 2023. Redis and the cube logo are registered trademarks of Redis Ltd. Terms of use & privacy policy.

Источник

How to access Redis log file

Have Redis setup with ruby on ubuntu server, but can’t figure out how to access its log file. Tutorial says it should be here:

@akonsu No not that either. I can start and stop it, access it with redis-cli, but no idea how to find the config or log file. And can’t find anyone explaining it neither on redis.io or anywhere else

Читайте также:  User agent android linux

is there /etc directory on your system? can you run which redis-server to find out where it is installed?

You can also use: locate *redis*log to quickly find an existing installation. If you just installed it, you may need to run updatedb first, which may turn out to be slower than looking over conf 🙂

6 Answers 6

sudo tail /var/log/redis/redis-server.log -n 100 

So if the setup was more standard that should be:

sudo tail /var/log/redis_6379.log -n 100 

This outputs the last 100 lines of the file.

Where your log file is located is in your configs that you can access with:

The log file may not always be shown using the above. In that case use

tail -f `less /etc/redis/redis.conf | grep logfile|cut -d\ -f2` 

Using cat to read a log file can be a very bad if it is too long (which happens a lot in log files). Using less or tail will be safer

This is a known, but someone may find it useful: When looking for signs of crash/issues, Redis log may not help much. it may just show normal op then service online messages. So check the webserver (apache?) error log, logs for handlers such as FCGI, and in the syslog for proc kills or other alerts. Also check any tracked/historical resource useage (like Cloudlinux or newrelic graphs) in order to have insight for future — example, a massive nightly MySQL backup happening at the same time as an SEO crawler speeding the entire site (gen all cache) may cause destruction, redis out of mem, etc

Читайте также:  Не устанавливается astra linux

You can also login to the redis-cli and use the MONITOR command to see what queries are happening against Redis.

You saved my day. My use-case was to start Redis-docker and from inside the container I needed to run a script to populate the sample data. But after running docker-server in the background, and injecting data, the container was exiting. So at the end after all my commands I added the Redis-CLI monitor and it worked. Thanks.

# The working directory. # # The DB will be written inside this directory, with the filename specified # above using the 'dbfilename' configuration directive. # # The Append Only File will also be created inside this directory. # # Note that you must specify a directory here, not a file name. dir /usr/local/var/db/redis/ # Specify the log file name. Also the empty string can be used to force # Redis to log on the standard output. Note that if you use standard # output for logging but daemonize, logs will be sent to /dev/null logfile "redis_log" 

So the log file is created at /usr/local/var/db/redis/redis_log with the name redis_log

You can also try MONITOR command from redis-cli to review the number of commands executed.

Источник

Оцените статью
Adblock
detector