- 操作系统Ubuntu 16.04.1
- 通过
apt-get
方式安装
添加apt源
echo "deb http://dl.bintray.com/rabbitmq-erlang/debian xenial erlang-21.x" | sudo tee /etc/apt/sources.list.d/bintray.erlang.list
echo "deb https://dl.bintray.com/rabbitmq/debian xenial main" | sudo tee /etc/apt/sources.list.d/bintray.rabbitmq.list
配置公钥
wget -O - "https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc" | sudo apt-key add -
安装erlang
sudo apt-get update
sudo apt-get install erlang
sudo apt-get install erlang-nox
遇到确认则输入
Y
即可。install的两个命令会等待一段时间
安装RabbitMQ
sudo apt-get install rabbitmq-server
安装日志如下
ubuntu@VM-16-6-ubuntu:~$ sudo apt-get install rabbitmq-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
socat
The following NEW packages will be installed:
rabbitmq-server socat
0 upgraded, 2 newly installed, 0 to remove and 222 not upgraded.
Need to get 9,614 kB of archives.
After this operation, 11.8 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://mirrors.tencentyun.com/ubuntu xenial/universe amd64 socat amd64 1.7.3.1-1 [321 kB]
Get:2 https://dl.bintray.com/rabbitmq/debian xenial/main amd64 rabbitmq-server all 3.7.10-1 [9,293 kB]
Fetched 9,614 kB in 44s (215 kB/s)
Selecting previously unselected package socat.
(Reading database ... 86218 files and directories currently installed.)
Preparing to unpack .../socat_1.7.3.1-1_amd64.deb ...
Unpacking socat (1.7.3.1-1) ...
Selecting previously unselected package rabbitmq-server.
Preparing to unpack .../rabbitmq-server_3.7.10-1_all.deb ...
Unpacking rabbitmq-server (3.7.10-1) ...
Processing triggers for man-db (2.7.5-1) ...
Processing triggers for systemd (229-4ubuntu21.2) ...
Processing triggers for ureadahead (0.100.0-19) ...
Setting up socat (1.7.3.1-1) ...
Setting up rabbitmq-server (3.7.10-1) ...
Adding group `rabbitmq' (GID 122) ...
Done.
Adding system user `rabbitmq' (UID 115) ...
Adding new user `rabbitmq' (UID 115) with group `rabbitmq' ...
Not creating home directory `/var/lib/rabbitmq'.
Processing triggers for systemd (229-4ubuntu21.2) ...
Processing triggers for ureadahead (0.100.0-19) ...
通过以下命令查看安装的状态
sudo rabbitmqctl status
至此,RabbitMQ安装完成。
切换到root账号,来启用manager ui插件
rabbitmq-plugins enable rabbitmq_management
rabbitmq-plugins
命令必须使用root账号
创建新账号
sudo rabbitmqctl add_user mq mq123456
为账号设置tag
sudo rabbitmqctl set_user_tags mq administrator
为账号设置权限
sudo rabbitmqctl set_permissions -p "/" mq ".*" ".*" ".*"
查看当前账号
sudo rabbitmqctl list_users
为安全起见,删除默认的guest账号
sudo rabbitmqctl delete_user guest
创建rabbitmq配置文件,sudo vi /etc/rabbitmq/rabbitmq.config
,内容如下
[
{rabbit,[
{tcp_listeners, [5672]},
{loopback_users, ["mq"]}
]}
].
loopback_users
是用来配置可远程访问的账号的rabbitmq.config
的更多配置,大家可以参考/usr/share/doc/rabbitmq-server/rabbitmq.config.example.gz
,里面有对各个属性的官方说明
重启RabbitMQ
sudo service rabbitmq-server restart
manager ui
安装后,会自动创建一个系统账号rabbitmq,通过此账号启动RabbitMQ。
不知道此账号的密码是什么,所以只能用root账号重置一下rabbitmq的密码
passwd rabbitmq
网友评论