CentOS RabbitMQ rpm 安装方法:
系统环境:CentOS6
IP地址:10.100.62.41
1.erlang安装:
erlang下载地址: http://www.rabbitmq.com/releases/erlang/ [[email protected] ~]# cd /opt/ytd_src/ [[email protected] ytd_src]# wget http://www.rabbitmq.com/releases/erlang/erlang-18.2-1.el6.x86_64.rpm --2017-10-30 07:30:33-- http://www.rabbitmq.com/releases/erlang/erlang-18.2-1.el6.x86_64.rpm 正在解析主机 www.rabbitmq.com (www.rabbitmq.com)... 104.20.62.197, 104.20.63.197, 2400:cb00:2048:1::6814:3fc5, ... 正在连接 www.rabbitmq.com (www.rabbitmq.com)|104.20.62.197|:80... 已连接。 已发出 HTTP 请求,正在等待回应... 200 OK 长度:18354700 (18M) [application/x-redhat-package-manager] 正在保存至: “erlang-18.2-1.el6.x86_64.rpm” 100%[===============================================================================>] 18,354,700 134KB/s 用时 3m 41s 2017-10-30 07:34:16 (81.0 KB/s) - 已保存 “erlang-18.2-1.el6.x86_64.rpm” [18354700/18354700]) [[email protected] ytd_src]# ll 总用量 17928 -rw-r--r-- 1 root root 18354700 1月 3 2016 erlang-18.2-1.el6.x86_64.rpm [[email protected] ytd_src]# rpm -ivh erlang-18.2-1.el6.x86_64.rpm 准备中... ################################# [100%] 正在升级/安装... 1:erlang-18.2-1.el6 ################################# [100%] [[email protected] ytd_src]# erlang版本地址: wget –no-cache http://www.convirture.com/repos/definitions/rhel/6.x/convirt.repo -O /etc/yum.repos.d/convirt.repo yum makecache yum install socat
2.rabbitMQ安装:
下载地址:https://dl.bintray.com/rabbitmq/rabbitmq-server-rpm/ [[email protected] ytd_src]# wget https://dl.bintray.com/rabbitmq/rabbitmq-server-rpm/rabbitmq-server-3.6.12-1.el6.noarch.rpm --2017-10-30 07:42:07-- https://dl.bintray.com/rabbitmq/rabbitmq-server-rpm/rabbitmq-server-3.6.12-1.el6.noarch.rpm 正在解析主机 dl.bintray.com (dl.bintray.com)... 35.161.20.85, 52.34.155.241 正在连接 dl.bintray.com (dl.bintray.com)|35.161.20.85|:443... 已连接。 ...... 已发出 HTTP 请求,正在等待回应... 200 OK 长度:4964260 (4.7M) [application/x-rpm] 正在保存至: “rabbitmq-server-3.6.12-1.el6.noarch.rpm” 100%[===============================================================================>] 4,964,260 1.54MB/s 用时 3.1s 2017-10-30 07:42:14 (1.54 MB/s) - 已保存 “rabbitmq-server-3.6.12-1.el6.noarch.rpm” [4964260/4964260]) [[email protected] ytd_src]# ll 总用量 22776 -rw-r--r-- 1 root root 18354700 1月 3 2016 erlang-18.2-1.el6.x86_64.rpm -rw-r--r-- 1 root root 4964260 9月 21 03:34 rabbitmq-server-3.6.12-1.el6.noarch.rpm [[email protected] ytd_src]# rpm --import https://www.rabbitmq.com/rabbitmq-release-signing-key.asc [[email protected] ytd_src]# rpm -ivh rabbitmq-server-3.6.12-1.el6.noarch.rpm 错误:依赖检测失败: socat 被 rabbitmq-server-3.6.12-1.el6.noarch 需要 解决报错: [[email protected] ytd_src]# wget –no-cache http://www.convirture.com/repos/definitions/rhel/6.x/convirt.repo -O /etc/yum.repos.d/convirt.repo [[email protected] ytd_src]# yum makecache -y [[email protected] ytd_src]# yum install socat -y [[email protected] ytd_src]# rpm -ivh rabbitmq-server-3.6.12-1.el6.noarch.rpm 准备中... ################################# [100%] 正在升级/安装... 1:rabbitmq-server-3.6.12-1.el6 ################################# [100%]
3.安装管理插件:
[[email protected] ytd_src]# rabbitmq-plugins enable rabbitmq_management
4.启动服务:
[[email protected] ytd_src]# service rabbitmq-server start Starting rabbitmq-server (via systemctl): [ 确定 ]
5.浏览器访问:
http://10.100.62.41:15672
用系统默认的guest账号 结果登录失败 可能权限的问题吧,果断创建一个用户.
添加用户: [[email protected] ytd_src]# rabbitmqctl add_user admin 123456 Creating user "admin" [[email protected] ytd_src]# rabbitmqctl set_user_tags admin administrator Setting tags for user "admin" to [administrator] [[email protected] ytd_src]#
6.重启服务:
[[email protected] ytd_src]# service rabbitmq-server restart
至此MQ单机版就已经安装完成了.
解决/etc/rabbitmq/rabbitmq.config (not found)问题:
Config file /etc/rabbitmq/rabbitmq.config (not found) Database directory [email protected] Log file [email protected] SASL log file [email protected] 新建一个文件:/etc/rabbitmq/rabbitmq.config,输入一下配置内容: [{rabbit, [{loopback_users, []}]}].
由于机器有限,就打算在测试环境给搭建个单机集群版的MQ。
单机集群版配置:
查看第一个节点的状态,(就是默认的单机版状态)
[[email protected] ~]# rabbitmqctl status Status of node [email protected]' [{pid,1957}, {running_applications, [email protected]
1.启动第一个节点(即是单机MQ)
RABBITMQ_NODE_PORT=5672 [email protected] rabbitmq-server #由于这个MQ前面已经启动,在这里再启动时可能会报已经启动的错误,暂且不理.
2.启动第二个节点:
RABBITMQ_NODE_PORT=5673 RABBITMQ_SERVER_START_ARGS="-rabbitmq_management listener [{port,15673}] -rabbitmq_stomp tcp_listeners [61614] -rabbitmq_mqtt tcp_listeners [1884]" [email protected] rabbitmq-server -detached [[email protected] ~]# rabbitmqctl status -n [email protected] Status of node [email protected]' [{pid,17574}, ......
3.启动第三个节点:
RABBITMQ_NODE_PORT=5674 RABBITMQ_SERVER_START_ARGS="-rabbitmq_management listener [{port,15674}] -rabbitmq_stomp tcp_listeners [61615] -rabbitmq_mqtt tcp_listeners [18845]" [email protected] rabbitmq-server -detached [[email protected] ~]# rabbitmqctl status -n [email protected] Status of node [email protected]' [{pid,19076}, ......
集群操作:
节点二([email protected])添加到集群:
停止第二个节点的应用程序: [[email protected] ~]# rabbitmqctl -n [email protected] stop_app Stopping rabbit application on node [email protected]' 重新设置第二个节点的元数据和状态为清空状态 [[email protected] ~]# rabbitmqctl -n [email protected] reset Resetting node [email protected]' [[email protected] ~]# [email protected]@v05-apppre-rabbitmq集群节点中 [[email protected] ~]# rabbitmqctl -n [email protected] join_cluster [email protected] Clustering node [email protected]' with [email protected]' [[email protected] ~]# [email protected] [[email protected] ~]# rabbitmqctl -n [email protected] start_app Starting node [email protected]'
节点三添加到集群:
[[email protected] ~]# rabbitmqctl -n [email protected] stop_app Stopping rabbit application on node [email protected]' [[email protected] ~]# rabbitmqctl -n [email protected] reset Resetting node [email protected]' [[email protected] ~]# rabbitmqctl -n [email protected] join_cluster [email protected] Clustering node [email protected]' with [email protected]' [[email protected] ~]# [[email protected] ~]# rabbitmqctl -n [email protected] start_app Starting node [email protected]' [[email protected] ~]#
查看集群状态:
[[email protected] ~]# rabbitmqctl cluster_status -n [email protected] Cluster status of node [email protected]' [{nodes,[{disc,[[email protected]', [email protected]', [email protected]']}]}, {running_nodes,[[email protected]', [email protected]', [email protected]']}, {cluster_name,<<"[email protected]">>}, {partitions,[]}, {alarms,[[email protected]',[]}, [email protected]',[]}, [email protected]',[]}]}] [[email protected] ~]#
参考文档:http://www.cnblogs.com/wanglan/p/7662471.html
http://blog.csdn.net/Java_HuiLong/article/details/73718714
https://github.com/rabbitmq/erlang-rpm
http://www.rabbitmq.com/download.html
https://www.cnblogs.com/kevingrace/p/7693042.html
原创文章,作者:奋斗,如若转载,请注明出处:https://blog.ytso.com/11680.html