您好,登錄后才能下訂單哦!
這篇文章主要講解了“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進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。