配置rabbitmq
简要记录:
1111
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, []).'
南通:
sudo rabbitmqctl eval 'rabbit_exchange:declare({resource, <<"ezoorepl">>, exchange, <<"nt1soazk_ex">>}, fanout, true, false, false, []).'
万国:
sudo rabbitmqctl eval 'rabbit_exchange:declare({resource, <<"ezoorepl">>, exchange, <<"wgsoazk_ex">>}, fanout, true, false, false, []).'
张北:
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).'
南通:
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).'
WG:
sudo rabbitmqctl eval 'rabbit_amqqueue:declare({resource, <<"ezoorepl">>, queue, <<"wgsoazk_wgsoa">>}, true, false, [], none).'
sudo rabbitmqctl eval 'rabbit_amqqueue:declare({resource, <<"ezoorepl">>, queue, <<"wgsoazk_nt1soa">>}, true, false, [], none).'
张北:
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">>}, []}).'
南通:
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">>}, []}).'
万国:
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">>}, []}).'
张北:
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 On1NgXOoy3lLMO
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