CentOS上面使用yum安装比较方便
先记录一些rabbitmq的基本操作命令:
$ sudo chkconfig rabbitmq-server on # 添加开机启动RabbitMQ服务 $ sudo /sbin/service rabbitmq-server start # 启动服务 $ sudo /sbin/service rabbitmq-server status # 查看服务状态 $ sudo /sbin/service rabbitmq-server stop # 停止服务 # 查看当前所有用户 $ sudo rabbitmqctl list_users # 查看默认guest用户的权限 $ sudo rabbitmqctl list_user_permissions guest # 由于RabbitMQ默认的账号用户名和密码都是guest。为了安全起见, 先删掉默认用户 $ sudo rabbitmqctl delete_user guest # 添加新用户 $ sudo rabbitmqctl add_user username password # 设置用户tag $ sudo rabbitmqctl set_user_tags username administrator # 赋予用户默认vhost的全部操作权限 $ sudo rabbitmqctl set_permissions -p / username ".*" ".*" ".*" # 查看用户的权限 $ sudo rabbitmqctl list_user_permissions username
准备工作:
Centos自带yum,首先给yum换源,换成国内的阿里云
第一步:安装erlang
安装rpm仓库:
[[email protected] ~]$ sudo rpm -Uvh http://ftp.riken.jp/Linux/fedora/epel/7/x86_64/e/epel-release-7-10.noarch.rpm
安装erlang
[[email protected] ~]$ yum install erlang
第二步:安装rabbitmq
先下载rpm
[[email protected] ~]$ sudo wget https://www.rabbitmq.com/releases/rabbitmq-server/v3.6.10/rabbitmq-server-3.6.10-1.el7.noarch.rpm
安装
[[email protected] ~]$ sudo yum install rabbitmq-server-3.6.10-1.el7.noarch.rpm
安装完成后启动服务:
[[email protected] ~]$ sudo yum install rabbitmq-server-3.6.10-1.el7.noarch.rpm
查看服务状态:
[[email protected] ~]$ service rabbitmq-server status
详细信息:
[[email protected] ~]$ sudo service rabbitmq-server status [sudo] password for hongdada: Redirecting to /bin/systemctl status rabbitmq-server.service ● rabbitmq-server.service - RabbitMQ broker Loaded: loaded (/usr/lib/systemd/system/rabbitmq-server.service; disabled; vendor preset: disabled) Active: active (running) since 日 2017-07-23 22:10:39 CST; 4min 3s ago Main PID: 34634 (beam.smp) Status: "Initialized" CGroup: /system.slice/rabbitmq-server.service ├─34634 /usr/lib64/erlang/erts-5.10.4/bin/beam.smp -W w -A 128 -P 1048576 -t 5000000 -stbt db -zdbbl 32000 -K true -- -root /... ├─34775 /usr/lib64/erlang/erts-5.10.4/bin/epmd -daemon ├─34977 inet_gethost 4 └─34978 inet_gethost 4 7月 23 22:10:38 localhost.localdomain rabbitmq-server[34634]: RabbitMQ 3.6.10. Copyright (C) 2007-2017 Pivotal Software, Inc. 7月 23 22:10:38 localhost.localdomain rabbitmq-server[34634]: ## ## Licensed under the MPL. See http://www.rabbitmq.com/ 7月 23 22:10:38 localhost.localdomain rabbitmq-server[34634]: ## ## 7月 23 22:10:38 localhost.localdomain rabbitmq-server[34634]: ########## Logs: /var/log/rabbitmq/[email protected] 7月 23 22:10:38 localhost.localdomain rabbitmq-server[34634]: ###### ## /var/log/rabbitmq/[email protected]sasl.log 7月 23 22:10:38 localhost.localdomain rabbitmq-server[34634]: ########## 7月 23 22:10:38 localhost.localdomain rabbitmq-server[34634]: Starting broker... 7月 23 22:10:39 localhost.localdomain rabbitmq-server[34634]: systemd unit for activation check: "rabbitmq-server.service" 7月 23 22:10:39 localhost.localdomain systemd[1]: Started RabbitMQ broker. 7月 23 22:10:39 localhost.localdomain rabbitmq-server[34634]: completed with 0 plugins.
查看对应的日志文件:
[[email protected] ~]$ cd /var/log/rabbitmq/ [[email protected] rabbitmq]$ ls [email protected] [email protected]-sasl.log [[email protected] rabbitmq]$ vi [email protected]
日志文件内容:
=INFO REPORT==== 23-Jul-2017::22:10:38 === Starting RabbitMQ 3.6.10 on Erlang R16B03-1 Copyright (C) 2007-2017 Pivotal Software, Inc. Licensed under the MPL. See http://www.rabbitmq.com/ =INFO REPORT==== 23-Jul-2017::22:10:38 === node : [email protected] home dir : /var/lib/rabbitmq config file(s) : /etc/rabbitmq/rabbitmq.config (not found) cookie hash : uyKwm1mYlbUecxvrRAhaaQ== log : /var/log/rabbitmq/[email protected] sasl log : /var/log/rabbitmq/[email protected]sasl.log database dir : /var/lib/rabbitmq/mnesia/[email protected] =INFO REPORT==== 23-Jul-2017::22:10:39 === Memory limit set to 1509MB of 3774MB total. =INFO REPORT==== 23-Jul-2017::22:10:39 === Enabling free disk space monitoring =INFO REPORT==== 23-Jul-2017::22:10:39 === Disk free limit set to 50MB "[email protected]" [只读] 75L, 2451C
发现/etc/rabbitmq/rabbitmq.config不存在
先创建用户:
[[email protected] system]$ sudo chkconfig rabbitmq-server on 注意:正在将请求转发到“systemctl enable rabbitmq-server.service”。 Created symlink from /etc/systemd/system/multi-user.target.wants/rabbitmq-server.service to /usr/lib/systemd/system/rabbitmq-server.service. [[email protected] system]$ sudo rabbitmqctl list_users Listing users guest [administrator] [[email protected] system]$ sudo rabbitmqctl add_user hongdada hongdada Creating user "hongdada" [[email protected] system]$ sudo rabbitmqctl set_user_tags hongdada administrator Setting tags for user "hongdada" to [administrator] [[email protected] system]$ sudo rabbitmqctl list_user_permissions hongdada Listing permissions for user "hongdada" [[email protected] system]$ sudo rabbitmqctl set_permissions -p / hongdada ".*" ".*" ".*" Setting permissions for user "hongdada" in vhost "/" [[email protected] system]$ sudo rabbitmqctl list_user_permissions hongdada Listing permissions for user "hongdada" / .* .* .*
创建rabbitmq.config文件
[ {rabbit, [%% %% Network Connectivity %% ==================== %% %% By default, RabbitMQ will listen on all interfaces, using %% the standard (reserved) AMQP port. %% {tcp_listeners, [5672]}, {loopback_users, ["hongda"]} ]} ].
最后启动Web管理器界面:(主要是找不到rabbitmq的安装位置了,可以用文件夹搜索)
[email protected] rabbitmq_server-3.6.10]$ cd /usr/lib/rabbitmq/lib/rabbitmq_server-3.6.10 [[email protected] rabbitmq_server-3.6.10]$ ls ebin include plugins sbin [[email protected] rabbitmq_server-3.6.10]$ sudo rabbitmq-plugins enable rabbitmq_management The following plugins have been enabled: amqp_client cowlib cowboy rabbitmq_web_dispatch rabbitmq_management_agent rabbitmq_management Applying plugin configuration to [email protected] started 6 plugins.
在虚拟机端访问:
打开防火墙端口:15672
http://www.cnblogs.com/uptothesky/p/6094357.html
http://www.cnblogs.com/crazylqy/p/6567253.html
http://mirrors.aliyun.com/help/centos?spm=5176.bbsr150321.0.0.d6ykiD
http://blog.csdn.net/weixin_35934768/article/details/52637273
时间: 2024-10-25 03:02:38