Allocate an example shown above, each instance (assuming 400 users can be connected) corresponding to a java, and those four java is 4 to 1600. Examples of the user, compared to a single instance of a server, you can do so possible full use of hardware resources and reasonable application. If 20,000 concurrent users, then about 9 server requires at least before they can accommodate, five tomcat server, nginx two dispatcher server, database server 2.
A, Tomcat multi-row configuration of the solid
1, extract and deploy tomcat program
[root@localhost ~]# tar xf apache-tomcat-8.5.40.tar.gz
[root@localhost ~]# mv apache-tomcat-8.5.40 /usr/local/
2, create a working directory two instances
[root@localhost ~]# mkdir -p /usr/local/tomcat_instance/tomcat1
[root@localhost ~]# mkdir -p /usr/local/tomcat_instance/tomcat2
3, conf directory under the directory are copied into the program tomcat instance directory to 2
[root@localhost ~]# cp -R /usr/local/apache-tomcat-8.5.40/conf/ /usr/local/tomcat_instance/tomcat1/
[root@localhost ~]# cp -R /usr/local/apache-tomcat-8.5.40/conf/ /usr/local/tomcat_instance/tomcat2/
4. Create an instance of start and stop scripts in the bin directory under tomcat instance directory
[root@localhost ~]# mkdir /usr/local/tomcat_instance/tomcat1/bin
[root@localhost ~]# mkdir /usr/local/tomcat_instance/tomcat2/bin
[root@localhost ~]# touch /usr/local/tomcat_instance/tomcat2//bin/startup.sh
[root@localhost ~]# touch /usr/local/tomcat_instance/tomcat1//bin/startup.sh
5, to open the script permissions
[root@localhost ~]# chmod +x /usr/local/tomcat_instance/tomcat1/bin/startup.sh
[root@localhost ~]# chmod +x /usr/local/tomcat_instance/tomcat2/bin/startup.sh
6, the first instance of open script editor
[Root @ localhost ~] # the first instance of vim /usr/local/tomcat_instance/tomcat1/bin/startup.sh // open the script editor
#!/bin/bash
export CATALINA_HOME="/usr/local/apache-tomcat-8.5.40"
export CATALINA_BASE="/usr/local/tomcat_instance/tomcat1"
export CATALINA_TMPDIR="$CATALINA_BASE/temp"
export CATALINA_PID="$CATALINA_BASE/bin/tomcat.pid"
export JAVA_OPTS="-server -Xms1024m -Xmx1024m -Djava.awt.headless=true -Dtomcat.name=tomcat1"
#创建logs目录
if [ ! -d "$CATALINA_BASE/logs" ]; then
mkdir $CATALINA_BASE/logs
fi
# Create a temp directory
IF [-d "$ CATALINA_BASE / temp"!]; The then
mkdir $ CATALINA_BASE / temp
fi
# Call tomcat startup script
bash $ CATALINA_HOME / bin / startup.sh " $ @"
[root @ localhost ~] # cp /usr/local/tomcat_instance/tomcat1/bin/startup.sh /usr/local/tomcat_instance/tomcat2/bin/startup.sh // cp script to the second instance the following to
cp: if cover "/usr/local/tomcat_instance/tomcat2/bin/startup.sh"? y
7, edit the script to open a second instance
[Root @ localhost ~] # vim /usr/local/tomcat_instance/tomcat2/bin/startup.sh // second instance script editor
#!/bin/bash
export CATALINA_HOME="/usr/local/apache-tomcat-8.5.40"
export CATALINA_BASE="/usr/local/tomcat_instance/tomcat2"
export CATALINA_TMPDIR="$CATALINA_BASE/temp"
export CATALINA_PID="$CATALINA_BASE/bin/tomcat.pid"
export JAVA_OPTS="-server -Xms1024m -Xmx1024m -Djava.awt.headless=true -Dtomcat.name=tomcat2"
#创建logs目录
if [ ! -d "$CATALINA_BASE/logs" ]; then
mkdir $CATALINA_BASE/logs
fi
# Create a temp directory
IF [-d "$ CATALINA_BASE / temp"!]; The then
mkdir $ CATALINA_BASE / temp
fi
# Call tomcat startup script
bash $ CATALINA_HOME / bin / startup.sh " $ @"
8, first shut down the instance script editor
[Root @ localhost ~] # vim /usr/local/tomcat_instance/tomcat1/bin/shutdown.sh // write the first instance shutdown script
#!/bin/bash
export CATALINA_HOME="/usr/local/apache-tomcat-8.5.40"
export CATALINA_BASE="/usr/local/tomcat_instance/tomcat1"
export CATALINA_TMPDIR="$CATALINA_BASE/temp"
export CATALINA_PID="$CATALINA_BASE/bin/tomcat.pid"
export JAVA_OPTS="-server -Xms1024m -Xmx1024m -Djava.awt.headless=true -Dtomcat.name=tomcat1"
# Call tomcat startup script
bash $ CATALINA_HOME / bin / shutdown.sh " $ @"
9, the second shutdown script editor
[Root @ localhost ~] # vim /usr/local/tomcat_instance/tomcat2/bin/shutdown.sh write // second instance shutdown script
#!/bin/bash
export CATALINA_HOME="/usr/local/apache-tomcat-8.5.40"
export CATALINA_BASE="/usr/local/tomcat_instance/tomcat2"
export CATALINA_TMPDIR="$CATALINA_BASE/temp"
export CATALINA_PID="$CATALINA_BASE/bin/tomcat.pid"
export JAVA_OPTS="-server -Xms1024m -Xmx1024m -Djava.awt.headless=true -Dtomcat.name=tomcat2"
# Call tomcat startup script
bash $ CATALINA_HOME / bin / shutdown.sh " $ @"
10, to close the script permissions
[root @ localhost ~] # chmod + x /usr/local/tomcat_instance/tomcat1/bin/shutdown.sh // permission to close the script
[root @ localhost ~] # chmod + x / usr / local / tomcat_instance / tomcat2 / bin /shutdown.sh // permission to close the script
11, modify the main configuration file
Note; modify the port each instance server.xml tomcat in (respectively modified more than three ports (Server port, Connector port, AJP)), not to the port or other examples of systems already occupied port to send conflict).
[root @ localhost ~] # vim /usr/local/tomcat_instance/tomcat2/conf/server.xml // modify the above mentioned three red font port Note; not and port systems or other instances already occupied port to send conflict this is what I do to modify the experiment 8090 8010 8006
[root @ localhost ~] # more vim /usr/local/tomcat_instance/tomcat1/conf/server.xml // modify red lettering said three port Note: do not other send a port or port system instance of conflict it is already occupied this is my modification of doing experiments 880580808009
12, created a test page
[root@localhost ~]# mkdir -p /usr/local/tomcat_instance/tomcat1/webapps/ROOT
[root@localhost ~]# mkdir -p /usr/local/tomcat_instance/tomcat2/webapps/ROOT
[Root @ localhost ~] # vim /usr/local/tomcat_instance/tomcat1/webapps/ROOT/index.jsp // create the first test page
<html>
<title>Tomcat-1</title>
<body>
Hello This is Tomcat-1.
</body>
</html>
[Root @ localhost ~] # vim /usr/local/tomcat_instance/tomcat2/webapps/ROOT/index.jsp // create a second test page
<html>
<title>Tomcat-2</title>
<body>
Hello This is Tomcat-2.
</body>
</html>
13, start the instance script
[Root @ localhost ~] # /usr/local/tomcat_instance/tomcat1/bin/startup.sh // startup script example
[Root @ localhost ~] # /usr/local/tomcat_instance/tomcat2/bin/startup.sh // startup script example
14, if the two instances are listening ports open
[root@localhost ~]# netstat -lnpt |grep java
tcp6 0 0 :::8080 :::* LISTEN 10451/java
tcp6 0 0 :::8090 :::* LISTEN 10505/java
tcp6 0 0 127.0.0.1:8005 :::* LISTEN 10451/java
tcp6 0 0 127.0.0.1:8006 :::* LISTEN 10505/java
tcp6 0 0 :::8009 :::* LISTEN 10451/java
tcp6 0 0 :::8010 :::* LISTEN 10505/java
15, the next step is to test whether access to the content of the test page