[root@localhost ~]# mount.cifs //192.168.100.10/tomcat /mnt //將存有tomcat的工具掛載到mnt目錄
Password for root@//192.168.100.10/tomcat:
[root@localhost ~]# cd /mnt //進(jìn)入mnt目錄
[root@localhost mnt]# ls //查看是否成功掛載
12D18CFCD6599AFF0445766ACC4CA231C5025773.torrent apache-tomcat-9.0.16.tar.gz
apache-jmeter-5.1 jdk-8u201-linux-x64.rpm
apache-jmeter-5.1.zip tomcat優(yōu)化壓測.jmx
[root@localhost mnt]# rpm -ivh jdk-8u201-linux-x64.rpm //安裝jdk包
警告:jdk-8u201-linux-x64.rpm: 頭V3 RSA/SHA256 Signature, 密鑰 ID ec551f03: NOKEY
準(zhǔn)備中... ################################# [100%]
正在升級/安裝...
1:jdk1.8-2000:1.8.0_201-fcs ################################# [100%]
Unpacking JAR files...
tools.jar...
plugin.jar...
javaws.jar...
deploy.jar...
rt.jar...
jsse.jar...
charsets.jar...
localedata.jar...
[root@localhost mnt]# cd /usr/java/ //進(jìn)入Java安裝目錄
[root@localhost java]# ls
default jdk1.8.0_201-amd64 latest
[root@localhost java]# cd jdk1.8.0_201-amd64/ //進(jìn)入jdk目錄
[root@localhost jdk1.8.0_201-amd64]# ls
bin jre README.html THIRDPARTYLICENSEREADME.txt
COPYRIGHT lib release
include LICENSE src.zip
javafx-src.zip man THIRDPARTYLICENSEREADME-JAVAFX.txt
[root@localhost jdk1.8.0_201-amd64]# pwd //查看當(dāng)前位置
/usr/java/jdk1.8.0_201-amd64 //復(fù)制此條目
[root@localhost jdk1.8.0_201-amd64]# vim /etc/profile //編輯profile文件進(jìn)行參數(shù)更新
export JAVA_HOME=/usr/java/jdk1.8.0_201-amd64 //聲明變量位置
export CLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar //聲明CLASS變量
export PATH=$JAVA_HOME/bin:$PATH //聲明環(huán)境變量
:qw
[root@localhost jdk1.8.0_201-amd64]# source /etc/profile //執(zhí)行profile文件
[root@localhost jdk1.8.0_201-amd64]# java -version //查看Java版本,測試Java是否安裝成功
java version "1.8.0_201"
Java(TM) SE Runtime Environment (build 1.8.0_201-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.201-b09, mixed mode)
root@localhost jdk1.8.0_201-amd64]# cd /mnt
[root@localhost mnt]# ls
12D18CFCD6599AFF0445766ACC4CA231C5025773.torrent apache-tomcat-9.0.16.tar.gz
apache-jmeter-5.1 jdk-8u201-linux-x64.rpm
apache-jmeter-5.1.zip tomcat優(yōu)化壓測.jmx
[root@localhost mnt]# tar zxvf apache-tomcat-9.0.16.tar.gz -C /usr/local/ //解壓tomcat文件到/usr/local目錄
[root@localhost mnt]# cd /usr/local/
[root@localhost local]# ls
apache-tomcat-9.0.16 bin etc games include lib lib64 libexec sbin share src
[root@localhost local]# mv apache-tomcat-9.0.16/ tomcat //將文件更名
[root@localhost local]# cd tomcat/ //進(jìn)入tomcat目錄
[root@localhost tomcat]# ls
bin conf lib logs README.md RUNNING.txt webapps
BUILDING.txt CONTRIBUTING.md LICENSE NOTICE RELEASE-NOTES temp work
[root@localhost tomcat]# cd bin //進(jìn)入命令存放目錄
[root@localhost bin]# ls
bootstrap.jar commons-daemon-native.tar.gz makebase.sh tomcat-juli.jar
catalina.bat configtest.bat setclasspath.bat tomcat-native.tar.gz
catalina.sh configtest.sh setclasspath.sh tool-wrapper.bat
catalina-tasks.xml daemon.sh shutdown.bat tool-wrapper.sh
ciphers.bat digest.bat shutdown.sh version.bat
ciphers.sh digest.sh startup.bat version.sh
commons-daemon.jar makebase.bat startup.sh
[root@localhost bin]# ln -s /usr/local/tomcat/bin/startup.sh /usr/bin/ //將軟件啟動腳本建立軟連接到系統(tǒng)命令目錄下
[root@localhost bin]# ln -s /usr/local/tomcat/bin/shutdown.sh /usr/bin/ //將關(guān)閉軟件腳本建立軟連接到系統(tǒng)命令目錄下
[root@localhost bin]# systemctl stop firewalld.service //關(guān)閉防火墻
[root@localhost bin]# setenforce 0 //關(guān)閉增強(qiáng)性安全功能
[root@localhost bin]# startup.sh //使用命令啟動tomcat服務(wù)(可以使用TAB鍵補(bǔ)全哦)
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr/java/jdk1.8.0_201-amd64
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Tomcat started.
[root@localhost bin]# netstat -ntap | grep 8080 //使用命令查看端口是否開啟
tcp6 0 0 :::8080 :::* LISTEN 3137/java
[root@localhost bin]# shutdown.sh //關(guān)閉軟件
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr/java/jdk1.8.0_201-amd64
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.j
[root@localhost security]# cd /usr/java/jdk1.8.0_201-amd64/jre/lib/security/ //進(jìn)入Java目錄
[root@localhost security]# vim java.security //修改jdk參數(shù),優(yōu)化tomcat啟動速度
...//省略部分內(nèi)容...
# In addition, if "file:/dev/random" or "file:/dev/urandom" is
# specified, the "NativePRNG" implementation will be more preferred than
# SHA1PRNG in the Sun provider.
#
securerandom.source=file:/dev/urandom //random更改為urandom優(yōu)化tomcat啟動速度
...//省略部分內(nèi)容...
:wq
[root@localhost security]# startup.sh //再次啟動,啟動速度加快
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr/java/jdk1.8.0_201-amd64
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Tomcat started.
[root@localhost security]# yum install -y bind //安裝DNSfuwu
Loaded plugins: fastestmirror, langpacks
base | 3.6 kB 00:00:00
extras | 2.9 kB 00:00:00
...//省略部分內(nèi)容...
Installed:
bind.x86_64 32:9.11.4-9.P2.el7
...//省略部分內(nèi)容...
Complete!
[root@localhost conf]# vim /etc/named.conf //編輯修改DNS服務(wù)主配置文件
...//省略部分內(nèi)容...
options {
listen-on port 53 { any; };
listen-on-v6 port 53 { ::1; };
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";
recursing-file "/var/named/data/named.recursing";
secroots-file "/var/named/data/named.secroots";
allow-query { any; };
...//省略部分內(nèi)容...
:wq
[root@localhost conf]# vim /etc/named.rfc1912.zones //編輯修改DNS服務(wù)區(qū)域配置文件
...//省略部分內(nèi)容...
zone "kgc.com" IN {
type master;
file "kgc.com.zone";
allow-update { none; };
};
...//省略部分內(nèi)容...
:wq
[root@localhost conf]# cd /var/named/ //進(jìn)入DNS服務(wù)區(qū)域數(shù)據(jù)文件存放目錄
[root@localhost named]# cp -p named.localhost kgc.com.zone //復(fù)制區(qū)域數(shù)據(jù)文件模板
[root@localhost named]# vim kgc.com.zone //編輯修改DNS服務(wù)區(qū)域數(shù)據(jù)配置文件
$TTL 1D
@ IN SOA @ rname.invalid. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS @
A 127.0.0.1
www IN A 192.168.144.133
:wq
[root@localhost named]# systemctl start named //啟動DNS服務(wù)
[root@localhost conf]# vim /etc/named.rfc1912.zones //編輯DNS服務(wù)區(qū)域配置文件
...//省略部分內(nèi)容...
zone "kgc.com" IN {
type master;
file "kgc.com.zone";
allow-update { none; };
};
zone "accp.com" IN {
type master;
file "accp.com.zone";
allow-update { none; };
};
...//省略部分內(nèi)容...
:wq
[root@localhost conf]# cd /var/named/ //進(jìn)入?yún)^(qū)域數(shù)據(jù)文件目錄
[root@localhost named]# cp -p kgc.com.zone accp.com.zone //復(fù)制DNS服務(wù)區(qū)域數(shù)據(jù)配置文件
[root@localhost named]# systemctl restart named //重啟DNS服務(wù)
[root@localhost named]# cd ~
[root@localhost ~]# cd /usr/local/tomcat/ //進(jìn)入tomcat目錄文件
[root@localhost tomcat]# ls
bin conf lib logs README.md RUNNING.txt webapps
BUILDING.txt CONTRIBUTING.md LICENSE NOTICE RELEASE-NOTES temp work
[root@localhost tomcat]# cd webapps/ //進(jìn)入服務(wù)網(wǎng)頁站點(diǎn)
[root@localhost webapps]# ls
docs examples host-manager manager ROOT
[root@localhost webapps]# mkdir kgc //創(chuàng)建目錄
[root@localhost webapps]# echo "this is kgc web" > kgc/index.jsp //編輯主頁文件
[root@localhost webapps]# mkdir accp //創(chuàng)建目錄
[root@localhost webapps]# echo "this is accp web" > accp/index.jsp //編輯主頁文件
[root@localhost webapps]# tree accp/ kgc/ //使用命令以樹形結(jié)構(gòu)查看目錄
accp/
└── index.jsp
kgc/
└── index.jsp
[root@localhost webapps]# cd ../conf/ //進(jìn)入tomcat配置文件存放目錄
[root@localhost conf]# ls
Catalina catalina.properties jaspic-providers.xml logging.properties tomcat-users.xml web.xml
catalina.policy context.xml jaspic-providers.xsd server.xml tomcat-users.xsd
[root@localhost conf]# vim server.xml //編輯配置文件,編輯虛擬主機(jī)配置
...//省略部分內(nèi)容...
...//省略部分內(nèi)容...
:wq
[root@localhost conf]# shutdown.sh //關(guān)閉tomcat服務(wù)
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr/java/jdk1.8.0_201-amd64
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
[root@localhost conf]# startup.sh //啟動tomcat服務(wù)
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr/java/jdk1.8.0_201-amd64
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Tomcat started.
【noCompressionUserAgents="gozilla, traviata"】對于以下的瀏覽器,不啟用壓縮
[root@localhost conf]# vim server.xml //編輯tomcat配置文件
...//省略部分內(nèi)容...