消息队列RabbitMQ安装

时间:2022-08-27 18:50:48

CentOS安装RabbitMQ时出现了好多问题,特此记录下安装方法:

一、安装Erlang环境

	>>: wget http://erlang.org/download/otp_src_20.1.tar.gz

	>>: tar -zxvf otp_src_20.1.tar.gz

	>>: cd otp_src_20.1

	erlang在安装前需要先安装下它的依赖工具(如已安装,可跳过):
	>>: yum -y install make gcc gcc-c++ kernel-devel m4 ncurses-devel openssl-devel unixODBC-devel

	>>: mkdir /usr/local/erlang

	>>: ./configure --prefix=/usr/local/erlang --without-javac 

	>>: make && make install


	配置环境变量:
		>>: vim /etc/profile
			export ERLANG_HOME=/usr/local/erlang
			export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$FLUME_HOME/bin:$ERLANG_HOME/bin:$PATH
		
		>>: source /etc/profile

	测试:
		>>: erl
		Erlang/OTP 20 [erts-9.1] [source] [64-bit] [smp:2:2] [ds:2:2:10] [async-threads:10] [hipe] [kernel-poll:false]

		Eshell V9.1  (abort with ^G)
		1> 

	erlang安装完成


二、安装RabbitMQ
	>>: wget http://www.rabbitmq.com/releases/rabbitmq-server/v3.6.6/rabbitmq-server-3.6.6-1.el7.noarch.rpm

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

	>>: yum install rabbitmq-server-3.6.6-1.el7.noarch.rpm

	# 添加开机启动
	>>: chkconfig rabbitmq-server on  

	# 启动rabbitmq,-detached代表后台守护进程方式启动
	>>: rabbitmq-server -detached

	启动服务【 /usr/local/rabbitmq/sbin/rabbitmq-server  -detached 】:
	>>: rabbitmq-server -detached
	查看状态:【 /usr/local/rabbitmq/sbin/rabbitmqctl status  】
	>>: rabbitmqctl status
	关闭服务【 /usr/local/rabbitmq/sbin/rabbitmqctl stop  】:
	>>: rabbitmqctl stop
	列出角色:
	>>: rabbitmqctl list_users



	配置网页插件
	>>: mkdir /etc/rabbitmq
	然后启用插件:
	>>: rabbitmq-plugins enable rabbitmq_management


	配置访问账号密码和权限:
	>>: rabbitmqctl add_user Allister Allister  //添加用户,后面两个参数分别是用户名和密码
	>>: rabbitmqctl set_permissions -p / Allister ".*" ".*" ".*"  //添加权限
	>>: rabbitmqctl set_user_tags Allister administrator  //修改用户角色


	登录:
	http:ip:15672   账号/密码:Allister/Allister

	为了安全,登陆之后删除guest用户。

  

官网安装步骤:http://www.rabbitmq.com/install-rpm.html

以上为我的安装步骤。