Centos7安装Rabbitmq

来自linux中国网wiki
跳到导航 跳到搜索

pre

Rabbitmq基于erlang语言开发,因此需要安装erlang虚拟机

libcrypto.so.10 有这个报错 记得服务器初始化就行了

 yum install iftop tcpdump  -y #其实就是安装这个带来的

Install Erlang

添加国内epel源 必要的为了后面的erlang依赖

###1、备份(如有配置其他epel源)
mv /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.backup
mv /etc/yum.repos.d/epel-testing.repo /etc/yum.repos.d/epel-testing.repo.backup
###2、下载新repo 到/etc/yum.repos.d/
#epel(RHEL 7)
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
#重新生成缓存:
yum makecache

#yum install erlang -y 
echo '[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' >/etc/yum.repos.d/rabbitmq-erlang.repo

#erlang21
yum install erlang -y 

#
rpm --import https://packages.erlang-solutions.com/rpm/erlang_solutions.asc

echo '[erlang-solutions]
name=CentOS $releasever - $basearch - Erlang Solutions
baseurl=https://packages.erlang-solutions.com/rpm/centos/$releasever/$basearch
gpgcheck=1
gpgkey=https://packages.erlang-solutions.com/rpm/erlang_solutions.asc
enabled=1' >/etc/yum.repos.d/myerlang.repo


#只能是这个不用翻墙
#将里面的baseurl 改为:baseurl=https://mirrors4.tuna.tsinghua.edu.cn/erlang-solutions/centos/7/
如下 
 cat myerlang.repo 
echo '[erlang-solutions]
name=CentOS $releasever - $basearch - Erlang Solutions
#baseurl=https://packages.erlang-solutions.com/rpm/centos/$releasever/$basearch
baseurl=https://mirrors4.tuna.tsinghua.edu.cn/erlang-solutions/centos/7/
#gpgcheck=1
gpgcheck=0
gpgkey=https://packages.erlang-solutions.com/rpm/erlang_solutions.asc
enabled=1' > /etc/yum.repos.d/myerlang.repo

yum makecache
yum install erlang  socat -y 

#上面这些有空要构建自己的yum 仓库

https://www.erlang-solutions.com/resources/download.html centos


#二进制包 
https://bintray.com/rabbitmq/rpm/erlang/21.0.4-1



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

验证是否安装成功,输入命令:erl

	erlang >= 19.3 被 rabbitmq-server-3.7.7-1.el7.noarch 需要
	socat 被 rabbitmq-server-3.7.7-1.el7.noarch 需要
	
	 erl 
Erlang R16B03-1 (erts-5.10.4)

rpm 安装erlang

  1. 翻墙下载
wget https://packages.erlang-solutions.com/erlang/esl-erlang/FLAVOUR_1_general/esl-erlang_19.2~centos~7_amd64.rpm 
  1. add epel if not
yum install unixODBC unixODBC-devel wxBase wxGTK SDL wxGTK-gl


http://www.cnblogs.com/knowledgesea/p/6291085.html

Install rabbitmq

#这个要翻墙
wget -c https://dl.bintray.com/rabbitmq/all/rabbitmq-server/3.7.7/rabbitmq-server-3.7.7-1.el7.noarch.rpm
rpm --import https://www.rabbitmq.com/rabbitmq-release-signing-key.asc
# this example assumes the CentOS 7 version of the package
yum install rabbitmq-server-3.7.7-1.el7.noarch.rpm

#um就会去自动下载对应依赖包
yum install rabbitmq-server-3.7.7-1.el7.noarch.rpm
#我是直接 rpm -ivh 
rpm  -ivh  rabbitmq-server-3.7.7-1.el7.noarch.rpm  --nodeps --force #强制安装了


#unstall 
yum  remove rabbitmq-server erlang

添加软件源

wget -c https://packagecloud.io/install/repositories/rabbitmq/rabbitmq-server/script.rpm.sh && bash -x script.sh 
yum install -y rabbitmq-server

docker rabbitmq

docker-compose rabbitmq

install docker-ce

Docker and docker-compose快速安装


#install docker
yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-selinux \
                  docker-engine-selinux \
                  docker-engine

yum install -y yum-utils \
           device-mapper-persistent-data \
           lvm2
           
yum-config-manager \
    --add-repo \
    https://mirrors.ustc.edu.cn/docker-ce/linux/centos/docker-ce.repo
    
yum makecache fast
yum install docker-ce -y   
systemctl enable docker
systemctl start docker




yum -y install vim wget curl yum-utils bash-completion bash-completion-extras epel-release lrzsz telnet python-pip
pip install docker-compose

mkdir -p /home/data/docker

echo '{"graph": "/home/data/docker"}' >/etc/docker/daemon.json
# cat /etc/docker/daemon.json 
{"graph": "/home/data/docker"}

systemctl restart docker

#验证docker储存位置
docker system info | grep "Root Dir"

dokcer-ce install

docker ins mq start

docker pull rabbitmq:3.6.10-management

mkdir -p /home/data/docker-compose-cailuw-market

vi docker-compose.yml

version: '3.1'  #"登录容器请执行:rabbitmq-plugins enable rabbitmq_management 才可>使用WEB管理页面"
services:
  rabbitmq:
    image: rabbitmq:3.6.10-management
    ports:
      - "5672:5672"
      - "15672:15672"
    hostname: dev-market-rabbit
    environment:
      RABBITMQ_DEFAULT_VHOST: /
      RABBITMQ_DEFAULT_USER: admin
      RABBITMQ_DEFAULT_PASS: root
      RABBITMQ_LOGS: /var/lib/rabbitmq/rabbitmq.log
      RABBITMQ_SASL_LOGS: /var/lib/rabbitmq/rabbitmq-sasl.log
    volumes:
      - ./data/rabbitmq:/var/lib/rabbitmq
    restart: always  


docker-compose up   -d rabbitmq
#docker-compose -f file  -d rabbitmq
#docker-compose -f docker-compose-base.yml -f docker-compose-prod.yml up -d mysql

PS:启动语句最后用rabbitmq:3.7.7-management而不是imageId,否则之后一堆容器看起来像坨屎一样

配置

创建rabbitmq的配置文件,并允许guest进行登录
echo '[{rabbit, [{loopback_users, []}]}].' > /etc/rabbitmq/rabbitmq.config


更改rabbitmq的环境变量

-- -home /var/lib/rabbitmq
#没做 /var/lib/rabbitmq/.erlang.cookie

# cat /etc/rabbitmq/rabbitmq-env.conf
RABBITMQ_MNESIA_BASE=/data/rabbitmq/mnesia
RABBITMQ_LOG_BASE=/data/rabbitmq/log
#ll rabbitmq-env.conf 
-rw-r--r-- 1 rabbitmq rabbitmq 80 Nov 10 18:35 rabbitmq-env.conf


创建数据目录和log目录

#mkdir -pv /data/rabbitmq/log
#chowm -R rabbitmq:rabbitmq /data/rabbitmq
启用management插件

rabbitmq-plugins enable rabbitmq_management

http://blog.51cto.com/zengestudy/1870247



systemctl start rabbitmq-server
systemctl  enable rabbitmq-server#开机自动启动

rabbitmqctl  status  #查看 rabbitmq-server 状态


管理RabbitMQ

#早上不行的原因是输入为家里的网段
rabbitmq-plugins enable rabbitmq_management 开启插件管理页面

rabbitmqctl add_user admin 123456
Creating user "admin" ...
[root@localhost sbin]# ./rabbitmqctl set_user_tags admin administrator
Setting tags for user "admin" to [administrator] ...

http://IP:15672/#/ 可以用刚建立的管理员用户登陆管理界面了

注意:系统自带账号guest具有所有的操作权限,并且又是默认账号,出于安全因素的考虑,guest用户只能通过localhost登陆使用,建议修改guest用户的密码以及新建其他账号管理使用rabbitmq。

Not management user 

(1) 新增一个用户

rabbitmqctl  add_user  Username  Password

添加admin账号,赋予administrator权限

rabbitmqctl add_user admin password
rabbitmqctl set_user_tags admin administrator


开启管理UI

echo '[{rabbit, [{loopback_users, []}]}].' >/etc/rabbitmq/rabbitmq.config

rabbitmq-plugins enable rabbitmq_management

#重启服务
systemctl  restart rabbitmq-server
#这个在7上有可能是不行的$ service rabbitmq-server restart

访问管理UI #这个有空要做安全配置
通过 http://ip:15672 使用guest,guest 进行登陆了 上面的新建用户 好像不行  可以 在web 界面添加

开启管理UI相关

[https://segmentfault.com/a/1190000010693696#articleHeader13 CentOs7.3 搭建 RabbitMQ 3.6 单机服务与使用 have user etc]

改进

配置有空要优化一下 看相关的see also

trouble shooting

利用国内源yum 安装erlang 21

  1. 将里面的baseurl 改为:baseurl=https://mirrors4.tuna.tsinghua.edu.cn/erlang-solutions/centos/7/

如下

 
echo '[erlang-solutions]
name=CentOS $releasever - $basearch - Erlang Solutions
#baseurl=https://packages.erlang-solutions.com/rpm/centos/$releasever/$basearch
baseurl=https://mirrors4.tuna.tsinghua.edu.cn/erlang-solutions/centos/7/
#gpgcheck=1
gpgcheck=0
gpgkey=https://packages.erlang-solutions.com/rpm/erlang_solutions.asc
enabled=1' > /etc/yum.repos.d/myerlang.repo

yum clean all
yum makecache
yum install erlang #21

yum --skip-broken问题

您可以尝试添加 --skip-broken 选项来解决该问题 #这个也可以 试一下 不建议用 ,今天遇到 其实加上 epel 依赖搞定就行了
 您可以尝试执行:rpm -Va --nofiles --nodigest
<pre>yum remove  erlang* #因为是安装erlang后出问题 网上的教程不要信 ,还是自己想到的办法 
yum clean all
yum makecache
yum install socat erlang  -y 


没添加epel源的依赖问题

记住 一定要添加epel源 不然安装rabbitmq 会识别不到 已安装的Erlang/OTP 21

15672 问题

15672 本地可以 telnet ,但是在其它机器上 telnet 不通 , web 也访问不了

see also

docker 安装rabbitMQ


rabbitmq 源码安装和使用

Install Erlang

Installing on RPM-based Linux

RPM包安装RabbitMQ_good

Linux下 RabbitMQ的安装与配置

使用国内源安装erlang

erlang-solutions-ubuntu国内镜像地址

CentOS 7 下安装 RabbitMQ

消息队列服务rabbitmq安装配置ttlsa

CentOS 安装 Erlang

在Centos7上安装Rabbitmq 3.7