首页 > 代码库 > CentOS7.2 安装RabbitMQ

CentOS7.2 安装RabbitMQ

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仓库:

[hongdada@localhost ~]$ sudo rpm -Uvh http://ftp.riken.jp/Linux/fedora/epel/7/x86_64/e/epel-release-7-10.noarch.rpm

安装erlang

[hongdada@localhost ~]$ yum install erlang

第二步:安装rabbitmq

先下载rpm

[hongdada@localhost ~]$ sudo wget https://www.rabbitmq.com/releases/rabbitmq-server/v3.6.10/rabbitmq-server-3.6.10-1.el7.noarch.rpm

安装

[hongdada@localhost ~]$ sudo yum install rabbitmq-server-3.6.10-1.el7.noarch.rpm

安装完成后启动服务:

[hongdada@localhost ~]$ sudo yum install rabbitmq-server-3.6.10-1.el7.noarch.rpm

查看服务状态:

[hongdada@localhost ~]$ service rabbitmq-server status

详细信息:

[hongdada@localhost ~]$ 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 47月 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/rabbit@localhost.log7月 23 22:10:38 localhost.localdomain rabbitmq-server[34634]: ######  ##        /var/log/rabbitmq/rabbit@localhost-sasl.log7月 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.

 查看对应的日志文件:

[hongdada@localhost ~]$ cd /var/log/rabbitmq/[hongdada@localhost rabbitmq]$ lsrabbit@localhost.log  rabbit@localhost-sasl.log[hongdada@localhost rabbitmq]$ vi rabbit@localhost.log

日志文件内容:

=INFO REPORT==== 23-Jul-2017::22:10:38 ===Starting RabbitMQ 3.6.10 on Erlang R16B03-1Copyright (C) 2007-2017 Pivotal Software, Inc.Licensed under the MPL.  See http://www.rabbitmq.com/=INFO REPORT==== 23-Jul-2017::22:10:38 ===node           : rabbit@localhosthome dir       : /var/lib/rabbitmqconfig file(s) : /etc/rabbitmq/rabbitmq.config (not found)cookie hash    : uyKwm1mYlbUecxvrRAhaaQ==log            : /var/log/rabbitmq/rabbit@localhost.logsasl log       : /var/log/rabbitmq/rabbit@localhost-sasl.logdatabase dir   : /var/lib/rabbitmq/mnesia/rabbit@localhost=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"rabbit@localhost.log" [只读] 75L, 2451C  

发现/etc/rabbitmq/rabbitmq.config不存在

先创建用户:

[hongdada@localhost 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.[hongdada@localhost system]$ sudo rabbitmqctl list_usersListing usersguest    [administrator][hongdada@localhost system]$ sudo rabbitmqctl add_user hongdada hongdadaCreating user "hongdada"[hongdada@localhost system]$ sudo rabbitmqctl set_user_tags hongdada administratorSetting tags for user "hongdada" to [administrator][hongdada@localhost system]$ sudo rabbitmqctl list_user_permissions hongdadaListing permissions for user "hongdada"[hongdada@localhost system]$ sudo rabbitmqctl set_permissions -p / hongdada ".*" ".*" ".*"Setting permissions for user "hongdada" in vhost "/"[hongdada@localhost system]$ sudo rabbitmqctl list_user_permissions hongdadaListing 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的安装位置了,可以用文件夹搜索)

hongdada@localhost rabbitmq_server-3.6.10]$ cd /usr/lib/rabbitmq/lib/rabbitmq_server-3.6.10[hongdada@localhost rabbitmq_server-3.6.10]$ lsebin  include  plugins  sbin[hongdada@localhost rabbitmq_server-3.6.10]$ sudo rabbitmq-plugins enable rabbitmq_managementThe following plugins have been enabled:  amqp_client  cowlib  cowboy  rabbitmq_web_dispatch  rabbitmq_management_agent  rabbitmq_managementApplying plugin configuration to rabbit@localhost... 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

CentOS7.2 安装RabbitMQ