在ubuntu上安装rabbitMq

官网提供的安装方法 https://www.rabbitmq.com/install-debian.html#apt-pinning

安装erlang

首先安装erlang,使用的是erlang-21.x版本

添加存储库签名密钥

通过key服务器添加key

sudo apt-key adv --keyserver "hkps.pool.sks-keyservers.net" --recv-keys "0x6B73A36E6026DFCA"

若失败则通过以下方法添加

wget -O - "https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc" | sudo apt-key add -

启用APT HTTPS传输

sudo apt-get install apt-transport-https

创建源列表文件

sudo touch /etc/apt/sources.list.d/bintray.erlang.list

向上述文件中添加下述内容

# Installs the latest 21.x version available in the repository.
deb http://dl.bintray.com/rabbitmq-erlang/debian stretch erlang-21.x

更新包索引并安装erlang

sudo apt-get update 

# This is recommended. Metapackages such as erlang and erlang-nox must only be used
# with apt version pinning. They do not pin their dependency versions.
sudo apt-get install -y erlang-base \
                        erlang-asn1 erlang-crypto erlang-eldap erlang-ftp erlang-inets \
                        erlang-mnesia erlang-os-mon erlang-parsetools erlang-public-key \
                        erlang-runtime-tools erlang-snmp erlang-ssl \
                        erlang-syntax-tools erlang-tftp erlang-tools erlang-xmerl

安装rabbitmq

安装rabbitmq的脚本,其中前两步和安装erlang时相同

#!/bin/sh

## Install RabbitMQ signing key 安装签名密钥
sudo apt-key adv --keyserver "hkps.pool.sks-keyservers.net" --recv-keys "0x6B73A36E6026DFCA"

## Install apt HTTPS transport 启用https传输
sudo apt-get install apt-transport-https

## Add Bintray repositories that provision latest RabbitMQ and Erlang 21.x releases 
## 添加rabbitmq的源列表文件
sudo tee /etc/apt/sources.list.d/bintray.rabbitmq.list <<EOF
deb https://dl.bintray.com/rabbitmq-erlang/debian bionic erlang-21.x
deb https://dl.bintray.com/rabbitmq/debian bionic main
EOF

## Update package indices
sudo apt-get update -y

## Install rabbitmq-server and its dependencies
sudo apt-get install rabbitmq-server -y --fix-missing

安装完成

启动服务:service rabbitmq-server start

设置远程访问

rabbitmq的安装路径为 /usr/lib/rabbitmq/

#开启后台管理页面
/usr/lib/rabbitmq/rabbitmq-plugins enable rabbitmq_management

如下为登陆界面url为host:15672
在ubuntu上安装rabbitMq_第1张图片

创建用户

默认的用户名为guest,密码为guest,不过此账号只能通过localhost:15672访问
故需要创建自用的管理员用户
创建方法如下

#添加用户
#/usr/lib/rabbitmq/rabbitmqctl add_user 账号 密码
/usr/lib/rabbitmq/rabbitmqctl add_user admin admin
#分配用户标签(为刚创建的admin用户赋予administrator标签)
/usr/lib/rabbitmq/rabbitmqctl set_user_tags admin administrator
#设置权限<即开启远程访问>(如果需要远程连接,例如java项目中需要调用mq,则一定要配置,否则无法连接到mq,admin为要赋予远程访问权限的刚创建的那个账号的名字,必须运行着rabbitmq此命令才能执行)
/usr/lib/rabbitmq/rabbitmqctl set_permissions -p "/" admin ".*" ".*" ".*" 

你可能感兴趣的:(ubuntu,工具安装)