Tomcat cluster in CentOS 6.6

Source: Internet
Author: User
Tags ssl connection

Tomcat cluster in CentOS 6.6

Installation environment: CentOS 6.6 (64-bit System)

  1. Install Tomcat site
  1. Install and configure JDK
    1. Uninstall the built-in JDK version before installation

-- View and uninstall the version with JDK installed

[Xju @ xjuCentOS desktop] $ su root

Password:

[Root @ xjuCentOS desktop] # rpm-qa | grep jdk

Java-1.7.0-openjdk-1.7.0.9-2.3.4.1.el6_3.i686

Java-1.6.0-openjdk-1.6.0.0-1.50.1.11.5.el6_3.i686

[Root @ xjuCentOS desktop] # rpm-e-nodeps java-1.6.0-openjdk-1.6.0.0-1.50.1.11.5.el6_3.i686

[Root @ xjuCentOS desktop] # rpm-e-nodeps java-1.7.0-openjdk-1.7.0.9-2.3.4.1.el6_3.i686

  1. Install JDK

# Chmod 777 jdk-7u79-linux-i586.rpm

# Rpm-ivh jdk-7u79-linux-i586.rpm

  1. Configure Environment Variables

-- Configure java environment variables

-- Modify the/etc/profile file and global variables, which may cause security problems to the system. bash_profile file. This method is more secure. It can control the permissions to use these environment variables to the user level. If you need to grant a user permission to use these environment variables, you only need to modify. you can use the bash_profile file.

-- Backup the configuration file

# Cp/etc/profile. bak

-- Edit the configuration file (Add the following content at the end)

# Vi/etc/profile

# Set Java Environment

Export JAVA_HOME =/usr/java/jdk1.7.0 _ 79

Export PATH = $ PATH: $ JAVA_HOME/bin

-- Reload the configuration file

# Source/etc/profile

Or:

# Vi/etc/profile. d/java. sh

Export JAVA_HOME =/usr/java/jdk1.7.0 _ 79

Export PATH = $ PATH: $ JAVA_HOME/bin

-- View the installed jdk version

# Java-version

# Javac-version

  1. Test jdk

-- Create a Test. java file in the text editor, enter the following code and save the file:

Public class Test {

Public static void main (String args []) {

System. out. println ("Hello, Java! ");

}

}

-- Compile

# Javac Test. java

-- Run

# Java Test

  1. Install and configure Tomcat
    1. Install two Tomcat servers

# Tar-zxvf apache-tomcat-7.0.62.tar.gz

# Cp-rf apache-tomcat-7.0.62/usr/local/tomcat1

# Mv apache-tomcat-7.0.62/usr/local/tomcat2

# Chown-R xju: xju/usr/local/tomcat1

# Chown-R xju: xju/usr/local/tomcat2

  1. Modify the port numbers of two tomcat servers

(1) modify the tomcat1 port number

$ Cd/usr/local/tomcat1/conf/

$ Cp server. xml server. xml. bak

$ Cp web. xml web. xml. bak

$ Vi server. xml

<Server port = "8005" shutdown = "SHUTDOWN">

<Connector port = "8080" protocol = "HTTP/1.1"

ConnectionTimeout = "20000"

RedirectPort = "8443"

URIEncoding = "UTF-8"/>

<Connector port = "8009" protocol = "AJP/1.3" redirectPort = "8443"/>

<Engine name = "Catalina" defaultHost = "localhost" jvmRoute = "tomcat1">

(2) modify the tomcat2 port number

$ Cd/usr/local/tomcat2/conf/

$ Cp server. xml server. xml. bak

$ Cp web. xml web. xml. bak

$ Vi server. xml

<Server port = "8006" shutdown = "SHUTDOWN">

<Connector port = "8081" protocol = "HTTP/1.1"

ConnectionTimeout = "20000"

RedirectPort = "8443"

URIEncoding = "UTF-8"/>

<Connector port = "8010" protocol = "AJP/1.3" redirectPort = "8443"/>

<Engine name = "Catalina" defaultHost = "localhost" jvmRoute = "tomcat2">

Tomcat default port remarks:

8005: indicates the port used to stop Tomcat

8080: indicates the HTTP connection Port

8009: indicates the listening port of Apache.

8443: indicates the SSL connection port.

  1. Start Tomcat

-- Start tomcat1

# Cd/usr/local/tomcat1/bin

#./Startup. sh -- start

#./Shutdown. sh -- close

Using CATALINA_BASE:/usr/local/tomcat1

Using CATALINA_HOME:/usr/local/tomcat1

Using CATALINA_TMPDIR:/usr/local/tomcat1/temp

Using JRE_HOME:/usr/java/jdk1.7.0 _ 79/jre/

Using CLASSPATH:/usr/local/export AT1/bin/bootstrap. jar:/usr/local/export AT1/bin/tomcat-juli.jar

Tomcat started.

  1. Add Tomcat boot auto start

(1) set tomcat1 to start automatically

Copy the/usr/local/tomcat1/bin/catalina. sh file to the/etc/init. d directory and change it to tomcat1.

# Cp/usr/local/tomcat1/bin/catalina. sh/etc/init. d/tomcat1

Modify the/etc/init. d/tomcat1 file and add the red part to the file:

# Vi/etc/init. d/tomcat1

Enter the following content in the first line (otherwise, an error occurs: tomcat does not support chkconfig ):

#! /Bin/sh

# Chkconfig: 2345 10 90

# Description: extends AT1 service

# Licensed to the Apache Software Foundation (ASF) under one or more

# Contributor license agreements. See the NOTICE file distributed

........................................ .............................

# $ Id: catalina. sh 1498485 2013-07-01 14: 37: 43Z markt $

#-----------------------------------------------------------------------------

CATALINA_HOME =/usr/local/tomcat1

JAVA_HOME =/usr/java/jdk1.7.0 _ 79

# OS specific support. $ var _ must _ be set to either true or false.

-- Add tomcat service:

# Chkconfig -- add partition at1

-- Set tomcat to auto-start upon startup:

# Chkconfig extends AT1 on

-- Disable and start the tomcat service. The generated tomcat does not have the restart command:

# Service implements AT1 stop

# Service extends AT1 start

(2) Set tomcat1 to start automatically

Copy the/usr/local/tomcat2/bin/catalina. sh file to the/etc/init. d directory and change it to tomcat2.

# Cp/usr/local/tomcat2/bin/catalina. sh/etc/init. d/tomcat2

Modify the/etc/init. d/tomcat2 file and add the red part to the file:

# Vi/etc/init. d/tomcat2

Enter the following content in the first line (otherwise, an error occurs: tomcat does not support chkconfig ):

#! /Bin/sh

# Chkconfig: 2345 10 90

# Description: Tomcat2 service

# Licensed to the Apache Software Foundation (ASF) under one or more

# Contributor license agreements. See the NOTICE file distributed

........................................ .............................

# $ Id: catalina. sh 1498485 2013-07-01 14: 37: 43Z markt $

#-----------------------------------------------------------------------------

CATALINA_HOME =/usr/local/tomcat2

JAVA_HOME =/usr/java/jdk1.7.0 _ 79

# OS specific support. $ var _ must _ be set to either true or false.

-- Add tomcat service:

# Chkconfig -- add tomcat2

-- Set tomcat to auto-start upon startup:

# Chkconfig tomcat2 on

-- Disable and start the tomcat service. The generated tomcat does not have the restart command:

# Service tomcat2 stop

# Service tomcat2 start

  1. Test Tomcat

# Cd/usr/local/tomcat/

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.