{"id":33,"date":"2012-03-12T00:17:29","date_gmt":"2012-03-11T20:17:29","guid":{"rendered":"http:\/\/pavlenko.net\/antony\/?p=33"},"modified":"2020-05-07T00:53:59","modified_gmt":"2020-05-06T20:53:59","slug":"network-load-balancing-with-solaris","status":"publish","type":"post","link":"http:\/\/pavlenko.net\/antony\/2012\/03\/12\/network-load-balancing-with-solaris\/","title":{"rendered":"network load balancing with Solaris"},"content":{"rendered":"<p>I know that everybody forgot about this blog but I&#8217;ll try to liven it up.<br \/>\nSome days ago at Moscow OpenSolaris User Group meeting was 2 presentations about network. First one was about Crossbow and all around and second one was about network load balancing &#8230; with Linux and FreeBSD and nothing about Solaris.<br \/>\nSo as nobody knew anything about network load balancing with Solaris i have decided to write about it.<br \/>\nThere are some solutions for network balancing in FreeBSD and Linux and really nothing like this exists in Solaris 10.<br \/>\nTime stands still and Solaris 11 Express is already exists and OpenSolaris already doesn&#8217;t exists \ud83d\ude42<br \/>\nIt is in the OpenSolaris appeared support ILB ( Integrated Load Balancer ) and now it is included to Solaris 11 Express.<br \/>\nSo let&#8217;s try to configure Solaris ILB.<br \/>\nFirst of all you need to check that ilb is installed and if no, install it.<\/p>\n<pre>\r\nroot@solaris:~# pkg search ilbadm\r\nINDEX      ACTION VALUE           PACKAGE\r\nbasename   file   usr\/sbin\/ilbadm pkg:\/service\/network\/load-balancer\/ilb@0.5.11-0.151.0.1\r\nroot@solaris:~# man pkg\r\nroot@solaris:~# pkg install pkg:\/service\/network\/load-balancer\/ilb@0.5.11-0.151.0.1\r\n               Packages to install:     1\r\n           Create boot environment:    No\r\n               Services to restart:     1\r\nDOWNLOAD                                  PKGS       FILES    XFER (MB)\r\nCompleted                                  1\/1       11\/11      0.2\/0.2\r\n\r\nPHASE                                        ACTIONS\r\nInstall Phase                                  38\/38 \r\n\r\nPHASE                                          ITEMS\r\nPackage State Update Phase                       1\/1 \r\nImage State Update Phase                         2\/2 \r\n\r\nPHASE                                          ITEMS\r\nReading Existing Index                           8\/8 \r\nIndexing Packages                                1\/1\r\nroot@solaris:~#\r\n<\/pre>\n<p>Now ILB installed and we can configure load balancing.<br \/>\nFirst of all let&#8217;s start ilb daemon. But before this we ought to start ip forwarding. If you forget to do so ilbadm output would be really helpful.<\/p>\n<pre>\r\nroot@solaris:~# ilbadm show-rule\r\nilbadm: socket() failed\r\nroot@solaris:~#\r\n<\/pre>\n<p>So let&#8217;s start ip forwarding and ilb daemon.<\/p>\n<pre> root@solaris:~# svcadm enable svc:\/network\/ipv4-forwarding\r\nroot@solaris:~# svcadm enable svc:\/network\/loadbalancer\/ilb:default <\/pre>\n<p>ILB supports 3 modes :<br \/>\n &#8211; DST<br \/>\n &#8211; Full NAT<br \/>\n &#8211; Half NAT<\/p>\n<p>In the DSR ( Direct Server Return ) mode, ILB balances the incoming requests to the back-end servers, and letting the return traffic from the servers bypass the load balancer by being sent directly to the client.<br \/>\nNAT-based load balancing involves rewriting of IP header information,and handles both the request and the response traffic.<br \/>\nIn Full NAT mode ILB involves rewriting of both source and destination IP fields, making it appear to the back-end servers that all connections are originating at the load balancer. Clients will also receive packets from preconfigured IP range.<br \/>\nIn the half-NAT mode ILB rewrites only destination IP address.<\/p>\n<p>I have used 3 servers to try ILB. Two of them i used as back-end servers. I have started nginx there. There IPs : 192.168.57.102,192.168.57.103. ILB was started at the third server with IP 192.168.57.101.<\/p>\n<p>First of all I&#8217;ve configured server group, which will process http traffic :<\/p>\n<pre>\r\nroot@solaris:~# ilbadm create-servergroup -s servers=192.168.57.102:80,192.168.57.103:80 websg\r\nroot@solaris:~# ilbadm show-servergroup\r\nroot@solaris:\/tmp# ilbadm show-sg\r\nSGNAME         SERVERID            MINPORT MAXPORT IP_ADDRESS\r\nwebsg          _websg.0            80      80      192.168.57.102\r\nwebsg          _websg.1            80      80      192.168.57.103\r\n<\/pre>\n<p>And then I&#8217;ve configured balance rule. First of all let&#8217;s try full NAT.<\/p>\n<pre>\r\nroot@solaris:\/tmp# ilbadm create-rule -e -i vip=192.168.56.101,port=80 -m lbalg=rr,type=NAT,proxy-src=192.168.56.101 -o servergroup=websg webrule\r\nroot@solaris:\/tmp# ilbadm show-rule\r\nRULENAME            STATUS LBALG       TYPE    PROTOCOL VIP         PORT\r\nwebrule             E      roundrobin  NAT     TCP  192.168.56.101  80\r\n<\/pre>\n<p>And that&#8217;s all!<br \/>\nI have configured that http traffic to 192.168.56.101 ( virtual IP ) will be load balanced across 2 servers using round robin algorithm. Clients will receive replies from IP 192.168.56.101.<br \/>\nLet&#8217;s change ILB mode from full NAT to Half NAT.<\/p>\n<pre>\r\nilbadm  delete-rule -a\r\nilbadm create-rule -e -i vip=192.168.56.101,port=80 -m lbalg=rr,type=h -o servergroup=websg webrule\r\nroot@solaris:\/tmp# ilbadm show-rule\r\nRULENAME            STATUS LBALG       TYPE    PROTOCOL VIP         PORT\r\nwebrule             E      roundrobin  HALF-NAT TCP 192.168.56.101  80\r\n<\/pre>\n<p>This is really easy to configure. Of course there are a lot of options. For example you can select load balancing algorithm Moreover, ILB offers an optional server monitoring feature that can provide server health checks. Another great options are : Session persistence and Connection draining<br \/>\nMore details about the ILB can be read on <a href=\"http:\/\/wikis.sun.com\/display\/OpenSolarisInfo\/Integrated+Load+Balancer\" title=\"wiki\">wiki<\/a><br \/>\nI&#8217;m not really an expert in load balancers but ILB looks much more useful and functional than FreeBSD or Linux analogs.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I know that everybody forgot about this blog but I&#8217;ll try to liven it up. Some days ago at Moscow OpenSolaris User Group meeting was 2 presentations about network. First one was about Crossbow and all around and second one was about network load balancing &#8230; with Linux and FreeBSD and nothing about Solaris. So [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[6,3],"tags":[],"_links":{"self":[{"href":"http:\/\/pavlenko.net\/antony\/wp-json\/wp\/v2\/posts\/33"}],"collection":[{"href":"http:\/\/pavlenko.net\/antony\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/pavlenko.net\/antony\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/pavlenko.net\/antony\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/pavlenko.net\/antony\/wp-json\/wp\/v2\/comments?post=33"}],"version-history":[{"count":2,"href":"http:\/\/pavlenko.net\/antony\/wp-json\/wp\/v2\/posts\/33\/revisions"}],"predecessor-version":[{"id":35,"href":"http:\/\/pavlenko.net\/antony\/wp-json\/wp\/v2\/posts\/33\/revisions\/35"}],"wp:attachment":[{"href":"http:\/\/pavlenko.net\/antony\/wp-json\/wp\/v2\/media?parent=33"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/pavlenko.net\/antony\/wp-json\/wp\/v2\/categories?post=33"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/pavlenko.net\/antony\/wp-json\/wp\/v2\/tags?post=33"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}