您的位置:首页 > 其它

rabbitmq安装完整版

2016-09-22 00:00 218 查看
摘要: 最近在学习rabbitmq,网上搜的安装教程,总是不完整,我自己参考了别人的教程,加上自己的实践,记录下安装步骤,供以后使用

1.安装依赖文件

[root@lugu-wugu-wxfile mq]# yum install ncurses-devel

[root@lugu-wugu-wxfile mq]# yum -y install openssl
[root@lugu-wugu-wxfile mq]# yum -y install ssl

[root@lugu-wugu-wxfile mq]# yum -y install xmlto

[root@lugu-wugu-wxfile mq]# yum -y install python-simplejson

[root@lugu-wugu-wxfile mq]# yum -y install python

进入 http://www.erlang.org/download.html 选择源文件下载

[root@lugu-wugu-wxfile mq]# wget http://www.erlang.org/download/otp_src_17.5.tar.gz

[root@lugu-wugu-wxfile mq]# tar zxvf otp_src_17.5.tar.gz

[root@lugu-wugu-wxfile mq]# cd otp_src_17.5

[root@lugu-wugu-wxfile mq]# ./configure

[root@lugu-wugu-wxfile mq]# make && make install

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

[root@lugu-wugu-wxfile mq]# erl

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

Eshell V6.4 (abort with ^G)

1> 9+1.

10

2> halt().

2.安装RabbitMQ

下载rabbitmq安装包

[root@lugu-wugu-wxfile mq]# wget http://www.rabbitmq.com/releases/rabbitmq-server/v3.6.0/rabbitmq-server-3.6.0.tar.xz

[root@lugu-wugu-wxfile mq]# xz -d rabbitmq-server-3.6.0.tar.xz

[root@lugu-wugu-wxfile mq]# tar xvf rabbitmq-server-3.6.0.tar

[root@lugu-wugu-wxfile mq]# cd rabbitmq-server-3.6.0

[root@lugu-wugu-wxfile mq]# make

[root@lugu-wugu-wxfile mq]# make install TARGET_DIR=/opt/rabbitmq SBIN_DIR=/opt/rabbitmq/sbin MAN_DIR=/opt/rabbitmq/man DOC_INSTALL_DIR=/opt/rabbitmq/doc

注意1:可能出现xz:Command not found

xz命令提示linux下提示bash:command not found解决方法

http://blog.sina.com.cn/s/blog_ba08e8e00101b1rs.html

注意2:make install时可能会报错:zip command not found.解决方法如下:

[root@lugu-wugu-wxfile mq]# yum install -y unzip zip;

3.使用RabbitMQ

启动MQ

[root@lugu-wugu-wxfile rabbitmq-server-3.6.0]# cd scripts/

[root@lugu-wugu-wxfile scripts]# ./rabbitmq-server -detached

Warning: PID file not written; -detached was passed.

查看状态

[root@lugu-wugu-wxfile scripts]# ./rabbitmqctl status

停止服务

[root@lugu-wugu-wxfile scripts]# ./rabbitmqctl stop

Stopping and halting node 'rabbit@lugu-wugu-wxfile' …

安装RabbitMQWeb管理插件

[root@lugu-wugu-wxfile scripts]# ./rabbitmq-plugins enable rabbitmq_management

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

enoent}

此时需要手动创建/etc/rabbitmq目录

[root@lugu-wugu-wxfile scripts]# mkdir /etc/rabbitmq

再次安装即可

[root@lugu-wugu-wxfile scripts]# ./rabbitmq-plugins enable rabbitmq_management

The following plugins have been enabled:

mochiweb

webmachine

rabbitmq_web_dispatch

amqp_client

rabbitmq_management_agent

rabbitmq_management

Applying plugin configuration to rabbit@lugu-wugu-wxfile... failed.

* Could not contact node rabbit@lugu-wugu-wxfile.

Changes will take effect at broker restart.

* Options: --online - fail if broker cannot be contacted.

--offline - do not try to contact broker.

添加账号

PS:默认账号guest只能在localhost访问

[root@lugu-wugu-wxfile scripts]# ./rabbitmqctl add_user admin admin

Creating user "admin" …

设置管理员

[root@lugu-wugu-wxfile scripts]# ./rabbitmqctl set_user_tags admin administrator

Setting tags for user "admin" to [administrator] …

设置读写权限

命令使用户admin具有/vhost1这个virtual host中所有资源的配置、写、读权限以便管理其中的资源

首先需要创建/vhost1

[root@lugu-wugu-wxfile scripts]# ./rabbitmqctl add_vhost /vhost1

Creating vhost "/vhost1” .

[root@lugu-wugu-wxfile scripts]# ./rabbitmqctl set_permissions -p /vhost1 admin '.*' '.*' '.*'

Setting permissions for user "admin" in vhost "/vhost1" …

然后就可以登录web页面了
http://192.168.1.20:15672
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息