Centos7下RabbitMQ的安装
一、前置依赖安装
yum -y install gcc glibc-devel make ncurses-devel openssl-devel xmlto perl wget gtk2-devel binutils-devel
二、erlang安装
erlang官网下载地址: http://erlang.org/download/
**注意:**rabbitMq 与erlang版本要匹配,参考https://www.rabbitmq.com/which-erlang.html
这里我们使用的版本是: “rabbitMq 3.9.9 + erlang 23.3”
默认安装路径:/url/local/erlang
# 下载
cd /home/soft
wget http://erlang.org/download/otp_src_23.3.tar.gz
tar -zxvf otp_src_23.3.tar.gz
cd otp_src_23.3/
# 编译安装
# 指定路径
./configure --prefix=/usr/local/erlang
make install
# 配置环境变量
echo 'export PATH=$PATH:/usr/local/erlang/bin' >> /etc/profile
source /etc/profile
# 测试
erl
# -------------------------------------------------------------------------
# Erlang/OTP 23 [erts-11.2] [source] [64-bit] [smp:1:1] [ds:1:1:10] [async-threads:1] [hipe]
# Eshell V11.2 (abort with ^G)
# 1> halt().
# -------------------------------------------------------------------------
三、rabbitMq安装
rabbitmq官网下载地址: https://github.com/rabbitmq/rabbitmq-server/releases 或 https://www.rabbitmq.com/download.html
默认端口:
Protocol Bound to Port amqp :: 5672 clustering :: 25672 http :: 15672 注意:默认guest只能在本机访问(uaer:pwd = guest:guest),不能远程访问。 如果要开启远程访问,需要新建用户
# 下载
cd /home/soft
wget https://github.com/rabbitmq/rabbitmq-server/releases/download/v3.9.9/rabbitmq-server-generic-unix-3.9.9.tar.xz
# 解压'*.tar.xz'需要两次
# 安装xz命令
yum install -y xz
# 第一次解压(*.tar.xz ->*.tar)
xz -d rabbitmq-server-generic-unix-3.9.9.tar.xz
# 第二次解压(*.tar -> *)
tar -xvf rabbitmq-server-generic-unix-3.9.9.tar
mv rabbitmq_server-3.9.9/ rabbitmq-3.9.9
mv rabbitmq-3.9.9/ /usr/local/
# 启动
cd /usr/local/rabbitmq-3.9.9/sbin
# 后台运行
./rabbitmq-server &
# 停止
cd /usr/local/rabbitmq-3.9.9/sbin
./rabbitmqctl stop
# 状态
./rabbitmqctl status
# 启用web插件
./rabbitmq-plugins enable rabbitmq_management
# 查看用户列表
./rabbitmqctl list_users
# -----------------------
# Listing users ...
# user tags
# admin []
# guest [administrator]
# -----------------------
# 添加用户
./rabbitmqctl add_user admin admin
# -----------------------
# Setting permissions for user "admin" in vhost "/" ...
# -----------------------
# 设置用户权限
./rabbitmqctl set_permissions -p "/" admin ".*" ".*" ".*"
# -----------------------
# Setting permissions for user "admin" in vhost "/" ...
# -----------------------
# 修改用户角色
./rabbitmqctl set_user_tags admin administrator
# -----------------------
# Setting tags for user "admin" to [administrator] ...
# -----------------------
./rabbitmqctl list_users
# -----------------------
# Listing users ...
# user tags
# admin [administrator]
# guest [administrator]
# -----------------------
# 删除guest默认用户
./rabbitmqctl delete_user guest