This paper is participating in the30 years of Linux”Topic essay activity

For services, Java back-end deployments, these are things that developers do almost every day,

Each time after updating the function, we need to update the code, we deploy the corresponding environment to see whether the function we wrote has taken effect;

For example, I now have a query function, used to query the current commodity data;

After the local testing is complete, you can publish the code on the test environment

At present, there are many means of our general deployment environment, the most commonly used Linux code command deployment,

For larger companies, they will have their own deployment environment with their own operations center, or they will deploy automatically with Jenkins

Their essence is to take the latest branch of Git (you can configure your own Develop code) and start it up.

For example, we will now use the data JAR package to deploy;

Which brings us to today’s topic, which is those commands during the deployment of a project;

Deployment Project Steps

  • Upload the project JAR package, zip package (usually front-end package) to the temporary directory TMP
  • Stop the project, place the existing project, and find the path to the package that needs to be replaced
  • Back up the previous JAR package, either to a folder, a name, etc
  • Cut and paste the new JAR package and start it on demand;

This is typically how small microservices are deployed:

Here we detail the Linux commands you need to know about deployment;

CD /opt/nspring Go to a specified directory PWD display the current directory example CD /opt/nspring Go to the nspring directory PWD display /opt/nspring ll Display the file information of the current directory in a list. It includes the file type, and the date it was created and some people like to use ls, but it depends on your personal habitsCopy the code

For example, I now want to see if my temporary directory, TMP, has uploaded the JAR I need to deploy

1. Upload the deployment JAR package to the server

CD/TMP ll - To go to the TMP directory, - is displayedCopy the code

If it’s been shown and found,

We then need to find the current service to replace and close it first

2. Find the services to be deployed and shut down the processes

Ps ef | grep Java / / will display the current directory to start the Java service, need to close that, (1) ps pipeline grep query the current information [user @ Lucas ~] $ps - ef | grep Java user 2021090809 PTS / 1 00:00:00 Java jar and Java. The jar User 21030 20996 0 21:30 PTS /2 00:00:00 grep Java (2) kill Kill process [user@luaca ~]$kill -9 20996 kill -9 Process IDCopy the code

3. Back up previous JAR files (do a good backup to prevent version rollback)

Jar Test01. Jar mkdir... /bk Current directory Creates a new Bk folderCopy the code

4. Paste the JAR in the temporary file to the specified directory

Mv Source directory File destination directory mv/TMP/test. jar /opt/nspring ll The information is displayedCopy the code

5. Start the service and view logs

/script/ start start indicates the start view log tail-500f console.log Contains the last 500 lines of the logCopy the code

5. View self-identification logs (Exit terminal)

In the tail command, the details of the current log file are usually followed and then exit the tail command Ctrl+ C to access the command againCopy the code

This is a basic tutorial, so you can try it out, usually with Linux,

I recommend xshell, XFTP,

www.netsarang.com/zh/xshell/

Everybody good night