安装Erlang
前期准备:
GNU make
Compiler -- GNU C Compiler, gcc or the C compiler frontend for LLVM, clang.
Perl 5
GNU m4 -- If HiPE (native code) support is enabled. HiPE can be disabled using --disable-hipe
ncurses, termcap, or termlib -- The development headers and libraries are needed, often known as ncurses-devel. Use --without-termcap to build without any of these libraries. Note that in this case only the old shell (without any line editing) can be used.
sed -- Stream Editor for basic text transformation.
依赖的软件包和工具
如果缺少,需要安装(本次已centos7.5 最小化安装)
# yum install gcc ncurses-devel clang sed perl openssl-devel
安装erlang
# cd /usr/local/src
# mkdir erlang
# cd erlang
# wget http://erlang.org/download/otp_src_19.3.tar.gz
注意:如果安装21版本,需要安装m4(yum install m4)
# tar zxvf opt_src_19.3.tar.gz
# cd opt_src_19.3.tar.gz
# ./configure --prefix=/usr/local/erlang
# make
# make install
环境变量增加内容
# vi /etc/profile
##### Add ENV for Erlang
export ERLANG_HOME=/usr/local/erlang
export PATH=$PATH:$ERLANG_HOME/bin
# source /etc/profile(立刻生效)
# erl (检查erlang安装结果,显示版本情况)
RabbitMQ简易安装
# cd /usr/local/
# wget http://www.rabbitmq.com/releases/rabbitmq-server/v3.6.15/rabbitmq-server-generic-unix-3.6.15.tar.xz
# xz -d rabbitmq-server-generic-unix-3.6.15.tar.xz
# tar xvf rabbitmq-server-generic-unix-3.6.15.tar
# mv rabbitmq_server-3.6.15 rabbitmq
# rm -f rabbitmq-server-generic-unix-3.6.15.tar
环境变量增加内容
# vi /etc/profile
##### Add ENV for RabbitMQ
export RABBITMQ_HOME=/usr/local/rabbitmq
export PATH=$PATH:$RABBITMQ_HOME/sbin
# source /etc/profile
没有rabbitmq.config的时候,缺省配置文件在$RABBIT_HOME/sbin/rabbitmq-defaults
rabbitmq-plugins enable rabbitmq_management
关于配置文件
配置文件目录$RABBITMQ_HOME/etc/rabbitmq/
配置文件:rabbitmq-env.conf / rabbitmq
集群搭建
vi /etc/hosts
172.23.0.21 mq1
172.23.0.22 mq2
172.23.0.23 mq3
以mq1为基
1、停mq2、mq3
rabbitmqctl stop
2、同步.erlang.cookie
将mq1中的.erlang.cookie同步到mq2、mq3 (scp rsync)
3、启动mq2、mq3
rabbitmq-server -detached
4、停mq2、mq3应用
rabbitmqctl stop_app
5、将mq2、mq3加到mq1中
在mq2、mq3上执行rabbitmqctl join_cluster rabbit@mq1
6、启动mq2、mq3应用
rabbitmqctl start_app
7、查看集群状态
[root@mq1 ~]# rabbitmqctl cluster_status
Cluster status of node rabbit@mq1
[{nodes,[{disc,[rabbit@mq1,rabbit@mq2,rabbit@mq3]}]},
{running_nodes,[rabbit@mq1]},
{cluster_name,<<"rabbit@mq1">>},
{partitions,[]},
可自己配置pid,不过不影响集群搭建
3、rabbitmq和erlang的版本对应表
http://www.rabbitmq.com/which-erlang.html?tdsourcetag=s_pctim_aiomsg
4、集群搭建过程中
需要先将rabbitmq停掉,再同步.erlang.cookie文件,否则停不掉rabbitmq
5、web页面不能访问
插件未启动 rabbitmq-plugins enable rabbitmq_management