CentOS6.x安装RabbitMQ
一、安装依赖文件
1 yum install build-essential openssl openssl-devel unixODBC unixODBC-devel make gcc gcc-c++ kernel-devel m4 ncurses-devel tk tcl -y
二、安装Erlang
1.安装
1 #下载地址:http://www.erlang.org/downloads 选择对应的版本下载 2 tar zxvf otp_src_19.2.tar.gz 3 cd otp_src_19.2 4 ./configure --prefix=/usr/local/erlang --enable-hipe --enable-threads --enable-smp-support --enable-kernel-poll --without-javac 5 make && make install
2.校验是否安装成功
1 #验证是否安装成功 2 cd /usr/local/erlang/bin 3 [root@will bin]# ./erl 4 Erlang/OTP 19 [erts-8.2] [source] [async-threads:10] [hipe] [kernel-poll:false] 5 6 Eshell V8.2 (abort with ^G) 7 1> halt(). 8 #当出现以上信息时表示安装完成。然后输入halt().退出即可
三、安装RabbitMQ
1.安装
1 #下载地址:http://www.rabbitmq.com/releases/rabbitmq-server/ 选择对应的版本下载 2 tar zxvf rabbitmq-server-generic-unix-3.6.6.tar.gz 3 mv rabbitmq_server-3.6.6 /usr/local/rabbitmq 4 5 #vim /etc/profile文件,增加下面的环境变量 6 #set erlang environment 7 export PATH=$PATH:/usr/local/erlang/bin 8 9 #set rabbitmq environment 10 export PATH=$PATH:/usr/local/rabbitmq/sbin 11 12 #使得文件生效 13 source /etc/profile
2.启动服务
后台启动服务
/usr/local/rabbitmq/sbin/rabbitmq-server -detached
查看服务状态
/usr/local/rabbitmq/sbin/rabbitmqctl status
结果显示为下图,则证明安装成功
[root@will ~]# /usr/local/rabbitmq/sbin/rabbitmqctl status Status of node rabbit@will ... [{pid,1980}, {running_applications, [{rabbitmq_management,"RabbitMQ Management Console","3.6.6"}, {rabbitmq_web_dispatch,"RabbitMQ Web Dispatcher","3.6.6"}, {webmachine,"webmachine","1.10.3"}, {mochiweb,"MochiMedia Web Server","2.13.1"}, {syntax_tools,"Syntax tools","2.1.1"}, {rabbitmq_management_agent,"RabbitMQ Management Agent","3.6.6"}, {rabbit,"RabbitMQ","3.6.6"}, {os_mon,"CPO CXC 138 46","2.4.1"}, {ssl,"Erlang/OTP SSL application","8.1"}, {public_key,"Public key infrastructure","1.3"}, {asn1,"The Erlang ASN1 compiler version 4.0.4","4.0.4"}, {compiler,"ERTS CXC 138 10","7.0.3"}, {mnesia,"MNESIA CXC 138 12","4.14.2"},
.............
{run_queue,0}, {uptime,6}, {kernel,{net_ticktime,60}}]
四、RabbitMQ常用命令
1.关闭rabbitmq服务
/usr/local/rabbitmq/sbin/rabbitmqctl stop
或
ps -ef | grep rabbit 和 kill -9 xxx
2.开启插件管理页面
/usr/local/rabbitmq/sbin/rabbitmq-plugins enable rabbitmq_management
3.创建用户
/usr/local/rabbitmq/sbin/rabbitmqctl add_user rabbitadmin 123456 (添加用户名密码)
/usr/local/rabbitmq/sbin/rabbitmqctl set_user_tags rabbitadmin administrator(设置tags)
/usr/local/rabbitmq/sbin/rabbitmqctl add_vhost will_test (添加vhost)
/usr/local/rabbitmq/sbin/rabbitmqctl set_permissions -p will_test rabbitadmin ".*" ".*" ".*" (为某个用户设置vhost)
4.WEB登录(关闭防火墙/开放15672端口)
http://192.168.1.188:15672