rabbitmq安裝 linux

rabbitmq 和erlang對照表html

https://www.rabbitmq.com/which-erlang.html#supported-version-policyjava

erlang地址:c++

https://www.erlang-solutions.com/resources/download.htmlgit

rabbitmq地址:github

https://www.rabbitmq.com/download.htmlshell

centos7vim

一. 安裝

	第一步:yum安裝erlang
	添加rabbitmq依賴的erlang yum命令repos

	/etc/yum.repos.d/rabbitmq-erlang.repo



	[rabbitmq-erlang]
	name=rabbitmq-erlang
	baseurl=https://dl.bintray.com/rabbitmq/rpm/erlang/21/el/7
	gpgcheck=1
	gpgkey=https://dl.bintray.com/rabbitmq/Keys/rabbitmq-release-signing-key.asc
	repo_gpgcheck=0
	enabled=1



	yum安裝:

	yum -y install erlang



	檢查安裝版本:

	erl



	返回:

	Erlang/OTP 21 [erts-10.0.7] [source] [64-bit] [smp:1:1] [ds:1:1:10] [async-threads:1] [hipe]



	Eshell V10.0.7  (abort with ^G)



第二步:安裝Rabbitmq


	下載rpm包:

	wget https://dl.bintray.com/rabbitmq/all/rabbitmq-server/3.7.7/rabbitmq-server-3.7.7-1.el7.noarch.rpm



	導入簽名密鑰

	rpm --import https://dl.bintray.com/rabbitmq/Keys/rabbitmq-release-signing-key.asc



	yum安裝:
	yum install rabbitmq-server-3.7.7-1.el7.noarch.rpm



	設置開機啓動:

	chkconfig rabbitmq-server on




	啓動、中止服務:

	/sbin/service rabbitmq-server start
	/sbin/service rabbitmq-server stop



	查看日誌:

	/var/log/rabbitmq/rabbit@[hostname].log



	查看狀態:

	systemctl status rabbitmq-server.service

	返回信息:

	● rabbitmq-server.service - RabbitMQ broker

	  Loaded: loaded (/usr/lib/systemd/system/rabbitmq-server.service; enabled; vendor preset: disabled)

	  Active: active (running) since Sun 2018-09-09 23:49:03 CST; 13min ago

	Main PID: 10908 (beam.smp)

	  Status: "Initialized"

	  CGroup: /system.slice/rabbitmq-server.service

			  ├─10908 /usr/lib64/erlang/erts-10.0.7/bin/beam.smp -W w -A 64 -MBas ageffcbf -MHas ageffcbf -MBlmbcs 512 -MHlmbcs 512 -MMm...

			  ├─11051 /usr/lib64/erlang/erts-10.0.7/bin/epmd -daemon

			  ├─11196 erl_child_setup 1024

			  ├─11213 inet_gethost 4

			  └─11214 inet_gethost 4



	Sep 09 23:49:01 izwz9dzweuke52904hqrmxz rabbitmq-server[10908]: ##  ##

	Sep 09 23:49:01 izwz9dzweuke52904hqrmxz rabbitmq-server[10908]: ##  ## RabbitMQ 3.7.7. Copyright (C) 2007-2018 Pivotal Soft... Inc.

	Sep 09 23:49:01 izwz9dzweuke52904hqrmxz rabbitmq-server[10908]: ##########  Licensed under the MPL. See http://www.rabbitmq.com/

	Sep 09 23:49:01 izwz9dzweuke52904hqrmxz rabbitmq-server[10908]: ######  ##

	Sep 09 23:49:01 izwz9dzweuke52904hqrmxz rabbitmq-server[10908]: ##########  Logs: /var/log/rabbitmq/rabbit@izwz9dzweuke52904hqrmxz.log

	Sep 09 23:49:01 izwz9dzweuke52904hqrmxz rabbitmq-server[10908]: /var/log/rabbitmq/rabbit@izwz9dzweuke52904hqrmxz_upgrade.log

	Sep 09 23:49:01 izwz9dzweuke52904hqrmxz rabbitmq-server[10908]: Starting broker...

	Sep 09 23:49:03 izwz9dzweuke52904hqrmxz rabbitmq-server[10908]: systemd unit for activation check: "rabbitmq-server.service"

	Sep 09 23:49:03 izwz9dzweuke52904hqrmxz systemd[1]: Started RabbitMQ broker.

	Sep 09 23:49:03 izwz9dzweuke52904hqrmxz rabbitmq-server[10908]: completed with 0 plugins.

	Hint: Some lines were ellipsized, use -l to show in full.



第三步:開放端口
	firewall-cmd --permanent --zone=public --add-port=25672/tcp

	firewall-cmd --permanent --zone=public --add-port=5672/tcp

	firewall-cmd --permanent --zone=public --add-port=5671/tcp

	firewall-cmd --permanent --zone=public --add-port=61613/tcp

	firewall-cmd --permanent --zone=public --add-port=61614/tcp

	firewall-cmd --permanent --zone=public --add-port=1883/tcp

	firewall-cmd --permanent --zone=public --add-port=8883/tcp

	firewall-cmd --reload



第四步:初始化Rabbitmq


	一、建立用戶和虛擬目錄



		建立用戶:

		rabbitmqctl add_user username password

		建立虛擬目錄:

		rabbitmqctl add_vhost myHostName

		設置用戶權限:

		rabbitmqctl set_permissions -p myHostName username  ".conf" ".write" ".read"

		設置用戶角色(設爲管理員):

		rabbitmqctl set_user_tags username administrator

	二、啓用WebUI管理界面插件:



		查看防火牆狀態:

		systemctl status firewalld

		若是發現防火牆狀態爲dead則啓動防火牆



		啓動防火牆:

		systemctl start firewalld

		再執行systemctl status firewalld,則爲running狀態



		關閉防火牆:

		systemctl stop firewalld



		啓動rabbitmq管理界面插件:

		rabbitmq-plugins enable rabbitmq_management



		開啓15672防火牆端口:

		firewall-cmd --permanent --zone=public --add-port=3306/tcp

		firewall-cmd --permanent --zone=public --add-port=15672/tcp



		重啓防火牆:

		firewall-cmd --reload



	三、啓用Shovel插件:

		啓用Shovel插件:

		rabbitmq-plugins enable rabbitmq_shovel

		rabbitmq-plugins enable rabbitmq_shovel_management



	打開服務管理界面,重啓RabbitMQ服務便可生效



	在服務器上瀏覽器中輸入http://localhost:15672便可進入Web UI管理界面,使用username/password登陸便可



	參考文檔:

	https://blog.csdn.net/jiyiqinlovexx/article/details/51203897

	http://www.rabbitmq.com/install-rpm.html#install-erlang-from-epel-repository

	https://github.com/rabbitmq/erlang-rpm

centos6安裝centos

一、安裝編譯工具


	yum -y install make gcc gcc-c++ kernel-devel m4 ncurses-devel openssl-devel


二、安裝Erlang


2.1 下載erlang
	官方下載地址:http://erlang.org/download/otp_src_18.3.tar.gz
		wget http://erlang.org/download/otp_src_18.3.tar.gz

2.2 安裝


	#解壓
	tar -zxvf otp_src_18.3.tar.gz
	cd otp_src_18.3


	#配置 '--prefix'指定的安裝目錄
	./configure --prefix=/usr/local/erlang --with-ssl -enable-threads -enable-smmp-support -enable-kernel-poll --enable-hipe --without-javac


	#安裝
	make && make install   #耐心等下完成便可.

2.3 配置erlang環境變量


	vim /etc/profile


	#在文件末尾添加下面代碼, 'ERLANG_HOME'等於上一步'--prefix'指定的目錄
	ERLANG_HOME=/usr/local/erlang
	PATH=$ERLANG_HOME/bin:$PATH
	export ERLANG_HOME
	export PATH


	#使環境變量生效
	source /etc/profile


	#輸入命令檢驗是否安裝成功
	erl

	#以下輸出表示安裝成功

	Erlang/OTP 18 [erts-7.3] [source] [64-bit] [async-threads:10] [hipe] [kernel-poll:false]
	Eshell V7.3  (abort with ^G)




3, 安裝RabbitMQ


	3.1 下載RabbitMQ
	官方下載地址http://www.rabbitmq.com/releases/rabbitmq-server/v3.6.1/rabbitmq-server-generic-unix-3.6.1.tar.xz
	wget http://www.rabbitmq.com/releases/rabbitmq-server/v3.6.1/rabbitmq-server-generic-unix-3.6.1.tar.xz
	3.2 安裝 
	RabbitMQ3.6版本無需make、make install 解壓就能夠用


	#解壓rabbitmq,官方給的包是xz壓縮包,因此須要使用xz命令
	xz -d rabbitmq-server-generic-unix-3.6.1.tar.xz


	#xz解壓後獲得.tar包,再用tar命令解壓
	tar -xvf rabbitmq-server-generic-unix-3.6.1.tar


	#移動目錄
	cp -rf ./rabbitmq_server-3.6.1 /usr/local/
	cd /usr/local/


	#修改文件夾名
	mv rabbitmq_server-3.6.1 rabbitmq-3.6.1


	#開啓管理頁面插件
	cd ./rabbitmq-3.6.1/sbin/
	./rabbitmq-plugins enable rabbitmq_management


	3.3 啓動


	#啓動命令,該命令ctrl+c後會關閉服務
	./rabbitmq-server


	#在後臺啓動Rabbit
	./rabbitmq-server -detached


	#關閉服務
	./rabbitmqctl stop


	#關閉服務(kill) 找到rabbitmq服務的pid   [不推薦]
	ps -ef|grep rabbitmq
	kill -9 ****


	3.4 添加管理員帳號


	#進入RabbitMQ安裝目錄
	cd /usr/local/rabbitmq-3.6.1/sbin


	#添加用戶
	#rabbitmqctl add_user Username Password
	./rabbitmqctl add_user admin 123456


	#設置用戶標籤
	#rabbitmqctl set_user_tags User Tag
	#[administrator]:管理員標籤
	./rabbitmqctl set_user_tags admin administrator

	#設置用戶權限
	./rabbitmqctl set_permissions -p "/" admin ".*" ".*" ".*"

	#設置完成後能夠查看當前用戶和角色(須要開啓服務)
	./rabbitmqctl list_users




	3.5 開放相關端口號:
	netstat -ntlp  #列出全部端口


	#添加如下端口號:


	/sbin/iptables -I INPUT -p tcp --dport 15672 -j ACCEPT
	/sbin/iptables -I INPUT -p tcp --dport 25672 -j ACCEPT
	/sbin/iptables -I INPUT -p tcp --dport 5672 -j ACCEPT
	/sbin/iptables -I INPUT -p tcp --dport 4369 -j ACCEPT
	/sbin/iptables -I INPUT -p tcp --dport 5671 -j ACCEPT


	/etc/init.d/iptables save   #保存修改

	service iptables restart    #重啓防火牆,修改生效

	3.6 登陸管理界面
	瀏覽器輸入地址:http://服務器IP地址:15672/
相關文章
相關標籤/搜索