RabbitMQ好文
- Rabbitmq Java Client Api详解
- tohxyblog-博客园-rabbitMQ教程系列
- robertohuang-CSDN-rabbitMQ教程系列
- RabbitMQ 中文文档
- RabbitMQ 能为你做些什么?
- RabbitMQ Quick(快速手册)
- RabbitMQ从入门到精通-CSDN专栏
- RabbitMQ入门教程 For Java
- RabbitMQ 原理介绍及安装部署
- RabbitMQ 技术入门与实战
- RabbitMQ知多少
安装RabbitMQ
Ubuntu
- 推荐-Installing RabbitMQ
- 我如何解决GPG错误“NO_PUBKEY”?
- Ubuntu中修复错误:'W: GPG error: NO PUBKEY'
添加RabbitMQ源:
sudo echo "deb http://www.rabbitmq.com/debian testing main" >> /etc/apt/sources.list
将RabbitMQ公钥加入我们的信任密钥列表,避免一些关于unsigned packages
的警告。
wget https://www.rabbitmq.com/rabbitmq-signing-key-public.asc
sudo apt-key add rabbitmq-signing-key-public.asc
更新软件列表,安装rabbitmq-server
:
apt-get update
apt-get install rabbitmq-server
rabbitmq的相关目录:
$ find / -name .erlang.cookie
/var/lib/rabbitmq/.erlang.cookie
执行apt-get update
之后报错:
W: GPG error: http://www.rabbitmq.com testing InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 6B73A36E6026DFCA
使用apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 6B73A36E6026DFCA
解决
启动MQ:
service rabbitmq-server start
发现通过ip:15672
还是无法访问,那么,还需要进一步设置,启用RabbitMQWeb管理插件:
rabbitmq-plugins enable rabbitmq_management
然后就可以通过浏览器访问了,当使用guest/guest
登陆时,报错,User can only log in via localhost
解决办法:
rabbitmqctl add_user admin admin
rabbitmqctl set_user_tags admin administrator
rabbitmqctl set_permissions -p / admin ".*" ".*" ".*"
添加用户参考:
- RabbitMQ 3.3.1 can not login with guest/guest
- How to Install RabbitMQ Server on Ubuntu 16.04 & 14.04
CentOS
yum -y install epel-release
yum -y update
wget https://www.rabbitmq.com/releases/rabbitmq-server/v3.6.10/rabbitmq-server-3.6.10-1.el7.noarch.rpm
rpm --import https://www.rabbitmq.com/rabbitmq-release-signing-key.asc
rpm -Uvh rabbitmq-server-3.6.10-1.el7.noarch.rpm
systemctl start rabbitmq-server
systemctl enable rabbitmq-server
rabbitmq-plugins enable rabbitmq_management
where -U to update if package is already installed, -v for verbose output, -h to print hash output
坑1:
在执行systemctl start rabbitmq-server.service
之后,报错:Failed to start RabbitMQ broker
:
原因,在运行systemctl start rabbitmq-server.service
之前,我先执行了rabbitmq-plugins enable rabbitmq_management
,导致/etc/rabbitmq/
下生成了enabled_plugins
。解决启动错误,先删除该文件。
此外,启动出错时,还有可能因为防护墙的原因,可以参考此篇文章关闭。
防火墙关闭解决办法:
firewall-cmd --permanent --add-port=5672/tcp
firewall-cmd --reload
setsebool -P nis_enabled 1
或者粗暴点的办法(不推荐)
`systemctl stop firewalld systemctl disable firewalld setenforce 0 (记得/etc/selinux/config也改成 disable,否则重启就不生效了)
坑2:
rabbitmq服务总算start成功了,但是执行rabbitmq-plugins enable rabbitmq_management
还是报错:
[root@SHA1000154085 rabbitmq]# rabbitmq-plugins enable rabbitmq_management
The following plugins have been enabled:
amqp_client
cowlib
cowboy
rabbitmq_web_dispatch
rabbitmq_management_agent
rabbitmq_management
Applying plugin configuration to rabbit@SHA1000154085... failed.
Error: {cannot_read_enabled_plugins_file,"/etc/rabbitmq/enabled_plugins",
eacces}
网上看到一篇文章,抱着绝望的心情执行了:
umask 0022; rabbitmq-plugins enable rabbitmq_management
竟然OK了!!!
坑3:
报错:"Cookie file /var/lib/rabbitmq/.erlang.cookie must be accessible by owner only"
解决办法-unable to start rabbitmq server on ubuntu 10.04:
chown rabbitmq:rabbitmq /var/lib/rabbitmq/.erlang.cookie
chmod 600 /var/lib/rabbitmq/.erlang.cookie
看来.erlang.cookie
的属组也很关键,修改好之后是这样的:
-rw------- 1 rabbitmq rabbitmq 20 Jun 14 14:31 .erlang.cookie
安装参考
- stackoverflow-How to install Install rabbitmq server on centos7
- How to Install RabbitMQ Server on CentOS 7
- RabbitMQ 基础
- how-to-install-rabbitmq-on-centos-7
- How to Install RabbitMQ on CentOS/RHEL 7/6 and Fedora
RabbitMQ集群
- rabbitmq 集群搭建
- Using RabbitMQ in Cluster
- CentOs7.3 搭建 RabbitMQ 3.6 Cluster 集群服务与使用
- Rabbitmq集群高可用测试
- RabbitMQ集群和高可用配置的技巧
修改hostname
临时修改hostname:hostname
推荐永久修改的方式:
CentOS系
$vi /etc/sysconfig/network
HOSTNAME=yourhostname
Debian发行版的hostname的配置文件是/etc/hostname
。
Ubuntu
vi /etc/hostname
还需要修改hosts
:
$vi /etc/hosts
127.0.0.1 node2
127.0.0.1 localhost node2 localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
最后reboot
重启,输入hostname
查看是否生效。
参考:
- CentOs6.5 修改主机名
- 修改centos等linux的hostname-永久生效
文件路径
[root@SHA1000154085 rabbitmq]# find / -name rabbitmq-server
/usr/lib/ocf/resource.d/rabbitmq/rabbitmq-server
/usr/lib/rabbitmq/lib/rabbitmq_server-3.6.10/sbin/rabbitmq-server
/usr/lib/rabbitmq/bin/rabbitmq-server
/usr/sbin/rabbitmq-server
/etc/logrotate.d/rabbitmq-server
重要方法
factory.setAutomaticRecoveryEnabled()
//默认rabbitmq client是打开了自动recover连接的能力的(5.0版本的rabbitmq 默认是打开的)
factory.setAutomaticRecoveryEnabled(true);
ExecutorService es = Executors.newFixedThreadPool(20);
return factory.newConnection(es);
channel.basicQos()
channel.basicQos(1); // accept only one unack-ed message at a time (see below)
参考-重要方法
- rabbitmq channel参数详解
- RabbitMQ指南(上)