标签:情况 OLE 启动命令 version 使用率 process nal ppi 负载
[root@web01 webapps] # cd /server/tools/
[root@web01 tools] # tar xf apache-tomcat-8.0.27.tar.gz -C /application
[root@web01 application] # ln -s /application/apache-tomcat-8.0.27/ /application/tomcat
?
[root@web01 application] # cd /server/tools/
[root@web01 tools] # tar xf jdk-8u60-linux-x64.tar.gz -C /application/
[root@web01 application] # ln -s jdk1.8.0_60/ /application/jdk
?
cat >>/etc/profile<<‘EOF‘
export JAVA_HOME=/application/jdk
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH
export
CLASSPATH=.$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$JAVA_HOM
E/lib/tools.jar
export TOMCAT_HOME=/application/tomcat
EOF
[root@web01 ipv4] # java -version
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)
You have new mail in /var/spool/mail/root
[root@web01 ipv4] #
[root@web01 ipv4] # /application/tomcat/bin/version.sh????????????查看tomcat和jdk的版本是不是一致的
Server number: 8.0.27.0
OS Name: Linux
OS Version: 3.10.0-1062.1.1.el7.x86_64
Architecture: amd64
JVM Version: 1.8.0_60-b27
[root@web01 ipv4] # /application/tomcat/bin/startup.sh
Using CATALINA_BASE: /application/tomcat
Using CATALINA_HOME: /application/tomcat
Using CATALINA_TMPDIR: /application/tomcat/temp
Using JRE_HOME: /application/jdk
Using CLASSPATH: /application/tomcat/bin/bootstrap.jar:/application/tomcat/bin/tomcat-juli.jar
Tomcat started.
You have new mail in /var/spool/mail/root
[root@web01 ipv4] #
?
[root@web01 tomcat] # ps -ef | grep java
root 12462 1 96 19:50 pts/2 00:00:02 /application/jdk/bin/java -Djava.util.logging.config.file=/application/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=12345 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=10.0.0.7 -Djava.endorsed.dirs=/application/tomcat/endorsed -classpath /application/tomcat/bin/bootstrap.jar:/application/tomcat/bin/tomcat-juli.jar -Dcatalina.base=/application/tomcat -Dcatalina.home=/application/tomcat -Djava.io.tmpdir=/application/tomcat/temp org.apache.catalina.startup.Bootstrap start
root 12480 8056 0 19:50 pts/2 00:00:00 grep --color=auto java
?
[root@web01 tomcat] # ss -lnptu | grep java
tcp LISTEN 0 100 :::8009 :::*
tcp LISTEN 0 100 :::8080 :::* users:(("java",pid=12462,fd=50))
[root@web01 tomcat] #
?
[root@web01 ipv4] # /application/tomcat/bin/shutdown.sh
Using CATALINA_BASE: /application/tomcat
Using CATALINA_HOME: /application/tomcat
Using CATALINA_TMPDIR: /application/tomcat/temp
Using JRE_HOME: /application/jdk
Using CLASSPATH: /application/tomcat/bin/bootstrap.jar:/application/tomcat/bin/tomcat-juli.jar
[root@web01 ipv4] #
?
[root@web01 tomcat] # ps -ef | grep java
root 12451 8056 0 19:50 pts/2 00:00:00 grep --color=auto java
[root@web01 tomcat] # ss -lnptu | grep java
[root@web01 tomcat] #
[root@web01 ipv4] # /application/tomcat/bin/catalina.sh????????????????表示tomcat启动还是关闭都会调用这个命令
主配置文件
22 <Server port="8005" shutdown="SHUTDOWN">????????????tomcat的shutdown端口,连接tomcat的时????????????????????????????????????????????????候,连接这个端口,并且输入暗号tomcat就会断开
41 <Resource name="UserDatabase" auth="Container"????????用户管理端,认证模式,用户密码模式(这个默认是开启的,在生产环境上一定要关闭)
42 type="org.apache.catalina.UserDatabase"
43 description="User database that can be updated and saved"
44 factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
45 pathname="conf/tomcat-users.xml" />
46 </GlobalNamingResources>
69 <Connector port="8080" protocol="org.apache.coyote.http11.Http11AprProtocol"????????表示tomcat的web管理端口(登录web的时候使用的就是这个端口)
94 <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />????????????apache和tomcat连接的时候预留的端口(如果不是tomcat建议将这行注释掉)
?
126 <Host name="localhost" appBase="webapps"????????????定义tomcat的域名和站点目录
127 unpackWARs="true" autoDeploy="true">????定义上传到站点目录的war包是不是自动解压
138 <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs
"
139 prefix="localhost_access_log" suffix=".txt"????????????访问日志的前缀和后缀
140 pattern="%h %l %u %t "%r" %s %b" />
tomcat管理配置文件
tomcat的额外功能
关闭tomcat程序
开启tomcat程序
查看tomcat和jdk的版本是不是可以兼容
java程序的站点目录
[root@web01 bin] # cd /application/tomcat/webapps/jpress/WEB-INF/classes/
You have new mail in /var/spool/mail/root
[root@web01 classes] # ll
total 36
-rw-r--r-- 1 root root 163 Dec 17 09:42 db.properties
Catalina的日志切割
?
记录tomcat最详细的信息(查看error和start)
因为对于日志文件来说,完全删除一个文件是要具备2个条件的
tomcat的访问日志
?
?
[root@web01 ~] # cd /application/tomcat/conf/
[root@web01 conf] # vim tomcat-users.xml
<?xml version=‘1.0‘ encoding=‘utf-8‘?>
?
<tomcat-users xmlns="http://tomcat.apache.org/xml"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://tomcat.apache.org/xml tomcat-users.xsd"
version="1.0">
<role rolename="admin-gui"/>????????????????配置server status
<role rolename="manager-gui"/>????????????配置Manage app
<role rolename="host-gui"/>????????????????配置HostManage
<user username="tomcat" password="tomcat" roles="admin-gui,manager-gui,host-gui"/>
</tomcat-users>
[root@web01 conf] #
[root@web01 conf] # /application/tomcat/bin/shutdown.sh
Using CATALINA_BASE: /application/tomcat
Using CATALINA_HOME: /application/tomcat
Using CATALINA_TMPDIR: /application/tomcat/temp
Using JRE_HOME: /application/jdk
Using CLASSPATH: /application/tomcat/bin/bootstrap.jar:/application/tomcat/bin/tomcat-juli.jar
You have new mail in /var/spool/mail/root
[root@web01 conf] # /application/tomcat/bin/startup.sh
Using CATALINA_BASE: /application/tomcat
Using CATALINA_HOME: /application/tomcat
Using CATALINA_TMPDIR: /application/tomcat/temp
Using JRE_HOME: /application/jdk
Using CLASSPATH: /application/tomcat/bin/bootstrap.jar:/application/tomcat/bin/tomcat-juli.jar
Tomcat started.
[root@web01 conf] #
采用编译的方法安装,这里就不详细说了
将jpress代码安装包放入到webapps目录下
[root@db ~] # yum -y install mariadb-server mariadb
MariaDB [(none)]> create database jpress charset utf8;
MariaDB [(none)]> show create database jpress;
+----------+-----------------------------------------------------------------+
| Database | Create Database |
+----------+-----------------------------------------------------------------+
| jpress | CREATE DATABASE `jpress` /*!40100 DEFAULT CHARACTER SET utf8 */ |
+----------+-----------------------------------------------------------------+
1 row in set (0.01 sec)
?
MariaDB [(none)]> grant all on jpress.* to ‘jpress‘@‘172.16.1.%‘ identified by ‘jpress‘;
[root@db ~] # systemctl restart mariadb.service
[root@web01 conf] # /application/tomcat/bin/startup.sh
Using CATALINA_BASE: /application/tomcat
Using CATALINA_HOME: /application/tomcat
Using CATALINA_TMPDIR: /application/tomcat/temp
Using JRE_HOME: /application/jdk
Using CLASSPATH: /application/tomcat/bin/bootstrap.jar:/application/tomcat/bin/tomcat-juli.jar
Tomcat started.
You have new mail in /var/spool/mail/root
[root@web01 conf] #
[root@web01 webapps] # vim /etc/rc.local
source /etc/profile
/application/tomcat/bin/startup.sh
?
?
?
模式 | 应用版本 | 核心点 | 特点 |
bio(blocking io) | tomcat7及以前的 | 同步模式,容易阻塞 | 一个线程处理一个请求,在并发量高的时候,容易造成线程数多,导致资源的浪费 |
nio(new io) | tomcat8 | 异步模式,不容易阻塞 | nio1(默认使用),nio2可以少量线程处理大量请求 |
apr(Apache Portable Runtime) | tomcat8 | 异步模式的 | 高并发的情况下使用 |
69 <Connector port="8080" protocol="org.apache.coyote.http11.Http11AprProtocol"
69 <Connector port="8080" protocol="org.apache.coyote.http11.Http11Nio2Protocol"
69 <Connector port="8080" protocol="org.apache.coyote.http11.Http11NioProtocol"
?
[root@web01 tools]# tar xf apache-tomcat-8.0.27.tar.gz????????????????解压tomcat包
[root@web01 tools]# cp -r apache-tomcat-8.0.27 tomcat8081 ????????????讲解压的包进行复制,并且修改名称
[root@web01 tools]# cp -r apache-tomcat-8.0.27 tomcat8082????????????将解压的包进行复制,并且修改名称
[root@web01 tools]# mv tomcat808* /application/????????????????????移动到/application目录下
[root@web01 tools]# ll /application/
drwxr-xr-x 9 root root 160 Dec 16 12:01 apache-tomcat-8.0.27
lrwxrwxrwx 1 root root ?25 Dec 16 11:52 jdk ->/application/jdk1.8.0_60/
drwxr-xr-x 8 ?10 ?143 255 Aug ?5 ?2015 jdk1.8.0_60
drwxr-xr-x 6 root root ?54 Nov ?5 19:03 nginx-1.16.1
lrwxrwxrwx 1 root root ?34 Dec 16 12:01 tomcat ->/application/apache-tomcat-8.0.27/
drwxr-xr-x 9 root root 160 Dec 17 11:10 tomcat8081
drwxr-xr-x 9 root root 160 Dec 17 11:10 tomcat8082
[root@web01 application]# sed -i ‘s#8080#8081#g‘????????????tomcat8081的网站web端口改为8081
tomcat8081/conf/server.xml
[root@web01 application]# sed -i ‘s#8005#8006#g‘????????????将关闭tomcat进程端口8005改为8006
tomcat8081/conf/server.xml
[root@web01 application]# sed -i ‘s#8009#8010#g‘????????????将apache和tomcat连接的端口8009改为8010
tomcat8081/conf/server.xml
[root@web01 application]#
[root@web01 application]#
[root@web01 application]# sed -i ‘s#8080#8082#g‘????????????tomcat8080的网站web端口改为8082
tomcat8082/conf/server.xml
[root@web01 application]# sed -i ‘s#8005#8007#g‘????????????将关闭tomcat进程端口8005改为8007
tomcat8082/conf/server.xml
[root@web01 application]# sed -i ‘s#8009#8011#g‘????????????将apache和tomcat连接的端口8009改为8011
tomcat8082/conf/server.xml
[root@web01 ~] # /application/tomcat8081/bin/startup.sh ????????????启动8081tomcat服务
Using CATALINA_BASE: /application/tomcat8081
Using CATALINA_HOME: /application/tomcat8081
Using CATALINA_TMPDIR: /application/tomcat8081/temp
Using JRE_HOME: /application/jdk
Using CLASSPATH: /application/tomcat8081/bin/bootstrap.jar:/application/tomcat8081/bin/tomcat-juli.jar
Tomcat started.
You have new mail in /var/spool/mail/root
[root@web01 ~] # /application/tomcat8082/bin/startup.sh ????????????启动8082tomcat服务
Using CATALINA_BASE: /application/tomcat8082
Using CATALINA_HOME: /application/tomcat8082
Using CATALINA_TMPDIR: /application/tomcat8082/temp
Using JRE_HOME: /application/jdk
Using CLASSPATH: /application/tomcat8082/bin/bootstrap.jar:/application/tomcat8082/bin/tomcat-juli.jar
Tomcat started.
[root@web01 ~] #
[root@web01 ~] # ss -lnptu | grep java
tcp LISTEN 0 50 :::12345 :::* users:(("java",pid=11734,fd=20))
tcp LISTEN 0 1 ::ffff:127.0.0.1:8005 :::* users:(("java",pid=11734,fd=68))
tcp LISTEN 0 1 ::ffff:127.0.0.1:8006 :::* users:(("java",pid=11653,fd=64))
tcp LISTEN 0 1 ::ffff:127.0.0.1:8007 :::* users:(("java",pid=11675,fd=64))
tcp LISTEN 0 100 :::8009 :::* users:(("java",pid=11734,fd=51))
tcp LISTEN 0 100 :::8010 :::* users:(("java",pid=11653,fd=47))
tcp LISTEN 0 100 :::8011 :::* users:(("java",pid=11675,fd=47))
tcp LISTEN 0 100 :::8080 :::* users:(("java",pid=11734,fd=50))
tcp LISTEN 0 100 :::8081 :::* users:(("java",pid=11653,fd=46))
tcp LISTEN 0 100 :::8082 :::* users:(("java",pid=11675,fd=46))
tcp LISTEN 0 50 :::34294 :::* users:(("java",pid=11734,fd=21))
tcp LISTEN 0 50 :::39958 :::* users:(("java",pid=11734,fd=19))
[root@web01 ~] # ps -ef | grep java
root 11653 1 3 19:51 pts/0 00:00:04 /application/jdk/bin/java -Djava.util.logging.config.file=/application/tomcat8081/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/application/tomcat8081/endorsed -classpath /application/tomcat8081/bin/bootstrap.jar:/application/tomcat8081/bin/tomcat-juli.jar -Dcatalina.base=/application/tomcat8081 -Dcatalina.home=/application/tomcat8081 -Djava.io.tmpdir=/application/tomcat8081/temp org.apache.catalina.startup.Bootstrap start
root 11675 1 3 19:51 pts/0 00:00:04 /application/jdk/bin/java -Djava.util.logging.config.file=/application/tomcat8082/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/application/tomcat8082/endorsed -classpath /application/tomcat8082/bin/bootstrap.jar:/application/tomcat8082/bin/tomcat-juli.jar -Dcatalina.base=/application/tomcat8082 -Dcatalina.home=/application/tomcat8082 -Djava.io.tmpdir=/application/tomcat8082/temp org.apache.catalina.startup.Bootstrap start
root 11734 1 15 19:52 pts/0 00:00:03 /application/jdk/bin/java -Djava.util.logging.config.file=/application/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=12345 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=10.0.0.7 -Djava.endorsed.dirs=/application/tomcat/endorsed -classpath /application/tomcat/bin/bootstrap.jar:/application/tomcat/bin/tomcat-juli.jar -Dcatalina.base=/application/tomcat -Dcatalina.home=/application/tomcat -Djava.io.tmpdir=/application/tomcat/temp org.apache.catalina.startup.Bootstrap start
root 11785 11497 0 19:53 pts/0 00:00:00 grep --color=auto java
[root@web01 ~] #
主要是查看jvm的状态(jvm里面主要是关注内存的使用率信息)
[root@web01 ROOT] # jps -lmv
11653 org.apache.catalina.startup.Bootstrap start -Djava.util.logging.config.file=/application/tomcat8081/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/application/tomcat8081/endorsed -Dcatalina.base=/application/tomcat8081 -Dcatalina.home=/application/tomcat8081 -Djava.io.tmpdir=/application/tomcat8081/temp
[root@web01 scripts] # ./show-busy-java-threads.sh
[1] Busy(73.0%) thread(2543/0x9ef) stack of java process(2542) under user(root):
"main" #1 prio=5 os_prio=0 tid=0x00007f4788009000 nid=0x9ef waiting on condition [0x00007f478e5db000]
java.lang.Thread.State: WAITING (parking)
????at sun.misc.Unsafe.park(Native Method)
vim /application/tomcat/bin/catalina.sh
97 CATALINA_OPTS="$CATALINA_OPTS ????????????????java内置变量,修改java启动参数
98 -Dcom.sun.management.jmxremote ????????????????????????开启tomcat远程监控监控功能
99 -Dcom.sun.management.jmxremote.port=12345????????????????监控的端口信息
100 -Dcom.sun.management.jmxremote.authenticate=false????????远程监控的认证信息
101 -Dcom.sun.management.jmxremote.ssl=false ????????????????https功能是否开启
102 -Djava.rmi.server.hostname=10.0.0.7"????????????????????远程监听的主机IP地址
?
97 CATALINA_OPTS="$CATALINA_OPTS
98 -Dcom.sun.management.jmxremote
99 -Dcom.sun.management.jmxremote.port=12345
100 -Dcom.sun.management.jmxremote.authenticate=false
101 -Dcom.sun.management.jmxremote.ssl=false
102 -Djava.rmi.server.hostname=10.0.0.7"
扩展:java内置变量去哪查看(-D后面接的就是java内置变量)
[root@web01 bin] # ps -ef | grep java
root 2542 1 0 08:00 pts/0 00:00:11 /application/jdk/bin/java -Djava.util.logging.config.file=/application/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=12345
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-Djava.rmi.server.hostname=10.0.0.7
-Djava.endorsed.dirs=/application/tomcat/endorsed -classpath /application/tomcat/bin/bootstrap.jar:/application/tomcat/bin/tomcat-juli.jar
-Dcatalina.base=/application/tomcat
-Dcatalina.home=/application/tomcat
-Djava.io.tmpdir=/application/tomcat/temp org.apache.catalina.startup.Bootstrap start
root 7534 2379 0 09:15 pts/0 00:00:00 grep --color=auto java
?
[root@web01 jpress]# cat /etc/nginx/conf.d/tomcat.conf
server {
listen 80;
server_name java.oldboy.com;
client_max_body_size 10m;
root /application/tomcat/webapps;
location / {
index index.jsp index.html index.htm;
}
location ~ \.jsp$ {
proxy_pass 127.0.0.1:8080;
}
}
upstream tomcat {
?server 10.0.0.7:8080;
?server 10.0.0.7:8081;
?server 10.0.0.8:8080;
}
server ??{
listen 80;
server_name tomcat.oldboy.com;
location / {
proxy_pass http://tomcat ;
}
}
因为tomcat占用的是本身的swap空间,不会占用系统内存,针对这个情况,做如下解决
内核对应的目录在:/proc/sys/目录下
内核对应的文件在: /proc/sys/vm/swappiness
[root@web01 sys] # vim /etc/sysctl.conf
# sysctl settings are defined through files in
vm.swappiness =0????????????????????????修改为0,不使用swap空间,优先使用物理内存
[root@web01 sys] # sysctl -p
vm.swappiness = 0
[root@web01 sys] #
vmstat/top/ps aux
H????????显示进程下面的详细线程信息
p????????指定单独的进程信息
?
[root@web01 sys] # echo ‘obase=16;2544‘| bc
9F0
[root@web01 sys] #
?
将上面的信息查出来发给研发分析问题原因
[root@web01 sys] # jmap -dump:format=b,file=/tmp/aa.bin 2542
Dumping heap to /tmp/aa.bin ...
Heap dump file created
[root@web01 sys] #
?
[root@web01 sys] # cd /application/tomcat/conf/
[root@web01 conf] # vim server.xml
22 <Server port="8005" shutdown="SHUTDOWN">????????这行进行修改
94 <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />????apache和tomcat连接的端口
注意:如果你使用的不是apache,建议将他给关闭
让普通用户的权限来进行运行服务
[root@web01 conf] # cat /application/tomcat/conf/web.xml
<init-param>
<param-name>listings</param-name>
<param-value>false</param-value>????????????默认false,如果是比较老的版本是开启的
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
[root@web01 conf] # cat /application/tomcat/conf/web.xml
<error-page>
<error-code>403</error-code>
<location>/forbidden.jsp</location>
</error-page>
<error-page>
<error-code>404</error-code>
<location>/notfound.jsp</location>
</error-page>
<error-page>
<error-code>500</error-code>
<location>/systembusy.jsp</location>
</error-page>
[root@web01 conf] # vim /application/tomcat/conf/server.xml
<Connector port="8080" protocol="org.apache.coyote.http11.Http11AprProtocol"
server="nginx-1.16.1"????????????????修改为nginx-1.16.1
maxThreads="500"
minSpareThreads="10"
connectionTimeout="20000"
redirectPort="8443" />
<!-- A "Connector" using the shared thread pool-->
<Context path="" docBase="/home/work/tomcat" debug="0"
reloadable="false" crossContext="true">
<Valve className="org.apache.catalina.valves.RemoteAddrValve"
allow="61.148.18.138,61.135.165.*" deny="*.*.*.*"/>
将权限更改为700,默认755,8.5版本以后就默认是700
[root@web01 conf] # vim /application/tomcat/conf/server.xml
<Valve className="org.apache.catalina.valves.AccessLogValve"
directory="logs" ?prefix="localhost_access_log."
suffix=".txt"
pattern="%h %l %u %t %r %s %b %{Referer}i %{User-Agent}i %D" resolveHosts="false"/>
?
<Connector port="8080" protocol="org.apache.coyote.http11.Http11AprProtocol"
70 server="nginx-1.16.1"
71 connectionTimeout="20000"
72 redirectPort="8443" />
?
路径:????C:\Users\liangyuxing\Desktop\apache-jmeter-5.2.1\bin\jmeter.bat
<Connector port="8080" protocol="org.apache.coyote.http11.Http11AprProtocol"
70 server="nginx-1.16.1"
71 maxThreads="500"????????????????设置线程的最大线程数量
72 minSpareThreads="10"????????????空闲时候最小的线程数量
73 connectionTimeout="20000"
74 redirectPort="8443" />
?
标签:情况 OLE 启动命令 version 使用率 process nal ppi 负载
原文地址:https://www.cnblogs.com/liangyuxing/p/12076631.html