技术流ken

运维拯救世界

DAY17: 课堂记录-tomcat –技术流ken

tomcat安装

 

第一步:官网下载安装包

https://tomcat.apache.org/

 

第二步:上传安装包

[root@ken ~]# rz

[root@ken ~]# ls
apache-tomcat-9.0.17.zip fuhai-jpress-alpha.zip
[root@ken ~]#

 

第三步:解压安装包

[root@ken ~]# unzip apache-tomcat-9.0.17.zip

 

第四步:移动文件到/usr/local

[root@ken ~]# mv apache-tomcat-9.0.17 /usr/local/tomcat

 

第五步:加执行权限

[root@ken local]# chmod -R +x tomcat/

 

第六步:下载java环境(jdk)

[root@ken bin]# yum install java -y   #java-1.8.0-openjdk

 

第七步:启动tomcat

[root@ken bin]# ./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
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Tomcat started.

 

第八步:检测端口

[root@ken bin]# ss -tnl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:22 *:*
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 1 ::ffff:127.0.0.1:8005 :::*
LISTEN 0 100 :::8009 :::*
LISTEN 0 100 :::8080 :::*
LISTEN 0 128 :::80 :::*
LISTEN 0 128 :::22 :::*
LISTEN 0 100 ::1:25 :::*

 

第九步:浏览器访问

ip:8080

 

第十步:关闭tomcat

[root@ken bin]# ./shutdown.sh
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar

 

 

tomcat网站根目录

 

webapps

 

tomcat日志

 

logs/catalina.out

tomcat主配置文件

 

[root@ken tomcat]# vim conf/server.xml

 

<Server port=”8005″ shutdown=”SHUTDOWN”>

<Connector port=”8080″ protocol=”HTTP/1.1″

<Connector port=”8009″ protocol=”AJP/1.3″ redirectPort=”8443″ />

<Host name=”localhost” appBase=”webapps”

 

8005端口接收shutdown指令

[root@ken tomcat]# telnet 127.0.0.1 8005
Trying 127.0.0.1…
Connected to 127.0.0.1.
Escape character is ‘^]’.
SHUTDOWN
Connection closed by foreign host.
[root@ken tomcat]#
[root@ken tomcat]#
[root@ken tomcat]# ss -tnl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:22 *:*
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 128 :::80 :::*
LISTEN 0 128 :::22 :::*
LISTEN 0 100 ::1:25 :::*

 

 

tomcat多实例部署-三台

 

第一步:复制两份tomcat文件

[root@ken local]# ls
bin etc games include lib lib64 libexec sbin share src tomcat
[root@ken local]# cp tomcat tomcat1 -a
[root@ken local]# cp tomcat tomcat2 -a
[root@ken local]# ls
bin etc games include lib lib64 libexec sbin share src tomcat tomcat1 tomcat2

 

第二步:修改tomcat1端口

只需要修改两处:

8005–》8006

8080–》8081

 

第三步:修改tomcat2端口

只需要修改两处:

8005–》8007

8080–》8082

 

第四步:启动各个tomcat实例

[root@ken local]# tomcat/bin/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
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Tomcat started.
[root@ken local]# tomcat1/bin/startup.sh
Using CATALINA_BASE: /usr/local/tomcat1
Using CATALINA_HOME: /usr/local/tomcat1
Using CATALINA_TMPDIR: /usr/local/tomcat1/temp
Using JRE_HOME: /usr
Using CLASSPATH: /usr/local/tomcat1/bin/bootstrap.jar:/usr/local/tomcat1/bin/tomcat-juli.jar
Tomcat started.
[root@ken local]# tomcat2/bin/startup.sh
Using CATALINA_BASE: /usr/local/tomcat2
Using CATALINA_HOME: /usr/local/tomcat2
Using CATALINA_TMPDIR: /usr/local/tomcat2/temp
Using JRE_HOME: /usr
Using CLASSPATH: /usr/local/tomcat2/bin/bootstrap.jar:/usr/local/tomcat2/bin/tomcat-juli.jar
Tomcat started.

 

第五步:查看端口

[root@ken local]# ss -tnl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:22 *:*
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 1 ::ffff:127.0.0.1:8005 :::*
LISTEN 0 100 :::8009 :::*
LISTEN 0 100 :::8080 :::*
LISTEN 0 128 :::80 :::*
LISTEN 0 100 :::8081 :::*
LISTEN 0 100 :::8082 :::*
LISTEN 0 128 :::22 :::*
LISTEN 0 100 ::1:25 :::*

 

第六步:访问网站

 

tomcat集群部署

 

nginx服务器:192.168.64.5

tomcat集群: 192.168.64.4

 

第一步:部署tomcat后端节点

 

第二步:编辑nginx配置文件

upstream ken {
server 192.168.64.4:8080 weight=2 max_fails=2 fail_timeout=2;
server 192.168.64.4:8081 weight=4 max_fails=2 fail_timeout=2;
server 192.168.64.4:8082 weight=1 max_fails=2 fail_timeout=2;

}

 

location / {
proxy_pass http://ken;
}

 

第三步:检测nginx配置并启动

[root@ken yum.repos.d]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
[root@ken yum.repos.d]# systemctl restart nginx

 

第四步:浏览器访问

访问的时候nginx服务器

 

tomcat上线jpress博客系统

 

第一步:下载jpress

https://gitee.com/fuhai/jpress/blob/alpha/wars/jpress-web-newest.war

 

第二步:上传软件包并解压

[root@ken ROOT]# ls
fuhai-jpress-alpha.zip

[root@ken ROOT]# unzip fuhai-jpress-alpha.zip

 

第三步:复制

[root@ken ROOT]# cp jpress/wars/jpress-web-newest.war .
[root@ken ROOT]# ls
fuhai-jpress-alpha.zip jpress jpress-web-newest.war

 

第四步:解压jpress-web-newest.war

[root@ken ROOT]# unzip jpress-web-newest.war

 

第五步:浏览器访问

输入ip:8080/jpress

 

第六步:下载数据库并启动

[root@ken ROOT]# yum install mariadb-server -y

[root@ken ROOT]# systemctl restart mariadb

 

 

第七步:创建数据库和用户

[root@ken ROOT]# mysql -uroot
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.60-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

MariaDB [(none)]> create database ken;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> grant all on *.* to ken@’localhost’ identified by ‘123’;
Query OK, 0 rows affected (0.00 sec)

 

第八步:浏览器输入数据库相关的库和用户

 

第九步:重启tomcat

[root@ken bin]# ./shutdown.sh
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
[root@ken bin]# ./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
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Tomcat started.

 

第十步:再次访问浏览器

就可以访问了

 

9 thoughts on “DAY17: 课堂记录-tomcat –技术流ken

  1. Nice post. I study something more challenging on different blogs everyday. It is going to always be stimulating to learn content from other writers and practice a little bit something from their store. I抎 want to use some with the content material on my blog whether you don抰 mind. Natually I抣l provide you with a link on your net blog. Thanks for sharing.

  2. I would like to get across my gratitude for your generosity for people who actually need help on this one study. Your very own commitment to passing the message all around had become quite helpful and have continuously empowered individuals like me to achieve their pursuits. Your personal helpful hints and tips implies so much a person like me and additionally to my fellow workers. Thank you; from each one of us.

  3. I am commenting to let you know of the beneficial discovery my friend’s princess obtained studying yuor web blog. She picked up a lot of issues, not to mention how it is like to have an amazing coaching mood to make the others without problems gain knowledge of some hard to do issues. You actually exceeded my desires. Thank you for supplying these insightful, trustworthy, informative and easy tips about your topic to Kate.

  4. I enjoy you because of all of your labor on this site. My mom delights in carrying out research and it’s easy to see why. I learn all of the compelling form you give practical ideas on the blog and even recommend contribution from website visitors about this situation and our own daughter is actually starting to learn a lot of things. Take pleasure in the rest of the year. You are carrying out a very good job.

  5. My husband and i have been really thankful Edward could conclude his analysis out of the precious recommendations he made from your own site. It’s not at all simplistic to simply choose to be giving out facts that people today might have been making money from. So we figure out we have you to thank because of that. The main explanations you have made, the straightforward site menu, the relationships you can assist to foster – it is many superb, and it’s really making our son and us consider that the subject is awesome, which is pretty indispensable. Many thanks for all the pieces!

  6. I intended to draft you the very little note so as to thank you once again relating to the marvelous methods you’ve shown here. It’s really surprisingly open-handed of you to provide openly all some people could have marketed as an e-book to help with making some bucks for themselves, chiefly seeing that you might have done it if you ever desired. Those creative ideas additionally acted to provide a easy way to recognize that the rest have the same fervor just as my personal own to understand more and more on the topic of this condition. I am certain there are a lot more fun sessions in the future for individuals that looked over your site.

  7. My husband and i got very excited Peter could complete his homework from the ideas he came across from your own web pages. It’s not at all simplistic to just choose to be giving out tactics which some others have been trying to sell. And we consider we have got the writer to appreciate for that. The entire explanations you’ve made, the simple site navigation, the friendships you assist to engender – it’s got many awesome, and it’s leading our son in addition to our family recognize that that matter is amusing, and that’s particularly indispensable. Many thanks for the whole thing!

  8. Thank you for all of your effort on this site. My mother takes pleasure in setting aside time for investigations and it is easy to understand why. Many of us hear all regarding the lively medium you produce functional thoughts on this web site and as well as foster contribution from visitors on this matter plus our own girl is without a doubt learning a lot of things. Have fun with the rest of the new year. You have been performing a great job.

  9. Thank you so much for giving everyone an exceptionally remarkable possiblity to read critical reviews from this blog. It really is very pleasurable and as well , stuffed with amusement for me personally and my office mates to search the blog at minimum 3 times per week to see the latest items you have. Not to mention, I’m certainly motivated for the excellent principles you give. Certain 2 tips in this posting are indeed the most effective we have all ever had.

发表评论

邮箱地址不会被公开。