{"id":509,"date":"2020-06-28T02:54:05","date_gmt":"2020-06-28T02:54:05","guid":{"rendered":"http:\/\/www.legendshub.com\/blog\/?p=509"},"modified":"2020-07-19T12:59:39","modified_gmt":"2020-07-19T12:59:39","slug":"rabbitmq-install-on-centos-7-in-cluster-mode-legendshub-blog","status":"publish","type":"post","link":"https:\/\/www.legendshub.com\/blog\/2020\/06\/28\/rabbitmq-install-on-centos-7-in-cluster-mode-legendshub-blog\/","title":{"rendered":"Rabbitmq Install on Centos 7 in cluster mode &#8211; Legendshub Blog"},"content":{"rendered":"\n<!-- Quick Adsense WordPress Plugin: http:\/\/quickadsense.com\/ -->\n<div class=\"2c935cf620b701aabbb7cc90bbf4023c\" data-index=\"1\" style=\"float: none; margin:0px 0 0px 0; text-align:center;\">\n<script async src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js\"><\/script>\r\n<script>\r\n  (adsbygoogle = window.adsbygoogle || []).push({\r\n    google_ad_client: \"ca-pub-5554449970657557\",\r\n    enable_page_level_ads: true\r\n  });\r\n<\/script>\n<\/div>\n\n<p>As we are fully aware of importance of Rabbitmq in enterprise environements. Today we will discuss how can we install rabbitmq in cluster mode in AWS on Centos 7. <\/p>\n\n\n\n<p>AWS Environment:<\/p>\n\n\n\n<p>In order to start installation of rabbitmq  we will launch two ec2 instances with Centos 7 on them. We will add autoscaling group and configure Load Balancer for them. Once we will have AWS environment set we are ready to start rabbitmq installation in cluster mode<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"1024\" src=\"http:\/\/www.legendshub.com\/blog\/wp-content\/uploads\/2020\/07\/My-Post-7-1024x1024.png\" alt=\"\" class=\"wp-image-559\" srcset=\"https:\/\/www.legendshub.com\/blog\/wp-content\/uploads\/2020\/07\/My-Post-7-1024x1024.png 1024w, https:\/\/www.legendshub.com\/blog\/wp-content\/uploads\/2020\/07\/My-Post-7-300x300.png 300w, https:\/\/www.legendshub.com\/blog\/wp-content\/uploads\/2020\/07\/My-Post-7-150x150.png 150w, https:\/\/www.legendshub.com\/blog\/wp-content\/uploads\/2020\/07\/My-Post-7-768x768.png 768w, https:\/\/www.legendshub.com\/blog\/wp-content\/uploads\/2020\/07\/My-Post-7-1536x1536.png 1536w, https:\/\/www.legendshub.com\/blog\/wp-content\/uploads\/2020\/07\/My-Post-7-2048x2048.png 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption>Rabbitmq Install<\/figcaption><\/figure>\n\n\n\n<p>We need to make sure we bring up the instances using the following role which enable them to describe ec2 instances and autoscaling groups.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">{\n\"Version\": \"2012-10-17\",\n\"Statement\": [\n              {\n              \"Effect\": \"Allow\",\n              \"Action\": [\n                         \"autoscaling:DescribeAutoScalingInstances\",\n                         \"ec2:DescribeInstances\"\n                         ],\n              \"Resource\": [\n                           \"*\"\n                           ]\n              }\n              ]\n}<\/pre>\n\n\n\n<p>Now we will login into once instance and configure two repository one for Erlang installation and second for Rabbitmq installation.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">cd \/etc\/yum.repos.d\/ vi rabbit_erlang.repo [rabbitmq_erlang]\nname=Repo to install erlang for centos7\nbaseurl=https:\/\/packagecloud.io\/rabbitmq\/erlang\/el\/7\/$basearch\nenabled=1\ngpgcheck=0\nrepo_gpgcheck=1\ngpgkey=https:\/\/packagecloud.io\/rabbitmq\/erlang\/gpgkey\n metadata_expire=300\n<br>sslcacert=\/etc\/pki\/tls\/certs\/ca-bundle.crt\n<br>sslverify=1 \nvi rabbitmq.repo [rabbitmq_erlang] \nname=Repo to install rabbitmq for centos7 baseurl=https:\/\/dl.bintray.com\/rabbitmq\/rpm\/rabbitmq-server\/v3.8.x\/el\/7\/ enabled=1\n<br>gpgcheck=0<\/pre>\n\n\n\n<p>Now repo has been configured but we generally observed that package install may conflict with existing epel repositories in Centos. So its best practice to disable existent repositories and enable new one.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">yum -q makecache -y --disablerepo='epel*' --enablerepo='rabbitmq*'<\/pre>\n\n\n\n<p>Once it is completed now we will go ahead and install rabbitmq-server , perl-JSON and erlang packages using yum command. Make sure latest version is installed<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">yum install erlang perl-JSON rabbitmq-server -y \nrpm -qa | grep rabbitmq<\/pre>\n\n\n\n<p>Now we have latest package of rabbitmq server installed on AWS instances. We will move ahead with maintaining hosts file for each node. To make sure every new node in existing auto scaling group join cluster successfully we need to find the way of automatic detection on AWS nodes within the autoscaling group. We can use the following script to do the same.<\/p>\n<!-- Quick Adsense WordPress Plugin: http:\/\/quickadsense.com\/ -->\n<div class=\"2c935cf620b701aabbb7cc90bbf4023c\" data-index=\"3\" style=\"float: none; margin:0px 0 0px 0; text-align:center;\">\n<script async src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js\"><\/script>\r\n<script>\r\n  (adsbygoogle = window.adsbygoogle || []).push({\r\n    google_ad_client: \"ca-pub-5554449970657557\",\r\n    enable_page_level_ads: true\r\n  });\r\n<\/script>\n<\/div>\n\n\n\n\n<div class=\"wp-container-5 wp-block-group\"><div class=\"wp-block-group__inner-container\">\n<div class=\"wp-container-4 wp-block-group\"><div class=\"wp-block-group__inner-container\">\n<div class=\"wp-container-3 wp-block-group\"><div class=\"wp-block-group__inner-container\">\n<pre class=\"wp-block-preformatted\">cat instance_discovery.sh<\/pre>\n\n\n\n<div class=\"wp-container-2 wp-block-group\"><div class=\"wp-block-group__inner-container\">\n<pre class=\"wp-block-preformatted\"> !\/bin\/bash<\/pre>\n\n\n\n<div class=\"wp-container-1 wp-block-group\"><div class=\"wp-block-group__inner-container\">\n<pre class=\"wp-block-preformatted\">curl http:\/\/169.254.169.254\/latest\/meta-data\/instance-id -o \"\/etc\/we.txt\"\ninstance=$(cat \/etc\/we.txt)\ngroup=$(aws ec2 describe-instances --instance-ids $instance --region us-east-1 | grep -B 1 autoscaling | grep Value | awk -F\":\" '{print $2}' | awk -F'\"' '{print $2}')\nfor ID in $(aws autoscaling describe-auto-scaling-instances --region us-east-1 --query \"AutoScalingInstances[?AutoScalingGroupName=='${group}'].InstanceId\" --output text);\ndo\necho $ID\naws ec2 describe-instances --instance-ids $ID --region us-east-1 --query Reservations[].Instances[].PrivateIpAddress --output text &gt;&gt; \/etc\/ghost\ndone\nfor ID in $(aws autoscaling describe-auto-scaling-instances --region us-east-1 --query \"AutoScalingInstances[?AutoScalingGroupName=='${group}'].InstanceId\" --output text);<br>do<br>aws ec2 describe-instances --instance-ids $ID --region us-east-1 --query Reservations[].Instances[].PrivateDnsName --output text| awk -F\".\" '{print $1}' &gt;&gt; \/etc\/ghost1\ndone\npaste \/etc\/ghost \/etc\/ghost1 &gt;&gt; \/etc\/hosts\nrm -rf \/etc\/ghost \n\/etc\/ghost1 \n\/etc\/we.txt<\/pre>\n<\/div><\/div>\n<\/div><\/div>\n<\/div><\/div>\n<\/div><\/div>\n<\/div><\/div>\n\n\n\n<p>Now once you run the above script all nodes within the autoscaling group will be amended to \/etc\/hosts file.<\/p>\n\n\n\n<p>As we have hosts file thing managed now. We will enable aws peer discovery plugin with few more plugins. To know more about AWS Peer discovery plugin follow the link below or one can watch the video linked beneath.<\/p>\n\n\n\n<p><a href=\"https:\/\/www.rabbitmq.com\/cluster-formation.html#peer-discovery-aws\">https:\/\/www.rabbitmq.com\/cluster-formation.html#peer-discovery-aws<\/a><\/p>\n\n\n\n<figure class=\"wp-block-embed-youtube wp-block-embed is-type-video is-provider-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"Rabbitmq Install on AWS in cluster mode (Hindi)  - Cloud and Tech Tutorials\" width=\"631\" height=\"355\" src=\"https:\/\/www.youtube.com\/embed\/RMB3p4grrqk?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<pre class=\"wp-block-preformatted\">rabbitmq-plugins enable rabbitmq_management\nrabbitmq-plugins enable rabbitmq_federation\nrabbitmq-plugins enable rabbitmq_federation_management\nrabbitmq-plugins enable rabbitmq_auth_mechanism_ssl \nrabbitmq-plugins enable rabbitmq_management_agent\nrabbitmq-plugins enable rabbitmq_shovel\nrabbitmq-plugins enable rabbitmq_shovel_management\nrabbitmq-plugins --offline enable rabbitmq_peer_discovery_aws<\/pre>\n\n\n\n<p>Now plugins are enabled we will now have to do configuration in rabbitmq file.As we will be using tags to add node in rabbitmq cluster. <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">vi \/etc\/rabbitmq\/rabbitmq\ncluster_formation.peer_discovery_backend = rabbitmq_peer_discovery_aws\ncluster_formation.aws.region = us-east-1\ncluster_formation.aws.instance_tags.region = us-east-1\ncluster_formation.aws.instance_tags.service = rabbitmq<\/p>cluster_formation.aws.use_private_ip = true\ncluster_formation.aws.use_autoscaling_group = true\nlog.file.level = debug<\/pre>\n\n\n\n<p>So we are ready to restart the service rabbitmq-server on first node.Once it is done we need to do package install on the second node. Do the config and restart the rabbitmq-service. It will automatically register the second node and you can see it registering by simultaneously running the following command.<\/p>\n\n<!-- Quick Adsense WordPress Plugin: http:\/\/quickadsense.com\/ -->\n<div class=\"2c935cf620b701aabbb7cc90bbf4023c\" data-index=\"100\" style=\"\">\n\n<\/div>\n\n<div style=\"font-size: 0px; height: 0px; line-height: 0px; margin: 0; padding: 0; clear: both;\"><\/div>","protected":false},"excerpt":{"rendered":"<p class=\"excerpt\">As we are fully aware of importance of Rabbitmq in enterprise environements. Today we will discuss how can we install rabbitmq in cluster mode in AWS on Centos 7. AWS Environment: In order to start installation of rabbitmq we will launch two ec2 instances with Centos 7 on them. We will add autoscaling group and configure Load Balancer for them.&hellip;<\/p>\n<p class=\"more-link-p\"><a class=\"btn btn-default\" href=\"https:\/\/www.legendshub.com\/blog\/2020\/06\/28\/rabbitmq-install-on-centos-7-in-cluster-mode-legendshub-blog\/\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":559,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[41,4,31],"tags":[142,141,140],"_links":{"self":[{"href":"https:\/\/www.legendshub.com\/blog\/wp-json\/wp\/v2\/posts\/509"}],"collection":[{"href":"https:\/\/www.legendshub.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.legendshub.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.legendshub.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.legendshub.com\/blog\/wp-json\/wp\/v2\/comments?post=509"}],"version-history":[{"count":26,"href":"https:\/\/www.legendshub.com\/blog\/wp-json\/wp\/v2\/posts\/509\/revisions"}],"predecessor-version":[{"id":569,"href":"https:\/\/www.legendshub.com\/blog\/wp-json\/wp\/v2\/posts\/509\/revisions\/569"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.legendshub.com\/blog\/wp-json\/wp\/v2\/media\/559"}],"wp:attachment":[{"href":"https:\/\/www.legendshub.com\/blog\/wp-json\/wp\/v2\/media?parent=509"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.legendshub.com\/blog\/wp-json\/wp\/v2\/categories?post=509"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.legendshub.com\/blog\/wp-json\/wp\/v2\/tags?post=509"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}