CentOS下最新版RabbitMQ安装
官网地址:https://www.rabbitmq.com/install-rpm.html#downloads
1、安装依赖环境erlang
cd /usr/local/src/
mkdir rabbitmq
cd rabbitmq
//下载rpm,如果下载速度慢可以本地下载上传Linux中也可
wget https://packages.erlang-solutions.com/erlang/esl-erlang/FLAVOUR_1_general/esl-erlang_19.3-1centos6_i386.rpm
rpm –import http://packages.erlang-solutions.com/rpm/erlang_solutions.asc //导入公钥
yum install esl-erlang_19.3-1centos6_i386.rpm //安装自动更新依赖(不建议使用rpm安装)
erl //验证是否安装成功
2、安装RabbitMQ
//下载
wget https://dl.bintray.com/rabbitmq/all/rabbitmq-server/3.6.6/rabbitmq-server-3.6.6-1.el6.noarch.rpm
//安装
rpm -ivh --nodeps rabbitmq-server-3.6.6-1.el6.noarch.rpm
3、开启远程访问权限
cd /etc/rabbitmq/
cp /usr/share/doc/rabbitmq-server-3.6.6/rabbitmq.config.example /etc/rabbitmq/
mv rabbitmq.config.example rabbitmq.config
编辑文件内容,打开注释,去除逗号即可,保存完重启MQ服务。
4、启用和配置
//常用的rabbitmq的命令
service rabbitmq-server start
service rabbitmq-server stop
service rabbitmq-server status
service rabbitmq-server rotate-logs|
service rabbitmq-server restart
service rabbitmq-server condrestart
service rabbitmq-server try-restart
service rabbitmq-server reload
service rabbitmq-server force-reload
ps -ef | grep rabbitmq 查看rabbitMq进程
netstat -anplt | grep LISTEN rabbitmq默认监听端口15672/5672
5、开启页面插件
rabbitmq-plugins enable rabbitmq_management
6、命令
$ sudo chkconfig rabbitmq-server on # 添加开机启动RabbitMQ服务
$ sudo /sbin/service rabbitmq-server start # 启动服务
$ sudo /sbin/service rabbitmq-server status # 查看服务状态
$ sudo /sbin/service rabbitmq-server stop # 停止服务
# 查看当前所有用户
$ sudo rabbitmqctl list_users
# 查看默认guest用户的权限
$ sudo rabbitmqctl list_user_permissions guest
# 由于RabbitMQ默认的账号用户名和密码都是guest。为了安全起见, 先删掉默认用户
$ sudo rabbitmqctl delete_user guest
# 添加新用户
$ sudo rabbitmqctl add_user username password
# 设置用户tag
$ sudo rabbitmqctl set_user_tags username administrator
# 赋予用户默认vhost的全部操作权限
$ sudo rabbitmqctl set_permissions -p / username ".*" ".*" ".*"
# 查看用户的权限
$ sudo rabbitmqctl list_user_permissions username