简体   繁体   English

RabbitMQ将VM连接到主机

[英]RabbitMQ connecting VM to Host

I'm new-ish to networking, and I'm swimming (drowning) in semantics. 我对网络很陌生,并且在语义上畅游(沉睡)。

I have a VM which runs a Java application. 我有一个运行Java应用程序的VM。 Ideally, it would be fed inputs from the host through a RabbitMQ queue. 理想情况下,它将通过RabbitMQ队列从主机输入输入。 The Java application would then place the results on another RabbitMQ queue on a different port where it will be used by the host application. 然后,Java应用程序会将结果放在主机应用程序将使用的另一个端口上的另一个RabbitMQ队列中。 After researching it for a bit, it seems like RabbitMQ only exists in the localhost space with listeners on different ports, am I correct in this? 经过一番研究后,似乎RabbitMQ仅存在于本地主机空间中,并且侦听器位于不同的端口上,我对此是否正确?

Do I need 2 RabbitMQ servers running in tandem, then, (one on the VM and other on Host) each listening to the same port? 我是否需要2台串联运行的RabbitMQ服务器(一个在VM上,另一个在主机上),每个服务器侦听同一端口? Or do I just need one RabbitMQ server running while both applications are pointed to the same IP Address/Port? 还是在两个应用程序都指向同一IP地址/端口的同时仅需要运行一台RabbitMQ服务器?

Also, I have also read that you cannot connect as 'guest/guest' unless it is on localhost, which I understand, but how is RabbitMQ supposed to be configured/reachable to anything besides localhost? 另外,我还读到,除非以guest / guest身份在localhost上连接,否则您不能以“ guest / guest”的身份连接,但是RabbitMQ应该如何配置/可访问除localhost之外的任何内容?

I've been researching for several hours, but the documentation does not point to a direct answer/how-to guide. 我已经研究了几个小时,但是文档并未指向直接的答案/方法指南。 Perhaps it is my lack of network experience. 也许是我缺乏网络经验。 If anyone could elaborate on these questions or point me to some articles/helpful guides, I would be much obliged. 如果有人可以详细说明这些问题或为我提供一些文章/有用的指南,那我将非常有义务。

PS -- I don't even know what code to display to give context. PS-我什至不知道要显示什么代码来提供上下文。 Let me know and I'll edit the code into the post. 让我知道,我将代码编辑到帖子中。

RabbitMQ listens to TCP port 5672 on all network interfaces out-of-the-box. RabbitMQ开箱即用地侦听所有网络接口上的TCP端口5672。 This includes the "loopback" interface (to allow fast connections to self) and interfaces visible to other remote hosts (including VMs). 这包括“环回”接口(允许快速连接到自身)和其他远程主机(包括VM)可见的接口。

For your use case, you probably need a single RabbitMQ instance for both directions. 对于您的用例,两个方向可能都需要一个RabbitMQ实例。 The application on the host will publish messages to one queue and the Java application in the VM will consume messages from that queue and push the result to a second queue. 主机上的应用程序会将消息发布到一个队列中,而VM中的Java应用程序将使用该队列中的消息并将结果推送到另一个队列中。 This second queue can be consumed by the application on the host. 该第二个队列可以由主机上的应用程序使用。

For the user, you need to create a new user with the appropriate rights. 对于该用户,您需要创建一个具有适当权限的新用户。 This is documented in the access control article . 访问控制文章中对此进行了说明 To create the user, you can do it from the management web UI (after you enabled the management plugin) or using the rabbitmqctl command line tool. 要创建用户,您可以从管理Web UI(启用管理插件后)或使用rabbitmqctl命令行工具进行操作。

The last part is networking between the host and the VM. 最后一部分是主机和VM之间的网络连接。 It really depends on the technology you use. 这实际上取决于您使用的技术。 It may work out-of-the-box or you may have to configure how VMs are connected to the network. 它可能是开箱即用的,或者您可能必须配置VM如何连接到网络。 Refer to the documentation of your hypervisor. 请参阅系统管理程序的文档。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM