在導(dǎo)出RabbitMQ集群元數(shù)據(jù)時,RabbitMQ支持導(dǎo)出全部Vhost或某個指定的Vhost,而不支持導(dǎo)出部分Vhost。您可以先導(dǎo)出全部Vhost,然后在導(dǎo)出的元數(shù)據(jù)文件中刪除不需要的Vhost,從而間接實現(xiàn)導(dǎo)出部分Vhost。
前提條件
在導(dǎo)出RabbitMQ集群元數(shù)據(jù)前,請確保您已開啟RabbitMQ管理插件。開啟RabbitMQ管理插件后,您才可以通過RabbitMQ控制臺或HTTP API導(dǎo)出RabbitMQ集群元數(shù)據(jù)。詳情請參見
開啟RabbitMQ管理插件。
背景信息
某個RabbitMQ集群有6個Vhost(hello1
、hello_amqp
、helloAMQP
、example2test
、example3test
和/
)。本文以導(dǎo)出其中4個Vhost (hello1
、hello_amqp
、helloAMQP
、example2test
)為例進(jìn)行說明。
導(dǎo)出部分Vhost
- 參考以下任一方式導(dǎo)出包括全部Vhost的RabbitMQ集群元數(shù)據(jù)文件。
導(dǎo)出的RabbitMQ集群元數(shù)據(jù)文件的
vhosts
列表如下:
{
"vhosts":[
{
"name":"hello1"
},
{
"name":"hello_amqp"
},
{
"name":"helloAMQP"
},
{
"name":"example2test"
},
{
"name":"example3test"
},
{
"name":"/"
}
]
}
- 在導(dǎo)出的RabbitMQ集群元數(shù)據(jù)文件的
vhosts
列表中刪除不需要的example3test
和/
。
說明 當(dāng)您從vhosts
列表刪除某個Vhost后,該Vhost下的Exchange、Queue和Binding都會同時失效,即這些Exchange、Queue和Binding在導(dǎo)入消息隊列RabbitMQ版時會被自動忽略。
修改后的RabbitMQ集群元數(shù)據(jù)文件的
vhosts
列表如下:
{
"vhosts":[
{
"name":"hello1"
},
{
"name":"hello_amqp"
},
{
"name":"helloAMQP"
},
{
"name":"example2test"
}
]
}