首页 > 代码库 > Centos6.5 安装 RabbitMQ3.6.1

Centos6.5 安装 RabbitMQ3.6.1

Centos6.5 安装 RabbitMQ3.6.1

个人安装RabbitMQ总结:


安装编译工具

yum -y install make gcc gcc-c++ kernel-devel m4 ncurses-devel openssl-devel
  • 1

安装Erlang

1. 下载erlang
下载地址:http://download.csdn.net/detail/a15134566493/9517595
官方下载地址:http://erlang.org/download/otp_src_18.3.tar.gz

2.安装

#解压tar xvf otp_src_18.3.tar.gzcd otp_src_18.3#配置 ‘--prefix‘指定的安装目录./configure --prefix=/usr/local/erlang --with-ssl -enable-threads -enable-smmp-support -enable-kernel-poll --enable-hipe --without-javac#安装make && make install
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

3.配置erlang环境变量

vim /etc/profile#在文件末尾添加下面代码 ‘ERLANG_HOME‘等于上一步‘--prefix‘指定的目录ERLANG_HOME=/usr/local/erlangPATH=$ERLANG_HOME/bin:$PATHexport ERLANG_HOMEexport PATH#使环境变量生效source /etc/profile#输入命令检验是否安装成功erl#如下输出表示安装成功
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14

技术分享

安装RabbitMQ

1.下载RabbitMQ
官方下载地址http://www.rabbitmq.com/releases/rabbitmq-server/v3.6.1/rabbitmq-server-generic-unix-3.6.1.tar.xz

2.安装 
RabbitMQ3.6版本无需make、make install 解压就可以用

#解压rabbitmq,官方给的包是xz压缩包,所以需要使用xz命令xz -d rabbitmq-server-generic-unix-3.6.1.tar.xz#xz解压后得到.tar包,再用tar命令解压tar -xvf rabbitmq-server-generic-unix-3.6.1.tar#移动目录 看个人喜好cp -rf ./rabbitmq_server-3.6.1 /usr/local/cd /usr/local/#修改文件夹名mv rabbitmq_server-3.6.1 rabbitmq-3.6.1#开启管理页面插件cd ./rabbitmq-3.6.1/sbin/./rabbitmq-plugins enable rabbitmq_management
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16

3.启动

#启动命令,该命令ctrl+c后会关闭服务./rabbitmq-server#在后台启动Rabbit./rabbitmq-server -detached#关闭服务./rabbitmqctl stop#关闭服务(kill) 找到rabbitmq服务的pid   [不推荐]ps -ef|grep rabbitmqkill -9 ****
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

4. 添加管理员账号

#进入RabbitMQ安装目录cd /usr/local/rabbitmq-3.6.1/sbin#添加用户#rabbitmqctl add_user Username Password./rabbitmqctl add_user rabbitadmin 123456#分配用户标签#rabbitmqctl set_user_tags User Tag#[administrator]:管理员标签./rabbitmqctl set_user_tags rabbitadmin administrator
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
5.登录管理界面
浏览器输入地址:http://服务器IP地址:15672/ 
技术分享

输入第4部添加的账号密码登录 
技术分享

其他

1.访问不了 
安装完成之后如果机器有iptables,需要开放端口

vim /etc/sysconfig/iptables#RabbitMQ-A INPUT -p tcp -m state --state NEW -m tcp --dport 15672 -j ACCEPT-A INPUT -p tcp -m state --state NEW -m tcp --dport 25672 -j ACCEPT-A INPUT -p tcp -m state --state NEW -m tcp --dport 5672 -j ACCEPT-A INPUT -p tcp -m state --state NEW -m tcp --dport 4369 -j ACCEPT-A INPUT -p tcp -m state --state NEW -m tcp --dport 5671 -j ACCEPT#RabbitMQ
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

RabbitMQ常用端口(摘自网络) 
4369 (epmd), 
25672 (Erlang distribution) 
56725671 (AMQP 0-9-1 without and with TLS) 
15672 (if management plugin is enabled) 
6161361614 (if STOMP is enabled) 
18838883 (if MQTT is enabled)

2.Warning: PID file not written; -detached was passed 
提示这句话暂时没处理,有空补上。

3.RabbitMQ压缩包.xz解压问题
需要安装xz软件(网上有教程,我之后也会补充)
如果嫌麻烦,可直接下载我解压好的包
下载地址:http://download.csdn.net/detail/a15134566493/9518835

有问题欢迎提建议。

注:1、有的地方说要把py版本升级到2.7,这里面并没有升级,没有问题。在安装erlang的时候./configure后面的参数要接上,不然会启动rabbitmq的时候会报ssl等错误。

  2、guest/guest一般来说是无法登录的,guest必须是localhost才能登录,所以得先用命令行新增用户才能登录。

  3、

1、如果写错了host (如:factory.setHost("locathost"); )报错:

 

Exception in thread "main" java.net.UnknownHostException: locathost
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:195)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:529)
at com.rabbitmq.client.impl.FrameHandlerFactory.create(FrameHandlerFactory.java:32)
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:588)
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:612)
at com.aaa.test.Send.main(Send.java:19)

 

2、如果写错了HOST的IP(如:factory.setHost("192.168.1.10"); )无此地址, 报错:

 

Exception in thread "main" java.net.ConnectException: Connection timed out: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:529)
at com.rabbitmq.client.impl.FrameHandlerFactory.create(FrameHandlerFactory.java:32)
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:588)
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:612)
at com.aaatest.Send.main(Send.java:19)

 

3、如果写错端口PORT(如:factory.setPort(5678);) 报错:

Exception in thread "main" java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:529)
at com.rabbitmq.client.impl.FrameHandlerFactory.create(FrameHandlerFactory.java:32)
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:588)
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:612)
at com.aaa.test.Send.main(Send.java:19)

 

4、如果写错用户名或者密码,报错:

 

Exception in thread "main" com.rabbitmq.client.AuthenticationFailureException: ACCESS_REFUSED - Login was refused using authentication mechanism PLAIN. For details see the broker logfile.
at com.rabbitmq.client.impl.AMQConnection.start(AMQConnection.java:338)
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:590)
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:612)
at com.aaa.test.Send.main(Send.java:19)

转:http://blog.csdn.net/a15134566493/article/details/51393955

Centos6.5 安装 RabbitMQ3.6.1