I know that everybody forgot about this blog but I’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 … with Linux and FreeBSD and nothing about Solaris.
So as nobody knew anything about network load balancing with Solaris i have decided to write about it.
There are some solutions for network balancing in FreeBSD and Linux and really nothing like this exists in Solaris 10.
Time stands still and Solaris 11 Express is already exists and OpenSolaris already doesn’t exists 🙂
It is in the OpenSolaris appeared support ILB ( Integrated Load Balancer ) and now it is included to Solaris 11 Express.
So let’s try to configure Solaris ILB.
First of all you need to check that ilb is installed and if no, install it.
root@solaris:~# pkg search ilbadm INDEX ACTION VALUE PACKAGE basename file usr/sbin/ilbadm pkg:/firstname.lastname@example.org root@solaris:~# man pkg root@solaris:~# pkg install pkg:/email@example.com Packages to install: 1 Create boot environment: No Services to restart: 1 DOWNLOAD PKGS FILES XFER (MB) Completed 1/1 11/11 0.2/0.2 PHASE ACTIONS Install Phase 38/38 PHASE ITEMS Package State Update Phase 1/1 Image State Update Phase 2/2 PHASE ITEMS Reading Existing Index 8/8 Indexing Packages 1/1 root@solaris:~#
Now ILB installed and we can configure load balancing.
First of all let’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.
root@solaris:~# ilbadm show-rule ilbadm: socket() failed root@solaris:~#
So let’s start ip forwarding and ilb daemon.
root@solaris:~# svcadm enable svc:/network/ipv4-forwarding root@solaris:~# svcadm enable svc:/network/loadbalancer/ilb:default
ILB supports 3 modes :
– Full NAT
– Half NAT
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.
NAT-based load balancing involves rewriting of IP header information,and handles both the request and the response traffic.
In 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.
In the half-NAT mode ILB rewrites only destination IP address.
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.
First of all I’ve configured server group, which will process http traffic :
root@solaris:~# ilbadm create-servergroup -s servers=192.168.57.102:80,192.168.57.103:80 websg root@solaris:~# ilbadm show-servergroup root@solaris:/tmp# ilbadm show-sg SGNAME SERVERID MINPORT MAXPORT IP_ADDRESS websg _websg.0 80 80 192.168.57.102 websg _websg.1 80 80 192.168.57.103
And then I’ve configured balance rule. First of all let’s try full NAT.
root@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 root@solaris:/tmp# ilbadm show-rule RULENAME STATUS LBALG TYPE PROTOCOL VIP PORT webrule E roundrobin NAT TCP 192.168.56.101 80
And that’s all!
I 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.
Let’s change ILB mode from full NAT to Half NAT.
ilbadm delete-rule -a ilbadm create-rule -e -i vip=192.168.56.101,port=80 -m lbalg=rr,type=h -o servergroup=websg webrule root@solaris:/tmp# ilbadm show-rule RULENAME STATUS LBALG TYPE PROTOCOL VIP PORT webrule E roundrobin HALF-NAT TCP 192.168.56.101 80
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
More details about the ILB can be read on wiki
I’m not really an expert in load balancers but ILB looks much more useful and functional than FreeBSD or Linux analogs.