1.安装Erlang
-
wget -P /home/download https://github.com/rabbitmq/erlang-rpm/releases/download/v21.2.3/erlang-21.2.3-1.el7.centos.x86_64.rpm
-
sudo rpm -Uvh /home/download/erlang-21.2.3-1.el7.centos.x86_64.rpm
-
sudo yum install -y socat
2.安装Rabbitmq
-
wget -P /home/download https://github.com/rabbitmq/rabbitmq-server/releases/download/v3.7.9/rabbitmq-server-3.7.9-1.el7.noarch.rpm
-
sudo rpm -Uvh /home/download/rabbitmq-server-3.7.9-1.el7.noarch.rpm
3. 启动和关闭
-
启动服务
sudo systemctl start rabbitmq-server
-
查看状态
sudo systemctl status rabbitmq-server
-
停止服务
sudo systemctl stop rabbitmq-server
-
设置开机启动
sudo systemctl enable rabbitmq-server
4.开启Web管理插件
-
开启插件
rabbitmq-plugins enable rabbitmq_management
-
添加用户
rabbitmqctl add_user 用户名(admin) 用户密码(admin)
-
为用户分配操作权限
rabbitmqctl set_user_tags admin administrator
-
为用户分配资源权限
rabbitmqctl set_permissions -p / admin ".*" ".*" ".*"
rabbitmq有一个默认的guest用户,但是只能通过localhost访问,以上是添加了一个admin的账户
5.添加防火墙端口
-
添加端口号
sudo firewall-cmd --zone=public --add-port=4369/tcp --permanent sudo firewall-cmd --zone=public --add-port=5672/tcp --permanent sudo firewall-cmd --zone=public --add-port=25672/tcp --permanent sudo firewall-cmd --zone=public --add-port=15672/tcp --permanent
-
重启防火墙
sudo firewall-cmd --reload
6.配置虚拟主机
-
查看已经有的虚拟主机
rabbitmqctl list_vhosts
-
增加一个名为fisher的虚拟主机
rabbitmqctl add_vhost fisher
-
添加虚拟主机的访问权限(其中admin是上面配置的用户)
rabbitmqctl set_permissions -p admin fisher '.*' '.*' '.*'
知是行之始,行是知之成