Building a Java compilation environment
First, the Java compilation environment
1. Preparatory work:
Download jdk-7u79-linux-x64.tar.gz Compression Pack
Unzip the tar zxf jdk-7u79-linux-x64.tar.gz-c/usr/local/
Under/usr/local/ln-s Jdk1.7.0_79/java (easy to update the software, as long as the soft link after the update is good)
2. Modifying environment variables
Vim/etc/profile
650) this.width=650; "Style=" background-image:none; border-right-0px; margin:0px; padding-left:0px; padding-right:0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px; padding-top:0px "title=" clip_image002 "border=" 0 "alt=" clip_image002 "src=" http://s3.51cto.com/wyfs02/M02/88/22/ Wkiol1fqaairf6vyaaamcj00v08038.gif "width=" 522 "height="/>
Source/etc/profile (Refresh file)
echo $PATH View Environment variables
[Email protected] java]# echo $JAVA _home
/usr/local/java
[Email protected] java]# echo $CLASSPATH
.:/ Usr/local/java/lib:/usr/local/java/jre/lib
[Email protected] java]# echo $PATH
/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/java/ Bin
3. Testing
Write a Java program:
Vim Test.java
650) this.width=650; "Style=" background-image:none; border-right-0px; margin:0px; padding-left:0px; padding-right:0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px; padding-top:0px "title=" clip_image004 "border=" 0 "alt=" clip_image004 "src=" http://s3.51cto.com/wyfs02/M01/88/22/ Wkiol1fqaajbitrhaaayrcjgj6y220.gif "width=" 418 "height=" 148 "/>
Javac Test.java (Compile build. class file)
Java test
[Email protected] ~]# Javac Test.java
[[email protected] ~]# ls
Anaconda-ks.cfg jdk-7u79-linux-x64.tar.gz
Apache-tomcat-7.0.37.tar.gz Test.class
Install.log Test.java
Install.log.syslog
[[Email protected] ~]# java test
Hello world!
650) this.width=650; "Style=" background-image:none; border-right-0px; margin:0px; padding-left:0px; padding-right:0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px; padding-top:0px "title=" clip_image006 "border=" 0 "alt=" clip_image006 "src=" http://s3.51cto.com/wyfs02/M02/88/22/ Wkiol1fqaamwubviaaauaslcm0e013.gif "width=" 377 "height="/>
Second, the installation of JSP support
1. Preparatory work
Download jdk-7u79-linux-x64.tar.gz
Unzip the tar zxf jdk-7u79-linux-x64.tar.gz-c/usr/local/
Ln-s Apache-tomcat-7.0.37/tomcat under/usr/local/(soft link to Tomcat)
2. Use
Default Publish directory:/usr/local/tomcat/webapps/root
Turn on JSP: Execute under/usr/local/tomcat/bin./startup.sh
View the listener port for the JSP: NETSTAT-ANTLP is port 8080.
3. Testing
Access 172.25.15.1:8080 to the Tomcat default publishing page in Firefox
Write your own Tomcat publishing page:
Write a file under/usr/local/tomcat/webapps/root test.jsp
650) this.width=650; "Style=" background-image:none; border-right-0px; margin:0px; padding-left:0px; padding-right:0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px; padding-top:0px "title=" clip_image008 "border=" 0 "alt=" clip_image008 "src=" http://s3.51cto.com/wyfs02/M00/88/22/ Wkiol1fqaanyxcmoaaasu3fsydy079.gif "width=" 536 "height="/>
Access 172.25.38.6:8080/test.jsp in Firefox
4. Configure Nginx to process PHP JSP dynamic page separately
Visit 172.25.15.1/test.jsp to access JSP pages
Vim/usr/local/lnmp/nginx/conf/nginx.conf
650) this.width=650; "Style=" background-image:none; border-right-0px; margin:0px; padding-left:0px; padding-right:0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px; padding-top:0px "title=" clip_image010 "border=" 0 "alt=" clip_image010 "src=" http://s3.51cto.com/wyfs02/M01/88/26/ Wkiom1fqaargybuuaaavcpoy2zu260.gif "width=" 558 "height=" 121 "/>
The request to access the. jsp file is given to Tomcat for processing
5. Deploying the Tomcat Cluster
Configuring a Java JSP on another virtual machine is the same as the first one
Can direct CP the first/usr/local/java Tomcat to the same location in the second station
The environment variable for the second virtual machine also needs to be changed to open Tomcat.
Environment Description: Server1:nginx Tomcat
: Server2:tomcat (two hosts Tomcat doing load balancing)
Modify Nginx configuration file:/usr/local/lnmp/nginx/conf/nginx.conf
650) this.width=650; "Style=" background-image:none; border-right-0px; margin:0px; padding-left:0px; padding-right:0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px; padding-top:0px "title=" clip_image012 "border=" 0 "alt=" clip_image012 "src=" http://s3.51cto.com/wyfs02/M00/88/22/ Wkiol1fqaardti99aaavbcvjvko224.gif "width=" 557 "height=" "/>"
650) this.width=650; "Style=" background-image:none; border-right-0px; margin:0px; padding-left:0px; padding-right:0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px; padding-top:0px "title=" clip_image014 "border=" 0 "alt=" clip_image014 "src=" http://s3.51cto.com/wyfs02/M02/88/23/ Wkiol1fqaartjiidaaaw-bjc7ws218.gif "width=" 557 "height=" 121 "/> Explanation: Access load Balancing group when accessing. JSP Yang points to upstream Yang;
650) this.width=650; "Style=" background-image:none; border-right-0px; margin:0px; padding-left:0px; padding-right:0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px; padding-top:0px "title=" clip_image015 "border=" 0 "alt=" clip_image015 "src=" http://s3.51cto.com/wyfs02/M00/88/23/ Wkiol1fqaavq1e45aaacm19t-jm827.gif "width=" "height="/>server1.server2; round Patrol.
JSP JSP
650) this.width=650; "Style=" background-image:none; border-right-0px; margin:0px; padding-left:0px; padding-right:0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px; padding-top:0px "title=" clip_image016 "border=" 0 "alt=" clip_image016 "src=" http://s3.51cto.com/wyfs02/M01/88/23/ Wkiol1fqaavqtedhaaabnhm1vjq524.gif "width=" 289 "height=" "/>650" this.width=650; "style=" Background-image:none ; border-right-0px; margin:0px; padding-left:0px; padding-right:0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px; padding-top:0px "title=" clip_image017 "border=" 0 "alt=" clip_image017 "src=" http://s3.51cto.com/wyfs02/M02/88/23/ Wkiol1fqaayab8h6aaabcqvm5fy487.gif "width=" 289 "height="/> T1 T2
M1 M2
Nginx accesses two processing servers via JSP and simultaneously backs up data to M1 m2. (data is not lost)
If there is no backend memcached the data in the T1 will be lost when T1 hangs off and switches to T2
Install memcached/etc/init.d/memcached start on two virtual machines
FREE-M Viewing memory information
650) this.width=650; "Style=" background-image:none; border-right-0px; margin:0px; padding-left:0px; padding-right:0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px; padding-top:0px "title=" clip_image019 "border=" 0 "alt=" clip_image019 "src=" http://s3.51cto.com/wyfs02/M00/88/26/ Wkiom1fqaayzjss2aaazpsfckns098.gif "width=" 557 "height="/>
Interview ask the current available memory space to see the use of the application mechanism, the cache plus buffers plus free memory, cached will involve application occupancy, if it is a sharing mechanism, you can add the cache if the app is exclusive, not add.
View memcached Yum Install Telnet-y
Telnet localhost 11211 (memcached default on port 11211)
Stats
Add Name 0 0 6 (0 mark bit 0 Timeout time 6 name bytes)
Get Name
Delete Name
Write a file under/usr/local/tomcat/webapps/root test.jsp
(Two virtual machines are configured)
<%@ page contenttype= "text/html; CHARSET=GBK "%>
<%@ page import= "java.util.*"%>
<body>
Server Info:
<%
Out.println (REQUEST.GETLOCALADDR () + ":" + request.getlocalport () + "<br>");%>
<%
Out.println ("<br> ID" + session.getid () + "<br>");
String dataname = Request.getparameter ("Dataname");
if (dataname! = null && dataname.length () > 0) {
String DataValue = Request.getparameter ("DataValue");
Session.setattribute (Dataname, DataValue);
}
Out.print ("<b>session list</b>");
Enumeration E = Session.getattributenames ();
while (E.hasmoreelements ()) {
String name = (string) e.nextelement ();
String value = Session.getattribute (name). toString ();
OUT.PRINTLN (name + "=" + value+ "<br>");
SYSTEM.OUT.PRINTLN (name + "=" + value);
}
%>
<form action= "test.jsp" method= "POST" >
Name:<input type=text size=20 name= "Dataname" >
<br>
Key:<input type=text size=20 name= "DataValue" >
<br>
<input type=submit>
</form>
</body>
Nginx Load in 6.sticky mode
Ip_hash will involve CDN issues, because multiple clients access the same CDN but Nginx receives the same CDN IP, so at this time the Ip_hash unreasonable
So use sticky
Preparatory work:
Download nginx-goodies-nginx-sticky-module-ng-c78b7dd79d0d.tar.gz
Unzip to/root/
Use the source to reinstall Nginx needs to switch off Nginx./configure when adding
650) this.width=650; "Style=" background-image:none; border-right-0px; margin:0px; padding-left:0px; padding-right:0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px; padding-top:0px "title=" clip_image021 "border=" 0 "alt=" clip_image021 "src=" http://s3.51cto.com/wyfs02/M00/88/26/ Wkiom1fqaa7i47phaaadpqrzdco787.gif "width=" 557 "height="/>
Make & make Install
The algorithm for modifying load balancing is sticky. Open Nginx
Turn off Tomcat for both virtual machines.
Two virtual machines: Copy the pre-downloaded jar package to Tomcat/lib
Remove Memcached-session-manager-tc6-1.5.1.jar (if you're using 7)
Modify Tomcat/conf/context.xml (172.25.15.5)
At the end add
<manager classname= "De.javakaffee.web.msm.MemcachedBackupSessionManager"
Memcachednodes= "n1:172.25.38.5:11211,n2:172.38.6.2:11211"
failovernodes= "N1"
Requesturiignorepattern= ". *\. (ICO|PNG|GIF|JPG|CSS|JS) $ "
Transcoderfactoryclass= "De.javakaffee.web.msm.serializer.kryo.KryoTranscoderFactory"
/>
Modify Tomcat/conf/context.xml (172.25.15.6)
At the end add
<manager classname= "De.javakaffee.web.msm.MemcachedBackupSessionManager"
Memcachednodes= "n1:172.25.38.5:11211,n2:172.25.38.6:11211"
Failovernodes= "N2"
Requesturiignorepattern= ". *\. (ICO|PNG|GIF|JPG|CSS|JS) $ "
Transcoderfactoryclass= "De.javakaffee.web.msm.serializer.kryo.KryoTranscoderFactory"
/>
Open tomcat on both sides
Tail-f Tomcat/logs/catalina.out
650) this.width=650; "Style=" background-image:none; border-right-0px; padding-left:0px; padding-right:0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px; padding-top:0px "title=" clip_image023 "border=" 0 "alt=" clip_image023 "src=" http://s3.51cto.com/wyfs02/M01/88/26/ Wkiom1fqaa7bswwvaaarhe9ljr0681.gif "width=" 557 "height="/>
That's the right thing to say.
Test: Firefox access 172.25.38.6 input data, turn off the running
Building a Java compilation environment