Linux configuration Java Tomcat environment

1. Backup
1. Enter the mysql directory

cd /var/lib/mysql (enter the mysql directory, there will be differences according to the installation)
2. Backup

mysqldump -u root -p password database name data table name > mysql.sql
Then a mysql.sql backup file is generated under the /var/lib/mysql directory

2. Restore
Method 1:
1. mysql -u root -p press Enter, enter the password, enter the MySQL console "mysql>"
2. Enter the MySQL Command Line Client, enter the password, enter "mysql>", enter the command show databases;, press Enter to see what databases are there; create the database you want to restore, type create database voice;, press Enter; switch to the newly created database, type use voice;, press Enter; import data, type source voice. sql;, press Enter, start importing, "mysql>" appears again and the restoration is successful without prompting an error.

Method 2:
[root @localhost ~]# cd /var/lib/mysql (enter the MySQL library directory and adjust the directory according to your own MySQL installation)
[root @localhost mysql]# mysql -u root -p voice<voice .sql, enter the password.

3. Download and upload xFtp5


4. Decompression

     tar -zxv -f apache-tomcat-7.0.69.tar.gz// decompress the compressed package 

    rm -rf apache-tomcat-7.0.69.tar.gz // delete the compressed package 
     mv apache-tomcat-7.0.69.tar.gz tomcat

    


5. Compress and decompress

    Compress and specify a directory
    example: zip -r /java/apache-tomcat-7.0.69/webapps/hsh.zip /java/apache-tomcat-7.0.69/webapps

    Unzip and specify the directory
    for example: unzip /java/apache-tomcat-7.0.69/webapps/hsh.zip -d /java/apache-tomcat-7.0.69/webapps

            
Six. Move
    
    mv [option (option)] source file or directory target file or directory
    Use the command:

    mv  webdata  /bin/usr/


7. Startup, shutdown and error tracking of the tomcat service under TOmcat
Linux. After using PuTTy to connect to the server remotely, the tomcat service is usually started and closed in the following ways:
switch to the bin directory under the tomcat home directory (cd usr/local/tomcat /bin)
1. Start the tomcat service
Method 1: Directly start ./startup.sh
Method 2: Start nohup as a service ./startup.sh &
Method 3: Start the console dynamic output method./catalina.sh run Dynamically display tomcat The console in the background outputs information, exit and close the service after Ctrl+C
Explanation:
The tomcat started by the first and third methods has a disadvantage. When the client connection is disconnected, the tomcat service will also stop immediately, and the second method can be used. As a linux service
, the tomcat that has been started through the first and second methods will be written to the corresponding log file, and the output information and error conditions of the tomcat console cannot be dynamically viewed. Through the third method, the console mode can be used. Start the tomcat service and
directly see the console output information in the background when the program is running. It is not necessary to open the catalina.out log file every time to view it, which is convenient for tracking and viewing the background output information. The tomcat console information includes the information output by log4j and System.out.println().
2. Shut down the tomcat
service./shutdown.sh


ps -ef|grep java
If the following similar information is displayed, it means that Tomcat has not been shut down

复制代码
root      7010
     1  0 Apr19 ?        00:30:13 /usr/local/java/bin/java 
-Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties
 -Djava.awt.headless=true 
-Dfile.encoding=UTF-8 -server -Xms1024m -Xmx1024m -XX:NewSize=256m 
-XX:MaxNewSize=256m -XX:PermSize=256m -XX:MaxPermSize=256m 
-XX:+DisableExplicitGC 
-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager 
-Djava.endorsed.dirs=/usr/local/tomcat/endorsed -classpath 
/usr/local/tomcat/bin/bootstrap.jar -Dcatalina.base=/usr/local/tomcat 
-Dcatalina.home=/usr/local/tomcat 
-Djava.io.tmpdir=/usr/local/tomcat/temp 
org.apache.catalina.startup.Bootstrap start
复制代码
*If you want to kill Tomcat directly, you can use the kill command to kill the Tomcat process directly

 kill -9 7010
and then continue to see if Tomcat is down

 ps -ef|grep java
If the following information appears, it means that Tomcat has been shut down

root      7010     1  0 Apr19 ?        00:30:30 [java] 

3. I don't know what the directory structure of your linux looks like. The following steps I commonly use, I hope to give you inspiration

 cd /tomcat7/logs/      
 tail -f catalina.out (catalina.out is the console log file)

8. Copy:
CP command 
format: CP [option] source file or directory destination file or directory 
option description: -b with the same name, back up the original file 
-f forcibly overwrite the file with the same name 
-r copy the file recursively to retain the original directory structure 

cp -r /tmp/a /root/a 


cp -r /java/apache-tomcat-7.0.69/webapps/ROOT/file /java/apache-tomcat-7.0.69/webapps/hsh


9. Delete
Delete a folder instance:
rm -rf /var/log/httpd/access
will delete the /var/log/httpd/access directory and all files and folders under it


10. Configure Java, Tomcat environment               

     [root@ora-rac2 ~]# vi /etc/profile Enter the configuration file, click i to insert and edit, after editing Esc -> :wq to save the        
     specific configuration information as follows:

      export JAVA_HOME=/cdr/jdk1.7.0_51

     export PATH=$JAVA_HOME/bin:$PATH

     export CLASSPATH=.:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:$CLASSPATH    

The first three lines are the java environment configuration

                                   
     export CATALINA_HOME= /usr/local/tomcat8.5

     export CATALINA_BASE= /usr/local/tomcat8.5  

The last two lines are the tomcat environment configuration. After saving, exit
 

 

    [root@ora-rac2 ~]# source /etc/profile            

Remember, this one must be executed! ! ! ! ! Close the currently connected session to take effect.
    

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325862119&siteId=291194637