Automatically deploy Java projects, hot deployment methods

Source: Internet
Author: User
Tags scp command

Most of the content goes from: https://www.cnblogs.com/hdwang/p/6081994.html

How to create a project don't go into it, you don't have to look down, no need to restart Tomcat for hot deployment

Next Install the plugin

The above default installed plug-in

Maven Integration Plugin

SSH plugin (to be used)

Deploy to Container Plugin

The above information prompts you to configure the MAVEN installation path, we can do so, by the way, configure the JDK path

MAVEN Build Command Configuration

Deployment Configuration

The tomcat user is configured within the Conf/tomcat-user.xml and the configuration is given below

<Tomcat-users><RoleRoleName= "Manager-gui"/><RoleRoleName= "Manager-status"/><RoleRoleName= "MANAGER-JMX"/><RoleRoleName= "Manager-script"/><role rolename= "Admin-gui "/> <role rolename= "Admin-script" /> " Span style= "COLOR: #0000ff" ><user username= "Tomcat"  Password= "Tomcat"  Roles= "MANAGER-GUI,MANAGER-STATUS,MANAGER-JMX, Manager-script,admin-gui,admin-script "/></< Span style= "COLOR: #800000" >tomcat-users>      

Save Configuration

5. Build

Click Navigation Jenkins--My views--click Study Project--Build now

If the interface card is found to be dead, it may be a JDK memory overflow that appears as follows

Set Tomcat's JDK parameters to

Windows adds the following parameters (added to the beginning of the file) in the Catalina.bat file:

Set java_opts=-server-xx:permsize=512m-xx:maxpermsize=2048m-xms512m-xmx2048m-xx:maxnewsize=512m

Linux adds the following parameters to the catalina.sh file (added to the beginning of the file):

Java_opts= "-server-xx:permsize=256m-xx:maxpermsize=1024m-xms512m-xmx1024m-xx:maxnewsize=256m"

If added successfully, can be viewed using the JPS-V command (both Windows and Linux are available)

Restart Tomcat, click Build again, and in console output you can see the entire build process, which indicates that the entire build deployment was successful.

6. Attach the shell footstep deployment mode, more flexible (both Jenkins and server must be Linux machines)----should not be deleted directly, should make a stable version of the last 1 months backup

The idea is to execute the remote script to close Tomcat and then execute the local script to copy the file to remote, then execute the remote script to start the Tomcat service. The above SCP command transfer file without password, you must configure the SSH key pair, configured as follows:

This assumes that host a (192.168.100.3) is used to obtain a file for Host B (192.168.100.4).

Execute the following command on host A to generate the pairing key: ssh-keygen-t RSA

When prompted to enter the default, the public key is stored in the user directory. The SSH directory, such as root, is stored in:

/root/.ssh/id_rsa.pub

Copy the Id_rsa.pub file from the. SSH directory to the ~/.ssh/directory in Host B and rename it to Authorized_keys, to host A to execute the command and Host B to establish trust, as an example (assuming Host B's IP is: 192.168.100.4):

SCP ~/.ssh/id_rsa.pub 192.168.100.4:/root/.ssh/authorized_keys

The following can be used in SCP, SSH command does not require a password to get Host B files ssh 192.168.100.4 Enter will not need a password.

If Machine B adds a public key for many individual machines, it needs to append the public key content to the Authorized_keys command as follows:cat id_rsa.pub >>/root/.ssh/authorized_keys

Automatically deploy Java projects, hot deployment methods

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.