Manually deploy the Dubbo service on Linux operating systems
1. Environment variable Configuration
Java environment variable----requires only JRE
Vi/etc/profile
# # Java ENV
Export java_home=/usr/local/java/jdk1.7.0_72
Export Jre_home= $JAVA _home/jre
Export classpath=.: $JAVA _home/lib/dt.jar: $JAVA _home/li/tools.jar: $JRE _home/lib/rt.jar
Export path= $PATH: $JAVA _home/bin: $JRE _home/bin
Source/etc/profile
2. Deployment Directory Specification
Objective: To facilitate management and avoid naming conflicts when applying migrations.
The directory structure I defined below (Linux):
--home ----------the Linux home directory
--JEESML-------------User Information
--j eesml------------project type
--app------------App App
--app1-------------App 1
--app2.-----------App 2
--service ----------Service Application
--service1----------Service 1
--service2 ... ---------Service 2
--job ------------Timing Scheduling Application
--job1 ... ------------ Timing Dispatch Engineering
--web ------------Web Project Project
--web1 ---------Web Project Project 1
--web2 ... ---------Web Project Engineering 2
3, Manual Maintenance Dubbo Service (not recommended)
Execute command:
# Java-jar Edu-service-xxx.jar &
Check to see which Java programs are running:
# Ps-ef | grep java
Kill PID Process ID
Kill-9 PID strong kill, not recommended to use, may be as data loss
4. Custom shell scripts for Dubbo service maintenance (recommended)
Script Naming conventions:
/home/jeesml/jeesml/service/xxx/service-xxx.sh
Example:/home/jeesml/jeesml/service/user/service-user.sh
Effect: Cd/home/jeesml/jeesml/service/user
. /service-user.sh start
. /service-user.sh stop
. /service-user.sh restart
5, Service Maintenance precautions
(1) Script specification---------as common as possible
(2) Daemon process
(3) Memory tuning settings-----on-demand adjustment
(4) Log processing---------keep only the logs that apply log4j output
(5) Avoid service conflicts----process name, port
(6) Avoid process manslaughter-----full match
Simple Script instance:
#!/bin/sh
# # Java ENV
Export java_home=/usr/local/java/jdk1.7.0_72
Export Jre_home= $JAVA _home/jre
# # Service Name
App_name=user
service_dir=/home/jeesml/jeesml/service/$APP _name
service_name=edu-service-$APP _name
Jar_name= $SERVICE _name\.jar
Pid= $SERVICE _name\.pid
CD $SERVICE _dir
Case "$" in
Start
Nohup $JRE _home/bin/java-xms256m-xmx512m-jar $JAR _name >/dev/null 2>&1 &
Echo $! > $SERVICE _dir/$PID
echo "= = = Start $SERVICE _name"
;;
Stop
Kill ' Cat $SERVICE _dir/$PID '
RM-RF $SERVICE _dir/$PID
echo "= = = Stop $SERVICE _name"
Sleep 5
##
# # Edu-service-aa.jar
# # Edu-service-aa-bb.jar
P_id= ' Ps-ef | Grep-w "$SERVICE _name" | Grep-v "grep" | awk ' {print $} '
If ["$P _id" = = ""]; Then
echo "= = = $SERVICE _name process not exists or stop success"
Else
echo "= = = $SERVICE _name process pid is: $P _id"
echo "= = = Begin Kill $SERVICE _name process, PID is: $P _id"
Kill-9 $P _id
Fi
;;
Restart
$ stop
Sleep 2
$ start
echo "= = = Restart $SERVICE _name"
;;
*)
# # Restart
$ stop
Sleep 2
$ start
;;
Esac
Exit 0
The script configuration is highly flexible and meets the requirements. Cocoa Reference Official Script sample, please go to the Exchange Group (446855438) to download the attachment information
Please continue to follow me on learning dubbo-Manual deployment of Dubbo services on Linux operating systems (5)
Because the first time to write about Dubbo blog, but also hope that you join Dubbo Learning Exchange Group (446855438), study together.
Learn from me dubbo-manually deploy Dubbo services on Linux operating systems (5)