• 通过命令行配置Rabbitmq


    1 安装
    yum install -y rabbitmq*

    如果之前有起来rabbitmq,先停止了
    

    2 启动
    sudo /etc/rc.d/init.d/rabbitmq-server start

    3 配置Q和等信息

    创建虚拟主机

    os.system("sudo rabbitmqctl add_vhost ezoorepl")
    

    创建fanout类型的交换器

    sudo rabbitmqctl eval 'rabbit_exchange:declare({resource, <<"ezoorepl">>, exchange, <<"wgsoazk_ex">>}, fanout, true, false, false, []).'
    
    IDC A:
    sudo rabbitmqctl eval 'rabbit_exchange:declare({resource, <<"ezoorepl">>, exchange, <<"nt1soazk_ex">>}, fanout, true, false, false, []).'
    IDC B:
    sudo rabbitmqctl eval 'rabbit_exchange:declare({resource, <<"ezoorepl">>, exchange, <<"wgsoazk_ex">>}, fanout, true, false, false, []).'
    IDC C:
    sudo rabbitmqctl eval 'rabbit_exchange:declare({resource, <<"ezoorepl">>, exchange, <<"zb1soazk_ex">>}, fanout, true, false, false, []).'
    

    创建队列

    sudo rabbitmqctl eval 'rabbit_amqqueue:declare({resource, <<"ezoorepl">>, queue, <<"wgsoazk_zb1soa">>}, true, false, [], none).'
    
    IDC A:
    sudo rabbitmqctl eval 'rabbit_amqqueue:declare({resource, <<"ezoorepl">>, queue, <<"nt1soazk_wgsoa">>}, true, false, [], none).'
    sudo rabbitmqctl eval 'rabbit_amqqueue:declare({resource, <<"ezoorepl">>, queue, <<"nt1soazk_zb1soa">>}, true, false, [], none).'
    
    IDC B:
    sudo rabbitmqctl eval 'rabbit_amqqueue:declare({resource, <<"ezoorepl">>, queue, <<"wgsoazk_zb1soa">>}, true, false, [], none).'
    sudo rabbitmqctl eval 'rabbit_amqqueue:declare({resource, <<"ezoorepl">>, queue, <<"wgsoazk_nt1soa">>}, true, false, [], none).'
    
    IDC C:
    sudo rabbitmqctl eval 'rabbit_amqqueue:declare({resource, <<"ezoorepl">>, queue, <<"zb1soazk_wgsoa">>}, true, false, [], none).'
    sudo rabbitmqctl eval 'rabbit_amqqueue:declare({resource, <<"ezoorepl">>, queue, <<"zb1soazk_nt1soa">>}, true, false, [], none).'
    

    创建绑定器,绑定exchange与queue

    sudo rabbitmqctl eval 'rabbit_binding:add({binding, {resource, <<"ezoorepl">>, exchange, <<"wgsoazk_ex">>}, <<"wgsoazk_zb1soa">>, {resource, <<"ezoorepl">>, queue, <<"wgsoazk_zb1soa">>}, []}).'
    
    IDC A:
    sudo rabbitmqctl eval 'rabbit_binding:add({binding, {resource, <<"ezoorepl">>, exchange, <<"nt1soazk_ex">>}, <<"nt1soazk_wgsoa">>, {resource, <<"ezoorepl">>, queue, <<"nt1soazk_wgsoa">>}, []}).'
    sudo rabbitmqctl eval 'rabbit_binding:add({binding, {resource, <<"ezoorepl">>, exchange, <<"nt1soazk_ex">>}, <<"nt1soazk_zb1soa">>, {resource, <<"ezoorepl">>, queue, <<"nt1soazk_zb1soa">>}, []}).'
    
    IDC B:
    sudo rabbitmqctl eval 'rabbit_binding:add({binding, {resource, <<"ezoorepl">>, exchange, <<"wgsoazk_ex">>}, <<"wgsoazk_wgsoa">>, {resource, <<"ezoorepl">>, queue, <<"wgsoazk_wgsoa">>}, []}).'
    sudo rabbitmqctl eval 'rabbit_binding:add({binding, {resource, <<"ezoorepl">>, exchange, <<"wgsoazk_ex">>}, <<"wgsoazk_nt1soa">>, {resource, <<"ezoorepl">>, queue, <<"wgsoazk_nt1soa">>}, []}).'
    
    IDC C:
    sudo rabbitmqctl eval 'rabbit_binding:add({binding, {resource, <<"ezoorepl">>, exchange, <<"zb1soazk_ex">>}, <<"zb1soazk_wgsoa">>, {resource, <<"ezoorepl">>, queue, <<"zb1soazk_wgsoa">>}, []}).'
    sudo rabbitmqctl eval 'rabbit_binding:add({binding, {resource, <<"ezoorepl">>, exchange, <<"zb1soazk_ex">>}, <<"zb1soazk_nt1soa">>, {resource, <<"ezoorepl">>, queue, <<"zb1soazk_nt1soa">>}, []}).'
    

    添加新用户

    sudo rabbitmqctl add_user admin 123456
    sudo rabbitmqctl set_user_tags admin administrator
    
    
    # sudo rabbitmqctl add_user guest guest
    # sudo rabbitmqctl set_user_tags guest administrator
    
    # 设置该用户在各个"虚拟主机"上的权限
    # sudo rabbitmqctl set_permissions -p / guest ".*" ".*" ".*"
    # sudo rabbitmqctl set_permissions -p ezoorepl guest ".*" ".*" ".*"
    
    sudo rabbitmqctl set_permissions -p / admin ".*" ".*" ".*"
    sudo rabbitmqctl set_permissions -p ezoorepl admin ".*" ".*" ".*"
    

    开启management插件

    rabbitmq-plugins enable rabbitmq_management
  • 相关阅读:
    Spring5源码--Spring AOP使用接口方式实现 配置xml文件
    什么是 JavaConfig?
    Spring Boot 有哪些优点?
    什么是 Spring Boot?
    问:一台客户端有三百个客户与三百个客户端有三百个客户对服务器施压,有什么区别?
    如何实现参数级联查询
    如何开发主从报表
    如何在报表中实现算法的可挂接需求
    如何实现报表的批量打印需求
    如何实现参数和报表间的联动效果
  • 原文地址:https://www.cnblogs.com/vinsent/p/12834878.html
Copyright © 2020-2023  润新知