Skip to content

Instantly share code, notes, and snippets.

@MnifR
Last active March 26, 2021 10:01
Show Gist options
  • Select an option

  • Save MnifR/1842433ef0c1d2b1d103e41feb2e087a to your computer and use it in GitHub Desktop.

Select an option

Save MnifR/1842433ef0c1d2b1d103e41feb2e087a to your computer and use it in GitHub Desktop.

Cli

rabbitmqctl Service management and operator tasks https://www.rabbitmq.com/rabbitmqctl.8.html

rabbitmq-diagnostics Diagnostics/Health check

rabbitmq-plugins Plugin management

rabbitmqadmin Operator tasks over HTTP API

Nodes in cluster

Nodes in cluster Nodes can be through directly through DNS or via Configuration, via plugin through AWS Instance Directory, Consul, etcd, Kubernetes or manually through the CLI be brought together in a cluster. All nodes must have DNS or / etc / hosts have resolvable FQDN

//Stops the RabbitMQ node to remove it a cluster. The other cluster nodesare informed of the stop.

sudo rabbitmqctl stop_app

//Resets the local node. All data in the local database are deleted. The node must be stopped beforehand via stop_app.

sudo rabbitmqctl reset

rabbitmqctl join_cluster <name> @ <node> [--ram] 

// adds the local node to the cluster in which <name> @ <node> is a member node.

rabbitmqctl start_app

//RabbitMQ starts on the local node 

rabbitmqctl cluster_status 

// lists all current nodes in the cluster.

rabbitmqctl forget_cluster_node [--of Offen] <name> @ <node>

//removes node <name> @ <node> from the cluster.The command must be on an active node of the cluster are executed. <name> @ <node> must be offline be.

rabbitmqctl update_cluster_nodes <name> @ <node> 

//updates the local node with the cluster contents from <name> @ <node>. This must be part of the Be a cluster in which the local node is also located.

rabbitmqctl force_boot 

// commands the local node to start even though this might not start because it assumes Not being the last node in the cluster. This means that all changes in the cluster Database lost after the shutdown of the local node happened.

rabbitmqctl sync_queue [-p vhost] 

//queue forces the synchronization of the queue “queue”, if necessary on Vhost “vhost”. While the synchronization is running,
Producers and consumers are enticed. the command only works on queues on more than one Nodes are mirrored.

rabbitmqctl purge_queue [-p vhost] 

//queue deletes the content of a queue.

###rabbitmq.conf cluster

loopback_users.guest = false
listeners.tcp.default = 5672

cluster_formation.peer_discovery_backend = rabbit_peer_discovery_classic_config
cluster_formation.classic_config.nodes.1 = rabbit@<hostname of the node-1>
cluster_formation.classic_config.nodes.2 = rabbit@<hostname of the node-2>
cluster_formation.classic_config.nodes.3 = rabbit@<hostname of the node-3>
.
.

Plugin command

rabbitmq-plugins list

rabbitmq-plugins enable plugin

rabbitmq-plugins disable plugin

Plugin list

managment
federation
federation_management
shovel_management

list queue

sudo rabbitmqctl list_queues

To list exchanges

sudo rabbitmqctl list_exchanges

enable federation plugin

rabbitmq-plugins enable rabbitmq_federation 

Basic Queue Mirroring

rabbitmqctl set_policy ha-fed \
    ".*" '{"federation-upstream-set":"all", "ha-mode":"nodes", "ha-params":["rabbit@<hostname of the node-1>","rabbit@<hostname of the node-2>","rabbit@<hostname of the node-3>"]}' \
    --priority 1 \
    --apply-to queues

https://www.rabbitmq.com/ha.html#mirroring-arguments

Automatic Synchronization

rabbitmqctl set_policy ha-fed \
   ".*" '{"federation-upstream-set":"all", "ha-sync-mode":"automatic", "ha-mode":"nodes", "ha-params":["rabbit@<hostname of the node-1>","rabbit@<hostname of the node-2>","rabbit@<hostname of the node-3>"]}' \
   --priority 1 \
   --apply-to queues

Command Linux

# start the service
service rabbitmq-server start
    
# stop the service
service rabbitmq-server stop

# restart the service
service rabbitmq-server restart

# check the status
service rabbitmq-server status
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment