Rabbitmq安装
Posted 小怪獣55
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Rabbitmq安装相关的知识,希望对你有一定的参考价值。
yum源
[Epel]
name=epel
baseurl=https://mirrors.aliyun.com/epel/$releasever/x86_64
gpgcheck=0
enabled = 1
[Ali]
name=aliyun
baseurl=https://mirrors.aliyun.com/centos/$releasever/os/x86_64/
gpgcheck=0
enabled = 1
1.安装
#1.
yum install rabbitmq-server -y
#2.
装完以后,暂时不启动
做高可用,要解析出每个主机的主机名,修改hosts文件进行解析
[root@mariadb ~]# cat /etc/hosts
192.168.47.28 mariadb
192.168.47.29 mariadb2
#3.
#端口5672 客户端使用;集群通讯使用端口:25672
[root@mariadb ~]# systemctl start rabbitmq-server
#4.打开rabbitMQ的web插件:可从浏览器查看当前主机的状态 端口15672
[root@mariadb ~]# rabbitmq-plugins enable rabbitmq_management
--------------------------------------------------------
The following plugins have been enabled:
mochiweb
webmachine
rabbitmq_web_dispatch
amqp_client
rabbitmq_management_agent
rabbitmq_management
Plugin configuration has changed. Restart RabbitMQ for changes to take effect.
#5.打开插件后必须重新启动一次
[root@mariadb ~]# systemctl restart rabbitmq-server
[root@mariadb ~]# systemctl status rabbitmq-server
[root@mariadb ~]# systemctl enable rabbitmq-server
#6.
[root@mariadb ~]# rabbitmq-plugins list #查看插件
4
#7.访问
192.168.47.28:15672 #账户/密码:默认guest
2.高可用
#1.查看集群状态
[root@mariadb ~]# rabbitmqctl cluster_status
Cluster status of node rabbit@mariadb ...
[nodes,[disc,[rabbit@mariadb]],
running_nodes,[rabbit@mariadb],
cluster_name,<<"rabbit@mariadb">>,
partitions,[]]
...done.
#2.加入集群条件
2.1.cookie是否一致
scp /var/lib/rabbitmq/.erlang.cookie 192.168.47.29:/var/lib/rabbitmq/.erlang.cookie
systemctl restart rabbitmq-server
[root@mariadb ~]# cat /var/lib/rabbitmq/.erlang.cookie
UAUYPUZHUTXUVTAFLGZN
[root@mariadb2 ~]# cat /var/lib/rabbitmq/.erlang.cookie
UAUYPUZHUTXUVTAFLGZN
2.2.能不能解析对方的主机名,修改/etc/hosts文件
vim /etc/hosts
------------------------
192.168.1.148 mariadb1
192.168.1.149 mariadb2
#3.加入到集群中
要把哪个节点加入到集群,先要把该节点清空,先停止
[root@mariadb2 ~]# rabbitmqctl stop_app #停止应用程序
[root@mariadb2 ~]# rabbitmqctl reset #清空数据
#将mariadb2添加到集群当中,并成为内存节点,不加--ram默认是磁盘节点 ;执行要成功,需要满足[加入集群条件]
[root@mariadb2 ~]# rabbitmqctl join_cluster rabbit@mariadb --ram
--------------------------------------------------------------
Clustering node rabbit@mariadb2 with rabbit@mariadb ...
...done.
[root@mariadb2 ~]# rabbitmqctl start_app
--------------------------------------------------------------
Starting node rabbit@mariadb2 ...
...done.
[root@mariadb2 ~]# rabbitmqctl cluster_status
--------------------------------------------------------------
Cluster status of node rabbit@mariadb2 ...
[nodes,[disc,[rabbit@mariadb],ram,[rabbit@mariadb2]],
running_nodes,[rabbit@mariadb,rabbit@mariadb2],
cluster_name,<<"rabbit@mariadb">>,
partitions,[]]
...done.
#4.改成镜像模式
[root@mariadb2 ~]# rabbitmqctl set_policy ha-all "#" "ha-mode":"all"
------------------------------------------------------------------------------------------
Setting policy "ha-all" for pattern "#" to "\\"ha-mode\\":\\"all\\"" with priority "0" ...
...done.
"#"为任意0个或多个即为所有,也可以使用"^test"匹配开头,还可以使用其他正则匹配
#5.创建用户及配置权限
[root@mariadb2 ~]# rabbitmqctl add_user openstack openstack123 #任何一个节点创建
Creating user "openstack" ...
...done.
[root@mariadb2 ~]# rabbitmqctl set_permissions openstack ".*" ".*" ".*" #配置权限
Setting permissions for user "openstack" in vhost "/" ...
...done.
以上是关于Rabbitmq安装的主要内容,如果未能解决你的问题,请参考以下文章