Common Problems and Solutions (Server)

1. Linux configure Java environment variables:

1. Unzip and install jdk

Enter the directory where the jdk-6u14-linux-i586.bin file is located under the shell terminal and
execute the command

./jdk-6u14-linux-i586.bin

 

At this time, an agreement will appear, continue to press Enter, when asked whether to agree, enter yes and press Enter. After that, a jdk1.6.0_14 directory will be generated in the current directory, and you can copy it to any directory.

2. Environment variables that need to be configured

1. PATH environment variable. The function is to specify the command search path. When the command is executed under the shell, it will look in the path specified by the PATH variable to see if it can find the corresponding command program. We need to add the bin directory under the jdk installation directory to the existing PATH variable. The bin directory contains frequently used executable files such as javac/java/javadoc. Execute tools such as javac/java.
2. CLASSPATH environment variable. The role is to specify the class search path. To use the classes that have been written, of course, the premise is that they can be found. The JVM searches for classes through CLASSPTH. We need to set dt.jar and tools.jar in the lib subdirectory under the jdk installation directory to CLASSPATH. Of course, the current directory "." must also be added to this variable.
3. JAVA_HOME environment variable. It points to the jdk installation directory, and software such as Eclipse/NetBeans/Tomcat finds and uses the installed jdk by searching the JAVA_HOME variable.

Three. Three ways to configure environment variables

1. Modify the /etc/profile file
. This method is recommended if your computer is only used for development, because all user shells have access to these environment variables, which may bring security problems to the system.
·Open /etc/profile with a text editor
·Add at the end of the profile file:

1 export JAVA_HOME=/usr/share/jdk1.6.0_14 
2 export PATH=$JAVA_HOME/bin:$PATH 
3 export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

 

·Login again
·Note
a. You need to change /usr/share/jdk1.6.0_14 to your jdk installation directory
b. Use a colon ":" to separate the paths under linux
c. $PATH / $CLASSPATH / $JAVA_HOME is to use To refer to the value of the original environment variable
When setting the environment variable, pay special attention not to overwrite the original value, this is a
common mistake.
d. The current directory "." in CLASSPATH cannot be lost. It is also a common mistake to lose the current directory.
e. export is to export these three variables as global variables.
f. Upper and lower case must be strictly differentiated.

2. Modify the .bash_profile file

This method is more secure. It can control the permissions to use these environment variables to the user level. If you need to give a user permission to use these environment variables, you only need to modify the .bash_profile file in the home directory of the individual user. .
·Open the .bash_profile file in the user directory with a text editor
·Add at the end of the .bash_profile file:

1 export JAVA_HOME=/usr/share/jdk1.6.0_14 
2 export PATH=$JAVA_HOME/bin:$PATH 
3 export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

 

·re-register

3. It is not recommended to use this method to set variables directly under the shell
, because if you change the shell, your settings will be invalid, so this method is only used temporarily, and it is more troublesome to set it again when you want to use it later.
Just execute the following command in the shell terminal:

1 export JAVA_HOME=/usr/share/jdk1.6.0_14 
2 export PATH=$JAVA_HOME/bin:$PATH 
3 export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

 

4. Test jdk

1. Create a new Test.java file with a text editor, enter the following code in it and save it:

1 public class test { 
2 public static void main(String args[]) { 
3     System.out.println("A new jdk test !"); 
4     } 
5 } 

2. Compile: execute the command javac Test.java
in the shell terminal 3. Run: execute the command java Test in the shell terminal
When the words "A new jdk test !" appear under the shell, the jdk is running normally.

5. Uninstall jdk

·Find the _uninst subdirectory of the jdk installation directory
·Execute the command ./uninstall.sh in the shell terminal to uninstall jdk.

 2. Install two or more tomcats under Linux system

Edit environment variables:

vi /etc/profile

Add the following code (the tomcat path needs to configure its own actual tomcat installation directory)

 1 ##########first tomcat###########
 2 CATALINA_BASE=/usr/local/tomcat
 3 CATALINA_HOME=/usr/local/tomcat
 4 TOMCAT_HOME=/usr/local/tomcat
 5 export CATALINA_BASE CATALINA_HOME TOMCAT_HOME
 6 ##########first tomcat############
 7 ##########second tomcat##########
 8 CATALINA_2_BASE=/usr/local/tomcat_2 #这个路径是你第二个tomcat的路径
 9 CATALINA_2_HOME=/usr/local/tomcat_2
10 TOMCAT_2_HOME=/usr/local/tomcat_2
11 export CATALINA_2_BASE CATALINA_2_HOME TOMCAT_2_HOME
12 ##########second tomcat##########

Save and exit.
Enter again:

source /etc/profile

to take effect.

The first tomcat, keep the uncompressed state without modification, go

to the bin directory of the second tomcat and
open catalina.sh, find the following red letter,

# OS specific support. $var _must_ be set to either true or false.

 

Add the following code below

1 export CATALINA_BASE=$CATALINA_2_BASE
2 export CATALINA_HOME=$CATALINA_2_HOME

 

Go to the conf directory of the second tomcat and
open server.xml to change the port:
modify the server.xml configuration and the first different startup and shutdown listening ports.
The modified example is as follows:

1  <Server port="9005" shutdown="SHUTDOWN">  端口:8005->9005
2 <!-- Define a non-SSL HTTP/1.1 Connector on port 8080 -->
3 <Connector port="9080" maxHttpHeaderSize="8192"  端口:8080->9080
4 maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
5 enableLookups="false" redirectPort="8443" acceptCount="100"
6 connectionTimeout="20000" disableUploadTimeout="true" />
7 <!-- Define an AJP 1.3 Connector on port 8009 -->
8 <Connector port="9009" 端口:8009->9009
9 enableLookups="false" redirectPort="8443" protocol="AJP/1.3" />

Enter the bin directories of the two tomcats and start tomcat--./startup.sh

Then visit http://localhost:8080 and http://localhost:9080 to see the familiar tomcat welcome interface.

3. Common commands of Centos (updated from time to time):

Empty the tomcat catalina.out log file

find /tomcat/logs/ -name 'catalina.out' | xargs truncate -s 0

Extract text.tar.gz to /home/app/test/ (absolute path)

tar -zxvf ./text.tar.gz -C /home/app/test/
rm filename //delete file
rm -rf // delete the folder

 

mv oldname newname // Modify the file name (folder name)

 

Add ./ before application to run directly

chmod 777 /home/software/jdk1.7.0_03/java;//Remarks: chmod is a command to assign permissions, 777 means to assign all permissions to this user, this group of users, and other users.

 

$sudo apt-get install gnome // download and install gnome 

 

$sudo apt-get remove gnome-shell //移除gnome

 

.Copy files, only when the modification time of the source file is newer than the destination file, will the file be copied

cp -u -v file1 file2

 

.Copy the file file1 to the file file2

cp file1 file2

 

.Copy file1 to file2 in interactive mode

cp -i file1 file2

 

.Copy the file file1 to file2, because the destination file already exists, so specify the mode of forced copying

cp -f file1 file2

 

.Copy the directory dir1 to the directory dir2

cp -R file1 file2

 

.Copy files file1, file2, file3 and directory dir1 to dir2 at the same time

cp -R file1 file2 file3 dir1 dir2

 

.Preserve file attributes when copying

cp -p a.txt tmp/

 

.Preserve the directory structure of files when copying

cp -P /var/tmp/a.txt ./temp/

 

.Generate backup file when copying

cp -b a.txt tmp/

 

.A backup file is generated when copying, the trailing mark ~1~ format

cp -b -V t a.txt /tmp

.specify the backup file tail

cp -b -S _bak a.txt /tmp

 

top command: view memory status
Top command monitors the resource occupation of a process. The following are various types of memory: VIRT: virtual memory usage
1. The virtual memory size "required" by the process, including the library, code, data, etc. used by the process
2. If a process applies for 100m of memory, but actually only uses 10m, then it will increase by 100m, not the actual usage
RES: resident memory usage Resident memory
1. The memory size currently used by the process, but not including swap out
2, Including the sharing of other processes
3. If you apply for 100m of memory and actually use 10m, it only grows by 10m, which is opposite to VIRT
4. Regarding the memory occupied by the library, it only counts the memory size occupied by the loaded library files
SHR: shared memory
1 , In addition to the shared memory of its own process, it also includes the shared memory of other processes
2. Although the process only uses a few shared library functions, it includes the size of the entire shared library
3. Calculate the physical memory size occupied by a process Formula: RES – SHR
4. After swap out, it will drop down DATA1, the memory occupied by data. If top is not displayed, press the f key to display it.
2. The real data space required by the program is really to be used in operation.

Four, python linux installation steps

1. First confirm the environment

1 [root@localhost install]# pwd
2 /data/install
3 
4 [root@localhost install]# cat /etc/redhat-release 
5 CentOS release 6.3 (Final)
6 
7 [root@localhost install]# uname -a
8 Linux localhost 2.6.32-358.6.2.el6.x86_64 #1 SMP Thu May 16 20:59:36 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

 

2. Download and install the python xx version

1 [root@localhost install]# wget https://www.python.org/ftp/python/x.x.x/Python-x.x.x.tgz
2 [root@localhost install]# tar -zxf Python-x.x.x.tgz
3 [root@localhost install]# cd Python-x.x.x

 

1  # There is a README file in the installation package, which describes how to install
 2 [root@localhost Python- 3.4 . 4 ] # ls 
3 aclocal.m4 config.sub configure.ac Grammar install - sh LICENSE Makefile.pre.in Modules Parser PCbuild Python setup.py
 4 config.guess configure
 Doc Include Lib Mac Misc Objects PC pyconfig.h. in README Tools
 5 6 [root@localhost Python- 3.4.4 ]# ./configure 7 [ root @ localhost Python- 3.4 .4 ] # make 8 

 [root@localhost Python-3.4.4]# make install

 

3. Test

[root@localhost Python-3.4.4]# python3
Python 3.4.4 (default, Jun 27 2016, 07:47:54) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-16)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

 

Guess you like

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