zoukankan      html  css  js  c++  java
  • 通过命令行配置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
  • 相关阅读:
    详解Android Intent
    【JAVA EE企业级开发四步走完全攻略】
    撼动IT界的10大编程语言
    System.getProperty() 常用值
    Android List,Adapter相关
    为程序员量身定制的12个目标
    java 算法数据
    JAVA基础之理解JNI原理
    Java 工厂模式
    linux下C语言读取网卡MAC地址
  • 原文地址:https://www.cnblogs.com/vinsent/p/12834878.html
Copyright © 2011-2022 走看看