rabbitmq编译部署以及常见报错

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了rabbitmq编译部署以及常见报错相关的知识,希望对你有一定的参考价值。

(一)源码安装Erlang
(1)下载erlang源码包
wget http://www.erlang.org/download/otp_src_R13B04.tar.gz
(2)解压缩erlang源码包
tar -zxvf otp_src_R13B04.tar.gz
(3)安装
./configure??--prefix=/usr/local/erlang
./make
./make install
如果抛出如下错误
No curses library functions found
请先安装?curses library? ? ? ??
yum -y install ncurses-devel
在安装otp时遇到了一点问题,整体的安装过程比较简单。

技术分享图片

这里我只需要解决APPLICATIONS DISABLED部分的问题:
1,安装unixODBC和unixODBC-devel,解决第一个问题;
2,因为我这里用不上Java编译了,因此可以在configure时增加 –disable-javac 避免第二个错误;
./configure --prefix=/usr/local/erlang --disable-javac
make && make install

定义环境变量 [[email protected] otp_src_R13B04]# cat /etc/profile.d/erlang.sh
export PATH=$PATH:/usr/local/erlang/bin

[[email protected] otp_src_R13B04]# erl -sname test
Erlang R13B04 (erts-5.7.5) [source] [64-bit] [rq:1] [async-threads:0] [kernel-poll:false]

安装rabbitmq
(1)下载rabbit包
wget http://www.rabbitmq.com/releases/rabbitmq-server/v3.2.0/rabbitmq-server-generic-unix-3.2.0.tar.gz
(2)解压到当前目录
tar -zxvf rabbitmq-server-generic-unix-3.2.0.tar.gz

(3)启动rabbitmq-server
cd?rabbitmq_server-3.2.0
sbin/rabbitmq-server

插件安装
cd /usr/local/rabbitmq/sbin/
./rabbitmq-plugins enable rabbitmq_management
可以在浏览器中输入:http://192.168.1.164:15672/ 默认用户是guest 默认密码是guest

======================================================
集群部署

设置 Erlang Cookie
??RabbitMQ节点之间和命令行工具 (e.g. rabbitmqctl)是使用Cookie互通的,Cookie是一组随机的数字+字母的字符串。当RabbitMQ服务器启动的时候,Erlang VM会自动创建一个随机内容的Cookie文件。如果是通过源安装RabbitMQ的话,Erlang Cookie 文件在/var/lib/rabbitmq/.erlang.cookie。如果是通过源码安装的RabbitMQ,Erlang Cookie文件$HOME/.erlang.cookie。
??本文演示的实例是用源码安装,由于这个文件权限是 400,所以需要先修改 node2、node3 中的该文件权限为 777:
[email protected]:~$ chmod 777 .erlang.cookie??然后将文件复制到node2、node3上面。
node2:
[email protected]:~$ chmod 777 .erlang.cookie
[email protected]:~$ scp -r node1:/home/lion/.erlang.cookie ~/
[email protected]‘s password:
.erlang.cookie 100% 20 0.0KB/s 00:00node3:
[email protected]:~$ chmod 777 .erlang.cookie
[email protected]:~$ scp -r node1:/home/lion/.erlang.cookie ~/
[email protected]‘s password:
.erlang.cookie 100% 20 0.0KB/s 00:00??分别在node1、node2、node3将权限恢复过来:
[email protected]:~$ chmod 400 .erlang.cookie??最后分别在确认三台机器上的.erlang.cookie的值是一致的
[email protected]:~$ cat .erlang.cookie
VORMVSAAOFOFEQKTNWBA

[email protected]:~$ cat .erlang.cookie
VORMVSAAOFOFEQKTNWBA

[email protected]:~$ cat .erlang.cookie
VORMVSAAOFOFEQKTNWBA

(3)分别启动rabbitmq
[[email protected] rabbitmq_server-3.2.0]# sbin/rabbitmq-server -detached

[[email protected] rabbitmq_server-3.2.0]# sbin/rabbitmq-server -detached

(4)创建clusterbr/>我们以[email protected]为主,将[email protected]加入到集群中
[[email protected] rabbitmq_server-3.2.0]# sbin/rabbitmqctl stop_app
[[email protected] rabbitmq_server-3.2.0]# sbin/rabbitmqctl join_cluster --ram [email protected] 在执行这个的时候一直报错
[[email protected] rabbitmq_server-3.2.0]# sbin/rabbitmqctl join_cluster --ram [email protected]
Clustering node [email protected] with [email protected] ...
Error: {cannot_discover_cluster,"The nodes provided are either offline or not running"}
需要让主机名字生效

[[email protected] rabbitmq_server-3.2.0]# sbin/rabbitmqctl start_app
查看集群状态
[[email protected] rabbitmq_server-3.2.0]# sbin/rabbitmqctl cluster_status
[[email protected] rabbitmq_server-3.2.0]# sbin/rabbitmqctl cluster_status
Cluster status of node [email protected] ...
br/>[{nodes,[{disc,[[email protected]]},{ram,[[email protected]]}]},
{running_nodes,[[email protected],[email protected]]},
{partitions,[]}]
...done.
[[email protected] rabbitmq_server-3.2.0]#

两个节点得到相同的输出,其中[email protected]节点形式是disc,[email protected]节点形式是ram。这和执行join_cluster命令是的选项--ram是一致的。
(5)改变节点形式

[plain] view plain copy print?1. [[email protected]?rabbitmq_server-3.2.0]#?sbin/rabbitmqctl?stop_app??

  1. [email protected]?...??
  2. ...done.??
  3. [[email protected]?rabbitmq_server-3.2.0]#?sbin/rabbitmqctl?change_cluster_node_type?disc??
  4. [email protected]?into?a?disc?node?...??
  5. ...done.??
  6. [[email protected]?rabbitmq_server-3.2.0]#?sbin/rabbitmqctl?start_app??
  7. [email protected]?...??
  8. ...done.??

我们将[email protected]的节点改为disc

[plain] view plain copy print?1. [[email protected]?rabbitmq_server-3.2.0]#?sbin/rabbitmqctl?cluster_status??

  1. [email protected]?...??
  2. [{nodes,[{disc,[[email protected],[email protected]]}]},??
  3. ?{running_nodes,[[email protected],[email protected]]},??
  4. ?{partitions,[]}]??
  5. ...done.??

两个节点都是disc的形式
(6)从cluster中分离

[plain] view plain copy print?1. [[email protected]?rabbitmq_server-3.2.0]#?sbin/rabbitmqctl?stop_app??

  1. [email protected]?...??
  2. ...done.??
  3. [[email protected]?rabbitmq_server-3.2.0]#?sbin/rabbitmqctl?reset??
  4. [email protected]?...??
  5. ...done.??
  6. [[email protected]?rabbitmq_server-3.2.0]#?sbin/rabbitmqctl?start_app??
  7. [email protected]?...??

[[email protected] rabbitmq_server-3.2.0]# sbin/rabbitmqctl cluster_status
Cluster status of node [email protected] ...
br/>[{nodes,[{disc,[[email protected]]}]},
{running_nodes,[[email protected]]},
{partitions,[]}]
...done.
硬删除:直接删掉集群中的某个节点:rabbitmqctl forget_cluster_node ? node_name




以上是关于rabbitmq编译部署以及常见报错的主要内容,如果未能解决你的问题,请参考以下文章

JavaScript 调试常见报错以及原因

MHA常见报错以及解决方法

Android Studio编译开源项目(含NDK开发)常见报错

mybatis常见报错!!

JVM-Sandbox常见报错

常见报错:如何解决 vs 编译器scanf函数报错问题?