Centos7安装部署Rabbitmq教程

依赖关系:

版本依赖一定要提前看清楚。

RabbitMQ相关版本依赖关系查看

https://www.rabbitmq.com/which-erlang.html

可以看到要求版本Erlang21.3.X或22.X

而Erlang则依赖于wxwidgets

所以我们应该先安装wxwidgets再安装erlang最后再安装RabbitMQ

(1)推荐安装方式:

yum包安装

erlang安装包下载地址:选择合适自己系统的版本

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

rabbitmq安装包下载地址:

https://www.rabbitmq.com/install-rpm.html#downloads

直接执行yum install 加包名直接安装即可。注意先安装erlang

 

(2)编译安装:(后来又试了一次,有报错,服务无法启动。。。)

我也不知道这个属于哪种安装方式。目前我是用来做测试的,所以不讲究这个。

简单一点地说,我这个教程使用的方法相当于Windows系统下的免安装绿色版

具体步骤:

 一. 安装wxwidgets

[root@localhost ~]# yum install gcc-c++ ncurses-devel fop unixODBC-devel mesa-libGLU-devel gtk3* -y   #提前安装好相关依赖
[root@localhost ~]# wget https://github.com/wxWidgets/wxWidgets/releases/download/v3.1.3/wxWidgets-3.1.3.tar.bz2
[root@localhost ~]# yum install bzip2 -y
[root@localhost ~]# bzip2 -d wxWidgets-3.1.3.tar.bz2 
[root@localhost ~]# tar -xvf wxWidgets-3.1.3.tar
[root@localhost ~]# cd wxWidgets-3.1.3
[root@localhost wxWidgets-3.1.3]# ./configure
[root@localhost wxWidgets-3.1.3]# make
[root@localhost wxWidgets-3.1.3]# make install
[root@localhost wxWidgets-3.1.3]# ldconfig

二. 安装Erlang

建议从官方网站下www.erlang.org,最近一次安装发现下载的包不能正常编译安装,使用原来的就可以,不知道是不是官方的包出问题了还是怎么回事

[root@localhost ~]# wget https://erlang.org/download/otp_src_22.1.tar.gz  #下载erlang
[root@localhost ~]# tar -zxvf otp_src_22.1.tar.gz  #解压erlang压缩包
[root@localhost ~]# cd otp_src_22.1
[root@localhost otp_src_22.1]# grep -A 11 "### Compiling from source" README.md   #查看README.MD文档,可以看到有相关的安装说明。grep -A可以查看相关上下文的下文指定行数
### Compiling from source

To compile Erlang from source, run the following commands. The complete building and installation instructions [can be found here](HOWTO/INSTALL.md).
```
git clone https://github.com/erlang/otp.git
cd otp
./otp_build autoconf
./configure
make
make install
```
Alternatively, you can use [Kerl](https://github.com/kerl/kerl), a script that lets you easily build Erlang with a few commands.
[root@localhost otp_src_22.1]#  ./configure --prefix=/usr/local/erlang --without-javac #使用--prefix指定安装目录。wx: Can not link the wx driver, wx will NOT be useable可忽略
[root@localhost otp_src_22.1]# make
[root@localhost otp_src_22.1]# make install  
[root@localhost otp_src_22.1]# echo 'export PATH=$PATH:/usr/local/erlang/bin'>> /etc/profile  #修改系统环境变量
[root@localhost otp_src_22.1]# source /etc/profile   #使系统环境变量生效
[root@localhost otp_src_22.1]# erl  #测试erl是否安装成功,如下显示说明成功
Erlang/OTP 22 [erts-10.5] [source] [64-bit] [smp:1:1] [ds:1:1:10] [async-threads:1] [hipe]

Eshell V10.5  (abort with ^G)
1>

三.  运行RabbitMQ

[root@localhost ~]# xz -d rabbitmq-server-generic-unix-3.8.2-rc.1.tar.xz
[root@localhost ~]# cd rabbitmq_server-3.8.2-rc.1/
[root@localhost rabbitmq_server-3.8.2-rc.1]# ls
ebin     LICENSE-APACHE2                 LICENSE-erlcloud             LICENSE-MIT-Flot       LICENSE-MPL           sbin
escript  LICENSE-APACHE2-excanvas        LICENSE-httpc_aws            LICENSE-MIT-jQuery     LICENSE-MPL2          share
etc      LICENSE-APACHE2-ExplorerCanvas  LICENSE-ISC-cowboy           LICENSE-MIT-jQuery164  LICENSE-MPL-RabbitMQ
include  LICENSE-APL2-Stomp-Websocket    LICENSE-MIT-EJS              LICENSE-MIT-Mochi      LICENSE-rabbitmq_aws
INSTALL  LICENSE-BSD-base64js            LICENSE-MIT-EJS10            LICENSE-MIT-Sammy      plugins
LICENSE  LICENSE-BSD-recon               LICENSE-MIT-Erlware-Commons  LICENSE-MIT-Sammy060   priv
[root@localhost rabbitmq_server-3.8.2-rc.1]# cd sbin/
[root@localhost sbin]# ls
cuttlefish   rabbitmq-defaults     rabbitmq-env      rabbitmq-queues  rabbitmq-upgrade
rabbitmqctl  rabbitmq-diagnostics  rabbitmq-plugins  rabbitmq-server
[root@localhost sbin]# ./rabbitmq-server

  ##  ##      RabbitMQ 3.8.2-rc.1
  ##  ##
  ##########  Copyright (c) 2007-2019 Pivotal Software, Inc.
  ######  ##
  ##########  Licensed under the MPL 1.1. Website: https://rabbitmq.com

  Doc guides: https://rabbitmq.com/documentation.html
  Support:    https://rabbitmq.com/contact.html
  Tutorials:  https://rabbitmq.com/getstarted.html
  Monitoring: https://rabbitmq.com/monitoring.html

  Logs: /root/rabbitmq_server-3.8.2-rc.1/var/log/rabbitmq/[email protected]
        /root/rabbitmq_server-3.8.2-rc.1/var/log/rabbitmq/rabbit@localhost_upgrade.log

  Config file(s): (none)

  Starting broker... completed with 0 plugins.
[root@localhost ~]# netstat -tlnp    #另开一个端口。执行./rabbitmq-server不能退出,否则RabbitMQ就退出了。以下加粗的端口即为RabbitMQ使用到的端口
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN      11397/mysqld        
tcp        0      0 0.0.0.0:4369            0.0.0.0:*               LISTEN      60445/epmd          
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1212/sshd           
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      3195/master         
tcp        0      0 0.0.0.0:10050           0.0.0.0:*               LISTEN      11655/zabbix_agentd
tcp        0      0 0.0.0.0:10051           0.0.0.0:*               LISTEN      11662/zabbix_server
tcp        0      0 0.0.0.0:25672           0.0.0.0:*               LISTEN      60486/beam.smp      
tcp        0      0 127.0.0.1:9000          0.0.0.0:*               LISTEN      11554/php-fpm: mast
tcp        0      0 127.0.0.1:27017         0.0.0.0:*               LISTEN      21992/mongod        
tcp6       0      0 :::80                   :::*                    LISTEN      11731/httpd         
tcp6       0      0 :::4369                 :::*                    LISTEN      60445/epmd          
tcp6       0      0 :::22                   :::*                    LISTEN      1212/sshd           
tcp6       0      0 ::1:25                  :::*                    LISTEN      3195/master         
tcp6       0      0 :::10050                :::*                    LISTEN      11655/zabbix_agentd
tcp6       0      0 :::10051                :::*                    LISTEN      11662/zabbix_server
tcp6       0      0 :::5672                 :::*                    LISTEN      60486/beam.smp      
[root@localhost ~]#

至此安装完成

四. rabbitmq常用命令

./rabbitmq-server  #启动RabbitMQ
rabbitmq-plugins enable rabbitmq_management    #启用web端,会启动15672端口
rabbitmqctl add_user admin 123456    #添加admin用户,密码为123456
rabbitmqctl  set_user_tags  admin  administrator    #设置admin为administrator
rabbitmqctl set_permissions -p "/" admin ".*" ".*" ".*"  #允许admin远程登录
./rabbitmqctl list_users    #查看admin是否是administrator

 

你可能感兴趣的:(Centos7安装部署Rabbitmq教程)