CentOS 7 deploys RabbitMQ service

   Copyright statement: This article is an original article by Shaon Puppet. Please indicate the original address for reprinting. Thank you very much. https://blog.csdn.net/wh211212/article/details/53127078

Introduction to RabbitMQ#

RabbitMQ installation#

# Install from EPEL
[ root@vdevops~]# yum --enablerepo=epel -y install rabbitmq-server
[ root@vdevops~]# systemctl start rabbitmq-server
[ root@vdevops /]# journalctl -xe
Nov 1201:30:01 vdevops.org CROND[3856]:(root)CMD(/usr/lib64/sa/sa1 11)
Nov 1201:30:04 vdevops.org rabbitmqctl[3831]: DIAGNOSTICS
Nov 1201:30:04 vdevops.org rabbitmqctl[3831]:===========
Nov 1201:30:04 vdevops.org rabbitmqctl[3831]: attempted to contact:[rabbit@vdevops]
Nov 1201:30:04 vdevops.org rabbitmqctl[3831]: rabbit@vdevops:
Nov 1201:30:04 vdevops.org rabbitmqctl[3831]:* unable to connect to epmd(port 4369) on vdevops:timeout(timed out)
Nov 1201:30:04 vdevops.org rabbitmqctl[3831]: current node details:
Nov 1201:30:04 vdevops.org rabbitmqctl[3831]:- node name: rabbitmqctl3831@vdevops
Nov 1201:30:04 vdevops.org rabbitmqctl[3831]:- home dir:/var/lib/rabbitmq
Nov 1201:30:04 vdevops.org rabbitmqctl[3831]:- cookie hash: s++dDMtIhAufFItw+ercBw==
Nov 1201: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 f
Nov 1201:30:04 vdevops.org systemd[1]: rabbitmq-server.service: control process exited, code=exited status=2
Nov 1201: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 1201:30:04 vdevops.org systemd[1]: Unit rabbitmq-server.service entered failed state.
Nov 1201:30:04 vdevops.org systemd[1]: rabbitmq-server.service failed.
Nov 1201:30:42 vdevops.org systemd[1]: Got automount request for/proc/sys/fs/binfmt_misc, triggered by 3860(find)
Nov 1201: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 1201: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.

Rabbitmq-server startup error: Failed to start RabbitMQ broker
Du Niang analysis: the hostname is configured incorrectly, the original hostname is vdevops.org, change to vdevops, modify the hostname setting in the hosts file

[ root@vdevops /]# hostnamectl set-hostname vdevops  #hostname change restart 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 2016-11-1201:32:41 CST; 3min 58s ago
 Process:3831 ExecStop=/usr/lib/rabbitmq/bin/rabbitmqctl stop(code=exited, status=2)
 Main PID:3891(beam)
 CGroup:/system.slice/rabbitmq-server.service
   ├─3891/usr/lib64/erlang/erts-5.10.4/bin/beam -W 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...
   ├─3908/usr/lib64/erlang/erts-5.10.4/bin/epmd -daemon
   ├─3963 inet_gethost 4
   └─3964 inet_gethost 4

Nov 1201:32:39 vdevops systemd[1]: Starting RabbitMQ broker...
Nov 1201:32:39 vdevops systemd[1]: rabbitmq-server.service: Got notification message from PID 3908, but reception only permitted for main PID 3891
Nov 1201:32:40 vdevops rabbitmq-server[3891]: RabbitMQ 3.3.5.Copyright(C)2007-2014 GoPivotal, Inc.
Nov 1201:32:40 vdevops rabbitmq-server[3891]: ##  ##      Licensed under the MPL.  See http://www.rabbitmq.com/
Nov 1201:32:40 vdevops rabbitmq-server[3891]: ##  ##
Nov 1201:32:40 vdevops rabbitmq-server[3891]: ##########  Logs:/var/log/rabbitmq/[email protected]
Nov 1201:32:40 vdevops rabbitmq-server[3891]: ######  ##        /var/log/rabbitmq/[email protected]
Nov 1201:32:40 vdevops rabbitmq-server[3891]: ##########
Nov 1201:32:41 vdevops systemd[1]: Started RabbitMQ broker.
Nov 1201:32:41 vdevops rabbitmq-server[3891]: Starting broker... completed with0 plugins.[root@vdevops~]# systemctl enable rabbitmq-server
Created symlink from/etc/systemd/system/multi-user.target.wants/rabbitmq-server.service to /usr/lib/systemd/system/rabbitmq-server.service.
[ root@linuxprobe~]# firewall-cmd --add-port=5672/tcp --permanent
success
[ root@linuxprobe~]# firewall-cmd --reload
success 
[ root@vdevops ~]# rabbitmqctl add_user linuxprobe password
Creating user "linuxprobe"......done.[root@vdevops ~]# rabbitmqctl list_users
Listing users ...
guest   [administrator]
linuxprobe  []...done.
# granting admin role to a user is like follows
[ root@vdevops ~]# rabbitmqctl change_password linuxprobe strongpassword
Changing password for user "linuxprobe"......done.
# granting admin role to a user is like follows
[ root@vdevops ~]# rabbitmqctl set_user_tags linuxprobe administrator
Setting tags for user "linuxprobe" to [administrator]......done.
# deleting a user is like follows
[ root@vdevops ~]# rabbitmqctl delete_user linuxprobe 
Deleting user "linuxprobe "......done.
[ root@vdevops ~]# rabbitmqctl add_vhost /my_vhost
Creating vhost "/my_vhost"......done.[root@vdevops ~]# rabbitmqctl list_vhosts 
Listing vhosts ...//my_vhost
... done.[root@vdevops ~]# rabbitmqctl delete_vhost /my_vhost
Deleting vhost "/my_vhost"......done.
# 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 linuxprobe
Listing permissions for user "linuxprobe".../my_vhost   .*.*.*...done.
# deleting permission of a specific user is like follows
[ root@vdevops ~]# rabbitmqctl clear_permissions -p /my_vhost linuxprobe
Clearing permissions for user "linuxprobe"in vhost "/my_vhost"......done.

RabbitMQ: Using Web UI

[ root@vdevops ~]# rabbitmq-plugins enable rabbitmq_management
The following plugins have been enabled:
 mochiweb
 webmachine
 rabbitmq_web_dispatch
 amqp_client
 rabbitmq_management_agent
 rabbitmq_management
Plugin configuration has changed. Restart RabbitMQ for changes to take effect.[root@vdevops ~]# systemctl restart rabbitmq-server

rabbitmqadmin use#

Download rabbitmqadmin on the Web UI. Log in to the Web UI and move to "http://(hostname or IP address): 15672/cli", then the following screen is displayed, you can download rabbitmqadmin here, right click here to save rabbitmqadmin.txt, and upload it to the server Change to rabbitmqadmin and add execute permission

[ root@localhost ~]# ll /usr/local/bin/rabbitmqadmin 
- rwxr-xr-x.1 root root 36112 Nov 1117: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 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       |+-------------+----------+---------------+-------------------+---------------+------------------+------------+-------------+

Recommended Posts

CentOS 7 deploys RabbitMQ service
CentOS7 deploys NFS service
CentOs7.3 build RabbitMQ 3.6 stand-alone service
centOs install rabbitMQ
centos6.9 rabbitmq 3.6.8 upgrade 3.8.2
CentOS online installation RabbitMQ3.7
CentOS 8 enable NTP service
CentOS7.3.1611 deploys k8s1.5.2 cluster
Centos6.9 build rabbitmq 3.6.8 cluster
CentOS 7 install Docker service
CentOS 7 deploy saltstack service
Centos7 deploys Kubernetes cluster
Centos7 build DNS service
Centos6.8 deploy vnc service
install RabbitMQ on centos
Install RabbitMQ on CentOS 7
CentOS online installation RabbitMQ3.7
CentOS7 deploys k8s cluster
Install RabbitMQ on CentOS7
CentOs7.3 build Solr stand-alone service
CentOS7 install rabbitmq cluster (binary)
CentOs7.3 build ZooKeeper-3.4.9 stand-alone service
CentOS deploys Harbor mirror warehouse
Centos7.2 deployment vnc service record
centos6.9 rabbitmq set up SSL
CentOs7.3 build SolrCloud cluster service
Centos7 deploys python3 virtual environment
CentOS 6 automatically installs RabbitMQ script
Centos 7 install jdk and package service service
CentOS 7 set up NTP, SSH service
CentOS 8 (2)
RabbitMQ cluster deployment record under Centos6.9
CentOS builds a cloud service platform
CentOS 8 - install and configure NFS service
CentOS 8 (1)
CentOS 7 Tomcat service installation and configuration
Build WeChat applet service based on CentOS
Build WeChat applet service based on CentOS
Create CentOS Docker image with httpd service
Centos7 deploys HAproxy to implement Nginx cluster
CentOS7 build gerrit code review service method
Centos8 use yum to install rabbitmq tutorial