High availability
HA + Apache + mod_proxy jako loadbalancer
Procedura konfiguracyjna
- Ściągnij Apache z modułem mod_proxy http://www.jboss.org/mod_cluster/downloads
- Zainstaluj serwer Apache
sudo tar xvfz mod_cluster-1.2.6.Final-linux2-x64.tar.gz -C /
Dla ubuntu dodatkowo:
Usunąć bibliotekę /opt/jboss/httpd/lib/libapr1
sudo apt-get install libaprutil1 libaprutil1-dev libapr1 libapr1-dev
- Uruchom serwer Apache (przeglądarka powinna wyświetlić It's works!)
sudo /opt/jboss/httpd/sbin/apachectl start
- Ustaw nazwę dla każdego serwera - atrybut name na poziomie znacznkia server
- Uruchom instancje serwera WildFly w konfiguracji trybie ha lub full-ha.
- Prztestuj działanie load balancera http://localhost:6666/mod_cluster_manager
- Zmodyfikuj plik http.conf podając adres ip balancera oraz port
HA + WildFly jako loadbalancer
IMPORTANT: this config is not suitable for production use, as it only uses a single network interface for production use the socket bindings used by modcluster (management and advertise) should be only exposed to the internal network, not a public IP
Cleanup existing servers that are enabled by default
:stop-servers(blocking=true)
/host=master/server-config=server-one:remove
/host=master/server-config=server-two:remove
/host=master/server-config=server-three:remove
/server-group=main-server-group:remove
/server-group=other-server-group:remove
Add the IP address 192.168.1.4 to the host aliases (replace with your local IP)
/profile=ha/subsystem=undertow/server=default-server/host=default-host:write-attribute(name=alias, value=[192.168.1.4])
Set the mod_cluster security key
/profile=ha/subsystem=modcluster/mod-cluster-config=configuration:write-attribute(name=advertise-security-key, value=mypassword)
Add backend server group
/server-group=backend-servers:add(profile=ha, socket-binding-group=ha-sockets)
Add backend servers, using the ha profile so mod_cluster support is included
/host=master/server-config=backend1:add(group=backend-servers, socket-binding-port-offset=100)
/host=master/server-config=backend2:add(group=backend-servers, socket-binding-port-offset=200)
Start the backend servers
/server-group=backend-servers:start-servers
Add system properties (so we can tell them apart)
/host=master/server-config=backend1/system-property=server.name:add(boot-time=false, value=backend1)
/host=master/server-config=backend2/system-property=server.name:add(boot-time=false, value=backend2)
Deploy the demo to our backend servers
deploy ~/workspace/modcluster-example/load-balancing-demo/target/clustering-demo.war --server-groups=backend-servers
Now set up the default profile to include the mod_cluster load balancer
/profile=default/subsystem=undertow/configuration=filter/mod-cluster=modcluster:add(management-socket-binding=http, advertise-socket-binding=modcluster, security-key=mypassword)
/profile=default/subsystem=undertow/server=default-server/host=default-host/filter-ref=modcluster:add
/socket-binding-group=standard-sockets/socket-binding=modcluster:add(multicast-port=23364, multicast-address=224.0.1.105)
/server-group=load-balancer:add(profile=default, socket-binding-group=standard-sockets)
/host=master/server-config=load-balancer:add(group=load-balancer)
/server-group=load-balancer:start-servers
Now lets add another server
/host=master/server-config=backend3:add(group=backend-servers, socket-binding-port-offset=300)
:start-servers
/host=master/server-config=backend3/system-property=server.name:add(boot-time=false, value=backend3)
And remove one
/host=master/server=backend1:stop