All application server instances run on Payara 4.1.1.154 - two on CentOS 7 and one on Solaris5.10. Note that for correct cluster replication you need to have configured the multicast routing - or to have all instances on the same network ;)
1) You need to do this as root: # aka apache2 and modules in debian linuxes
yum install httpd
2) You need time synchronization - one minute error is fatal. You can select another server for time sychronization - check also if it is accessible from the server.yuminstallntp ntpdate
chkconfig ntpd onntpdate pool.ntp.org
3) Edit the httpd.conf file and add two lines (use correct hostname, valid from the outside world): vim/etc/httpd/conf/httpd.confServerName myhost.mydomain.orgLoadModule rewrite_module modules/mod_rewrite.so
4) Edit httpd configuration file and put the loadbalancer settings in it. vim/etc/httpd/conf.d/00-default.conf
- VirtualHost will run on port 80
- you need some time to hold the session on one instance, where the user logs in - in this time the new session will be replicated to other payara instances in cluster. If the next request would be faster, the session would be invalidated. This is the reason why you need also the ROUTEID cookie - the stickysession changes it's value because a new session is created.
- third internal host has status +H - that means "hot standby" - it will be routed only if other hosts would be inaccessible.
<VirtualHost *:80>ProxyRequests OffRewriteEngine OffHeader add Set-Cookie "ROUTEID=.%{BALANCER_WORKER_ROUTE}e; path=/; Max-Age=60;" env=BALANCER_ROUTE_CHANGEDServerName myhost.mydomain.orgLogLevel debugProxyPass /balancer-manager !ProxyPass / balancer://myhost.mydomain.org/ stickysession=ROUTEIDProxyPassReverse / http://myinternal1.mydomain:8300/ProxyPassReverse / http://myinternal2.mydomain:8300/ProxyPassReverse / http://myinternal3.mydomain:8300/ProxyPassReverseCookieDomainmyinternal1.mydomainmyhost.mydomain.orgProxyPassReverseCookieDomainmyinternal2.mydomainmyhost.mydomain.orgProxyPassReverseCookieDomainmyinternal3.mydomainmyhost.mydomain.orgProxyPassReverseCookiePath / /<Proxy balancer://cisas1.lab.i.cz>BalancerMember http://:8300 loadfactor=1 route=int1myinternal1.mydomainBalancerMember http://:8300 loadfactor=1 route=int2myinternal2.mydomainBalancerMember http://:8300 status=+H route=int3myinternal3.mydomainOrder Deny,AllowDeny from noneAllow from allProxySet stickysession=ROUTEIDProxySet lbmethod=bytraffic</Proxy></VirtualHost>
5) Allow the httpd service to access the outside world via TCP
- without that you will get only HTTP 503 and some message in error_log that the action was declined. /usr/sbin/setseboolhttpd_can_network_connect 1
6) Run the httpd service (and loadbalancing) and watch logs systemctl restart httpd.servicejournalctl -xntail-1000f/var/log/httpd/error_log
Žádné komentáře:
Okomentovat