当前位置:   article > 正文

CentOS7 安装RabbitMQ_-p 5672:5672 -p 15672:15672

-p 5672:5672 -p 15672:15672

docker安装:

docker pull rabbitmq:3.7.7-management

docker run -d --name rabbitmq3.7.7 -p 5672:5672 -p 15672:15672 -v `pwd`/data:/var/lib/rabbitmq --hostname myRabbit -e RABBITMQ_DEFAULT_VHOST=my_vhost  -e RABBITMQ_DEFAULT_USER=admin -e RABBITMQ_DEFAULT_PASS=admin docker.io/rabbitmq:3.7.7-management

http://ip:15672

账号:admin /admin

 

 

普通方式安装:

第一、下载erlang和rabbitmq-server的rpm:

centos 7 下载:

wget --no-check-certificate https://www.rabbitmq.com/releases/erlang/erlang-19.0.4-1.el7.centos.x86_64.rpm

wget  --no-check-certificate   https://www.rabbitmq.com/releases/rabbitmq-server/v3.6.15/rabbitmq-server-3.6.15-1.el7.noarch.rpm

centos6 下载:

wget  --no-check-certificate https://www.rabbitmq.com/releases/rabbitmq-server/v3.6.15/rabbitmq-server-3.6.15-1.el6.noarch.rpm

wget  --no-check-certificate  https://www.rabbitmq.com/releases/erlang/erlang-19.0.4-1.el6.x86_64.rpm

 

安装 erlang

rpm -ivh  erlang-19.0.4-1.el7.centos.x86_64.rpm

 

安装mq:

rpm -ivh rabbitmq-server-3.6.15-1.el7.noarch.rpm

[root@bogon rabitMq]# rpm -ivh rabbitmq-server-3.6.15-1.el7.noarch.rpm
警告:rabbitmq-server-3.6.15-1.el7.noarch.rpm: 头V4 RSA/SHA1 Signature, 密钥 ID 6026dfca: NOKEY
错误:依赖检测失败:
        socat 被 rabbitmq-server-3.6.15-1.el7.noarch 需要
[root@bogon rabitMq]#

报错: 需要安装socat

  1. 安装 socat 参考:https://www.cnblogs.com/ray30th/p/6651800.html
  2. Step 1:
  3. wget --no-cache http://www.convirture.com/repos/definitions/rhel/6.x/convirt.repo -O /etc/yum.repos.d/convirt.repo
  4. wget --no-cache http://www.convirture.com/repos/definitions/rhel/6.x/convirt.repo -O /etc/yum.repos.d/convirt.repo
  5. --2017-03-31 14:57:37-- http://www.convirture.com/repos/definitions/rhel/6.x/convirt.repo
  6. 正在解析主机 www.convirture.com... 69.195.93.219
  7. 正在连接 www.convirture.com|69.195.93.219|:80... 已连接。
  8. 已发出 HTTP 请求,正在等待回应... 200 OK
  9. 长度:184 [text/plain]
  10. 正在保存至: “/etc/yum.repos.d/convirt.repo”
  11. Step 2:
  12. yum makecache
  13. Step 3:
  14. yum install socat
  15. 又报错了,这次是yum报错了

 

 

[root@bogon rabitMq]# yum makecache
已加载插件:fastestmirror
File contains no section headers.
file: file:///etc/yum.repos.d/convirt.repo, line: 1

解决:https://blog.csdn.net/qq_38860828/article/details/82797592

  1. 在Linux正常更新过程中 有可能会突然出现某些加速插件启动,但是下面却又一些莫名其妙的内容,内容并非是错误提示. 比如:
  2. File contains no section headers. file: file:///etc/yum.repos.d/convirt.repo, line: 1 ‘\n’
  3. 解决办法:
  4. /etc/yum.repos.d下的文件全部删除,再重新下载对应操作系统版本的即可
  5. 1)centos5.*的下载连接: [root@bastion-IDC yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
  6. 2)centos6.*的下载连接: [root@bastion-IDC yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
  7. 3)centos7.*的下载连接: [root@bastion-IDC yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

 

 

再次安装socat  yum install socat  ,ok  成功

然后再次安装rabbitmq

  1. [root@bogon rabitMq]# rpm -ivh rabbitmq-server-3.6.15-1.el7.noarch.rpm
  2. 警告:rabbitmq-server-3.6.15-1.el7.noarch.rpm: 头V4 RSA/SHA1 Signature, 密钥 ID 6026dfca: NOKEY
  3. 准备中... ################################# [100%]
  4. 正在升级/安装...
  5. 1:rabbitmq-server-3.6.15-1.el7 ################################# [100%]

 第四、启动和关闭:

/sbin/service rabbitmq-server stop #关闭

/sbin/service rabbitmq-server start #启动

/sbin/service rabbitmq-server status #状态

先启动,启动时间比较长,得等会

  1. [root@bogon rabitMq]# /sbin/service rabbitmq-server status
  2. Redirecting to /bin/systemctl status rabbitmq-server.service
  3. ● rabbitmq-server.service - RabbitMQ broker
  4. Loaded: loaded (/usr/lib/systemd/system/rabbitmq-server.service; disabled; vendor preset: disabled)
  5. Active: active (running) since 二 2019-07-02 23:11:37 CST; 7min ago
  6. Main PID: 1762 (beam.smp)
  7. Status: "Initialized"
  8. CGroup: /system.slice/rabbitmq-server.service
  9. ├─1762 /usr/lib64/erlang/erts-8.0.3/bin/beam.smp -W w -A 64 -P 1048576 -t 5000000 -stbt db -zdbbl 128000 -K true -- -root /usr/lib64/erlang -progname erl -- -home /var/lib/rabbitm...
  10. ├─1903 /usr/lib64/erlang/erts-8.0.3/bin/epmd -daemon
  11. ├─2019 erl_child_setup 1024
  12. ├─2031 inet_gethost 4
  13. └─2040 inet_gethost 4
  14. 702 23:11:02 bogon rabbitmq-server[1762]: RabbitMQ 3.6.15. Copyright (C) 2007-2018 Pivotal Software, Inc.
  15. 702 23:11:02 bogon rabbitmq-server[1762]: ## ## Licensed under the MPL. See http://www.rabbitmq.com/
  16. 702 23:11:02 bogon rabbitmq-server[1762]: ## ##
  17. 702 23:11:02 bogon rabbitmq-server[1762]: ########## Logs: /var/log/rabbitmq/rabbit@bogon.log
  18. 702 23:11:02 bogon rabbitmq-server[1762]: ###### ## /var/log/rabbitmq/rabbit@bogon-sasl.log
  19. 702 23:11:02 bogon rabbitmq-server[1762]: ##########
  20. 702 23:11:02 bogon rabbitmq-server[1762]: Starting broker...
  21. 702 23:11:37 bogon rabbitmq-server[1762]: systemd unit for activation check: "rabbitmq-server.service"
  22. 702 23:11:37 bogon systemd[1]: Started RabbitMQ broker.
  23. 702 23:11:37 bogon rabbitmq-server[1762]: completed with 0 plugins

ok了

cd 到 /sbin

 ./rabbitmq-plugins list

 

./rabbitmqctl status

第六、其他

运行如下的命令,增加用户admin,密码admin

[root@localhost sbin]# ./rabbitmqctl add_user admin admin 
Creating user "admin" ... 
...done. 
[root@localhost sbin]# ./rabbitmqctl set_user_tags admin administrator
Setting tags for user "admin" to [administraotr] ... 
...done. 
[root@localhost sbin]# ./rabbitmqctl list_users 
Listing users ... 
admin   [administraotr] 
guest   [administrator] 
...done.

第七、扩展参考

NET下RabbitMQ实践[配置篇]

NET下RabbitMQ实践[示例篇]

NET下RabbitMQ实践[WCF发布篇]

NET下RabbitMQ实践[实战篇] 

RabbitMQ C# Tutorial

[Erlang 0086] RabbitMQ 集群: 从零开始

 

继续 ,成功启动后,通过网页  :http://********:15672 访问失败

配置网页插件:

首先创建目录,否则可能报错:

mkdir /etc/rabbitmq

     

然后启用插件:

rabbitmq-plugins enable rabbitmq_management

     

配置防火墙:

配置linux 端口 15672 网页管理 5672 AMQP端口:

    firewall-cmd --permanent --add-port=15672/tcp
    firewall-cmd --permanent --add-port=5672/tcp
    systemctl restart firewalld.service

浏览器中输入服务器IP:15672 就可以看到RabbitMQ的WEB管理页面了,登录
 

 

报错,发现之前的 ./rabbitmqctl set_user_tags admin administrator给弄错了, 这个问题不大,重新set下ok

登录后:

 

新建 virtual_hosts

授权

 

  1. //最普通的连接代码
  2. public class ConnectionUtils{
  3. public static Connection getConnection() throws IOException, TimeoutException {
  4. ConnectionFactory factory = new ConnectionFactory();
  5. //设置服务地址
  6. factory.setHost("127.0.0.1");
  7. factory.setPort(5672);
  8. factory.setVirtualHost("virtual_hosts_test");
  9. factory.setUsername("admin");
  10. factory.setPassword("admin");
  11. return factory.newConnection();
  12. }
  13. }

 

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小桥流水78/article/detail/956341
推荐阅读
相关标签
  

闽ICP备14008679号