1、下载安装包
https://pan.baidu.com/s/1oRU9gNjuXR5XDLBj_MSlGA
2、在centos上创建文件夹
![1f183015b7905a6e6b7070e1e71ba185.png](https://i-blog.csdnimg.cn/blog_migrate/744fd68ddcf6cf78d0001cf70ae82360.png)
3、rabbitmq 安装
rpm -ivh erlang-19.0.4-1.el7.centos.x86_64.rpm
erl -version
yum install socat
rpm -ivh rabbitmq-server-3.6.6-1.el7.noarch.rpm
info
[root@izm5eem0bopc0rg4tm78luz rabbitmq]# ll
total 23508
-rw-r--r-- 1 root root 18580960 Sep 16 14:42 erlang-19.0.4-1.el7.centos.x86_64.rpm
-rw-r--r-- 1 root root 5487706 Sep 16 14:42 rabbitmq-server-3.6.6-1.el7.noarch.rpm
[root@izm5eem0bopc0rg4tm78luz rabbitmq]# rpm -ivh erlang-19.0.4-1.el7.centos.x86_64.rpm
Preparing... ################################# [100%]
Updating / installing...
1:erlang-19.0.4-1.el7.centos ################################# [100%]
[root@izm5eem0bopc0rg4tm78luz rabbitmq]# erl -version
Erlang (SMP,ASYNC_THREADS,HIPE) (BEAM) emulator version 8.0.3
[root@izm5eem0bopc0rg4tm78luz rabbitmq]# rpm -ivh rabbitmq-server-3.6.6-1.el7.noarch.rpm
warning: rabbitmq-server-3.6.6-1.el7.noarch.rpm: Header V4 RSA/SHA1 Signature, key ID 6026dfca: NOKEY
error: Failed dependencies:
socat is needed by rabbitmq-server-3.6.6-1.el7.noarch
[root@izm5eem0bopc0rg4tm78luz rabbitmq]# yum install socat
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package socat.x86_64 0:1.7.3.2-2.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
===================================================================================================================================================================
Package Arch Version Repository Size
===================================================================================================================================================================
Installing:
socat x86_64 1.7.3.2-2.el7 base 290 k
Transaction Summary
===================================================================================================================================================================
Install 1 Package
Total download size: 290 k
Installed size: 1.1 M
Is this ok [y/d/N]: y
Downloading packages:
socat-1.7.3.2-2.el7.x86_64.rpm | 290 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
Installing : socat-1.7.3.2-2.el7.x86_64 1/1
Verifying : socat-1.7.3.2-2.el7.x86_64 1/1
Installed:
socat.x86_64 0:1.7.3.2-2.el7
Complete!
[root@izm5eem0bopc0rg4tm78luz rabbitmq]# rpm -ivh rabbitmq-server-3.6.6-1.el7.noarch.rpm
warning: rabbitmq-server-3.6.6-1.el7.noarch.rpm: Header V4 RSA/SHA1 Signature, key ID 6026dfca: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:rabbitmq-server-3.6.6-1.el7 ################################# [100%]
[root@izm5eem0bopc0rg4tm78luz rabbitmq]#
4、状态与启动
systemctl status rabbitmq-server #Active: active (running) 说明处于运行状态
service rabbitmq-server start # 启动
service rabbitmq-server stop # 停止
service rabbitmq-server restart # 重启
info
[root@izm5eem0bopc0rg4tm78luz rabbitmq]# systemctl status rabbitmq-server
● rabbitmq-server.service - RabbitMQ broker
Loaded: loaded (/usr/lib/systemd/system/rabbitmq-server.service; disabled; vendor preset: disabled)
Active: inactive (dead)
[root@izm5eem0bopc0rg4tm78luz rabbitmq]# service rabbitmq-server start
Redirecting to /bin/systemctl start rabbitmq-server.service
[root@izm5eem0bopc0rg4tm78luz rabbitmq]# systemctl status rabbitmq-server
● rabbitmq-server.service - RabbitMQ broker
Loaded: loaded (/usr/lib/systemd/system/rabbitmq-server.service; disabled; vendor preset: disabled)
Active: active (running) since Mon 2019-09-16 15:06:12 CST; 41s ago
Main PID: 7936 (beam.smp)
Status: "Initialized"
CGroup: /system.slice/rabbitmq-server.service
├─7936 /usr/lib64/erlang/erts-8.0.3/bin/beam.smp -W w -A 64 -P 1048576 -t 5000000 -stbt db -zdbbl 32000 -K true -- -root /usr/lib64/erlang -progname erl -- -home /var/lib/rabbitmq -- -pa /usr/lib/rabbi...
├─8072 /usr/lib64/erlang/erts-8.0.3/bin/epmd -daemon
├─8199 erl_child_setup 1024
├─8528 inet_gethost 4
└─8529 inet_gethost 4
Sep 16 15:06:02 izm5eem0bopc0rg4tm78luz rabbitmq-server[7936]: RabbitMQ 3.6.6. Copyright (C) 2007-2016 Pivotal Software, Inc.
Sep 16 15:06:02 izm5eem0bopc0rg4tm78luz rabbitmq-server[7936]: ## ## Licensed under the MPL. See http://www.rabbitmq.com/
Sep 16 15:06:02 izm5eem0bopc0rg4tm78luz rabbitmq-server[7936]: ## ##
Sep 16 15:06:02 izm5eem0bopc0rg4tm78luz rabbitmq-server[7936]: ########## Logs: /var/log/rabbitmq/rabbit@izm5eem0bopc0rg4tm78luz.log
Sep 16 15:06:02 izm5eem0bopc0rg4tm78luz rabbitmq-server[7936]: ###### ## /var/log/rabbitmq/rabbit@izm5eem0bopc0rg4tm78luz-sasl.log
Sep 16 15:06:02 izm5eem0bopc0rg4tm78luz rabbitmq-server[7936]: ##########
Sep 16 15:06:02 izm5eem0bopc0rg4tm78luz rabbitmq-server[7936]: Starting broker...
Sep 16 15:06:12 izm5eem0bopc0rg4tm78luz rabbitmq-server[7936]: systemd unit for activation check: "rabbitmq-server.service"
Sep 16 15:06:12 izm5eem0bopc0rg4tm78luz systemd[1]: Started RabbitMQ broker.
Sep 16 15:06:13 izm5eem0bopc0rg4tm78luz rabbitmq-server[7936]: completed with 0 plugins.
5、基本操作
# 查看当前所有用户
$ sudo rabbitmqctl list_users
# 查看默认guest用户的权限
$ sudo rabbitmqctl list_user_permissions guest
# 由于RabbitMQ默认的账号用户名和密码都是guest。为了安全起见, 先删掉默认用户
$ sudo rabbitmqctl delete_user guest
# 添加新用户
$ sudo rabbitmqctl add_user username password
# 设置用户tag
$ sudo rabbitmqctl set_user_tags username administrator
# 赋予用户默认vhost的全部操作权限
$ sudo rabbitmqctl set_permissions -p / username ".*" ".*" ".*"
# 查看用户的权限
$ sudo rabbitmqctl list_user_permissions username
6、rabbitmq配置文件
find / -name rabbitmq-defaults #查找默认配置文件的位置
find / -name "rabbitmq.config.example" #rabbit模板文件的位置
![e28ea1bdd92337a755012884e8cc0781.png](https://i-blog.csdnimg.cn/blog_migrate/dfbaa58dd2b3e39706cd2229ffd1ae1c.png)
![32e1bb5469ea4e3d830f6e52b46f46be.png](https://i-blog.csdnimg.cn/blog_migrate/cb8e649c5d0fa645684e124bfad0be5e.png)
将模板存储到上面查找的位置,命名为rabbitmq.conf
[root@izm5eem0bopc0rg4tm78luz ~]# cd /etc/rabbitmq
[root@izm5eem0bopc0rg4tm78luz rabbitmq]# mv rabbitmq.config.example rabbitmq.config
![05a44939645d9e9d5d6a5f800536b30b.png](https://i-blog.csdnimg.cn/blog_migrate/bf482b06f900266bb6bfad0b5343752e.png)
重启rabbitmq服务
结束。
安装延时消息插件并启用插件
RabbitMQ 延迟队列插件应用 以及 java 代码使用延迟消息