rabbitmq-01:
yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
wget https://packages.erlang-solutions.com/erlang-solutions-1.0-1.noarch.rpm
rpm -Uvh erlang-solutions-1.0-1.noarch.rpm
rpm --import https://packages.erlang-solutions.com/rpm/erlang_solutions.asc
下载对应版本:
yum install erlang
tar xf rabbitmq-server-generic-unix-3.7.5.tar.xz -C /data/
# 配置环境变量
vim /etc/profile
export RABBITMQ_HOME=/data/rabbitmq_server
export PATH=$RABBITMQ_HOME/sbin:$PATH
source /etc/profile
# 启动
rabbitmq-server -detached
rabbitmqctl add_user anthony anthony666
rabbitmqctl set_user_tags anthony administrator
rabbitmqctl add_vhost /anthony
rabbitmqctl set_permissions -p /anthony anthony '.*' '.*' '.*'
rabbitmq-plugins enable rabbitmq_management
rabbitmq-02:与rabbitmq-01配置同理
/root/.erlang.cookie 一致
rabbitmqctl stop_app
rabbitmqctl join_cluster rabbit@rabbitmq-01
rabbitmqctl start_app
# 设置镜像模式
rabbitmqctl set_policy -p /anthony anthony "^" '{"ha-mode":"all","ha-sync-mode":"automatic"}'
# 启动
rabbitmqctl cluster_status
########移除节点
rabbitmqctl stop_app
rabbitmqctl reset
# 查看用户信息
rabbitmqctl list_users
注意事项;
两台机器之间需要绑定host主机地址
1.1.1.153 rabbitmq-01
1.1.1..154 rabbitmq-02
保证两台机器之间的erlang cookie是一致的:
/root/.erlang.cookie
保证erlang cookie权限是400
chmod 400 /root/.erlang.cookie
15672为web访问端口
5672为服务端口
查看5672端口占用进程