Deploy the RabbitMQ service in CentOS 7

Source: Internet
Author: User
Tags rabbitmq rabbitmq tutorial amq

Deploy the RabbitMQ service in CentOS 7
GuideMQ is called Message Queue. MQ is a communication method for applications. Applications communicate by reading and writing messages in and out of the queue (for Application Data) without dedicated connections. Message transmission refers to the communication between programs by sending data in messages, rather than by directly calling each other. Direct calls are usually used for such remote process calls. Queuing means that applications communicate through queues. The use of the queue removes the need to receive and send applications simultaneously. Among them, more mature MQ products include ibm websphere mq and so on.

About RabbitMQ
  • The message proxy software of RabbitMQ is installed to implement AMQP (Advanced Message Queue Protocol)
  • RabbitMQ Tutorial: http://www.rabbitmq.com/getstarted.html
  • RabbitMQ installation: http://www.rabbitmq.com/download.html
  • RabbitMQ column: http://blog.csdn.net/column/details/rabbitmq.html
RabbitMQ Installation
# Install from EPEL[root@vdevops~]# yum --enablerepo=epel -y install rabbitmq-server[root@vdevops~]# systemctl start rabbitmq-server[root@vdevops /]# journalctl -xeNov 12 01:30:01 vdevops.org CROND[3856]: (root) CMD (/usr/lib64/sa/sa1 1 1)Nov 12 01:30:04 vdevops.org rabbitmqctl[3831]: DIAGNOSTICSNov 12 01:30:04 vdevops.org rabbitmqctl[3831]: ===========Nov 12 01:30:04 vdevops.org rabbitmqctl[3831]: attempted to contact: [rabbit@vdevops]Nov 12 01:30:04 vdevops.org rabbitmqctl[3831]: rabbit@vdevops:Nov 12 01:30:04 vdevops.org rabbitmqctl[3831]: * unable to connect to epmd (port 4369) on vdevops: timeout (timed out)Nov 12 01:30:04 vdevops.org rabbitmqctl[3831]: current node details:Nov 12 01:30:04 vdevops.org rabbitmqctl[3831]: - node name: rabbitmqctl3831@vdevopsNov 12 01:30:04 vdevops.org rabbitmqctl[3831]: - home dir: /var/lib/rabbitmqNov 12 01:30:04 vdevops.org rabbitmqctl[3831]: - cookie hash: s++dDMtIhAufFItw+ercBw==Nov 12 01:30:04 vdevops.org polkitd[1007]: Unregistered Authentication Agent for unix-process:3798:36632 (system bus name :1.23, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8) (disconnected fNov 12 01:30:04 vdevops.org systemd[1]: rabbitmq-server.service: control process exited, code=exited status=2Nov 12 01:30:04 vdevops.org systemd[1]: Failed to start RabbitMQ broker.-- Subject: Unit rabbitmq-server.service has failed-- Defined-By: systemd-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel-- -- Unit rabbitmq-server.service has failed.-- -- The result is failed.Nov 12 01:30:04 vdevops.org systemd[1]: Unit rabbitmq-server.service entered failed state.Nov 12 01:30:04 vdevops.org systemd[1]: rabbitmq-server.service failed.Nov 12 01:30:42 vdevops.org systemd[1]: Got automount request for /proc/sys/fs/binfmt_misc, triggered by 3860 (find)Nov 12 01:30:42 vdevops.org systemd[1]: Mounting Arbitrary Executable File Formats File System...-- Subject: Unit proc-sys-fs-binfmt_misc.mount has begun start-up-- Defined-By: systemd-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel-- -- Unit proc-sys-fs-binfmt_misc.mount has begun starting up.Nov 12 01:30:42 vdevops.org systemd[1]: Mounted Arbitrary Executable File Formats File System.-- Subject: Unit proc-sys-fs-binfmt_misc.mount has finished start-up-- Defined-By: systemd-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel-- -- Unit proc-sys-fs-binfmt_misc.mount has finished starting up.-- -- The start-up result is done.

Error in rabbitmq-server startup: Failed to start RabbitMQ broker

Du Niang resolution: Host hostname configuration error. The original hostname is vdevops.org, changed to vdevops, and changed the hostname settings in the hosts file.

[Root @ vdevops/] # hostnamectl set-hostname vdevops # hostname change restart start rabbitmq-server [root @ vdevops/] # systemctl status rabbitmq-server ● rabbitmq-server.service-RabbitMQ broker Loaded: loaded (/usr/lib/systemd/system/rabbitmq-server.service; disabled; vendor preset: disabled) Active: active (running) since Sat 01:32:41 CST; 3 min 58 s ago Process: 3831 ExecStop =/usr/lib/rabbitmq/bin/rabbitm Qctl stop (code = exited, status = 2) Main PID: 3891 (beam) CGroup:/system. slice/rabbitmq-server.service restart-3891/usr/lib64/erlang/erts-5.10.4/bin/beam-W-K true-A30-P 1048576 ---root/usr/lib64/erlang-progname erl ---home/var/lib/rabbitmq ---pa/usr/lib/rabbitmq/lib/rabbitmq_server-3.3.5/sbin /.. /ebin-nos... capacity-3908/usr/lib64/erlang/erts-5.10.4/bin/epmd-daemon capacity-3963 inet_gethost 4 Capacity-3964 Inet_gethost 4Nov 12 01:32:39 vdevops restart EMD [1]: Starting RabbitMQ broker... nov 12 01:32:39 vdevops systemd [1]: rabbitmq-server.service: Got notification message from PID 3908, but failed tion only permitted for main PID 3891Nov 12 01:32:40 vdevops rabbitmq-server [3891]: RabbitMQ 3.3.5. copyright (C) 2007-2014 GoPivotal, Inc. nov 12 01:32:40 vdevops rabbitmq-server [3891]: #### Licensed under the MP L. see http://www.rabbitmq.com/Nov 12 01:32:40 vdevops rabbitmq-server [3891]: ### Nov 12 01:32:40 vdevops rabbitmq-server [3891]: ########## Logs: /var/log/rabbitmq/rabbit@vdevops.logNov 12 01:32:40 vdevops rabbitmq-server [3891]: ########/var/log/rabbitmq/rabbit@vdevops-sasl.logNov 12 01:32:40 vdevops rabbitmq-server [3891]: ########## Nov 12 01:32:41 vdevops systemd [1]: Started RabbitMQ broker. no V 12 01:32:41 vdevops rabbitmq-server [3891]: Starting broker... completed with 0 plugins. [root @ vdevops ~] # Systemctl enable rabbitmq-serverCreated symlink from/etc/systemd/system/multi-user.target.wants/rabbitmq-server.service to/usr/lib/systemd/system/rabbitmq-server.service.
Firewall settings
[root@linuxprobe~]# firewall-cmd --add-port=5672/tcp --permanentsuccess[root@linuxprobe~]# firewall-cmd --reloadsuccess 
To use RabbitMQ, add a user first.
[root@vdevops ~]# rabbitmqctl add_user linuxprobe passwordCreating user "linuxprobe" ......done.[root@vdevops ~]# rabbitmqctl list_usersListing users ...guest   [administrator]linuxprobe  []...done.# granting admin role to a user is like follows[root@vdevops ~]# rabbitmqctl change_password linuxprobe strongpasswordChanging password for user "linuxprobe" ......done.# granting admin role to a user is like follows[root@vdevops ~]# rabbitmqctl set_user_tags linuxprobe administratorSetting tags for user "linuxprobe" to [administrator] ......done.# deleting a user is like follows[root@vdevops ~]# rabbitmqctl delete_user linuxprobe Deleting user "linuxprobe " ......done.
To use RabbitMQ, you must also add a virtual host.
[root@vdevops ~]# rabbitmqctl add_vhost /my_vhostCreating vhost "/my_vhost" ......done.[root@vdevops ~]# rabbitmqctl list_vhosts Listing vhosts ...//my_vhost...done.[root@vdevops ~]# rabbitmqctl delete_vhost /my_vhostDeleting vhost "/my_vhost" ......done.
Authorize the user of the VM as follows:
# rabbitmqctl set_permissions [-p vhost] [user] [permission ? (modify) (write) (read)][root@vdevops ~]# rabbitmqctl set_permissions -p /my_vhost linuxprobe ".*" ".*" ".*"Setting permissions for user "linuxprobe" in vhost "/my_vhost" ......done.# [root@vdevops ~]#  rabbitmqctl list_user_permissions linuxprobeListing permissions for user "linuxprobe" .../my_vhost   .*  .*  .*...done.# deleting permission of a specific user is like follows[root@vdevops ~]# rabbitmqctl clear_permissions -p /my_vhost linuxprobeClearing permissions for user "linuxprobe" in vhost "/my_vhost" ......done.
RabbitMQ: Use Web UI
[root@vdevops ~]# rabbitmq-plugins enable rabbitmq_managementThe following plugins have been enabled:  mochiweb  webmachine  rabbitmq_web_dispatch  amqp_client  rabbitmq_management_agent  rabbitmq_managementPlugin configuration has changed. Restart RabbitMQ for changes to take effect.[root@vdevops ~]# systemctl restart rabbitmq-server
Client Access

Http: // vdevops: 15672/

Use rabbitmqadminYou can configure RabbitMQ to use rabbitmqadmin

Download rabbitmqadmin from the Web UI. Log on to the Web UI and move to "http: // (host name or IP address): 15672/hosts". Then, upload the file to the server and change it to rabbitmqadmin, and add the execution permission.

Upload rabbitmqadmin to the RabbitMQ server and set the appropriate permissions. This example shows the following settings:
[root@localhost ~]# ll /usr/local/bin/rabbitmqadmin -rwxr-xr-x. 1 root root 36112 Nov 11 17:23 /usr/local/bin/rabbitmqadmin[root@vdevops bin]# rabbitmqadmin list users+------------+------------------------------+---------------+|    name    |        password_hash         |     tags      |+------------+------------------------------+---------------+| guest      | k2rhpzCrZBKkY5WRhUWrGm5DCkg= | administrator || linuxprobe | P+YxK1QXIYrJpek5i//rPjn5SME= | administrator |+------------+------------------------------+---------------+[root@vdevops bin]# cd[root@vdevops ~]# rabbitmqadmin list users+------------+------------------------------+---------------+|    name    |        password_hash         |     tags      |+------------+------------------------------+---------------+| guest      | k2rhpzCrZBKkY5WRhUWrGm5DCkg= | administrator || linuxprobe | P+YxK1QXIYrJpek5i//rPjn5SME= | administrator |+------------+------------------------------+---------------+[root@vdevops ~]# rabbitmqadmin list vhosts+-----------+---------+|   name    | tracing |+-----------+---------+| /         | False   || /my_vhost | False   |+-----------+---------+

Rabbitmqadmin more use tutorial reference: http://www.rabbitmq.com/management-cli.html

[root@vdevops ~]# rabbitmqadmin declare user name=centos password=password tags=administrator user declared[root@vdevops ~]# rabbitmqadmin declare permission vhost=/vhost01 user=centos configure=".*" write=".*" read=".*" *** vhost_or_user_not_found[root@vdevops ~]# rabbitmqadmin declare vhost name=/vhost01 vhost declared[root@vdevops ~]# rabbitmqadmin declare permission vhost=/vhost01 user=centos configure=".*" write=".*" read=".*" permission declared[root@vdevops ~]# rabbitmqadmin -V /vhost01 -u centos -p password declare queue name=my_queue01 queue declared[root@vdevops ~]# rabbitmqadmin -V /vhost01 -u centos -p password publish routing_key=my_queue01 payload='Hello RabbitMQ World!' exchange=amq.default Message published[root@vdevops ~]# rabbitmqadmin -V /vhost01 -u centos -p password get queue=my_queue01 requeue=false+-------------+----------+---------------+-----------------------+---------------+------------------+------------+-------------+<>| routing_key | exchange | message_count |        payload        | payload_bytes | payload_encoding | properties | redelivered |+-------------+----------+---------------+-----------------------+---------------+------------------+------------+-------------+| my_queue01  |          | 0             | Hello RabbitMQ World! | 21            | string           |            | False       |+-------------+----------+---------------+-----------------------+---------------+------------------+------------+-------------+[root@vdevops ~]# rabbitmqadmin -V /vhost01 -u centos -p password publish routing_key=my_queue01 payload='Hello LinuxProbe!' exchange=amq.default Message published[root@vdevops ~]# rabbitmqadmin -V /vhost01 -u centos -p password get queue=my_queue01 requeue=false+-------------+----------+---------------+-------------------+---------------+------------------+------------+-------------+| routing_key | exchange | message_count |      payload      | payload_bytes | payload_encoding | properties | redelivered |+-------------+----------+---------------+-------------------+---------------+------------------+------------+-------------+| my_queue01  |          | 0             | Hello LinuxProbe! | 17            | string           |            | False       |+-------------+----------+---------------+-------------------+---------------+------------------+------------+-------------+

Original address: http://www.linuxprobe.com/ethernet-channel-bonding.html


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.