Answers:
sudo rabbitmqctl状态
并查找如下所示的行:
{rabbit,“ RabbitMQ”,“ 2.6.1”},
您可以简单地从命令行执行:
sudo rabbitmqctl status | grep rabbit
3.8.4
,更好的搜索字符串sudo rabbitmqctl status | grep -i "version"
。
如果rabbitimq无法启动,我发现确定版本的唯一方法是通过安装程序系统。
Eample Debian / Ubuntu:
dpkg -s rabbitmq-server | grep Version
yum list rabbitmq-server
针对Rhel / Centos / Fedora
正如Marek在本地服务器上或在远程服务器上(使用amqplib)所说的那样:
from amqplib import client_0_8 as amqp
import sys
conn = amqp.Connection(host=sys.argv[1], userid="guest", password="guest", virtual_host="/", insist=False)
for k, v in conn.server_properties.items():
print k, v
另存为checkVersion.py
并运行python checkVersion.py dev.rabbitmq.com
:
% python checkVersion.py dev.rabbitmq.com
information Licensed under the MPL. See http://www.rabbitmq.com/
product RabbitMQ
copyright Copyright (C) 2007-2011 VMware, Inc.
capabilities {}
platform Erlang/OTP
version 2.6.0
由于我一直想在Windows计算机上使用C#来执行此操作,并且当前所有答案都是针对* nix的,因此我将发布最终使用的代码:
public string GetRabbitMqVersion()
{
string prefix = "rabbitmq_server-";
var dirs = System.IO.Directory.EnumerateDirectories(@"C:\Program Files (x86)\RabbitMQ Server", string.Format("{0}*",prefix));
foreach (var dir in dirs)
{
//Just grab the text after 'rabbitmq_server-' and return the first item found
var i = dir.LastIndexOf(prefix);
return dir.Substring(i+16);
}
return "Unknown";
}
使用C#获取RMQ版本
using (var connection = connectionFactory.CreateConnection())
{
if (connection.ServerProperties.ContainsKey("version"))
Console.WriteLine("Version={0}",
Encoding.UTF8.GetString((byte[])connection.ServerProperties["version"]));
}
输出:
版本= 3.6.3
我使用以下命令将输出缩减为版本,
rabbitmqctl status | grep "{rabbit,\"RabbitMQ\""
输出:
{rabbit,"RabbitMQ","3.7.3"},
登录到管理ui,然后在右上角找到该版本。也使用以下命令查找版本
# sudo bash
# rabbitmqctl status | grep rabbit