安装RabbitMQ(一)
安装Erlang
安装erlang环境用yum安装erlangyum install erlang执行上面语句时报错说找不到包,那得先安装EPEL库yum install epel-release再执行yum install erlang---------------------
下载安装rabbitmq
mq版本连接查询地址:http://www.rabbitmq.com/releases/rabbitmq-server/v3.1.5/
下载安装rabbitmq[root@bogon local]#wget http://www.rabbitmq.com/releases/rabbitmq-server/v3.1.5/rabbitmq-server-3.1.5-1.noarch.rpm[root@bogon local]#yum -y install rabbitmq-server-3.1.5-1.noarch.rpm[root@bogon local]#rabbitmq-server start //启动 或者这样启动:rabbitmq-server -detachedWarning: PID file not written; -detached was passed.我这里是提示这个,但是rabbitmq服务已经启动成功
Transaction check error:file /usr/bin/epmd from install of erlang-erts-20.0-1.el7.centos.x86_64 conflicts with file from package esl-erlang-20.0-1.x86_64file /usr/bin/erl from install of erlang-erts-20.0-1.el7.centos.x86_64 conflicts with file from package esl-erlang-20.0-1.x86_64file /usr/bin/erlc from install of erlang-erts-20.0-1.el7.centos.x86_64 conflicts with file from package esl-erlang-20.0-1.x86_64file /usr/bin/escript from install of erlang-erts-20.0-1.el7.centos.x86_64 conflicts with file from package esl-erlang-20.0-1.x86_64file /usr/bin/run_erl from install of erlang-erts-20.0-1.el7.centos.x86_64 conflicts with file from package esl-erlang-20.0-1.x86_64file /usr/bin/to_erl from install of erlang-erts-20.0-1.el7.centos.x86_64 conflicts with file from package esl-erlang-20.0-1.x86_64file /usr/bin/dialyzer from install of erlang-dialyzer-20.0-1.el7.centos.x86_64 conflicts with file from package esl-erlang-20.0-1.x86_64file /usr/bin/ct_run from install of erlang-common_test-20.0-1.el7.centos.x86_64 conflicts with file from package esl-erlang-20.0-1.x86_64注意:出现这种情况,运行如下命令[root@bogon local]#yum remove esl-erlang-20.0-1.x86_64 esl-erlang-20.0-1.x86_64 esl-erlang-20.0-1.x86_64 esl-erlang-20.0-1.x86_64 esl-erlang-20.0-1.x86_64 esl-erlang-20.0-1.x86_64 esl-erlang-20.0-1.x86_64 esl-erlang-20.0-1.x86_64
启动成功
如果启动失败如下处理:
[root@besttone2 rabbitmq]# rabbitmq-server restart
BOOT FAILED =========== Error description: {error,{cannot_log_to_file,"/var/log/rabbitmq/rabbit@xxx2.log", {error,eacces}}} Log files (may contain more information): /var/log/rabbitmq/rabbit@xxx2.log /var/log/rabbitmq/rabbit@xxx2-sasl.log Stack trace: [{rabbit,ensure_working_log_handler,5,[{file,"src/rabbit.erl"},{line,873}]}, {rabbit,ensure_working_log_handlers,0, [{file,"src/rabbit.erl"},{line,844}]}, {rabbit,'-boot/0-fun-0-',0,[{file,"src/rabbit.erl"},{line,281}]}, {rabbit,start_it,1,[{file,"src/rabbit.erl"},{line,417}]}, {init,start_em,1,[]}, {init,do_boot,3,[]}] {"init terminating in do_boot",{error,{cannot_log_to_file,"/var/log/rabbitmq/rabbit@besttone2.log",{error,eacces}}}} init terminating in do_boot () Crash dump is being written to: erl_crash.dump...done解决措施:
/var/log/rabbitmq/ 这个目录下的两个日志文件的 用户和组 设定成rabbitmqchmod -R rabbitmq:rabbitmq /var/log/rabbitmq/
--------------------- 作者:小学肄业 来源:CSDN 原文:https://blog.csdn.net/xiaoxueyiye/article/details/78720886 版权声明:本文为博主原创文章,转载请附上博文链接!图片.png
复制一个新的窗口
安装插件[root@bogon ~]#rabbitmq-plugins enable rabbitmq_management
创建用户
[root@bogon ~]#rabbitmqctl list_users //查看用户列表[root@bogon ~]#rabbitmqctl add_user admin admin // 创建用户[root@bogon ~]#rabbitmqctl set_user_tags admin administrator // 设置角色
在浏览器中输入: http://服务器地址:15672
图片.png
查看rabbitmq安装在那里:
-
whereis rabbitmq
-
whereis erlang
查询yum安装的相关包:
yum list | grep erlang
卸载 MQ:
rpm -q -a | grep MQSeries
卸载erlang相关的包:
yum remove erlang-asn1.x86_64
使用rabbitctl添加用户
第一、添加mq用户并设置密码
root@live-mq-01:~ # rabbitmqctl add_user mq 123456
1 | root@live-mq-01:~ # rabbitmqctl add_user mq 123456 |
第二、添加mq用户为administrator角色
root@live-mq-01:~ # rabbitmqctl set_user_tags mq administrator
1 | root@live-mq-01:~ # rabbitmqctl set_user_tags mq administrator |
第三、设置mq用户的权限,指定允许访问的vhost以及write/read
root@live-mq-01:~ # rabbitmqctl set_permissions -p "/" mq ".*" ".*" ".*"Setting permissions for user "live" in vhost "/" ......done.
1 2 3 | root@live-mq-01:~ # rabbitmqctl set_permissions -p "/" mq ".*" ".*" ".*" Setting permissions for user "live" in vhost "/" ... ...done. |
第四、查看vhost(/)允许哪些用户访问
root@live-mq-01:~ # rabbitmqctl list_permissions -p /Listing permissions in vhost "/" ...mq .* .* .*...done.
1 2 3 4 | root@live-mq-01:~ # rabbitmqctl list_permissions -p / Listing permissions in vhost "/" ... mq .* .* .* ...done. |
第五、配置允许远程访问的用户,rabbitmq的guest用户默认不允许远程主机访问。
root@live-mq-01:~ # cat /etc/rabbitmq/rabbitmq.config [ {rabbit, [{tcp_listeners, [5672]}, {loopback_users, ["mq"]}]}].
1 2 3 4 | root@live-mq-01:~ # cat /etc/rabbitmq/rabbitmq.config [ {rabbit, [{tcp_listeners, [5672]}, {loopback_users, ["mq"]}]} ]. |