您好,登录后才能下订单哦!
这篇文章主要讲解了“linux环境下如何搭建rabbitMQ单节点”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“linux环境下如何搭建rabbitMQ单节点”吧!
linux环境 CentOS-6.5-x86_64
erlang版本 otp_src_20.0.tar.gz
wget http://erlang.org/download/otp_src_20.0.tar.gz
rabbitMQ版本 rabbitmq-server-generic-unix-3.6.15.tar.xz
https://www.rabbitmq.com/releases/rabbitmq-server/v3.6.15/
开始搭建
先修改hosts,命名主机名称,192.168.220.129是我虚拟机的一个IP
# vi /etc/hosts
192.168.220.129 rabbitmq
# cd /usr/local/src (把otp_src_20.0.tar.gz 以及rabbitmq-server-generic-unix-3.6.15.tar上传到此目录)
# tar xvf otp_src_20.0.tar.gz (由于rabbitmq是erlang语言开发的,所以先安装erlang环境)
# cd otp_src_20.0
#./configure --prefix=/usr/local/erlang --with-ssl --enable-threads --enable-smp-support --enable-kernel-poll --enable-hipe --without-javac
执行完之后,如果出现下图红色框所示,还需要 ncurses-devel.x86_64
会报个小错 Makefile:248: /usr/local/otp_src_20.0/make/x86_64-unknown-linux-gnu/otp_ded.mk: No such file or directory error: No curses library functions found
# yum install ncurses-devel.x86_64
#./configure --prefix=/usr/local/erlang --with-ssl --enable-threads --enable-smp-support --enable-kernel-poll --enable-hipe --without-javac
继续执行,出现以下的信息,说明正常了
#make && make install
安装完之后,配置一下erlang的环境变量
#vi /etc/profile
添加后保存退出
#source /etc/profile
使用source使文件立即生效
#erl
erlang环境OK了,接下来是rabbitMQ的安装
#cd /usr/local/src
#tar xvf rabbitmq-server-generic-unix-3.6.15.tar
[root@rabbitmq src]# mv rabbitmq_server-3.6.15/ ../rabbitmq
#vi /etc/profile
按照如上如所示配置rabbitMQ环境变量,并执行source /etc/profile
#source /etc/profile
#rabbitmq-server -detached
执行rabbitmq-server -detached 启动后台守护进程启动,否则shell退出后,rabbitmq也退出。
#rabbitmqctl status
查看rabitmq状态是否启动,如果抛如下错误
Status of node rabbit@rabbitmq
Error: unable to connect to node rabbit@rabbitmq: nodedown
DIAGNOSTICS
===========
attempted to contact: [rabbit@rabbitmq]
rabbit@rabbitmq:
* connected to epmd (port 4369) on rabbitmq
* epmd reports: node 'rabbit' not running at all
no other nodes on rabbitmq
* suggestion: start the node
current node details:
- node name: 'rabbitmq-cli-31@rabbitmq'
- home dir: /root
- cookie hash: JTCyebhk7sHDdUd5ICe4kg==
执行rabbitmq-service stop停掉服务先
# rabbitmq-server stop
如果stop命令执行后抛如下命令,大概的意思是erlang还依赖openssl
BOOT FAILED
===========
Error description:
{error,{missing_dependencies,[crypto,ssl],
[cowboy,cowlib,rabbitmq_management,
rabbitmq_management_agent,
rabbitmq_trust_store]}}
Log files (may contain more information):
/usr/local/rabbitmq/var/log/rabbitmq/rabbit@rabbitmq.log
/usr/local/rabbitmq/var/log/rabbitmq/rabbit@rabbitmq-sasl.log
Stack trace:
[{rabbit_plugins,ensure_dependencies,1,
[{file,"src/rabbit_plugins.erl"},{line,185}]},
{rabbit_plugins,prepare_plugins,1,
[{file,"src/rabbit_plugins.erl"},{line,203}]},
{rabbit,broker_start,0,[{file,"src/rabbit.erl"},{line,300}]},
{rabbit,start_it,1,[{file,"src/rabbit.erl"},{line,424}]},
{init,start_em,1,[]},
{init,do_boot,3,[]}]
{"init terminating in do_boot",{error,{missing_dependencies,[crypto,ssl],[cowboy,cowlib,rabbitmq_management,rabbitmq_management_agent,rabbitmq_trust_store]}}}
init terminating in do_boot ({error,{missing_dependencies,[crypto,ssl],[cowboy,cowlib,rabbitmq_management,rabbitmq_management_agent,rabbitmq_trust_store]}})
Crash dump is being written to: erl_crash.dump...done
进入/usr/local/src目录下载openssl
#cd /usr/local/src
#wget http://www.openssl.org/source/openssl-1.0.1s.tar.gz
#tar -zvxf openssl-1.0.1s.tar.gz
#cd openssl-1.0.1s
#./config --prefix=/usr/local/openssl
#vi Makefile
使用/搜索CFLAG 添加如下图所示,其实就是添加-fPIC
#make && make install
安装完成后,还需要重新安装一下erlang,方式有一点改变,就是openssl指定了安装的路径,回到otp_src_20.0安装包下
#cd /usr/local/src/otp_src_20.0
#./configure --prefix=/usr/local/erlang --with-ssl=/usr/local/openssl --enable-threads --enable-smp-support --enable-kernel-poll --enable-hipe --without-javac
#make && make install
安装完成后,重新启动rabbitmq
#rabbitmq-server -detached
#ps -ef |grep rabbitmq
#rabbitmqctl status
rabbitmq服务已经搭建完成,然后开启rabbitmq web服务,看到started 6 plugins,说明已经启动成功
#rabbitmq-plugins enable rabbitmq_management
剩下的就是开启防火墙了
#vi /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 5672 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 15672 -j ACCEPT
#service iptables restart
打开浏览器,输入你的IP:15672即可访问
感谢各位的阅读,以上就是“linux环境下如何搭建rabbitMQ单节点”的内容了,经过本文的学习后,相信大家对linux环境下如何搭建rabbitMQ单节点这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是亿速云,小编将为大家推送更多相关知识点的文章,欢迎关注!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。