Load Balancer mit mod jk (Linux): Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
(17 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) | |||
Zeile 7: | Zeile 7: | ||
Dazu siehe [[Java (Ubuntu)]] | Dazu siehe [[Java (Ubuntu)]] | ||
=== Apache === | |||
Dazu siehe [[Apache (Linux)]] | |||
=== Tomcat === | === Tomcat === | ||
Zu Installation siehe [[Tomcat (Linux)]] | |||
=== mod_jk === | === mod_jk === | ||
Zeile 16: | Zeile 21: | ||
sudo apt-get install libapache2-mod-jk | sudo apt-get install libapache2-mod-jk | ||
sudo a2enmod jk | sudo a2enmod jk | ||
</pre> | |||
== Konfiguration == | |||
=== Testdaten erstellen === | |||
<pre> | |||
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 | |||
</pre> | |||
In ''index.jsp'' folgenden Code einfügen: | |||
<pre> | |||
<HTML> | |||
<HEAD> | |||
<TITLE>Hello World</TITLE> | |||
</HEAD> | |||
<BODY> | |||
<H1>Hello World</H1> | |||
Today is: <%= new java.util.Date().toString() %> | |||
</BODY> | |||
</HTML> | |||
</pre> | |||
Kurzer Funktionstest: | |||
<pre> | |||
http://localhost:8080/tomcat-demo/helloworld/ | |||
</pre> | |||
=== Datei ''worker.properties'' erstellen === | |||
<pre> | |||
sudo nano /etc/apache2/workers.properties | |||
</pre> | |||
Folgenden Inhalt einfügen: | |||
<pre> | |||
# 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 | |||
</pre> | |||
=== Datei ''jk.conf'' ändern === | |||
<pre> | |||
sudo nano /etc/apache2/mods-available/jk.conf | |||
</pre> | |||
In dieser Datei folgende Zeile ändern: | |||
<pre> | |||
JkWorkersFile /etc/apache2/workers.properties | |||
</pre> | |||
=== Datei ''000-default'' ändern === | |||
<pre> | |||
sudo nano /etc/apache2/sites-available/000-default.conf | |||
</pre> | |||
Folgende Zeile einfügen: | |||
<pre> | |||
<VirtualHost *:80> | |||
... | |||
JkMount /tomcat-demo* worker1 | |||
... | |||
</VirtualHost> | |||
</pre> | |||
=== Apache neustarten === | |||
<pre> | |||
sudo service apache2 restart | |||
</pre> | |||
=== Finaler Funktionstest === | |||
<pre> | |||
http://localhost/tomcat-demo/helloworld/ | |||
</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)