LinuxTomcat cluster uses Note 1 to set up javaWeb running status

Source: Internet
Author: User
Some time ago I have been engaged in linux, and many tools have never been done before. The image is not so profound. At this moment, we will record the history for future questioning. I: Let's talk about our plan. There are a total of six server servers. The two servers are placed in Oracle10g for database clusters (this is not within the scope of this article), and the other four are Application Server servers. First, four servers will be installed with the linux operating system. The version I used is RedHatEnterpriseLinux5. After installation, all the servers will go to ssh. Any one has a performance

Some time ago I have been engaged in linux, and many tools have never been done before. The image is not so profound. At this moment, we will record the history for future questioning.

I: Let's talk about our plan. There are a total of six server servers. The two servers have 10 Gb Oracle Database Cluster (this is not within the scope of this article), and the other four are Application Server servers. First, place the linux operating system on four servers. The version I use is RedHat Enterprise Linux 5. After installation, enable the ssh service in full. Find any mechanical device with a performer and use things to connect to four servers through ssh.

2: First Place jdk, go to the home page of sun http://java.sun.com/j2se/1.5.0/download.jsp download jdk placement file jdk-1_5_0_05-linux-i586.bin

First use chmod 755 entrusted with permissions, and then enter the jdk-1_5_0_05-linux-i586.bin File Location Directory under the shell terminal, the implementation of the number order. /jdk-1_5_0_05-linux-i586.bin at this time will present a peace talk, continue to press the carriage return, when asked whether the approval of the hour, enter yes, press Enter. After the current directory will be born with a jdk-1.5.0_05 directory, you can copy it to any directory.

Sample Code:

Chomod 755 jdk-1_5_0_05-linux-i586.bin

Cd/home/java

/Jdk-1_5_0_05-linux-i586.bin

Three methods are available to set the configuration variables.

1. Click the/etc/profile file

If your computer is used only in this way, because the shell of all users has the right to use these variables, it will probably bring security issues to the system.

· Use the text editor to open/etc/profile
· Intervene at the end of the profile file:

JAVA_HOME =/usr // jdk1.5.0 _ 05
PATH = $ JAVA_HOME/bin: $ PATH
CLASSPATH =.: $ JAVA_HOME/lib/dt. jar: $ JAVA_HOME/lib/tools. jar
JRE_HOME =/usr/share/jdk1.5.0 _ 05/jre
Export JAVA_HOME
Export PATH
Export CLASSPATH
Export JRE_HOME

· Restart the system to make the configuration take effect
· Indicates
A. Change/usr/share/jdk1.5.0 _ 05jdk to your jdk placement directory.
B. Use the colon ":" in linux to separate paths.
C. $ PATH/$ CLASSPATH/$ JAVA_HOME is used to reference the original variable value.
When setting variables, pay attention to the fact that the original value cannot be overwritten. This is
Common errors.
D. The current directory "." In CLASSPATH cannot be lost. It is also a common error to discard the current directory.
E. export exports the three variables as global variables.
F. Make a harsh distinction between large and small write statements.

2. Click the. bashrc file.
    
This method is more secure. It can control the permissions of variables used in these situations to the user level. If you need to grant a user permission to use these variables, you only need to click under the main contents of your personal user. you can use the bashrc file.

· Use the text editor to open the. bashrc file under the user's directory
· Intervene at the end of the. bashrc file:
      
Set JAVA_HOME =/usr/jdk1.5.0 _ 05
Export JAVA_HOME
Set PATH = $ JAVA_HOME/bin: $ PATH
Export PATH
Set CLASSPATH =.: $ JAVA_HOME/lib/dt. jar: $ JAVA_HOME/lib/tools. jar
Export CLASSPATH

· Log on from scratch

3. directly set variables in shell

I don't agree to use this method. because of changing the shell, your settings will be invalid. In this way, you just need to use it. In the future, you need to set it from the beginning to make use of it.

You only need to make the following orders on the shell terminal:

Export JAVA_HOME =/usr/jdk1.5.0 _ 05
Export PATH = $ JAVA_HOME/bin: $ PATH
Export CLASSPATH =.: $ JAVA_HOME/lib/dt. jar: $ JAVA_HOME/lib/tools. jar

Test jdk

Execute the command "java-version" on the terminal. If jdk version is jdk1.6.0 _ 01, it indicates that jdk has been successfully placed.

Uninstall jdk

· Find the _ uninst subitem In the jdk placement directory
· Run the command./uninstall. sh on the shell terminal to uninstall jdk.


3. Place tomcat. The tomcat version I use is 6.0. For the purpose of testing and training, I have placed three tomcat servers for each server.

 

1. Download apache-tomcat-6.0.10.tar.gz

2) # tar-zxvf apache-tomcat-6.0.10.tar.gz; // Extract

3) # cp-R apache-tomcat-6.0.10/home/java/tomcat; // copy apache-tomcat-6.0.10 to/home/java/and rename it tomcat

4) # cp./tomcat./tomcat2 // copy two tomcat servers

5) # cp./tomcat./tomcat3

6) in turn, click the three server. xml configuration files, and pay attention to the terminal slogans cannot be repeated:

Port: 8005-> 8015

8010

MaxThreads = "150" minSpareThreads = "25" maxSpareThreads = "75"

EnableLookups = "false" redirectPort = "8443" acceptCount = "100"

ConnectionTimeout = "20000" disableUploadTimeout = "true"/>

8019

EnableLookups = "false" redirectPort = "8443" protocol = "AJP/1.3"/>


Use the text editor to open/etc/profile
Intervene at the end of the profile file

CATALINA_1_BASE =/home/java/tomcat
CATALINA_1_HOME =/home/java/tomcat
TOMCAT_1_HOME =/home/java/tomcat
Export CATALINA_1_BASE
Export catalina_{home
Export TOMCAT_1_HOME

CATALINA_2_BASE =/home/java/tomcat2
CATALINA_2_HOME =/home/java/tomcat2
TOMCAT_2_HOME =/home/java/tomcat2
Export CATALINA_2_BASE
Export CATALINA_2_HOME
Export TOMCAT_2_HOME

CATALINA_3_BASE =/home/java/tomcat3
CATALINA_3_HOME =/home/java/tomcat3
TOMCAT_3_HOME =/home/java/tomcat3
Export CATALINA_1_BASE
Export catalina_{home
Export TOMCAT_1_HOME

7)/home/java/tomcat/bin/startup. sh; // start each tomcat

Using CATALINA_BASE:/java/home/tomcat

Using CATALINA_HOME:/java/home/tomcat

Using CATALINA_TEMDIR:/java/home/tomcat/temp

Using JAVA_HOME: =/usr/share/jdk1.5.0 _ 05

By now, tomcat has been placed. At this moment, you can use the viewer to greet http: // localhost: 8080 to present the default tomcat page and declare that it has been placed.

4. configure Server Load balancer and Server clusters. You can choose from apache and nginx, which are commonly used.


Download the latest source code package at http://www.nginx.net.

Unzip: tar zxvf nginx-0.5.33.tar.gz
Next:./configure
Next, make // compile the necessary c statement here.
End: make install
Okay. The placement is complete.

The default placement path is
/Usr/local/nginx

Click to set the device decoration File
/Usr/local/nginx/conf/nginx. conf
Click the following content

# User nobody;
Worker_processes 9;

# Error_log logs/error. log;
# Error_log logs/error. log notice;
# Error_log logs/error. log info;

# Pid logs logging. pid;

Events {
Worker_connections 1024;
}

Http {
Include mime. types;
Default_type application/octet-stream;

Sendfile on;

Upstream trxsys {
Server 192.168.16.171: 8010; # The place where the traffic is redirected (the forwarding location)
Server 192.168.16.171: 9020;
}

Server {
Listen 80;
Server_name localhost;
Error_page 500 502 503 x.html;
Location =/50x.html {
Root html;
}

Location /{
Proxy_pass http: // trxsys)
Proxy_redirect off;
Proxy_set_header Host $ host;
Proxy_set_header X-Real-IP $ remote_addr;
Proxy_set_header X-Forwarded-For $ proxy_add_x_forwarded_for;
Client_max_body_size 10 m;
Client_body_buffer_size 128 k;
Proxy_connect_timeout 90;
Proxy_send_timeout 90;
Proxy_read_timeout 90;
Proxy_buffer_size 4 k;
Proxy_buffers 4 32 k;
Proxy_busy_buffers_size 64 k;
Proxy_temp_file_write_size 64 k;
}
}
}

Start nginx
/Usr/local/nginx/sbin/nginx

Closed: killall-r nginx

Test the configuration file nginx-t.

After placement, You need to include the 80-side slogans in the linux Firewall Trust List.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.