#安装依赖项
yum install -y gcc gcc-c++ glibc-devel make ncurses-devel openssl-devel autoconf java-1.8.0-openjdk-devel git
erlang与rabbitmq 版本对应 参见 官网 https://www.rabbitmq.com/which-erlang.html
安装erlang 以下方案二选一,不同centos的系统还是的参见官网这里是centos 7的
详见官网说明 https://github.com/rabbitmq/erlang-rpm (这个时效性能比较强 参考一下就行,谁知道官网啥时候又更新新版本了)
#编辑该文件
vi /etc/yum.repos.d/rabbitmq_erlang.repo
#文件内容修改如下:
# In /etc/yum.repos.d/rabbitmq_erlang.repo
[rabbitmq_erlang]
name=rabbitmq_erlang
baseurl=https://packagecloud.io/rabbitmq/erlang/el/7/$basearch
repo_gpgcheck=1
gpgcheck=0
enabled=1
gpgkey=https://packagecloud.io/rabbitmq/erlang/gpgkey
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300
[rabbitmq_erlang-source]
name=rabbitmq_erlang-source
baseurl=https://packagecloud.io/rabbitmq/erlang/el/7/SRPMS
repo_gpgcheck=1
gpgcheck=0
enabled=1
gpgkey=https://packagecloud.io/rabbitmq/erlang/gpgkey
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300
执行安装
yum install erlang
#编辑该文件
vi /etc/yum.repos.d/rabbitmq-erlang.repo
#文件内容修改如下:
# In /etc/yum.repos.d/rabbitmq-erlang.repo
[rabbitmq-erlang]
name=rabbitmq-erlang
baseurl=https://dl.bintray.com/rabbitmq-erlang/rpm/erlang/22/el/7
gpgcheck=1
gpgkey=https://dl.bintray.com/rabbitmq/Keys/rabbitmq-release-signing-key.asc
repo_gpgcheck=0
enabled=1
执行安装
yum install erlang
#安装socat
yum -y install socat
#下载rabbitmq
wget https://github.com/rabbitmq/rabbitmq-server/releases/download/v3.8.0/rabbitmq-server-3.8.0-1.el6.noarch.rpm
#安装rabbitmq
rpm -ivh rabbitmq-server-3.8.0-1.el6.noarch.rpm
#试运行rabbitmq
rabbitmq-server
如报以下错误,
ERROR: epmd error for host “192”:badarg (unknown POSIX error)
修改
vi /etc/rabbitmq/rabbitmq-env.conf
追加如下配置:
NODENAME=rabbit@localhost
#启动服务
systemctl start rabbitmq-server
#查看服务状态
systemctl status rabbitmq-server
#重启服务
systemctl restart rabbitmq-server
#设置为开机启动
systemctl enable rabbitmq-server
rabbitmq-plugins enable rabbitmq_management
#添加端口
firewall-cmd --add-port=5672/tcp --permanent
firewall-cmd --add-port=15672/tcp --permanent
#重新加载配置
firewall-cmd --reload
# 防火墙启动关闭
systemctl start firewalld.service
systemctl stop firewalld.service
systemctl enable firewalld.service
# 查看防火墙端口列表
firewall-cmd --permanent --list-port
出现错误执行 systemctl unmask firewalld 即可
#执行命令,即可实现取消服务的锁定
systemctl unmask firewalld
#下次需要锁定该服务时执行
systemctl mask firewalld
自己机器的ip地址加端口
http://192.168.100.100:15672/
用户名:guest
密码:guest
#添加用户 用户名 admin 密码 admin web管理工具可用此用户登录
sudo rabbitmqctl add_user admin admin
#设置用户角色 管理员
sudo rabbitmqctl set_user_tags admin administrator
#tag(administrator,monitoring,policymaker,management)
#设置用户权限(接受来自所有Host的所有操作)
sudo rabbitmqctl set_permissions -p "/" admin '.*' '.*' '.*'
#查看用户权限
sudo rabbitmqctl list_user_permissions admin
修改 rabbitmq.config
vi /etc/rabbitmq/rabbitmq.config
#保存以下配置()
[
{rabbit, [{tcp_listeners, [5672]}, {loopback_users, ["admin"]}]}
].
# 添加用户
sudo rabbitmqctl add_user
# 删除用户
sudo rabbitmqctl delete_user
# 修改用户密码
sudo rabbitmqctl change_password
# 清除用户密码(该用户将不能使用密码登陆,但是可以通过SASL登陆如果配置了SASL认证)
sudo rabbitmqctl clear_password
# 设置用户tags(相当于角色,包含administrator,monitoring,policymaker,management)
sudo rabbitmqctl set_user_tags
# 列出所有用户
sudo rabbitmqctl list_users
# 创建一个vhosts
sudo rabbitmqctl add_vhost
# 删除一个vhosts
sudo rabbitmqctl delete_vhost
# 列出vhosts
sudo rabbitmqctl list_vhosts [ ...]
# 针对一个vhosts给用户赋予相关权限;
sudo rabbitmqctl set_permissions [-p ]
# 清除一个用户对vhosts的权限;
sudo rabbitmqctl clear_permissions [-p ]
# 列出哪些用户可以访问该vhosts;
sudo rabbitmqctl list_permissions [-p ]
# 列出用户访问权限;
sudo rabbitmqctl list_user_permissions
其它配置参考
https://www.rabbitmq.com/documentation.html