RabbitMQ消息队列(二)——安装

1、安装
在Mac下安装RabbitMQ是非常简单的,一般默认RabbitMQ服务器依赖的Erlang已经安装,只需要用下面两个命令就可以完成RabbitMQ的安装(前提是homebrew已经被安装 见https://brew.sh/):
brew update
brew install rabbitmq

 

耐心等待,安装完成后需要将/usr/local/sbin添加到$PATH,可以将下面这两行加到~/.bash_profile:

# RabbitMQ Configexport PATH=$PATH:/usr/local/sbin

编辑完后:wq保存退出,使环境变量立即生效。

source ~/.bash_profile

 

2、启动RabbitMQ服务
上面配置完成后,需要关闭终端窗口,重新打开,然后输入下面命令即可启动RabbitMQ服务:

rabbitmq-server

如果执行上面命令出现以下问题
[plain] view plain copy
 
  1. wangbindeMacBook-Air:sbin wangbin$ rabbitmq-server  
  2. 2017-06-13 15:26:21 Error when reading /Users/wangbin/.erlang.cookie: eacces  
  3. 2017-06-13 15:26:21 crash_report  
  4. initial_call: {auth,init,['Argument__1']}  
  5. pid: <0.45.0>  
  6. registered_name: []  
  7. error_info: {exit,{"Error when reading /Users/wangbin/.erlang.cookie: eacces",[{auth,init_cookie,0,[{file,"auth.erl"},{line,286}]},{auth,init,1,[{file,"auth.erl"},{line,140}]},{gen_server,init_it,6,[{file,"gen_server.erl"},{line,328}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,247}]}]},[{gen_server,init_it,6,[{file,"gen_server.erl"},{line,352}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,247}]}]}  
  8. ancestors: [net_sup,kernel_sup,<0.34.0>]  
  9. messages: []  
  10. links: [<0.43.0>]  
  11. dictionary: []  
  12. trap_exit: true  
  13. status: running  
  14. heap_size: 610  
  15. stack_size: 27  
  16. reductions: 618  
  17. 2017-06-13 15:26:21 supervisor_report  
  18. supervisor: {local,net_sup}  
  19. errorContext: start_error  
  20. reason: {"Error when reading /Users/wangbin/.erlang.cookie: eacces",[{auth,init_cookie,0,[{file,"auth.erl"},{line,286}]},{auth,init,1,[{file,"auth.erl"},{line,140}]},{gen_server,init_it,6,[{file,"gen_server.erl"},{line,328}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,247}]}]}  
  21. offender: [{pid,undefined},{id,auth},{mfargs,{auth,start_link,[]}},{restart_type,permanent},{shutdown,2000},{child_type,worker}]  
  22. 2017-06-13 15:26:21 supervisor_report  
  23. supervisor: {local,kernel_sup}  
  24. errorContext: start_error  
  25. reason: {shutdown,{failed_to_start_child,auth,{"Error when reading /Users/wangbin/.erlang.cookie: eacces",[{auth,init_cookie,0,[{file,"auth.erl"},{line,286}]},{auth,init,1,[{file,"auth.erl"},{line,140}]},{gen_server,init_it,6,[{file,"gen_server.erl"},{line,328}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,247}]}]}}}  
  26. offender: [{pid,undefined},{id,net_sup},{mfargs,{erl_distribution,start_link,[]}},{restart_type,permanent},{shutdown,infinity},{child_type,supervisor}]  
  27. 2017-06-13 15:26:21 crash_report  
  28. initial_call: {application_master,init,['Argument__1','Argument__2','Argument__3','Argument__4']}  
  29. pid: <0.33.0>  
  30. registered_name: []  
  31. error_info: {exit,{{shutdown,{failed_to_start_child,net_sup,{shutdown,{failed_to_start_child,auth,{"Error when reading /Users/wangbin/.erlang.cookie: eacces",[{auth,init_cookie,0,[{file,"auth.erl"},{line,286}]},{auth,init,1,[{file,"auth.erl"},{line,140}]},{gen_server,init_it,6,[{file,"gen_server.erl"},{line,328}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,247}]}]}}}}},{kernel,start,[normal,[]]}},[{application_master,init,4,[{file,"application_master.erl"},{line,134}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,247}]}]}  
  32. ancestors: [<0.32.0>]  
  33. messages: [{'EXIT',<0.34.0>,normal}]  
  34. links: [<0.32.0>,<0.31.0>]  
  35. dictionary: []  
  36. trap_exit: true  
  37. status: running  
  38. heap_size: 610  
  39. stack_size: 27  
  40. reductions: 174  
  41. 2017-06-13 15:26:21 std_info  
  42. application: kernel  
  43. exited: {{shutdown,{failed_to_start_child,net_sup,{shutdown,{failed_to_start_child,auth,{"Error when reading /Users/wangbin/.erlang.cookie: eacces",[{auth,init_cookie,0,[{file,"auth.erl"},{line,286}]},{auth,init,1,[{file,"auth.erl"},{line,140}]},{gen_server,init_it,6,[{file,"gen_server.erl"},{line,328}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,247}]}]}}}}},{kernel,start,[normal,[]]}}  
  44. type: permanent  
  45. {"Kernel pid terminated",application_controller,"{application_start_failure,kernel,{{shutdown,{failed_to_start_child,net_sup,{shutdown,{failed_to_start_child,auth,{\"Error when reading /Users/wangbin/.erlang.cookie: eacces\",[{auth,init_cookie,0,[{file,\"auth.erl\"},{line,286}]},{auth,init,1,[{file,\"auth.erl\"},{line,140}]},{gen_server,init_it,6,[{file,\"gen_server.erl\"},{line,328}]},{proc_lib,init_p_do_apply,3,[{file,\"proc_lib.erl\"},{line,247}]}]}}}}},{kernel,start,[normal,[]]}}}"}  
  46. Kernel pid terminated (application_controller) ({application_start_failure,kernel,{{shutdown,{failed_to_start_child,net_sup,{shutdown,{failed_to_start_child,auth,{"Error when reading /Users/wangbin/.e  
  47.   
  48. Crash dump is being written to: erl_crash.dump...done  



则执行:
sudo ./rabbitmq-server
cd /usr/local/Cellar/rabbitmq/3.6.9/sbin

sudo rabbitmq-server
 

3、登录Web管理界面
浏览器输入localhost:15672,账号密码全输入guest即可登录。
 
这里如果显示找不到主机,请在hosts文件中添加
vi /private/etc/hosts
127.0.0.1 localhost
这里需要注意下,从3.3.1版本开始,RabbitMQ默认不允许远程ip登录,即只能使用localhost登录。如果希望远程登录,请添加用户权限,方法见我的另一篇文章设置RabbitMQ远程ip登录
posted @ 2017-09-18 14:43  BinMax。  阅读(558)  评论(0)    收藏  举报