Since RabbitMQ is based on the Erlang language development, so before you install RabbitMQ, you need to install Erlang.
Erlang installation are of two kinds:
(1) Erlang Solution Installation ( recommended )
wget https://packages.erlang-solutions.com/erlang-solutions-1.0-1.noarch.rpm
rpm -Uvh erlang-solutions-1.0-1.noarch.rpm
yum install erlang
(2) from EPEL source installation (Erlang version installed in this way may not be current, and sometimes can not meet the minimum required version of RabbitMQ)
yum install epel-release
yum install erlang
Installation RabbitMQ:
wget http://www.rabbitmq.com/releases/rabbitmq-server/v3.6.15/rabbitmq-server-3.6.15-1.el7.noarch.rpm
After the download is complete the installation:
yum install rabbitmq-server-3.6.15-1.el7.noarch.rpm
If you experience when you install the following dependence error:
Error: Package: SOCATA-1.7.2.3-1.el6.x86_64 (warm) Requires: libreadline.so.5 () (64bit)
You may try to perform:
yum install socat
RabbitMQ some of the basic operations:
# Add the boot RabbitMQ service
systemctl enable rabbitmq-server.service
# Check the service status
systemctl status rabbitmq-server.service
# Start Service
systemctl start rabbitmq-server.service
# Out of service
systemctl stop rabbitmq-server.service
# View all current users
rabbitmqctl list_users
# Default guest user's viewing permissions
rabbitmqctl list_user_permissions guest
# Due to RabbitMQ default account user name and password are guest. To be safe, first delete the default user
rabbitmqctl delete_user guest
# Add a new user
rabbitmqctl add_user username password
# Set the user tag
rabbitmqctl set_user_tags username administrator
# Gives all the operating authority of the user's default vhost
rabbitmqctl set_permissions -p / username ".*" ".*" ".*"
# View a user's permissions
rabbitmqctl list_user_permissions username
For more on
rabbitmqctl
the use, you can refer to the help manual .Open web management interface
If only from the command line operation RabbitMQ, somewhat inconvenient. Fortunately, RabbitMQ comes with a web management interface, only you need to start the plug-in can be used.
rabbitmq-plugins enable rabbitmq_management
Visit: http: // localhost: 15672
Configuration RabbitMQ
RabbitMQ on the configuration, you can download the RabbitMQ profile template to
/etc/rabbitmq/rabbitmq.config
follow the needs of your changes.
On the specific role of each configuration item can refer to the official documentation .Open User Remote Access
By default, the default RabbitMQ of
guest
users only allow access to the machine, if you wantguest
users to remotely access, then only need to profileloopback_users
list is set to be empty, as follows:{loopback_users, []}
Also on the newly added users, directly from, if you want to add new users only local access remote access, user names can be added to the list above, such as only allowing the
admin
user to access the machine.{loopback_users, ["admin"]}
restart …
View log location
systemctl status rabbitmq-server.service
Here you can see the location of log files, go to the file location, open the file:
Shown here is the configuration file is not found, we can create this file yourself:
cd /etc/rabbitmq/
vim rabbitmq.config
Edit follows:
[{rabbit, [{loopback_users, []}]}].
The meaning here is open to use, rabbitmq default user guest created a password is guest, only the default user is the local access, localhost or 127.0.0.1, you need to add the above configuration from external access.
After saving the configuration restart the service:
systemctl stop rabbitmq-server.service
systemctl start rabbitmq-server.service
At this point you can access from the outside, but this time look at the log file, or the original content was found, or not found the display configuration file, you can delete the files manually restart the service, but this does not affect the use of:
rm rabbit\@mythsky.log
service rabbitmq-server stop
service rabbitmq-server start
Note: Remember to open port 5672 and 15672 (iptables version)
/iptables -I INPUT -p tcp --dport 5672 -j ACCEPT
/iptables -I INPUT -p tcp --dport 15672 -j ACCEPT
WEB UI:
设置权限
rabbitmqctl add_vhost admin
rabbitmqctl set_permissions -p admin admin ".*" ".*" ".*"
注释:主要是set_permissions的使用,先看下命令的格式:
set_permissions [-p vhost] {user} {conf} {write} {read}
需要注意以下几点的理解:
1.这里的权限,只是针对一般用户的访问权限,注意和角色的区分。举个例子来说,非管理用户(普通用户),角色设置为none,然后在这里配置conf、write、read的权限。
2.conf、write、read采用正则表达式,这里的正则主要是针对exchange和queue。主要2种特殊的表达式:
^$:表示完全不匹配(即没有权限)
.*:表示匹配所有(即所有权限)
常用命令
add_user <UserName> <Password>
delete_user <UserName>
change_password <UserName> <NewPassword>
list_users
add_vhost <VHostPath>
delete_vhost <VHostPath>
list_vhostsset_permissions [-p <VHostPath>] <UserName> <Regexp> <Regexp> <Regexp>
clear_permissions [-p <VHostPath>] <UserName>
list_permissions [-p <VHostPath>]
list_user_permissions <UserName>
list_queues [-p <VHostPath>] [<QueueInfoItem> ...]
list_exchanges [-p <VHostPath>] [<ExchangeInfoItem> ...]
list_bindings [-p <VHostPath>]
list_connections [<ConnectionInfoItem> ...]