Linux under Tomcat Service

Source: Internet
Author: User
Tags change settings clear screen system echo

One: The startup, shutdown, and error tracking of the Tomcat service under Linux, after using putty to connect to the server remotely, typically starts the shutdown of the Tomcat service in several ways:
Switch to the bin directory under the Tomcat home directory (CD Usr/local/tomcat/bin)
1. Start the Tomcat service
Mode one: Direct start./startup.sh
Mode two: Start nohup as a service./startup.sh &
Mode three: the console dynamic output mode starts./catalina.sh Run dynamically displays the console output information of the Tomcat daemon, and then exits and closes the service after CTRL + C
Explain:
Through the way one, the way the Tomcat has a disadvantage, when the client connection disconnects, the Tomcat service will stop immediately, through the two can be run as a Linux service
Tomcat initiated by way one, mode two, its log will be written to the corresponding log file, and can not dynamically view the Tomcat console output information and error conditions, through the way three can start the Tomcat service in console mode,
directly see the program Runtime background console output information, do not have to be very troublesome to open the Catalina.out log file for viewing, so that it is easy to track the background output information. The Tomcat console information includes information such as log4j and System.out.println () output.

2, close the Tomcat service
./shutdown.sh

3,tomcat Runtime JVM Memory allocation
Configuration in MyEclipse under the ⑴ development environment
-xms256m-xmx512m-xx:newsize=64m-xx:maxnewsize=128m-xx:permsize=512m-xx:maxpermsize=512m
⑵, online environment (start directly via Catalina or startup command line)
①linux under: catalina.sh
# OS specific support. $var _must_ is set to either True or FALSE. Add the following line after the comment
Java_opts= "-server-xms256m-xmx512m-xx:newsize=64m-xx:maxnewsize=128m-xx:permsize=512m-xx:maxpermsize=512m"
②windows under: Cattalina.bat
REM Guess catalina_home If not defined adds the following line after the comment
Set java_opts=-xms256m-xmx512m-xx:newsize=64m-xx:maxnewsize=128m-xx:permsize=512m-xx:maxpermsize=512m

II: Some common commands under Linux are explained:
1,pwd--> showing current working directory (pwd:print working directory)
2,ls--> Show current directory contents (list)
Ls|more split screen display ("|" As a pipe character, pass the previous command result to the following command, more for split screen)
Ls/usr>test01/abc.txt appends the contents of the specified directory to the Abc.txt text document in the test01 directory
Ls-l Display long format, abbreviated LL, mainly see the name of the file, size, permissions, etc.
Ls-a Show hidden files
3,cd--> changing the current working directory
Cd/usr--> go to the specified directory
CD usr--> go to a subdirectory of the specified directory
Cd.. --return to the top level directory
CD-To return to the home directory
4,clear--> Clear Screen
5,cat--> displaying file contents
Cat File|more Display the contents of the file (first display the contents of the file, and then pass the result content to the next command split screen)
Cat File|grep ABC Displays the contents of the file containing the character ABC (the contents of the file are displayed first, then the result content is passed to the next command search, grep has the search function)
Cat > Catalina.out Empty log content
6,touch--> Creating a new file
7,mkdir--> Creating a new directory
8,rm--> Deleting a file or directory
RM file.txt Deleting files
RM-RF test01 Delete a directory that is not empty (parameter R: Recursive recursion,f: Forced force)
9,rmdir--> Delete Empty Directory
10,cp--> Copying files
CP Src.txt Dest.txt
11,mv--> Moving files
MV Abc.txt Def.txt renamed
MV test01 test02 Change directory name
The MV test is equivalent to MV t+ (press TAB), and the TAB key has the function of finding supplemental commands.
12,chmod--> Changing the permissions mode
chmod +x catalina.sh is the catalina.sh executable permission (parameter x: Execute execute). Whether a file under Linux can be executable depends on the file attributes, not the extension.
chmod a+r catalina.out Set the file catalina.out to be readable by everyone. (Parameter A: everyone)
chmod ugo+r Catalina.out is also a file catalina.out that can be read by everyone. (Parameter u: File owner User,g:group Group, O:other Other)
A simple editor under the 13,vi-->linux
Vi. bash_profile Open Linux User-level initial file,: Wq save exit,: q! do not save exit
14,tail--Show file trailer content
Tail-f./catalina.out, #将文件最尾部内容显示在屏幕上, and constantly refresh the display, press CTRL + C or delete to exit.
15,netstat or lsof--> View network ports and process numbers
①netstat-anp|grep 8080 Direct view process PID for a specified port
#结果为
Protocol local address external address state PID
TCP 0.0.0.0:80 0.0.0.0:8080 LISTENING 5144/java

②lsof-i:8080 direct view of process PID for a specified port
#结果为
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
Java 5144 root 33u IPv6 127800 TCP *:8080 (LISTEN)
Then 5144 is 8080 pid of the Tomcat process on this port, and then you can kill the process: Kill-9 5144
Compare Windows netstat command: Netstat-ano|findstr 8080,taskkill-f-pid 5144 (F:force mandatory)
16,ping-View Network is connected
Ping 127.16.8.66 See if the current machine and directory machine can communicate properly (mainly see if the TCP/IP protocol is normal)
17,ipconfig View IP Address
Ipconfig-all can see the IP address and MAC address of each network adapter (local NIC, wireless network card)
18,ps--View program activity process
Ps-ef |grep Tomcat to see if Tomcat is already running and kills its process if there is one
#结果为:
Sun 1540 1 0 10:21 pts/1 00:00:06/java/jdk/bin/java-djava.util.logging.manager=org.apache.juli.classloaderlogmanager -djava.endorsed.dirs=/java/tomcat/common/endorsed-classpath:/java/tomcat/bin/bootstrap.jar:/java/tomcat/bin/ commons-logging-api.jar-dcatalina.base=/java/tomcat-dcatalina.home=/java/tomcat-djava.io.tmpdir=/java/tomcat/ Temp Org.apache.catalina.startup.Bootstrap Start
Then 1540 is the process number PID = 1540, then you can kill the process: Kill-9 1540
Compare Windows tasklist commands: tasklist | findstr tomcat,taskkill-f-pid 5144
19,telnet--> test if the remote port is connected
Telnet 10.4.200.114 1433
① Port unobstructed condition
Trying 10.4.200.114 ...
Connected to 10.4.200.114 (10.4.200.114).
Escape character is ' ^] '.
② port is not in the case
Trying 10.4.200.114 ...
If you can ping through, but the port is not available, it is possible that the firewall disabled the port, the workaround:
Under Linux: View firewall: Iptables–l
Immediate effect, fail after reboot (on: Service iptables start, Shutdown: Service iptables stop)
Set up firewall: Setup (garbled) Fix putty tool garbled: View the character set used in Linux system echo $LANG $LANGUAGE, choose menu modification Settings (change settings)---> conversion (translation)-- > select utf-8--> Applications (apply)
Win7 Firewall Open port method: Control Panel--System and security---Windows Firewall---Advanced settings--inbound rules--new rule--add 1433 port.
20,DF--View disk space (Diskfree)
Df-lh/usr/local
21,du--> Viewing used space (diskused)
Du-h/usr
Du-h--max-depth=1 View folder size
A common performance analysis tool under 22,top-->linux that enables real-time display of resource usage for each process in the system, similar to the Task Manager for Windows
Top-s Viewing memory usage
Top-s | grep Java View information for Java processes

23,linux Compression and decompression
1,tar.gz This format is the most used compression format under Linux. It does not take up too much CPU when compressing, and it can get a very ideal compression rate.
TAR-ZCVF archive_name.tar.gz directory_to_compress---Compress a directory
TAR-ZXVF archive_name.tar.gz---unzip to the current directory
TAR-ZXVF archive_name.tar.gz-c/usr/temp/---unzip to the specified directory
Parameter explanation:
-z-gzip call gzip to compress the tar archive file further into tar.gz format, or to extract the tar.gz format complete
-x-extract extracting specified (or all) files that have been archived
-c-create Creating a new archive file
-v-verbose Generating Verbose output
-f-file specifying the archive file name
-R append file to end of archive file
-C Change Directory

2, compress/unzip zip format
Zip file.zip./directory/*--Compress all files and directories in the specified directory
Unzip file.zip-d./test---unzip to the specified directory
Unzip File.zip---unzip to the current directory
Unzip-v Largefile.zip---only view the contents of the compressed package and do not unzip

Three: Several differences between Linux and Windows:
Echo $PATH echoes the value of the Linux environment variable PATH, the environment variable under Linux must be capitalized
Echo%path% echoes the value of the Windows environment variable path

Export Path=/usr/local/tomcat Modify the setting of the Linux environment variable path value (temporary), the Linux file system path is a slash
Set Path=d:\program Files\tomcat modifies the value of the Windows environment variable path (temporary), the Windows file system path is a backslash

Linux: viewing, modifying user-level initial files (. bash_profile) under Linux, which is a hidden file (permanent)
Windows: Computer----high-level----environment variables, viewing, modifying environment variables (permanent)

Linux command Search with grep, for example netstat-anp|grep 8080
Windows DOS command search with findstr, for example NETSTAT-ANP|FINDSTR 8080

Startup, shutdown, kill process for Tomcat under Linux

Open Terminal
Cd/java/tomcat
#执行
Bin/startup.sh #启动tomcat
Bin/shutdown.sh #停止tomcat
Tail-f logs/catalina.out #看tomcat的控制台输出; #看是否已经有tomcat在运行了
Ps-ef |grep tomcat# If there is, use kill;
Kill-9 pid #pid for the corresponding process number such as Ps-ef |grep tomcat output as follows Sun 5144 1 0 10:21 pts/1 00:00:06/java/jdk/bin/java-djava.util.loggi Ng.manager=org.apache.juli.classloaderlogmanager-djava.endorsed.dirs=/java/tomcat/common/endorsed-classpath:/ Java/tomcat/bin/bootstrap.jar:/java/tomcat/bin/commons-logging-api.jar-dcatalina.base=/java/tomcat- Dcatalina.home=/java/tomcat-djava.io.tmpdir=/java/tomcat/temp org.apache.catalina.startup.Bootstrap Start 5144 Just for process number PID = 5144
Kill-9 5144 can kill Tomcat completely #直接查看指定端口的进程pidnetstat-anp|grep 9217# result is TCP 0 0::: 9217:::* LISTEN 26127/java# 26127 is the PID of the Tomcat process on this port of 9217, then you can kill the process kill-9 26127# and then start Tomcat.

Linux under Tomcat Service

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.