码迷,mamicode.com
首页 > 其他好文 > 详细

安装rabbitmq

时间:2020-01-29 10:20:51      阅读:69      评论:0      收藏:0      [点我收藏+]

标签:设置   rect   dispatch   super   解决   asc   for   flow   登录   

一.安装erlang

先新建rabbitmq文件夹
cd /usr/local/src/ 
mkdir rabbitmq 
cd rabbitmq 
//下载rpm,如果下载速度慢可以本地下载上传Linux中也可 
wget https://packages.erlang-solutions.com/erlang/esl-erlang/FLAVOUR_1_general/esl-erlang_21.2.2-1~centos~7_amd64.rpm
//导入公钥
 rpm –import http://packages.erlang-solutions.com/rpm/erlang_solutions.asc  
//安装自动更新依赖(不建议使用rpm安装)
yum install esl-erlang_21.2.2-1~centos~7_amd64.rpm  
//验证是否安装成功
erl

二.安装rabbitmq

//下载rabbitmq 
wget https://github.com/rabbitmq/rabbitmq-server/releases/download/v3.7.9/rabbitmq-server-3.7.9-1.el7.noarch.rpm

//导入RabbitMQ signing key.Before the Yum repository can be used, RabbitMQ signing key must be imported first. This makes RPM tools trust the signature on the packages provided in the repository. To do so, run rpm --import as a superuser:
rpm --import https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc
或者
//RabbitMQ public signing key is also available from rabbitmq.com
rpm --import https://www.rabbitmq.com/rabbitmq-release-signing-key.asc

//新增文件.In order to use the Yum repository, a .repo file (e.g. rabbitmq.repo) has to be added under the /etc/yum.repos.d/ directory. The contents of the file will vary slightly between distributions (e.g. CentOS 7 vs. CentOS 6 vs. OpenSUSE). The following example targest CentOS 7:
[bintray-rabbitmq-server]
name=bintray-rabbitmq-rpm
baseurl=https://dl.bintray.com/rabbitmq/rpm/rabbitmq-server/v3.7.x/el/7/
gpgcheck=0
repo_gpgcheck=0
enabled=1

On CentOS 6 the baseurl line would be slightly different:
[bintray-rabbitmq-server]
name=bintray-rabbitmq-rpm
baseurl=https://dl.bintray.com/rabbitmq/rpm/rabbitmq-server/v3.7.x/el/6/
gpgcheck=0
repo_gpgcheck=0
enabled=1

The following example targets OpenSUSE:
[bintray-rabbitmq-server]
name=bintray-rabbitmq-rpm
baseurl=https://dl.bintray.com/rabbitmq/rpm/rabbitmq-server/v3.7.x/opensuse/42.1/
gpgcheck=0
repo_gpgcheck=0
enabled=1

The following example targets SLES 11.x:
[bintray-rabbitmq-server]
name=bintray-rabbitmq-rpm
baseurl=https://dl.bintray.com/rabbitmq/rpm/rabbitmq-server/v3.7.x/sles/11
gpgcheck=0
repo_gpgcheck=0
enabled=1


//安装rabbitmq 
yum install rabbitmq-server-3.7.9-1.el7.noarch.rpm
rpm -ivh --nodeps rabbitmq-server-3.7.9-1.el7.noarch.rpm

三.可能出现的问题

1、如果出现如下错误,但是的确安装了erlang对应版本:

error: Failed dependencies:
    erlang >= R16B-03 is needed by rabbitmq-server-3.6.3-1.noarch  
复制代码
解决方式:
添加--nodeps你的rpm命令,参考连接:StackOverflow问答
rpm -ivh --nodeps rabbitmq-server-3.5.7-1.noarch.rpm
复制代码
检查https://stackoverflow.com/a/40218299/877813,并添加--nodeps你的rpm命令

2、出现如下错误的情况;说缺少socat依赖

socat is needed by rabbitmq-server-3.6.6-1.el6.noarch
复制代码
解决方式:
yum -y install socat
此时会报错没有socat包或是找不到socat包,解决方法安装centos的epel的扩展源
yum -y install epel-release
之后执行yum -y install socat

安装时如果遇到下面的依赖错误:
Error: Package: socat-1.7.2.3-1.el6.x86_64 (epel) Requires: libreadline.so.5()(64bit)
可以尝试先执行:
yum install socat

四.启动和配置

1.RabbitMQ的一些基本操作:

# 添加开机启动RabbitMQ服务
systemctl enable rabbitmq-server.service
# 查看服务状态
systemctl status  rabbitmq-server.service
# 启动服务
systemctl start rabbitmq-server.service
# 停止服务
systemctl stop rabbitmq-server.service
# 查看当前所有用户
rabbitmqctl list_users
# 查看默认guest用户的权限
rabbitmqctl list_user_permissions guest
# 由于RabbitMQ默认的账号用户名和密码都是guest。为了安全起见, 先删掉默认用户
rabbitmqctl delete_user guest
# 添加新用户
rabbitmqctl add_user username password
# 设置用户tag
rabbitmqctl set_user_tags username administrator
# 赋予用户默认vhost的全部操作权限
rabbitmqctl set_permissions -p / username ".*" ".*" ".*"
# 查看用户的权限
rabbitmqctl list_user_permissions username

2、基本配置:(配置的时候输入命令需要在/usr/local/src/ rabbitmq文件夹)

//开启管理页面插件
rabbitmq-plugins enable rabbitmq_management
管理插件安装完成后,出现如下提示,表示安装成。
The following plugins have been enabled:
  mochiweb
  webmachine
  rabbitmq_web_dispatch
  amqp_client
  rabbitmq_management_agent
  rabbitmq_management
Plugin configuration has changed. Restart RabbitMQ for changes to take effect.


增加访问用户,默认用户guest只能本地访问。
rabbitmqctl add_user admin eternityzhang

设置角色:
rabbitmqctl set_user_tags admin administrator


设置默认vhost(“/”)访问权限
rabbitmqctl set_permissions -p / admin ".*" ".*" ".*"

关于RabbitMQ的配置,可以下载RabbitMQ的配置文件模板到/etc/rabbitmq/rabbitmq.config, 然后按照需求更改即可。
关于每个配置项的具体作用,可以参考官方文档。
https://github.com/rabbitmq/rabbitmq-server/blob/master/docs/rabbitmq.config.example
搜索到%%{loopback_users,[]},  去掉%%和最后的逗号并保存

开机自启动:
chkconfig rabbitmq-server on 输入之后会转到systemctl enable rabbitmq-server.service


可以用浏览器输入localhost:15672,账号密码输入admin/eternityzhang即可登录:

参考

链接:https://juejin.im/post/5af879e76fb9a07ab11144b6
链接: https://www.jianshu.com/p/86c28453a50b

安装rabbitmq

标签:设置   rect   dispatch   super   解决   asc   for   flow   登录   

原文地址:https://www.cnblogs.com/eternityz/p/12239590.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!