阿里云上搭建RabbitMQ(1)

刚好有点闲钱,在双十二上买了一个阿里云服务器,买完之后顿时就后悔了,发现腾讯云比阿里云更便宜,这是购买阿里云的心得,下面开始安装RabbitMQ了

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

买完服务器先把想要的端口开放出来吧!15672端口是RabbitMQ的web访问端口,不管别的开放了再说(我基本上就是能开放的都开放,免得到时候出问题了还要找半天,结果发现是端口没开放,这就很尴尬了),出入方向我都开通了

上服务器安装Erlang

打开 /etc/yum.repos.d/重写epel.repo

[epel]
name=Extra Packages for Enterprise Linux 7 - $basearch
#baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch
failovermethod=priority
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7

安装Erlang输入命令:

yum install erlang

测试安装是否成功:erl

[root@localhost yum.repos.d]# erl
Erlang R16B03-1 (erts-5.10.4) [source] [64-bit] [async-threads:10] [hipe] [kernel-poll:false]

Eshell V5.10.4  (abort with ^G)

安装socat

yum -y install socat

安装RabbitMQ

  1. https://github.com/rabbitmq/rabbitmq-server/releases/tag/rabbitmq_v3_6_8
  2. 下载rabbitmq-server-3.6.8-1.el7.noarch.rpm文件。
  3. 将文件上传至服务器
  4. 安装RabbitMQ:
rpm -ivh rabbitmq-server-3.6.8-1.el7.noarch.rpm

 完成安装。

运行

  • 启动服务:
service rabbitmq-server start 
  • 停止服务 :
service rabbitmq-server stop
  • 查看RabbitMQ启动状态 :
rabbitmqctl status
  • 如果出现以下提示,表示服务未启动
    Status of node rabbit@localhost ...
    Error: unable to connect to node rabbit@localhost: nodedown
    
    DIAGNOSTICS
    ===========
    
    attempted to contact: [rabbit@localhost]
    
    rabbit@localhost:
      * connected to epmd (port 4369) on localhost
      * epmd reports: node 'rabbit' not running at all
                      no other nodes on localhost
      * suggestion: start the node
    
    current node details:
    - node name: 'rabbitmq-cli-25@localhost'
    - home dir: /var/lib/rabbitmq
    - cookie hash: 89Yd7T7BIp47U/btt8IyzA==

    账号管理

  • 创建用户:我这里创建的 账号:rabbitstudy ,密码:123456 
[root@localhost ~]# rabbitmqctl add_user rabbitstudy 123456
Creating user "rabbitstudy" ...
  • 给用户分配权限
[root@localhost ~]# rabbitmqctl set_permissions -p "/" rabbitstudy ".*" ".*" ".*"
Setting permissions for user "rabbitstudy" in vhost "/" ...
  • 查看用户列表
[root@localhost ~]# rabbitmqctl list_users
Listing users ...
guest   [administrator]
rabbitstudy     []
  • 分配用户标签为administrator
[root@localhost ~]# rabbitmqctl set_user_tags rabbitstudy administrator
Setting tags for user "rabbitstudy" to [administrator] ...
  • 开启管理页面插件,才可以使用web管理端
rabbitmq-plugins enable rabbitmq_management
  • 关闭防火墙
    systemctl stop firewalld

    防火墙根据自己的条件而定,如果需要打开防火墙,那就开发端口:15672

现在RabbitMQ已经安装完成了,我们打开网页来看一下:http://自己服务器的地址:15672

看到这个页面说明RabbitMQ已经完成,只要登入账号和密码就行了

我这里设置的账号和密码是:rabbitstudy    123456

完成了!!!

猜你喜欢

转载自blog.csdn.net/qq_36191137/article/details/85013281