当前位置:   article > 正文

[Linux]RabbitMQ

[Linux]RabbitMQ

1 问题

环境: CentOS7.8.2003 (x86 / 64bit)

版本: RabbitMQ 3.6.15 (Erlang 19.3)

安装方式: 二进制源码压缩安装

91b27e475fb038505062c070096d8d21.png

2 解决思路

2.1 思路1 关闭进程,并重启

step1 查询mq的进程

ps -ef | grep rabbitmq

step2 杀掉mq进程

ps -ef | grep rabbitmq | grep -v grep | awk ‘{print $2}’ | xargs kill -9

step3 启动mq

rabbitmq-server -detached

Warning: PID file not written; -detached was passed.

step4 在查询mq的状态

rabbitmqctl status

fa4b5e49bde5d6f6628441c35539d250.png

2.2 思路2 erlang安装版本与rabbitmq版本不兼容

2.3 思路3 RabbitMQ的依赖件: erlang的cookie

1 安装方式:

Linux中,rabbitmq安装方式主要有两种:RPM安装 和 二进制安装(编译安装/压缩包安装)

2 .erlang.cookie是什么

.erlang.cookie是erlang实现分布式的必要文件;

erlang分布式的每一个节点上要保持相同的.erlang.cookie文件,同时该文件的权限至少应为400。

3 .erlang.cookie文件路径?

Linux

$HOME/.erlang.cookie 【二进制安装(编译安装/压缩包安装)】

若用root角色安装,则 /root/.erlang.cookie;其他用户为/home/用户名/.erlang.cookie

~/.erlang.cookie

/var/lib/rabbitmq/.erlang.cookie 【RPM安装】

Windows

C:Users${username}.erlang

用上面这个文件覆盖下面目录的文件

C:Windows.erlang.cookie

C:WindowsSystem64configsystemprofile

C:WindowsSystem32configsystemprofile

4 可通过rabbitmq的启动日志,查看rabbitmq的home目录以及.erlang.cookie文件的位置等信息。

=INFO REPORT==== 20-Jul-2018::13:34:56 ===

node : rabbit@he10

home dir : /root (我是用root用户启动的)

config file(s) : /home/rabbitmq_server-3.6.1/etc/rabbitmq/rabbitmq.config (not found)

cookie hash : 063Gh+RyPjHRzyuSPf9wWA==

rabbit@localhost:

* connected to epmd (port 4369) on localhost

* epmd reports: node ‘rabbit’ not running at all

other nodes on localhost: [‘rabbitmq-cli-17’]

* suggestion: start the node

current node details:

- node name: ‘rabbitmq-cli-17@Hydrant’

- home dir: /root

- cookie hash: 063Gh+RyPjHRzyuSPf9wWA==

2.4 思路4 重新安装RabbitMQ的服务

代价最高

3 补充

RabbitMQ相关的命令

[rabbitmq-server]

[service] rabbitmq-server stop #[service] : 表示中括号内的service命令可加可不加,下同

[service] rabbitmq-server start #前台启动rabbitmq服务

[service] rabbitmq-server restart

[service] rabbitmq-service remove

[service] rabbitmq-server -detached #后台启动rabbitmq服务

[rabbitmqctl]

rabbitmqctl status

rabbitmqctl stop

Stops the Erlang node on which RabbitMQ is running. To restart the node follow the instructions for Running the Server in the installation guide[1].

rabbitmqctl start_app

rabbitmqctl stop_app

rabbitmqctl shutdown

Shuts down the Erlang process on which RabbitMQ is running. The command is blocking and will return after the Erlang process exits. If RabbitMQ fails to stop, it will return a non-zero exit code.

rabbitmqctl change_password {username} {password}

rabbitmqctl list_users #查看监听用户

rabbitmqctl add_user {username} {password}

rabbitmqctl set_user_tags {username} {tag …}

rabbitmqctl set_user_tags admin administrator

rabbitmqctl set_permissions [-p vhost] {user} {conf} {write} {read}

rabbitmqctl set_permissions -p “/” admin “.*” “.*” “.*”

rabbitmqctl delete_user {username}

[rabbitmq-plugins]

rabbitmq-plugins enable/disable rabbitmq_management #开启/禁用 rabbitmq的web管理插件

rabbitmq-plugins enable/disable rabbitmq_web_stomp

rabbitmq-plugins enable/disable rabbitmq_tracing #开启/禁用 rabbitmq_tracing能跟踪RabbitMQ中消息的流入流出情况

4 参考文献

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/菜鸟追梦旅行/article/detail/452641
推荐阅读
相关标签
  

闽ICP备14008679号