准备虚拟机系统 我的系统如下
系统版本7.2
清理yum并从新缓存
###清理yum 缓存
yum clean all
###缓存yum仓库
yum makecache
关闭防火墙
##临时关闭防火墙
systemctl stop firewalld
###禁止开机启动
systemctl disable firewalld
安装perl
yum install perl
安装wget工具
yum install -y wget
安装相关依赖工具
yum install ncurses ncurses-base ncurses-devel ncurses-libs ncurses-static ncurses-term ocaml-curses ocaml-curses-devel openssl-devel zlib-devel make ncurses-devel gcc gcc-c++ unixODBC unixODBC-devel openssl openssl-devel -y
下载erlang安装包
####进入/usr/local目录
cd /usr/local/
####下载erlang安装包
wget http://erlang.org/download/otp_src_20.0.tar.gz
解压erlang
tar -zxvf otp_src_20.0.tar.gz
配置编译环境
cd otp_src_20.0
./configure --prefix=/usr/local/erlang --with-ssl -enable-threads -enable-smmp-support -enable-kernel-poll --enable-hipe --without-javac
安装
make && make install
验证erlang是否安装成功
cd /usr/local/erlang/bin
./erl
配置erlang的环境变量
vi /etc/profile
export PATH=$PATH:/usr/local/erlang/bin
source /etc/profile
接下来正式安装rabbitmq
导入秘钥
rpm --import https://www.rabbitmq.com/rabbitmq-release-signing-key.asc
下载安装包
cd /usr/local
wget -O rabbitmq-server-3.6.10-1.el7.noarch.rpm https://www.rabbitmq.com/releases/rabbitmq-server/v3.6.10/rabbitmq-server-3.6.10-1.el7.noarch.rpm
安装socat
yum -y install socat
安装epel-release
yum -y install epel-release
安装rpm包
yum install rabbitmq-server-3.6.10-1.el7.noarch.rpm -y
创建一个空文件
vi /etc/rabbitmq/rabbitmq.config
在这个文件中录入如下内容:
###注意方括号后面有一个英文的小点
[].
设置 rabbitMQ-server 服务自动启动
systemctl enable rabbitmq-server
启用RabbitMQ服务
systemctl start rabbitmq-server
启用RabbitMQ的管理插件
rabbitmq-plugins enable rabbitmq_management
开启RabbitMQ的管理端口
firewall-cmd --zone=public --add-port=15672/tcp --permanent
firewall-cmd --reload
重启 rabbitmq-server 服务
systemctl restart rabbitmq-server
使用你的ip就可以访问了,比如我的是192.168.100.150
http://192.168.100.150:15672
配置RabbitMQ默认数据库和日志路径
1.为将要指定的目录设置访问权限
mkdir /usr/local/rabbitmq_dir
chown rabbitmq:rabbitmq /usr/local/rabbitmq_dir
chmod 777 /usr/local/rabbitmq_dir
2.创建rabbitmq-env.conf文件到 /etc/rabbitmq/rabbitmq-env.conf 并编辑配置如下内容:
创建:
vi /etc/rabbitmq/rabbitmq-env.conf
RABBITMQ_MNESIA_BASE=/usr/local/rabbitmq_dir
RABBITMQ_LOG_BASE=/usr/local/rabbitmq_dir
重启rabbitmq-server
systemctl restart rabbitmq-server
添加RabbitMQ用户,并设置其角色和权限
#添加用户,用户名和密码均为"admin"
rabbitmqctl add_user admin admin
#设置用户角色为administrator
rabbitmqctl set_user_tags admin administrator
#为admin分配vhost "/"的权限
rabbitmqctl set_permissions -p / admin ".*" ".*" ".*"
下面就可以用admin用户登录了
http://192.168.100.150:15672
rabbitmq常用命令:
##列出所有用户
rabbitmqctl list_users
###删除用户
rabbitmqctl delete_user xxx(用户名)
###清除用户权限
rabbitmqctl clear_permissions -p vhostpath xxxx(用户名)
###列出用户权限
rabbitmqctl list_user_permissions xxx(用户名)
###修改密码
rabbitmqctl change_password xxx(username) newpassword
来源:oschina
链接:https://my.oschina.net/u/2614774/blog/1930344