一、安装依赖包:
[root@localhost ~]# yum -y install make gcc gcc-c++ kernel-devel m4 ncurses-devel openssl-devel unixODBC unixODBC-devel httpd python-simplejson
[root@localhost ~]# yum -y install epel-release # 之后再执行yum -y install socat,有先后顺序
[root@localhost ~]# yum -y install socat
二、安装erlang环境
1、下载包,编译安装
[root@localhost ~]# wget http://erlang.org/download/otp_src_19.3.tar.gz
[root@localhost ~]# tar xf otp_src_19.3.tar.gz
[root@localhost ~]# cd otp_src_19.3/
[root@localhost otp_src_19.3]# ./configure --prefix=/usr/local/erlang --enable-smp-support --enable-threads --enable-sctp --enable-kernel-poll --enable-hipe --with-ssl --without-javacerlang语言编译配置选项:–prefix 指定安装目录 –enable-smp-support启用对称多处理支持(Symmetric Multi-Processing对称多处理结构的简称)–enable-threads启用异步线程支持–enable-sctp启用流控制协议支持(Stream Control Transmission Protocol,流控制传输协议)–enable-kernel-poll启用Linux内核poll–enable-hipe启用高性能Erlang –with-ssl 启用ssl包 –without-javac 不用java编译
[root@localhost otp_src_19.3]# make && make install #这一步等待时间较长
2、配置erlang的环境变量:
[root@localhost otp_src_19.3]# vim /etc/profile加入这一行:export PATH=$PATH:/usr/local/erlang/bin[root@localhost otp_src_19.3]# source /etc/profile
3、测试erlang安装是否成功 :
[root@localhost local]# erl
Erlang/OTP 19 [erts-8.3] [source] [64-bit] [async-threads:10] [hipe] [kernel-poll:false]Eshell V8.3 (abort with ^G)
1>
出现上面的这种情况,就是erlang安装成功了。V8.3就是显示的版本号
三、安装rabbitMQ
1、下载rpm包,并安装
[root@localhost home]# wget http://www.rabbitmq.com/releases/rabbitmq-server/v3.6.12/rabbitmq-server-3.6.12-1.el6.noarch.rpm
[root@localhost home]# rpm -i --nodeps rabbitmq-server-3.6.12-1.el6.noarch.rpm
警告:rabbitmq-server-3.6.12-1.el6.noarch.rpm: 头V4 RSA/SHA512 Signature, 密钥 ID 6026dfca: NOKEY
[root@localhost home]#
2、生成配置文件:
[root@localhost home]# cp /usr/share/doc/rabbitmq-server-3.6.12/rabbitmq.config.example /etc/rabbitmq/rabbitmq.config
[root@localhost home]# ln -s /usr/local/erlang/bin/erl /usr/bin/erl
[root@localhost home]#
3、添加环境变量:
[root@localhost home]# vim /etc/profile加入:export PATH=$PATH:/usr/lib/rabbitmq/bin
[root@localhost home]# source /etc/profile
4、检查并开启web监控:
首先,运行以下命令,开启rabbitmq
[root@localhost home]# rabbitmq-server RabbitMQ 3.6.12. Copyright (C) 2007-2017 Pivotal Software, Inc.## ## Licensed under the MPL. See http://www.rabbitmq.com/## ############ Logs: /var/log/rabbitmq/rabbit@localhost.log###### ## /var/log/rabbitmq/rabbit@localhost-sasl.log##########Starting broker...completed with 0 plugins. #这里显示是0,是因为还没有开启web监控
Ctrl+c退出来,安装插件:
[root@localhost home]# rabbitmq-plugins enable rabbitmq_management
The following plugins have been enabled:amqp_clientcowlibcowboyrabbitmq_web_dispatchrabbitmq_management_agentrabbitmq_managementApplying plugin configuration to rabbit@localhost... failed.* Could not contact node rabbit@localhost.Changes will take effect at broker restart.* Options: --online - fail if broker cannot be contacted.--offline - do not try to contact broker.
[root@localhost home]# echo $?
0
[root@localhost home]#
5、正式启动rabbitmq
启动rabbitmq有以下两种方法。
第一种方法是,直接运行rabbitmq-server命令(但是这种方式,一旦终端退出后,rabbitmq服务就停止了,所以不推荐这么做)。
[root@localhost home]# rabbitmq-server RabbitMQ 3.6.12. Copyright (C) 2007-2017 Pivotal Software, Inc.## ## Licensed under the MPL. See http://www.rabbitmq.com/## ############ Logs: /var/log/rabbitmq/rabbit@localhost.log###### ## /var/log/rabbitmq/rabbit@localhost-sasl.log##########Starting broker...completed with 6 plugins. #这里显示6,说明web插件已经安装好啦
第二种方法是,运行service rabbitmq-server xxx命令。
service rabbitmq-server start #启动
service rabbitmq-server stop #停止
service rabbitmq-server restart #重启
service rabbitmq-server status #查看状态
service rabbitmq-server etc #查看有哪些命令可以使用
同时将rabbitmq-server加入到开机自启动服务中,运行以下命令:
[root@rabbitmqserver bin]# chkconfig rabbitmq-server on
最佳实践是第二种方法。
第二种方式启动rabbitmq:
[root@localhost home]# service rabbitmq-server start
Starting rabbitmq-server (via systemctl): [ 确定 ]
[root@localhost home]#
6、开启15674端口
服务连接需要用到15674端口,放开15674端口:
[root@localhost home]# cd /usr/lib/rabbitmq/lib/rabbitmq_server-3.6.12/sbin/ #这个目录因人而异,可以用find / -type f -name "rabbitmq-plugins"命令找到具体的路径,注意修改
[root@localhost sbin]# ll
total 36
-rwxr-xr-x 1 root root 1480 Sep 11 2017 rabbitmqctl
-rwxr-xr-x 1 root root 1869 Sep 11 2017 rabbitmq-defaults
-rwxr-xr-x 1 root root 12095 Sep 11 2017 rabbitmq-env
-rwxr-xr-x 1 root root 1362 Sep 11 2017 rabbitmq-plugins
-rwxr-xr-x 1 root root 10971 Sep 11 2017 rabbitmq-server
[root@localhost sbin]# rabbitmq-plugins enable rabbitmq_web_stomp
The following plugins have been enabled:sockjsrabbitmq_stomprabbitmq_web_stompApplying plugin configuration to rabbit@localhost... started 3 plugins.
检查端口,已经起来了:
[root@localhost sbin]# netstat -tlunp|grep 15674
tcp 0 0 0.0.0.0:15674 0.0.0.0:* LISTEN 30339/beam.smp
[root@localhost sbin]#
7、界面管理账号创建与授权(5步骤):
1)添加管理员账号:
[root@localhost home]# rabbitmqctl add_user rabbitadmin 123456
Creating user "rabbitadmin"
2)分配用户标签为管理员
[root@localhost home]# rabbitmqctl set_user_tags rabbitadmin administrator
Setting tags for user "rabbitadmin" to [administrator]
[root@localhost home]#
3)创建和赋角色完成后查看并确认
[root@localhost home]# rabbitmqctl list_users
Listing users
rabbitadmin [administrator]
guest [administrator]
[root@localhost home]#
4)登录rabbitmq管理界面(切记:访问之前检查防火墙问题)
浏览器输入地址:http://服务器IP地址:15672/
用户名/密码:rabbitadmin/123456
登录进去是这样的界面:
5)用户授权问题:
上述新建的rabbitadmin用户虽然是管理员,但是进去之后会发现这种状态:
所以还需要给用户进行再次授权:
[root@localhost rabbitmq]# rabbitmqctl set_permissions -p "/" rabbitadmin ".*" ".*" ".*"
Setting permissions for user "rabbitadmin" in vhost "/"
[root@localhost rabbitmq]#
刷新页面,权限已经OK:
到此,单机版的Rabbitmq就部署好了
Rabbitmq集群部署:https://blog.51cto.com/10950710/2135717
部署参考文档:
https://www.cnblogs.com/mcgrady/p/7614417.html
https://blog.csdn.net/yunfeng482/article/details/72853983