RabbitMQ installation, the cluster configuration windows environment

The company should be the selection of several common messaging middleware, RabbitMQ as the final choice of technical standards ActiveMQ, RabbitMQ, RocketMQ in. RabbitMQ paper record of the installation process.

 

1, first of all look at the three main problems we use messaging middleware to solve:

  a, decoupling between the system: between two systems originally (strongly dependent) direct call can be decoupled by the intermediate addition of messaging middleware.

  B, clipping (high concurrency): e.g. spike scene, an upstream line system efficiency is high (10,000 moment generated orders), the business logic of the system downstream of the spike complex and time-consuming, may be added in the middle of the message middleware, upstream system mq send a message to, the downstream processing system according to their ability to take in the timing of the tasks mq, so that the overall system robustness is enhanced.

  C, asynchronous: the original is set during the execution of the synchronization sequence (A-> B-> C), while performing some processes can be changed (A-> B and A-> C simultaneously performed), so that the external variable overall system response fast.

 

2, rabbitmq using erlang language development, so the installation of the first installed erlang environment, and different versions of rabbitmq corresponding to different erlang version, which point to pay special attention, otherwise installed not up and running, the specific can be viewed in rabbitmq official website version correspondence. The other is the attention .erlang.cookie file in the c: \ windows directory must have the best, otherwise I might not up and running. Install a lot of online tutorials, such as:

https://blog.csdn.net/qq_36505948/article/details/82734133

After installation is complete, you can access the management console through the browser address  http: // localhost: 15672  using the guest user name, password guest logon to view.

Note: guest account can only be used by way of the browser to log on locally, not remotely log in or create connection systems development approach. For example, the following code will go wrong:

ConnectionFactory factory = new ConnectionFactory();

factory.HostName = "172.16.170.75";

factory.UserName = "guest";

factory.Password = "guest";

using (IConnection conn = factory.CreateConnection ()) - Authentication error will occur

The solution is to add a new station in the management of the account.

 

3, rabbitmq switching center (Exchange) may interface a plurality of message queues (Queue), the system sends a message to an upstream Exchange, Exchange matching rules set forward the message to the corresponding Queue inside. Three modes: the mode Fanout and forwards the message to all the Queue; the Direct mode, routingkey with bindingKey exact match, will be sent to the corresponding Queue; under Topic mode, routingkey bindingKey and, when in line with the matching rule, will be sent to the corresponding Queue. Want to use Direct mode straightforward enough.

 

4, rabbitmq news persistent storage, need to declare switching center (Exchange), the message queue (Queue) are persistent mode (durable = true), or in case of a hung message service, the message is lost.

 

5, rabbitmq local news generally stored in C: \ Users \ Administrator \ AppData \ Roaming \ RabbitMQ \ db \ rabbit @ WIN-GJAQLSGL4BB-mnesia \ msg_stores \ under vhosts directory (windows environment, Administrator for the windows currently logged in user account, WIN- GJAQLSGL4BB the machine name), *. rdq file for persistence. After the service starts, it will send a message to be loaded into memory from rdq file. Note that, if the file explorer (document window) to open these directories rabbitmq, the service is restarted after, there may be displayed state = DOWN, not available. I suspect because permissions conflict, the solution is to close the file window to restart the service.

 

6, high-availability cluster configuration windows environment

  a, two machines are installed and erlang RabbitMQ; 

  B, two machines were modified hosts file, as follows (the contents of both machines the same):

    172.16.170.75 rabbit@WIN-GJAQLSGL4BB

    172.16.170.74 rabbit@WIN-GJAQLSGL4BA

   C, the two machines are increased profile rabbitmq.config (C: \ Users \ Administrator \ AppData \ Roaming \ directory under RabbitMQ), as follows (note that the last point of not less content as two machines.):

    [{rabbit,[{cluster_nodes,['rabbit@WIN-GJAQLSGL4BA','rabbit@WIN-GJAQLSGL4BB']}]}].

   d, increased profile of two machines, as follows (note that the machine name and address of the machine- ip):

    NODENAME=rabbit@WIN-GJAQLSGL4BB

    NODE_IP_ADDRESS=172.16.170.75

    NODE_PORT=5672

    RABBITMQ_MNESIA_BASE=C:\Users\Administrator\AppData\Roaming\RabbitMQ\db

    RABBITMQ_LOG_BASE=C:\Users\Administrator\AppData\Roaming\RabbitMQ\log

   e, the two machines to ensure consistent .erlang.cookie file (this file hash value is used to verify the identity of the cluster communication): Copy a machine .erlang.cookie to (c another machine: \ Users \ Administrator, and C: \ Windows \ System32 \ config \ systemprofile two directories)

   f, turn off the firewall! Or set inbound and outbound firewall rules (the first time I turn off the firewall configuration because it did not cause a problem Unexplained) , otherwise the latter will fail. Open these port numbers: 4369, 5672, 15672, 25672

   g, in rabbitmq rabbit @ WIN-GJAQLSGL4BB machine installation directory (C: \ Program Files \ RabbitMQ Server \ rabbitmq_server-3.7.5 \ sbin>) Run the following commands:

    rabbitmqctl stop_app (close node)

    rabbitmqctl reset (reset configuration)

    rabbitmqctl start_app (node ​​restart)

   h, the rabbitmq rabbit @ WIN-GJAQLSGL4BA machine installation directory (C: \ Program Files \ RabbitMQ Server \ rabbitmq_server-3.7.5 \ sbin>) Run the following commands:

    rabbitmqctl stop_app (close node)

    rabbitmqctl reset (reset configuration)

    rabbitmqctl join_cluster rabbit @ WIN-GJAQLSGL4BB (to another node added to the cluster)

    rabbitmqctl start_app (node ​​restart)

  This time should be able to see from a management station node becomes 2 a. Figure:  

 

 

  i, the management station Admim - "policies, add a strategy, here is the match all means, no matter what the message node message producer to send a message, the message will be within all server nodes in the cluster storage. High Availability mode setting Baidu other specific inquiries.

   

 

  j, OK, this step can be carried out destructive testing. RabbitMQ server to shut down one of them, the consumer can still get messages from other nodes in the server. When the server is restarted, the message has not been consumed will be automatically synchronized to the machine.

Guess you like

Origin www.cnblogs.com/coldlight/p/11830517.html