rabbitmq单机创建集群,指定端口号
rabbitmq单机创建集群,指定端口号
单机创建集群
1.停用web管理插件
./rabbitmq-plugins disable rabbitmq_management
停用节点(如果有开启)
./rabbitmqctl stop_app
2.设置环境变量(端口号,web端口号),以后台方式启动
注意新版去掉 rabbit@ hostname跟RABBITMQ_NODENAME=rabbit 对应
如 echo '192.168.1.1 rabbit ' >> /etc/hosts
vim /etc/hosts
1 IP rabbitmq-node1
2 IP rabbitmq-node2
3 IP rabbitmq-node3
291 rabbitmqctl -n rabbit2 stop_app
292 rabbitmqctl -n rabbit2 reset
293 rabbitmqctl -n rabbit2 join_cluster `hostname -s`
294 rabbitmqctl -n rabbit2 start_app
295 rabbitmqctl -n rabbit3 stop_app
296 rabbitmqctl -n rabbit3 reset
297 rabbitmqctl -n rabbit3 join_cluster `hostname -s`
298 rabbitmqctl -n rabbit3 start_app
299 rabbitmqctl -n rabbit cluster_status
--------------------------------------------------------------------------------------------
vim /etc/hosts
1 IP rabbit@rabbitmq-node1
2 IP rabbit@rabbitmq-node2
3 IP rabbit@rabbitmq-node3
-
RABBITMQ_NODE_PORT=5672 RABBITMQ_NODENAME=rabbit RABBITMQ_SERVER_START_ARGS="-rabbitmq_management listener [{port,15672}]" ./rabbitmq-server -detached
-
RABBITMQ_NODE_PORT=5673 RABBITMQ_NODENAME=hare RABBITMQ_SERVER_START_ARGS="-rabbitmq_management listener [{port,15673}]" ./rabbitmq-server -detached
-
RABBITMQ_NODE_PORT=5674 RABBITMQ_NODENAME=hare1 RABBITMQ_SERVER_START_ARGS="-rabbitmq_management listener [{port,15674}]" ./rabbitmq-server -detached
556 RABBITMQ_NODE_PORT=5672 RABBITMQ_SERVER_START_ARGS="-rabbitmq_management listener [{port,15672}]" RABBITMQ_NODENAME=rabbit rabbitmq-server -detached
557 RABBITMQ_NODE_PORT=5673 RABBITMQ_SERVER_START_ARGS="-rabbitmq_management listener [{port,15673}]" RABBITMQ_NODENAME=rabbit1 rabbitmq-server -detached
558 RABBITMQ_NODE_PORT=5674 RABBITMQ_SERVER_START_ARGS="-rabbitmq_management listener [{port,15674}]" RABBITMQ_NODENAME=rabbit6 rabbitmq-server -detached-----------------------------------------------
RABBITMQ_NODE_PORT=5672 RABBITMQ_SERVER_START_ARGS="-rabbitmq_management listener [{port,15672}]" RABBITMQ_NODENAME=rabbit rabbitmq-server -detached
288 RABBITMQ_NODE_PORT=5673 RABBITMQ_SERVER_START_ARGS="-rabbitmq_management listener [{port,15673}]" RABBITMQ_NODENAME=rabbit2 rabbitmq-server -detached
289 RABBITMQ_NODE_PORT=5674 RABBITMQ_SERVER_START_ARGS="-rabbitmq_management listener [{port,15674}]" RABBITMQ_NODENAME=rabbit3 rabbitmq-server -detached
290 netstat -tunlp
291 rabbitmqctl -n rabbit2 stop_app
292 rabbitmqctl -n rabbit2 reset
293 rabbitmqctl -n rabbit2 join_cluster rabbit@`hostname -s`
294 rabbitmqctl -n rabbit2 start_app
295 rabbitmqctl -n rabbit3 stop_app
296 rabbitmqctl -n rabbit3 reset
297 rabbitmqctl -n rabbit3 join_cluster rabbit@`hostname -s`
298 rabbitmqctl -n rabbit3 start_app
299 rabbitmqctl -n rabbit cluster_status
300 rabbitmqctl set_policy ha-all "^" '{"ha-mode":"all"}'
301 cd
302 ls
303 rabbitmqctl -h
304 rabbitmqctl -v
305 rabbitmqctl -version
306 rabbitmqctl status | grep rabbit
307 ls
308 scp rabbitmq_delayed_message_exchange-20171215-3.6.x.ez /usr/lib/rabbitmq/lib/rabbitmq_server-3.6.10/plugins/
309 cp rabbitmq_delayed_message_exchange-20171215-3.6.x.ez /usr/lib/rabbitmq/lib/rabbitmq_server-3.6.10/plugins/
310 rabbitmq-plugins enable rabbitmq_delayed_message_exchange
311 rabbitmq plugins
312 rabbitmq-plugins list
313 rabbitmq-plugins enable rabbitmq_delayed_message_exchange 20171215-3.6.x
314 cd /usr/lib/rabbitmq/lib/rabbitmq_server-3.6.10/plugins/
三个节点已经启动,通过./rabbitmqctl cluster_status查看并没有在一个集群里。分别停用后面两个节点,然后加入到第一个集群,再重新启动
-
./rabbitmqctl -n hare stop_app
-
./rabbitmqctl -n hare join_cluster rabbit@`hostname -s`
-
./rabbitmqctl -n hare start_app
下面该hare1了,这里设置成磁盘节点
-
./rabbitmqctl -n hare stop_app
-
./rabbitmqctl -n hare join_cluster --ram rabbit@`hostname -s`
-
./rabbitmqctl -n hare start_app
最后通过./rabbitmqctl cluster_status查看状态:
踢出集群:
./rabbitmqctl -n hare1 stop_app
./rabbitmqctl forget_cluster_node hare1@localhost
加入集群:
./rabbitmqctl -n hare1 join_cluster --ram rabbit@`hostname -s`
./rabbitmqctl -n hare1 start_app
启动web管理插件
./rabbitmq-plugins -n rabbit enable rabbitmq_management
./rabbitmq-plugins -n hare enable rabbitmq_management
./rabbitmq-plugins -n hare1 enable rabbitmq_management
转载于:https://my.oschina.net/zcjlq/blog/1574463
无法guest登录
解决办法:
Step1:执行如下命令
命令1:rabbitmqctl set_user_tags guest administrator
命令2:rabbitmqctl set_permissions -p / guest '.*' '.*' '.*'
重启rabbitmq即可。测试如果还是无法登陆,则进行Step2。
Step2:在rabbitmq的配置文件目录下创建一个rabbitmq.config文件。文件中添加如下配置(请不要忘记那个“.”):
[{rabbit, [{loopback_users, []}]}].