1、安装 erlang 语言环境 

安装依赖文件 

#yum install ncurses-devel 

wget http://www.erlang.org/download/otp_src_17.1.tar.gz 

tar zxvf otp_src_17.1.tar.gz && cd otp_src_17.1 

#./configure #make && make install 

安装完成以后,执行 erl 看是否能打开 eshell,用’halt().’退出,注意后面的点号,那是 erlang 的结束符。 

[root@localhost src]# erl 

Erlang/OTP 17 [erts-6.1] [source] [64-bit] [async-threads:10] [hipe] [kernel-poll:false] 

Eshell V6.1 (abort with ^G) 

2> 9+3. 

12 

3> 

halt(). 

2、安装 RabbitMQ 

安装依赖文件: 

yum install xmlto 

进入 http://www.rabbitmq.com/download.html 选择最新的源码包 

#wget http://www.rabbitmq.com/releases/rabbitmq-server/v3.3.4/rabbitmq-server-3.3.4.tar.gz #tar zxvf rabbitmq-server-3.3.4.tar.gz 

#cd rabbitmq-server-3.3.4 

#make TARGET_DIR=/usr/local/rabbitmq SBIN_DIR=/usr/local/rabbitmq/sbin MAN_DIR=/usr/local/rabbitmq/man DOC_INSTALL_DIR=/usr/local/rabbitmq/doc 

#make TARGET_DIR=/usr/local/rabbitmq SBIN_DIR=/usr/local/rabbitmq/sbin MAN_DIR=/usr/local/rabbitmq/man DOC_INSTALL_DIR=/usr/local/rabbitmq/doc install 

3、启动 rabbitmq-server 常用命令: 

运行 rabbitmq: # /usr/rabbitmq/sbin/rabbitmq-server -detached 

查看 rabbitmq 状态: # /usr/rabbitmq/sbin/rabbitmqctl status 

关闭 rabbitmq: # /usr/rabbitmq/sbin/rabbitmqctl stop 

4、查看 RabbitMQ 服务启动的状态,并开启 RabbitMQ 的相应管理插件 

[root@localhost sbin]# ./rabbitmqctl status 

Status of node rabbit@localhost ... 

[{pid,35112}, 

{running_applications,[{rabbit,"RabbitMQ","3.3.4"},           

         {os_mon,"CPO CXC 138 46","2.2.15"},          

          {xmerl,"XML parser","1.3.7"},            

         {mnesia,"MNESIA CXC 138 12","4.12.1"},           

            {sasl,"SASL CXC 138 11","2.4"},             

            {stdlib,"ERTS CXC 138 10","2.1"},                                       {kernel,"ERTS CXC 138 10","3.0.1"}]},             

{os,{unix,linux}}, 

{erlang_version,"Erlang/OTP 17 [erts-6.1] [source] [64-bit] [async-threads:30] [hipe] [kernel-poll:true]\n"}, 

{memory,[{total,35218336}, 

    {connection_procs,2728}, 

       {queue_procs,5456}, 

        {plugins,0}, 

        {other_proc,13339072}, 

        {mnesia,57552}, 

        {mgmt_db,0}, 

        {msg_index,33968}, 

        {other_ets,708832}, 

        {binary,30112}, 

         {code,16881166}, 

        {atom,654217}, 

        {other_system,3505233}]}, 

{alarms,[]}, {listeners,[{clustering,25672,"::"},{amqp,5672,"::"}]}, {vm_memory_high_watermark,0.4}, {vm_memory_limit,769332019}, {disk_free_limit,50000000}, {disk_free,45550653440}, {file_descriptors,[{total_limit,924}, 

        {total_used,3}, 

        {sockets_limit,829}, 

        {sockets_used,1}]}, 

{processes,[{limit,1048576},{used,124}]}, 

{run_queue,0}, 

{uptime,2182}] 

...done. 

[root@localhost sbin]# ./rabbitmq-plugins list 

[ ] amqp_client 3.3.4 

[ ] cowboy 0.5.0-rmq3.3.4-git4b93c2d 

[ ] eldap 3.3.4-gite309de4 

[ ] mochiweb 2.7.0-rmq3.3.4-git680dba8 

[ ] rabbitmq_amqp1_0 3.3.4 

[ ] rabbitmq_auth_backend_ldap 3.3.4 

[ ] rabbitmq_auth_mechanism_ssl 3.3.4 

[ ] rabbitmq_consistent_hash_exchange 3.3.4 

[ ] rabbitmq_federation 3.3.4 

[ ] rabbitmq_federation_management 3.3.4 

[ ] rabbitmq_management 3.3.4 

[ ] rabbitmq_management_agent 3.3.4 

[ ] rabbitmq_management_visualiser 3.3.4 

[ ] rabbitmq_mqtt 3.3.4 

[ ] rabbitmq_shovel 3.3.4 

[ ] rabbitmq_shovel_management 3.3.4 

[ ] rabbitmq_stomp 3.3.4 

[ ] rabbitmq_test 3.3.4 

[ ] rabbitmq_tracing 3.3.4 

[ ] rabbitmq_web_dispatch 3.3.4 

[ ] rabbitmq_web_stomp 3.3.4 

[ ] rabbitmq_web_stomp_examples 3.3.4 

[ ] sockjs 0.3.4-rmq3.3.4-git3132eb9 

[ ] webmachine 1.10.3-rmq3.3.4-gite9359c7 

安装插件: 

[root@localhost sbin]# rabbitmq-plugins enable rabbitmq_management 

安装插件时报以下错误 

Error: {cannot_write_enabled_plugins_file,"/etc/rabbitmq/enabled_plugins", enoent} 

则需要进行下列操作: mkdir /etc/rabbitmq/ touch /etc/rabbitmq/enable_plugins 即可,

再次安装插件:

[root@localhost sbin]# rabbitmq-plugins enable rabbitmq_management 

插件安装完成后提示重新启动 rabbitmq 

# /usr/rabbitmq/sbin/rabbitmqctl stop 

# /usr/rabbitmq/sbin/rabbitmq-server -detached 

安装完成后 

ps –elf | grep rabbit 可查看 rabbitmq 的进程,默认端口 5672,可用 ss -tunlp|grep 5672 查看, web 端默认端口 15672,集群端口 25672,所以要进行开放端口或关闭防火墙: 

[root@localhost sbin]# firewall-cmd --add-port=5672/tcp --permanent 

success 

[root@localhost sbin]# firewall-cmd --add-port=15672/tcp --permanent 

success 

[root@localhost sbin]# firewall-cmd –reload 

同时,为了后续的任务实验,需要 copy 份配置文件: 

cp /usr/local/rabbitmq/doc/rabbitmq.config.example /etc/rabbitmq/ 

同时进行修改:

 有时无法登陆解决办法 

#vim /etc/rabbitmq/rabbitmq.config 

写入信息,并保存 

[{rabbit, [{loopback_users, []}]}]. 

这里的意思是开放使用,rabbitmq 默认创建的用户 guest,密码也是 guest,这个用户默认只能是本机 访问,localhost 或者 127.0.0.1,从外部访问需要添加上面的配置。 

做完修改应当重启 

运行如下的命令,增加用户 admin,密码 admin 

[root@localhost sbin]# ./rabbitmqctl add_user admin admin 

Creating user "admin" ... 

...done. 

[root@localhost sbin]# ./rabbitmqctl set_user_tags admin administraotr 

Setting tags for user "admin" to [administraotr] ... 

...done. 

[root@localhost sbin]# ./rabbitmqctl list_users 

Listing users ... 

admin [administraotr] 

guest [administrator] 

...done. 

浏览器访问即可 http://ip:15672