Load Balancer mit mod jk (Linux): Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
(3 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) | |||
Zeile 60: | Zeile 60: | ||
Folgenden Inhalt einfügen: | Folgenden Inhalt einfügen: | ||
<pre> | <pre> | ||
# Define | # Define load balancer a 2 real workers using ajp13 | ||
worker.list=worker1 | worker.list=jkstatus,testServer,worker1,worker2 | ||
# Set properties for | |||
worker.jkstatus.type=status | |||
# ---------------------------------------------------------------------------- | |||
# Set properties for workers (ajp13) | |||
worker.worker1.type=ajp13 | worker.worker1.type=ajp13 | ||
worker.worker1.host=localhost | worker.worker1.host=localhost | ||
worker.worker1.port=8009 | worker.worker1.port=8009 | ||
worker.worker2.type=ajp13 | |||
worker.worker2.host=localhost | |||
worker.worker2.port=9009 | |||
# ---------------------------------------------------------------------------- | |||
# loadbalancer configuration | |||
worker.testServer.type=lb | |||
worker.testServer.balance_workers=worker1,worker2 | |||
worker.testServer.sticky_session=1 | |||
worker.testServer.retries=100 | |||
</pre> | </pre> | ||
Zeile 92: | Zeile 109: | ||
... | ... | ||
</VirtualHost> | </VirtualHost> | ||
</pre> | |||
=== Apache neustarten === | |||
<pre> | |||
sudo service apache2 restart | |||
</pre> | </pre> | ||
Aktuelle Version vom 22. Mai 2016, 10:06 Uhr
Noch in Bearbeitung
Installation
Java
Dazu siehe Java (Ubuntu)
Apache
Dazu siehe Apache (Linux)
Tomcat
Zu Installation siehe Tomcat (Linux)
mod_jk
sudo apt-get install libapache2-mod-jk sudo a2enmod jk
Konfiguration
Testdaten erstellen
cd /opt/tomcat/apache-tomcat-6.0.45/webapps/ sudo -u tomcat mkdir tomcat-demo sudo -u tomcat mkdir tomcat-demo/helloworld sudo -u tomcat nano tomcat-demo/helloworld/index.jsp
In index.jsp folgenden Code einfügen:
<HTML> <HEAD> <TITLE>Hello World</TITLE> </HEAD> <BODY> <H1>Hello World</H1> Today is: <%= new java.util.Date().toString() %> </BODY> </HTML>
Kurzer Funktionstest:
http://localhost:8080/tomcat-demo/helloworld/
Datei worker.properties erstellen
sudo nano /etc/apache2/workers.properties
Folgenden Inhalt einfügen:
# Define load balancer a 2 real workers using ajp13 worker.list=jkstatus,testServer,worker1,worker2 worker.jkstatus.type=status # ---------------------------------------------------------------------------- # Set properties for workers (ajp13) worker.worker1.type=ajp13 worker.worker1.host=localhost worker.worker1.port=8009 worker.worker2.type=ajp13 worker.worker2.host=localhost worker.worker2.port=9009 # ---------------------------------------------------------------------------- # loadbalancer configuration worker.testServer.type=lb worker.testServer.balance_workers=worker1,worker2 worker.testServer.sticky_session=1 worker.testServer.retries=100
Datei jk.conf ändern
sudo nano /etc/apache2/mods-available/jk.conf
In dieser Datei folgende Zeile ändern:
JkWorkersFile /etc/apache2/workers.properties
Datei 000-default ändern
sudo nano /etc/apache2/sites-available/000-default.conf
Folgende Zeile einfügen:
<VirtualHost *:80> ... JkMount /tomcat-demo* worker1 ... </VirtualHost>
Apache neustarten
sudo service apache2 restart
Finaler Funktionstest
http://localhost/tomcat-demo/helloworld/
Links
http://thetechnocratnotebook.blogspot.co.at/2012/05/installing-tomcat-7-and-apache2-with.html
Zurück zu Tomcat (Linux)