{"id":11709,"date":"2019-03-15T23:10:16","date_gmt":"2019-03-15T23:10:16","guid":{"rendered":"http:\/\/www.appservgrid.com\/paw92\/?p=11709"},"modified":"2019-03-15T23:10:16","modified_gmt":"2019-03-15T23:10:16","slug":"setting-up-xr-crossroads-load-balancer-for-web-servers-on-rhel-centos","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/15\/setting-up-xr-crossroads-load-balancer-for-web-servers-on-rhel-centos\/","title":{"rendered":"Setting Up \u2018XR\u2019 (Crossroads) Load Balancer for Web Servers on RHEL\/CentOS"},"content":{"rendered":"<p><strong>Crossroads<\/strong>\u00a0is a service independent, open source load balance and fail-over utility for Linux and TCP based services. It can be used for HTTP, HTTPS, SSH, SMTP and DNS etc. It is also a multi-threaded utility which consumes only one memory space which leads to increase the performance when balancing load.<\/p>\n<p>Let\u2019s have a look at how XR works. We can locate XR between network clients and a nest of servers which dispatches client requests to the servers balancing the load.<\/p>\n<p>If a server is down, XR forwards next client request to the next server in line, so client feels no down time. Have a look at the below diagram to understand what kind of a situation we are going to handle with XR.<\/p>\n<div id=\"attachment_14694\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Install-XR-Crossroads-Load-Balancer.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-14694\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Install-XR-Crossroads-Load-Balancer.jpg\" sizes=\"auto, (max-width: 620px) 100vw, 620px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Install-XR-Crossroads-Load-Balancer.jpg 720w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Install-XR-Crossroads-Load-Balancer-620x297.jpg 620w\" alt=\"Install XR Crossroads Load Balancer\" width=\"620\" height=\"297\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Install XR Crossroads Load Balancer<\/p>\n<\/div>\n<p>There are two web-servers, one gateway server which we install and setup XR to receive client requests and distribute them among the servers.<\/p>\n<pre><strong>XR Crossroads Gateway Server<\/strong> : 172.16.1.204\r\n<strong>Web Server 01<\/strong> : 172.16.1.222\r\n<strong>Web Server 02<\/strong> : 192.168.1.161<\/pre>\n<p>In above scenario, my gateway server (i.e XR Crossroads) bears the IP address\u00a0<strong>172.16.1.222<\/strong>,\u00a0<strong>webserver01<\/strong>\u00a0is\u00a0<strong>172.16.1.222<\/strong>\u00a0and it listens through port\u00a0<strong>8888<\/strong>\u00a0and\u00a0<strong>webserver02<\/strong>\u00a0is\u00a0<strong>192.168.1.161<\/strong>\u00a0and it listens through port\u00a0<strong>5555<\/strong>.<\/p>\n<p>Now all I need is to balance the load of all the requests that receives by the XR gateway from internet and distribute them among two web-servers balancing the load.<\/p>\n<h3>Step1: Install XR Crossroads Load Balancer on Gateway Server<\/h3>\n<p><strong>1.<\/strong>\u00a0Unfortunately, there isn\u2019t any binary RPM packages available for crosscroads, the only way to install XR crossroads from source tarball.<\/p>\n<p>To compile XR, you must have\u00a0<strong>C++<\/strong>\u00a0compiler and\u00a0<strong>Gnu make<\/strong>\u00a0utilities installed on the system in order to continue installation error free.<\/p>\n<pre># yum install gcc gcc-c++ make\r\n<\/pre>\n<p>Next, download the source tarball by going to their official site (<a href=\"https:\/\/crossroads.e-tunity.com\/\" target=\"_blank\" rel=\"nofollow noopener\">https:\/\/crossroads.e-tunity.com<\/a>), and grab the archived package (i.e.\u00a0<strong>crossroads-stable.tar.gz<\/strong>).<\/p>\n<p>Alternatively, you may use following\u00a0<strong>wget<\/strong>\u00a0utility to download the package and extract it in any location (eg:\u00a0<strong>\/usr\/src\/<\/strong>), go to unpacked directory and issue \u201c<strong>make install<\/strong>\u201d command.<\/p>\n<pre># wget https:\/\/crossroads.e-tunity.com\/downloads\/crossroads-stable.tar.gz\r\n# tar -xvf crossroads-stable.tar.gz\r\n# cd crossroads-2.74\/\r\n# make install\r\n<\/pre>\n<div id=\"attachment_14698\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Install-XR-Crossroads-Load-Balancer.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-14698\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Install-XR-Crossroads-Load-Balancer-620x354.png\" sizes=\"auto, (max-width: 620px) 100vw, 620px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Install-XR-Crossroads-Load-Balancer-620x354.png 620w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Install-XR-Crossroads-Load-Balancer.png 856w\" alt=\"Install XR Crossroads Load Balancer\" width=\"620\" height=\"354\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Install XR Crossroads Load Balancer<\/p>\n<\/div>\n<p>After installation finishes, the binary files are created under\u00a0<strong>\/usr\/sbin\/<\/strong>\u00a0and XR configuration within\u00a0<strong>\/etc<\/strong>\u00a0namely \u201c<strong>xrctl.xml<\/strong>\u201d.<\/p>\n<p><strong>2.<\/strong>\u00a0As the last prerequisite, you need two web-servers. For ease of use, I have created two python\u00a0<strong>SimpleHTTPServer<\/strong>\u00a0instances in one server.<\/p>\n<p>To see how to setup a python SimpleHTTPServer, read our article at\u00a0<a href=\"https:\/\/www.tecmint.com\/python-simplehttpserver-to-create-webserver-or-serve-files-instantly\/\" target=\"_blank\" rel=\"noopener\">Create Two Web Servers Easily Using SimpleHTTPServer<\/a>.<\/p>\n<p>As I said, we\u2019re using two web-servers, and they are\u00a0<strong>webserver01<\/strong>\u00a0running on\u00a0<strong>172.16.1.222<\/strong>\u00a0through port\u00a0<strong>8888<\/strong>and\u00a0<strong>webserver02<\/strong>\u00a0running on\u00a0<strong>192.168.1.161<\/strong>\u00a0through port\u00a0<strong>5555<\/strong>.<\/p>\n<div id=\"attachment_14700\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/XR-WebServer01.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-14700\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/XR-WebServer01.jpg\" alt=\"XR WebServer 01\" width=\"420\" height=\"37\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">XR WebServer 01<\/p>\n<\/div>\n<div id=\"attachment_14699\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/XR-WebServer02.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-14699\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/XR-WebServer02.jpg\" alt=\"XR WebServer 02\" width=\"442\" height=\"37\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">XR WebServer 02<\/p>\n<\/div>\n<h3>Step 2: Configure XR Crossroads Load Balancer<\/h3>\n<p><strong>3.<\/strong>\u00a0All requisites are in place. Now what we have to do is configure the\u00a0<code>xrctl.xml<\/code>\u00a0file to distribute the load among the web-servers which receives by the XR server from the internet.<\/p>\n<p>Now open\u00a0<code>xrctl.xml<\/code>\u00a0file with\u00a0<a href=\"https:\/\/www.tecmint.com\/vi-editor-usage\/\" target=\"_blank\" rel=\"noopener\">vi\/vim editor<\/a>.<\/p>\n<pre># vim \/etc\/xrctl.xml\r\n<\/pre>\n<p>and make the changes as suggested below.<\/p>\n<pre>&lt;?xml version=&lt;94&gt;1.0&lt;94&gt; encoding=&lt;94&gt;UTF-8&lt;94&gt;?&gt;\r\n&lt;configuration&gt;\r\n&lt;system&gt;\r\n&lt;uselogger&gt;true&lt;\/uselogger&gt;\r\n&lt;logdir&gt;\/tmp&lt;\/logdir&gt;\r\n&lt;\/system&gt;\r\n&lt;service&gt;\r\n&lt;name&gt;Tecmint&lt;\/name&gt;\r\n&lt;server&gt;\r\n&lt;address&gt;<strong>172.16.1.204:8080<\/strong>&lt;\/address&gt;\r\n&lt;type&gt;tcp&lt;\/type&gt;\r\n&lt;webinterface&gt;0:8010&lt;\/webinterface&gt;\r\n&lt;verbose&gt;yes&lt;\/verbose&gt;\r\n&lt;clientreadtimeout&gt;0&lt;\/clientreadtimeout&gt;\r\n&lt;clientwritetimout&gt;0&lt;\/clientwritetimeout&gt;\r\n&lt;backendreadtimeout&gt;0&lt;\/backendreadtimeout&gt;\r\n&lt;backendwritetimeout&gt;0&lt;\/backendwritetimeout&gt;\r\n&lt;\/server&gt;\r\n&lt;backend&gt;\r\n&lt;address&gt;<strong>172.16.1.222:8888<\/strong>&lt;\/address&gt;\r\n&lt;\/backend&gt;\r\n&lt;backend&gt;\r\n&lt;address&gt;<strong>192.168.1.161:5555<\/strong>&lt;\/address&gt;\r\n&lt;\/backend&gt;\r\n&lt;\/service&gt;\r\n&lt;\/configuration&gt;\r\n<\/pre>\n<div id=\"attachment_14702\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Configure-XR-Crossroads-Load-Balancer.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-14702\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Configure-XR-Crossroads-Load-Balancer-620x369.jpg\" sizes=\"auto, (max-width: 620px) 100vw, 620px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Configure-XR-Crossroads-Load-Balancer-620x369.jpg 620w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Configure-XR-Crossroads-Load-Balancer-1024x609.jpg 1024w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Configure-XR-Crossroads-Load-Balancer.jpg 1267w\" alt=\"Configure XR Crossroads Load Balancer\" width=\"620\" height=\"369\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Configure XR Crossroads Load Balancer<\/p>\n<\/div>\n<p>Here, you can see a very basic XR configuration done within\u00a0<strong>xrctl.xml<\/strong>. I have defined what the XR server is, what are the back end servers and their ports and web interface port for the XR.<\/p>\n<p><strong>4.<\/strong>\u00a0Now you need to start the XR daemon by issuing below commands.<\/p>\n<pre># xrctl start\r\n# xrctl status\r\n<\/pre>\n<div id=\"attachment_14703\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Start-XR-Crossroads.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-14703\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Start-XR-Crossroads-620x369.jpg\" sizes=\"auto, (max-width: 620px) 100vw, 620px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Start-XR-Crossroads-620x369.jpg 620w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Start-XR-Crossroads-1024x610.jpg 1024w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Start-XR-Crossroads.jpg 1263w\" alt=\"Start XR Crossroads\" width=\"620\" height=\"369\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Start XR Crossroads<\/p>\n<\/div>\n<p><strong>5.<\/strong>\u00a0Okay great. Now it\u2019s time to check whether the configs are working fine. Open two web browsers and enter the IP address of the XR server with port and see the output.<\/p>\n<div id=\"attachment_14705\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Verify-Web-Server-Load-Balancing.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-14705\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Verify-Web-Server-Load-Balancing-620x413.jpg\" sizes=\"auto, (max-width: 620px) 100vw, 620px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Verify-Web-Server-Load-Balancing-620x413.jpg 620w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Verify-Web-Server-Load-Balancing-1024x682.jpg 1024w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Verify-Web-Server-Load-Balancing.jpg 1181w\" alt=\"Verify Web Server Load Balancing\" width=\"620\" height=\"413\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Verify Web Server Load Balancing<\/p>\n<\/div>\n<p>Fantastic. It works fine. now it\u2019s time to play with XR.<\/p>\n<p><strong>6.<\/strong>\u00a0Now it\u2019s time to login into XR Crossroads dashboard and see the port we\u2019ve configured for web-interface. Enter your XR server\u2019s IP address with the port number for web-interface you have configured in\u00a0<strong>xrctl.xml<\/strong>.<\/p>\n<pre>http:\/\/172.16.1.204:8010\r\n<\/pre>\n<div id=\"attachment_14706\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/XR-Crossroads-Dashboard.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-14706\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/XR-Crossroads-Dashboard-609x450.jpg\" sizes=\"auto, (max-width: 609px) 100vw, 609px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/XR-Crossroads-Dashboard-609x450.jpg 609w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/XR-Crossroads-Dashboard-1024x757.jpg 1024w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/XR-Crossroads-Dashboard.jpg 1275w\" alt=\"XR Crossroads Dashboard\" width=\"609\" height=\"450\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">XR Crossroads Dashboard<\/p>\n<\/div>\n<p>This is what it looks like. It\u2019s easy to understand, user-friendly and easy to use. It shows how many connections each back end server received in the top right corner along with the additional details regarding the requests receiving. Even you can set the load weight each server you need to bear, maximum number of connections and load average etc..<\/p>\n<p>The best part is, you actually can do this even without configuring\u00a0<strong>xrctl.xml<\/strong>. Only thing you have to do is issue the command with following syntax and it will do the job done.<\/p>\n<pre># xr --verbose --server tcp:172.16.1.204:8080 --backend 172.16.1.222:8888 --backend 192.168.1.161:5555\r\n<\/pre>\n<p>Explanation of above syntax in detail:<\/p>\n<ol>\n<li><strong>\u2013verbose<\/strong>\u00a0will show what happens when the command has executed.<\/li>\n<li><strong>\u2013server<\/strong>\u00a0defines the XR server you have installed the package in.<\/li>\n<li><strong>\u2013backend<\/strong>\u00a0defines the webservers you need to balance the traffic to.<\/li>\n<li><strong>Tcp<\/strong>\u00a0defines it uses tcp services.<\/li>\n<\/ol>\n<p>For more details, about documentations and configuration of CROSSROADS, please visit their official site at:\u00a0<a href=\"https:\/\/crossroads.e-tunity.com\/\" target=\"_blank\" rel=\"nofollow noopener\">https:\/\/crossroads.e-tunity.com\/<\/a>.<\/p>\n<p><strong>XR Corssroads<\/strong>\u00a0enables many ways to enhance your server performance, protect downtime\u2019s and make your admin tasks easier and handier. Hope you enjoyed the guide and feel free to comment below for the suggestions and clarifications.<\/p>\n<p><strong>Read Also<\/strong>:\u00a0<a href=\"https:\/\/www.tecmint.com\/setting-up-pound-web-server-load-balancing-in-linux\/\" target=\"_blank\" rel=\"noopener\">Installing Pound Load Balancer to Control Web Server Load<\/a><\/p>\n<p><a href=\"https:\/\/www.tecmint.com\/setting-up-xr-crossroads-load-balancer-for-web-servers-on-rhel-centos\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Crossroads\u00a0is a service independent, open source load balance and fail-over utility for Linux and TCP based services. It can be used for HTTP, HTTPS, SSH, SMTP and DNS etc. It is also a multi-threaded utility which consumes only one memory space which leads to increase the performance when balancing load. Let\u2019s have a look at &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/15\/setting-up-xr-crossroads-load-balancer-for-web-servers-on-rhel-centos\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Setting Up \u2018XR\u2019 (Crossroads) Load Balancer for Web Servers on RHEL\/CentOS&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-11709","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/11709","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=11709"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/11709\/revisions"}],"predecessor-version":[{"id":11710,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/11709\/revisions\/11710"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=11709"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=11709"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=11709"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}