单节点安装
erl安装1
2
3
4
5
6
7# erlang安装
yum -y install make gcc gcc-c++ kernel-devel m4 ncurses-devel openssl-devel unixODBC unixODBC-devel httpd python-simplejson
wget http://erlang.org/download/otp_src_19.3.tar.gz
tar -zxf otp_src_19.3.tar.gz
./configure --prefix=/usr/local/erlang
make
make install
1 | # 配置环境变量 |
1 | # 测试 |
rabbitmq安装1
2# rabbitmq下载地址
https://www.rabbitmq.com/releases/rabbitmq-server/
1 | wget https://www.rabbitmq.com/releases/rabbitmq-server/v2.7.0/rabbitmq-server-generic-unix-2.7.0.tar.gz |
1 | ./sbin/rabbitmq-server |
集群配置
确保两台机器都正确安装rabbitmq1
2
3
4
5
6
7
8
9
10# 主机名称修改
vim /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=host1
# 也可以使用指令临时修改主机名
hostnamectl set-hostname 新主机名
vim /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=host2
1 | # 同步host |
将host1的rabbitmq cookie配置给host21
2
3
4
5
6
7
8# 同步cookie
vim /root/.erlang.cookie
SLTASOPTCNCVPPREUWOV
复制SLTASOPTCNCVPPREUWOV
进入host2
vim /root/.erlang.cookie
修改
1 | # 启动host1 |
到这里就安装成功了,笔者在添加节点的时候存在报错1
2
3Clustering node rabbit@tencent2 with [rabbit@cui] ...
Error: {failed_to_cluster_with,[rabbit@cui],
"Mnesia could not connect to some nodes."}
对这个错误从两个方向进行排查1
2
3主机名是否正确配置-能ping通
erlang版本和rabbitmq版本是否一致
可以配合./rabbitmqctl -n rabbit@host1 status指令,在host2上执行看能否正确连接host1
yum安装1
2
3
4
5
6
7
8
9
10
11
12
13
14
15yum install erlang
wget http://www.rabbitmq.com/releases/rabbitmq-server/v3.5.0/rabbitmq-server-3.5.0-1.noarch.rpm
yum install rpm
rpm -ivh rabbitmq-server-3.5.0-1.noarch.rpm
# 开启管理员界面
rabbitmq-plugins enable rabbitmq_management
# 添加管理员账号
rabbitmqctl add_user rabbitadmin 123456
# 分配用户标签
rabbitmqctl set_user_tags rabbitadmin administrator
#创建和赋角色完成后查看并确认
rabbitmqctl list_users
service rabbitmq-server restart
1 | 访问http://XXX.XXX.XXX.XXX:15672/ |
参考文章
https://www.imooc.com/article/42017
https://www.jianshu.com/p/434eb8bfaa5f