There is a Spring Cloud jar package, the file name is: RDS.jar. The jdk1.8 version is required, and it needs to be deployed on the Centos 7.5 server. It is best to set it to start automatically!
systemctl stop firewalld.service
systemctl disable firewalld.service
Unzip jdk
mkdir /data
tar zxvf jdk-8u211-linux-x64.tar.gz -C /data/
Add environment variables
vi /etc/profile
The inside is as follows:
set java environment
JAVA_HOME=/data/jdk1.8.0_211/
JRE_HOME=/data/jdk1.8.0_211/jre
CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
export JAVA_HOME JRE_HOME CLASS_PATH PATH
Reload environment variables
source /etc/profile
View java version
# java -version
java version "1.8.0_211"Java(TM) SE Runtime Environment (build 1.8.0_211-b12)Java HotSpot(TM)64-Bit Server VM (build 25.211-b12, mixed mode)
Create application directory
mkdir /data/rds/
Upload RDS.jar to this directory
Start the java application
java -jar /data/rds/RDS.jar
JVM running for 11.918 appears, indicating that the startup is successful.
Let's create a startup script first
vim /etc/init.d/rds
The content is as follows:
#! /bin/bash
#
# auditd Start jar package
#
# chkconfig:23451188
# description: This is rds project
####### jar file path
export PROJECT_HOME=/data/rds/export PROJECT_NAME=RDS
#######
####### Start command
export START="source /etc/profile && cd $PROJECT_HOME;nohup java -jar ${PROJECT_HOME}/${PROJECT_NAME}.jar > output.log 2>&1 &"stop_jar(){for i in $(ps -aux|grep $PROJECT_NAME|grep -v grep|awk '{print $2}');do
kill -9 $i;
done
} case"$1"in
start)
echo "Starting $PROJECT_NAME"
eval $START
;;
stop)
echo "Stop $PROJECT_NAME"
stop_jar
;;
restart)
echo "Stop $PROJECT_NAME..."
stop_jar
echo "Starting $PROJECT_NAME"
eval $START
;;
esac
Enter the system directory and create a service file
cd /usr/lib/systemd/system/
vim rds.service
The content is as follows:
[ Unit]
Description=rds - rds web server
After=network.target remote-fs.target nss-lookup.target
[ Service]
Type=forking
ExecStart=/etc/init.d/rds start
ExecStop=/etc/init.d/rds stop
PrivateTmp=true[Install]
WantedBy=multi-user.target
Description:
After the service script is written in accordance with the above, it is saved in the /usr/lib/systemd/system directory with 754 permissions
Then execute (modify or add files need to execute the following statement to take effect)
Load configuration
systemctl daemon-reload
Test start command
systemctl restart rds
Check if the java process exists
ps -aux|grep RDS
Set up auto start
systemctl enable rds
Reference link for this article:
https://www.cnblogs.com/lamp01/p/8932740.html
https://www.jianshu.com/p/6753bcc72ead
Recommended Posts