您的位置:首页 > 其它

rabbitmq 学习-5-server管理

2010-10-19 16:06 148 查看
RabbitMQServerAdministrator'sGuidehttp://www.rabbitmq.com/admin-guide.html#installation1,RabbitmqDB第一次启动,会检查是否有数据库,没有则创建一个db,存放在C:\DocumentsandSettings\Administrator\ApplicationData\RabbitMQ,DB会存储关于user,virtualhost,持久化消息等信息此目录下有两个文件夹:db,log并会使用到这些资源:virtualhost:/user:guest/guestguest会分配所有的权限到virtualhost/上2,命令行管理工具rabbitmqctlRabbitmqctl是rabbitmq的一个命令行管理工具,它用来对某个机器上(host)的节点(node)进行管理,本机默认的node名称是”rabbit”,hostname可以使用hostname–s查看执行相关命令时,可明确指定一个节点,例如:rabbitmqctl–nnode_name@host_nameadd_userusernamepassword这个命令将在指定的机器(host_name)的节点(node_name)上创建一个用户在启动rabbitmq的时命令行中,可以查看到node名称++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++RabbitMQ1.6.0(AMQP8-0)Copyright(C)2007-2009LShiftLtd.,CohesiveFinancialTechnologiesLLC.,andRabbitTechnologiesLtd.LicensedundertheMPL.Seehttp://www.rabbitmq.com/node:rabbit@WWW-65592D80C4A//这里就是node_name@host_namelog:C:/DocumentsandSettings/Administrator/ApplicationData/RabbitMQ/log/rabbit.log//日志目录sasllog:C:/DocumentsandSettings/Administrator/ApplicationData/RabbitMQ/log/rabbit-sasl.log//日志目录databasedir:c:/DocumentsandSettings/Administrator/ApplicationData/RabbitMQ/db/rabbit-mnesia//db目录startingdatabase...donestartingcoreprocesses...donestartingrecovery...donestartingpersister...donestartingguidgenerator...donestartingbuiltinapplications...donestartingTCPlisteners...donebrokerrunning++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++3,查看node状态rabbitmqctl-qstatus输出:++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++[{running_applications,[{rabbit,"RabbitMQ","1.6.0"},{mnesia,"MNESIACXC13812","4.4.10"},{os_mon,"CPOCXC13846","2.2.2"},{sasl,"SASLCXC13811","2.1.6"},{stdlib,"ERTSCXC13810","1.16.2"},{kernel,"ERTSCXC13810","2.13.2"}]},{nodes,['rabbit@WWW-65592D80C4A']},{running_nodes,['rabbit@WWW-65592D80C4A']}]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++4,关闭rabbitmqrabbitmqctlstop直接关闭rabbitmq,关闭rabbitmq节点(elr进程也关掉了),需要通过rabbitmq-server才能重新启动rabbitmqctlstop_app关闭rabbitmq应用程序,但是erl进行还在,可以通过rabbitmqctlstart_app恢复rabbitmqctlstart_app启动rabbitmq应用程序++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++E:\rabbitmq_server-1.6.0\sbin>rabbitmqctlstop_appStoppingnode'rabbit@WWW-65592D80C4A'......done.E:\rabbitmq_server-1.6.0\sbin>rabbitmqctlstopStoppingandhaltingnode'rabbit@WWW-65592D80C4A'......done.++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++5,查看rabbitmq状态
rabbitmqctlstatus
rabbitmqctl–qstatus

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Statusofnode'rabbit@WWW-65592D80C4A'...
[{running_applications,[{rabbit,"RabbitMQ","1.6.0"},
{mnesia,"MNESIACXC13812","4.4.10"},
{os_mon,"CPOCXC13846","2.2.2"},
{sasl,"SASLCXC13811","2.1.6"},
{stdlib,"ERTSCXC13810","1.16.2"},
{kernel,"ERTSCXC13810","2.13.2"}]},
{nodes,['rabbit@WWW-65592D80C4A']},
{running_nodes,['rabbit@WWW-65592D80C4A']}]
...done.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6,重置rabbitmq
rabbitmqctlreset
rabbitmqctlforce_reset
使用force_reset与reset不同之外在于:它会无条件的重置rabbitmq,不管rabbitmqdatabasestate,和rabbitmq已经在集群环境中配置,这个命令应该在迫不得已的情况去使用
重置rabbitmq,会有以下影响:
1,从集群节点中删除
2,删除db数据,如user,vhost信息,持久化消息
重置成功后,必须stoprabbitmq,例如使用:rabbitmqctlstop_app

7,修改日志文件后缀名
rabbitmqctlrotate_logssuffix_name
修改日志文件后缀名,执行以后,可以马上看到log目录下创建了指定后缀的日志文件:

rabbit.log.rabbit.log
rabbit-sasl.log.rabbit.log
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
E:\rabbitmq_server-1.6.0\sbin>rabbitmqctlrotate_logs.rabbit.log
Rotatinglogstofileswithsuffix".rabbit.log"...
...done.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
8,集群管理
rabbitmqctlclusterclusternode...

9,rabbitmqctl所有命令:
Usage:rabbitmqctl[-q][-n<node>]<command>[<arg>...]
Availablecommands:
stop-stopstheRabbitMQapplicationandhaltsthenode
stop_app-stopstheRabbitMQapplication,leavingthenoderunning
start_app-startstheRabbitMQapplicationonanalready-runningnode
reset-resetsnodetodefaultconfiguration,deletingalldata
force_reset
cluster<ClusterNode>...
status
rotate_logs[Suffix]
close_connection<ConnectionPid><ExplanationString>
add_user<UserName><Password>
delete_user<UserName>
change_password<UserName><NewPassword>
list_users
add_vhost<VHostPath>
delete_vhost<VHostPath>
list_vhosts
set_permissions[-p<VHostPath>]<UserName><Regexp><Regexp><Regexp>
clear_permissions[-p<VHostPath>]<UserName>
list_permissions[-p<VHostPath>]
list_user_permissions<UserName>
list_queues[-p<VHostPath>][<QueueInfoItem>...]
list_exchanges[-p<VHostPath>][<ExchangeInfoItem>...]
list_bindings[-p<VHostPath>]
list_connections[<ConnectionInfoItem>...]
list_channels[<ChannelInfoItem>...]
list_consumers[-p<VHostPath>]
Quietoutputmodeisselectedwiththe"-q"flag.Informational
messagesaresuppressedwhenquietmodeisineffect.
<node>shouldbethenameofthemasternodeoftheRabbitMQ
cluster.Itdefaultstothenodenamed"rabbit"onthelocal
host.Onahostnamed"server.example.com",themasternodewill
usuallyberabbit@server(unlessRABBITMQ_NODENAMEhasbeensetto
somenon-defaultvalueatbrokerstartuptime).Theoutputofhostname
-sisusuallythecorrectsuffixtouseafterthe"@"sign.
Thelist_queues,list_exchangesandlist_bindingscommandsacceptan
optionalvirtualhostparameterforwhichtodisplayresults.The
defaultvalueis"/".
<QueueInfoItem>mustbeamemberofthelist[name,durable,
auto_delete,arguments,pid,owner_pid,exclusive_consumer_pid,
exclusive_consumer_tag,messages_ready,messages_unacknowledged,
messages_uncommitted,messages,acks_uncommitted,consumers,
transactions,memory].Thedefaultistodisplaynameand(numberof)
messages.
<ExchangeInfoItem>mustbeamemberofthelist[name,type,durable,
auto_delete,arguments].Thedefaultistodisplaynameandtype.
Theoutputformatfor"list_bindings"isalistofrowscontaining
exchangename,queuename,routingkeyandarguments,inthatorder.
<ConnectionInfoItem>mustbeamemberofthelist[pid,address,port,
peer_address,peer_port,state,channels,user,vhost,timeout,
frame_max,client_properties,recv_oct,recv_cnt,send_oct,send_cnt,
send_pend].Thedefaultistodisplayuser,peer_address,peer_port
andstate.
<ChannelInfoItem>mustbeamemberofthelist[pid,connection,
number,user,vhost,transactional,consumer_count,
messages_unacknowledged,acks_uncommitted,prefetch_count].The
defaultistodisplaypid,user,transactional,consumer_count,
messages_unacknowledged.
Theoutputformatfor"list_consumers"isalistofrowscontaining,
inorder,thequeuename,channelprocessid,consumertag,anda
booleanindicatingwhetheracknowledgementsareexpectedfromthe
consumer.
本文摘自:http://sunjun041640.blog.163.com/blog/static/25626832201032681053285/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐