EduArn is your learning hub for AI, Cloud Computing, and DevOps tools and technologies. Explore detailed guides, practical examples, and real-world use cases of artificial intelligence platforms, cloud services, automation tools, CI/CD pipelines, containers, Kubernetes, infrastructure as code, and modern IT solutions. Learn how emerging technologies are transforming software development, deployment, and business operations while building your technical skills for the future.
<?xml version='1.0' encoding='utf-8'?> <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <tomcat-users> <!-- NOTE: By default, no user is included in the "manager-gui" role required to operate the "/manager/html" web application. If you wish to use this app, you must define such a user - the username and password are arbitrary. --> <!-- NOTE: The sample user and role entries below are wrapped in a comment and thus are ignored when reading this file. Do not forget to remove <!.. ..> that surrounds them. --> <role rolename="tomcat"/> <role rolename="role1"/> <user username="tomcat" password="tomcat" roles="tomcat"/> <user username="both" password="tomcat" roles="tomcat,role1"/> <user username="role1" password="tomcat" roles="role1"/> <role rolename="admin"/> <role rolename="admin-gui"/> <role rolename="admin-script"/> <role rolename="manager"/> <role rolename="manager-gui"/> <role rolename="manager-script"/> <role rolename="manager-jmx"/> <role rolename="manager-status"/> <user name="admin" password="adminadmin" roles="admin,manager,admin-gui,admin-script,manager-gui,manager-script,manager-jmx,manager-status" /> </tomcat-users>
4. Start tomcat /etc/init.d/tomcat start 5. Access the Web Interface http://server_IP_address:8080 or http://127.0.0.1:8080
Follow the following steps: 1. Installed the Apache httpd in Apache server. 2. Install the java or upgrade 3. Install the tomcat in web server. 4. Access the virtual host from client with domain name.
In more details: 1. Installed the Apache httpd in Apache server. Logging into the Apache server with root user Note: I'm using the,Red Hat Enterprise Linux # yum install httpd To start/stop/restart the Apache/httpd, run: # chkconfig httpd on # /etc/init.d/httpd start/stop/restart
Edit the Apache conf file, httpd.conf located under /etc/httpd/conf/httpd.conf #vi /etc/httpd/conf/httpd.conf
Save it and close it. Restart the Apache server: /etc/init.d/httpd restart Note: # indicate i have logging with root user.
2. Install the java or upgrade Refer the java installation.
3. Install the tomcat in web server. Refer the tomcat install in Unix.
Assuming tomcat have installed in both web server and configure with AJP port Web Server 1 (tomcat with AJP port 20010) Web Server 2 (tomcat with AJP port 20020)
In this tutorial, we'll discuses about (Apache Server) load balancer, hardware & software.
Let's discussed about software load balancer:
First of all we need to understand the need of load balancer, as in web application, we can used either, web server or application server for deploying the our app. Ensuring our application are working with n-number of users load without failure. That will be done with help of Load balance. See the image below for high level flow:
The client opens a connection to the system such as http://localhost:80/myapp thus creating a web request.
The load balancer dispatches the web request onto one of the nodes, depending on the load balancing strategy.
The transparent HTTP session failover makes sure that the sessions are replicated across the cluster. Session replication is indicated by dotted blue both side arrow in the figure.
Where as app/web server are configure in Node 1 as http://localhost:9001, Node 2 as http://localhost:9002 and Node 3 as http://localhost:9003. All app/web server are connecting with Database (DB).
Note: port 9001, 9002 and 9003 are for app/web server port where our myapp deployed.
Need to deploy the three tomcate instance in same machine or different, I did that in same machine with as suggested port.
Assuming jdk have been installed and JAVA_HOME set.
We can set up our system to use either sticky sessions or non-sticky sessions.
Sticky Sessions Here, all web requests of one HTTP session are served from the same cluster node. If a request of a HTTP session was first dispatched to Node 1 such as http://localhost:9001, all subsequent requests will be dispatched to Node 1, such as http://localhost:9001.
Non-Sticky Sessions Here, web requests are dispatched to random nodes across the cluster, depending on the load balancing strategy. If a request of a HTTP session was first dispatched to Node 1 such as http://localhost:9001, subsequent requests might be dispatched to any nodes, such as http://localhost:9002 or http://localhost:9003.
Without a session replication mechanism, we need to use sticky sessions: on a non-sticky session system, every individual node which has processed the session once will have an individual copy of the session. Take a session cart, for example: on a non-sticky session system, each time the session is processed by a different node, that node holds a representation of the cart at the time.
Transparent HTTP Session details:
This is the single time configuration, As soon as the infrastructure for load balancing and transparent HTTP session is set up, we can use the infrastructure for any number of app.
Configure a load balancer.
Typically, in production environments, a hardware load balancer is used. However, for testing or development in project use, for example, a hardware load balancer might be too expensive or not be available. Instead of a hardware load balancer, we can use software load balancers, such as:
•Apache http Server.
How To Use Apache HTTP Server as Load Balancer
Apache Server is open sour http server and is available for many common operating systems. The Apache HTTP Server can be extended in functionality by integrating modules.
How to Use Apache HTTP Server as a Load Balancer:
Adding the additional functionality by using modules (also called "mods")
mod_proxy_balancer Required. Provides load balancing functionality. For details, see the Apache website: http://httpd.apache.org/.
mod_headers Optional. Required for sticky sessions. For details, see the Apache website: http://httpd.apache.org/. How to enable the mods in Appache server ${APACHE_INSTALL}/conf/httpd.conf file and uncomment/add the lines that reference mods. For example, from
Order Deny,Allow Deny from all Allow from all </Location>
Load balancer port is set to 80 and application is visible as http://localhost:80/myapp
Note: If Node 1 will down, it will redirect to next available Node 2 or Node 3. If Node 2 is down then it will redirect to Node 1 or Node 3. If Node 3 is down then it will redirect to Node 1 or Node 2.
Ref: http://www.apache.org/
/etc/httpd/conf/httpd.conf
################################################################ ### Non Stickey Session ################################################################
Tomcat Default examples refer for this located under, if you want to deploy make sure deploy the same war/ear file in all nodes/tomcat instance: /tomcat9001/apache-tomcat-6.0.43/webapps/examples /tomcat9001/apache-tomcat-6.0.43/webapps/examples