安装
sudo yum -y install erlang #安装erlang
sudo yum -y install rabbitmq-server
sudo systemctl enable rabbitmq-server
sudo systemctl start rabbitmq-server #启动服务
启动web管理系统
这一步不是必须的,命令行也可以
//生效管理插件
$ sudo 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.
//查看生效的插件,前面有e的就是已经生效的
$ sudo rabbitmq-plugins list
[e] amqp_client 3.3.5
[ ] cowboy 0.5.0-rmq3.3.5-git4b93c2d
[ ] eldap 3.3.5-gite309de4
[e] mochiweb 2.7.0-rmq3.3.5-git680dba8
[ ] rabbitmq_amqp1_0 3.3.5
[ ] rabbitmq_auth_backend_ldap 3.3.5
[ ] rabbitmq_auth_mechanism_ssl 3.3.5
[ ] rabbitmq_consistent_hash_exchange 3.3.5
[ ] rabbitmq_federation 3.3.5
[ ] rabbitmq_federation_management 3.3.5
[E] rabbitmq_management 3.3.5
[e] rabbitmq_management_agent 3.3.5
[ ] rabbitmq_management_visualiser 3.3.5
[ ] rabbitmq_mqtt 3.3.5
[ ] rabbitmq_shovel 3.3.5
[ ] rabbitmq_shovel_management 3.3.5
[ ] rabbitmq_stomp 3.3.5
[ ] rabbitmq_test 3.3.5
[ ] rabbitmq_tracing 3.3.5
[e] rabbitmq_web_dispatch 3.3.5
[ ] rabbitmq_web_stomp 3.3.5
[ ] rabbitmq_web_stomp_examples 3.3.5
[ ] sockjs 0.3.4-rmq3.3.5-git3132eb9
[e] webmachine 1.10.3-rmq3.3.5-gite9359c7
// 重启服务生效配置
$sudo systemctl restart rabbitmq-server
管理界面配置
访问 127.0.0.1:15672
账号密码都是guest
登入后先需改下密码,可以直接用这个新账号,添加管理员标签后可以登陆
配置vhost
// 添加虚拟机rabbitmqctl add_vhost vhost_name
$sudo rabbitmqctl add_vhost rmq
// 创建一个用户rabbitmqctl add_user username password
$sudo rabbitmqctl add_user rmq 123456
// 为用户分配角色rabbitmqctl set_user_tags username administrator/monitoring/management
$sudo rabbitmqctl set_user_tags rmq administrator
// 设置访问权限rabbitmqctl set_permissions -p vhostname username ".*" ".*" ".*"
$sudo rabbitmqctl set_permissions -p rmq rmq ".*" ".*" ".*"
当时又遇到一个异常,处理方法如下
重启rabbitmq很慢并报错如下:
rabbitmq-server[2528]: ERROR: epmd error for host iZ25jvky68fZ: timeout (timed out)
hostname的问题,尤其是老的阿里云主机切换过网络会出这种问提,修改/etc/hosts文件里的host指向的ip为本地即可,然后重启
如果遇到什么问题需要重新安装需卸载后删除
rm -rf /var/lib/rabbitmq/
网友评论