部署文档(rabbitmq篇)

这段时间多次安装rabbitmq, 写篇日志记录下, 方便以后.

本文默认环境为Ubuntu 16.04+

1 安装Erlang环境

1
2
3
4
5
6
7
8
sudo apt-get update
sudo apt-get upgrade
cd /tmp
wget http://packages.erlang-solutions.com/ubuntu/erlang_solutions.asc
sudo apt-key add erlang_solutions.asc
sudo apt-get update
sudo apt-get install erlang
sudo apt-get install erlang-nox

2 添加rabbitmq的apt源

1
2
echo 'deb http://www.rabbitmq.com/debian/ testing main' | sudo tee /etc/apt/sources.list.d/rabbitmq.list
wget -O- https://www.rabbitmq.com/rabbitmq-release-signing-key.asc |sudo apt-key add -

3 安装rabbitmq本体

1
2
sudo apt-get update
sudo apt-get install rabbitmq-server -y

4 启停rabbitmq命令

1
2
3
4
sudo systemctl enable rabbitmq-server
sudo systemctl start rabbitmq-server
sudo systemctl status rabbitmq-server
sudo systemctl stop rabbitmq-server

更多systemctl使用可以自行搜索
或者简单的命令行启动

1
2
3
sudo rabbitmq-server
sudo rabbitmq-server --detached (后台启动)
sudo rabbitmqctl stop

5 安装管理插件(可选)

1
sudo rabbitmq-plugins enable rabbitmq_management

安装后可以访问15672端口通过UI界面查看rabbitmq当前工作状态

添加rabbitmq用户及vhost

1
2
3
4
sudo rabbitmqctl add_user myuser mypassword
sudo rabbitmqctl add_vhost myvhost
sudo rabbitmqctl set_user_tags myuser mytag
sudo rabbitmqctl set_permissions -p myvhost myuser ".*" ".*" ".*"

rabbitmq安装后会有一个默认账户guest:guest, 可以安全起见做删除处理.

1
sudo rabbitmqctl delete_user guest