This article addresses various methods for determining the Redis server version you're connected to, focusing on the INFO
command and exploring alternative approaches.
The INFO
command in Redis is a versatile tool that provides a wealth of information about the server's status and configuration. To specifically view the Redis version, you can use the INFO
command alone, or more specifically, INFO server
. The output will contain a line that explicitly states the version.
For example, connecting to your Redis server via the redis-cli
command-line tool, you would execute:
redis-cli INFO
or, for a more concise output focusing solely on server information:
redis-cli INFO server
The output will resemble this (the version number will differ depending on your installation):
<code># Server redis_version:6.2.6 redis_git_sha1:00000000 redis_git_dirty:0 redis_build_id:6d03a23a05373240 redis_mode:standalone os:Linux 5.15.0-76-generic x86_64 arch_bits:64 multiplexing_api:epoll gcc_version:11.3.0 process_id:12345 run_id:67890abcdef tcp_port:6379 uptime_in_seconds:3600 uptime_in_days:0 hz:10 configured_hz:10 lru_clock:1678901234 executable:redis-server config_file:/etc/redis/redis.conf</code>
The redis_version
line clearly indicates the Redis version. The other lines provide additional details about the server's environment and configuration.
The primary and most straightforward way to determine the Redis server version is by using the INFO
command as detailed above. This command provides a comprehensive overview of the server's state, including the version number. This method is preferred because it’s directly supported by Redis and provides other valuable information alongside the version.
The INFO
command offers a wealth of information beyond just the version number. The output is structured into sections, each providing details on a specific aspect of the Redis server. Key sections and their information include:
You can obtain specific sections by appending the section name to the INFO
command (e.g., INFO memory
, INFO clients
). Running INFO
without any arguments provides all sections.
While the INFO
command is the recommended approach, a few alternative methods exist, though they are less direct and comprehensive:
redis-server
executable: You could inspect the redis-server
executable itself, often found in /usr/local/bin
or /usr/bin
. The version information might be embedded within the executable's metadata (though accessing this varies depending on your OS and tools). This method is not reliable as it doesn't necessarily reflect the running instance's version.redis.conf
) might contain a comment or setting indicating the version used during installation, but this is not guaranteed and unreliable.In summary, using the INFO
command (specifically INFO server
) is the most efficient, reliable, and recommended way to determine the Redis server version. It provides the version information directly and alongside a wealth of other valuable server details.
The above is the detailed content of How to view version using INFO command in Redis. For more information, please follow other related articles on the PHP Chinese website!