1.Linux安装JDK
1.安装位置
2.安装包
1.jdk-8u171-linux-x64.rpm
2.下载地址https://www.oracle.com/cn/java/technologies/downloads/
3.安装步骤
1.将安装包上传到虚拟机中
[ root@localhost opt]
jdk-8u171-linux-x64.rpm
2.执行安装命令
[ root@localhost opt]
准备中.. .
正在升级/安装.. .
1 :jdk1.8-2000:1.8.0_171-fcs
Unpacking JAR files.. .
tools.jar.. .
plugin.jar.. .
javaws.jar.. .
deploy.jar.. .
rt.jar.. .
jsse.jar.. .
charsets.jar.. .
localedata.jar.. .
3.查看安装目录
[ root@localhost opt]
jdk1.8-1.8.0_171-fcs.x86_64
[ root@localhost opt]
/usr
/usr/java
.. .
[ root@localhost ~]
[ root@localhost java]
default jdk1.8.0_171-amd64 latest
[ root@localhost java]
[ root@localhost default]
bin javafx-src.zip man THIRDPARTYLICENSEREADME-JAVAFX.txt
COPYRIGHT jre README.html THIRDPARTYLICENSEREADME.txt
db lib release
include LICENSE src.zip
4.配置环境变量
[ root@localhost default]
export JAVA_HOME = /usr/java/default
export PATH = $PATH : $JAVA_HOME /bin
export CLASSPATH = .
[ root@localhost default]
5.通过yum安装
yum -y install java-1.8.0-openjdk*
4.测试
[ root@localhost /]
java version "1.8.0_171"
Java( TM) SE Runtime Environment ( build 1.8 .0_171-b11)
Java HotSpot( TM) 64 -Bit Server VM ( build 25.171 -b11, mixed mode)
5.卸载
[ root@localhost /]
[ root@localhost /]
[ root@localhost /]
[ root@localhost /]
[ root@localhost /]
2.Linux安装Erlang
1.安装位置
2.安装包
1.erlang-21.3-1.el7.x86_64.rpm
2.下载地址https://packagecloud.io/rabbitmq/erlang
3.安装步骤
1.将安装包上传到虚拟机中
2.执行安装命令
3.查看安装目录
4.测试
3.Linux安装Tomcat
1.安装位置
2.压缩包
1.apache-tomcat-8.5.60.tar.gz
2.下载地址https://tomcat.apache.org/download-80.cgi
3.安装步骤
1.将压缩包上传到虚拟机中
[ root@localhost tomcat]
apache-tomcat-8.5.60.tar.gz
2.执行解压命令
[ root@localhost tomcat]
apache-tomcat-8.5.60/conf/
apache-tomcat-8.5.60/conf/catalina.policy
.. .
[ root@localhost tomcat]
apache-tomcat-8.5.60 apache-tomcat-8.5.60.tar.gz
3.启动tomcat
[ root@localhost tomcat]
[ root@localhost apache-tomcat-8.5.60]
[ root@localhost bin]
Using CATALINA_BASE: /opt/tomcat/apache-tomcat-8.5.60
Using CATALINA_HOME: /opt/tomcat/apache-tomcat-8.5.60
Using CATALINA_TMPDIR: /opt/tomcat/apache-tomcat-8.5.60/temp
Using JRE_HOME: /usr/java/default
Using CLASSPATH: /opt/tomcat/apache-tomcat-> 8.5 .60/bin/bootstrap.jar:/opt/tomcat/apache-tomcat-8.5.60/bin/tomcat-juli.jar
Using CATALINA_OPTS:
Tomcat started.
[ root@localhost bin]
84071 Jps
64888 Bootstrap
[ root@localhost bin]
HTTP/1.1 200
Content-Type: text/html; charset = UTF-8
Transfer-Encoding: chunked
Date: Mon, 24 Oct 2022 22 :24:18 GMT
4.关闭Linux防火墙和selinux
5.查看tomcat启动日志
[ root@localhost apache-tomcat-8.5.60]
bin CONTRIBUTING.md logs RELEASE-NOTES webapps
BUILDING.txt lib NOTICE RUNNING.txt work
conf LICENSE README.md temp
[ root@localhost apache-tomcat-8.5.60]
[ root@localhost logs]
catalina.2022-10-25.log localhost.2022-10-25.log
catalina.out localhost_access_log.2022-10-25.txt
host-manager.2022-10-25.log manager.2022-10-25.log
[ root@localhost logs]
[ root@localhost logs]
[ root@localhost logs]
[ root@localhost logs]
4.启动多个Tomcat服务器
5.部署项目
1.进入tomcat
服务器的webapps
目录 2.创建一个自定义文件夹 3.进入文件夹传入项目资源 4.通过路径访问资源项目
4.Linux安装MySQL
1.安装位置
1./opt/mysql5.7
2.安装包
1.mysql57-community-release-el7-9.noarch.rpm
2.下载地址https://downloads.mysql.com/archives/community/
2.安装步骤
1.通过wget下载rpm安装包
[ root@localhost tomcat]
2.通过rpm安装MySQL
[ root@localhost mysql5.7]
3.通过yum安装mysql(一般使用yum安装)
[ root@localhost mysql5.7]
3.启动MySQL
[ root@localhost mysql5.7]
[ root@localhost mysql5.7]
[ root@localhost mysql5.7]
[ root@localhost mysql5.7]
mysql> set global validate_password_policy = 0 ;
mysql> set global validate_password_length = 4 ;
mysql> alter user root@'localhost' identified by 'root' ;
ALTER USER 'root' @'%' IDENTIFIED WITH mysql_native_password BY '123456' ;
4.设置root允许远程访问
mysql> use mysql;
mysql> update user set host = '%' where user = 'root' ;
mysql> flush privileges;
5.关闭Linux防火墙
[ root@localhost mysql5.7]
● mysqld.service - MySQL Server
Loaded: loaded ( /usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: inactive ( dead)
Docs: man:mysqld( 8 )
http://dev.mysql.com/doc/refman/en/using-systemd.html
6.Navicat连接MySQL
7.远程访问MySQL
5.Linux安装Redis
1.下载安装包
2.安装位置
3.安装gcc
[ root@localhost gcc]
4.解压,编译,安装
[ root@localhost redis]
[ root@localhost redis-3.2.9]
[ root@localhost redis-3.2.9]
[ root@localhost redis-3.2.9]
5.备份配置文件
[ root@localhost redis-3.2.9]
[ root@localhost redis-3.2.9]
6.启动redis
1.方式一:前台启动
(不能关闭窗口,否则服务关闭)
[ root@localhost redis-3.2.9]
[ root@localhost redis-3.2.9]
[ root@localhost redis-3.2.9]
[ root@localhost redis-3.2.9]
[ root@localhost redis-3.2.9]
[ root@localhost redis-3.2.9]
[ root@localhost redis-3.2.9]
127.0 .0.1:6379 > shutdown
127.0 .0.1:6379 > exit
2.方式二:后台启
动(守护进程,可以关闭窗口)
[ root@node1 redis-3.2.9]
[ root@localhost redis-3.2.9]
[ root@node1 redis-3.2.9]
[ root@node1 redis-3.2.9]
6.Linux安装RabbitMQ
1.需要先安装Erlang
2.Erlang
和RabbitMQ
版本关系
1.安装位置
2.安装包
1.rabbitmq-server-3.8.8-1.el7.noarch.rpm
2.下载地址https://github.com/rabbitmq/rabbitmq-server/releases/tag/v3.10.18
3.安装步骤
1.通过rpm安装RabbitMQ
2.通过yum安装RabbitMQ(未测试成功)
1.推荐使用yum
方式进行安装,方便快速,且自动解决erlang
语言依赖关系 2.方式一curl -s https://packagecloud.io/install/repositories/rabbitmq/rabbitmq-server/script.rpm.sh | sudo bash
1.使用官方提供的安装脚本 2.此脚本会直接添加yum
源,并安装最新版的RabbitMQ Server
3.方式二
rpm --import https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.as
rpm --import https: //packagecloud.io/rabbitmq/erlang/gpgkey
rpm --import https://packagecloud.io/rabbitmq/rabbitmq-server/gpgkey
[ rabbitmq_erlang]
name = rabbitmq_erlang
baseurl = https://packagecloud.io/rabbitmq/erlang/el/7/$basearch
repo_gpgcheck = 1
gpgcheck = 1
enabled = 1
gpgkey = https://packagecloud.io/rabbitmq/erlang/gpgkey
https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc
sslverify = 1
sslcacert = /etc/pki/tls/certs/ca-bundle.crt
metadata_expire = 300
[ rabbitmq_erlang-source]
name = rabbitmq_erlang-source
baseurl = https://packagecloud.io/rabbitmq/erlang/el/7/SRPMS
repo_gpgcheck = 1
gpgcheck = 0
enabled = 1
gpgkey = https://packagecloud.io/rabbitmq/erlang/gpgkey
sslverify = 1
sslcacert = /etc/pki/tls/certs/ca-bundle.crt
metadata_expire = 300
[ rabbitmq_server]
name = rabbitmq_server
baseurl = https://packagecloud.io/rabbitmq/rabbitmq-server/el/7/$basearch
repo_gpgcheck = 1
gpgcheck = 1
enabled = 1
gpgkey = https://packagecloud.io/rabbitmq/rabbitmq-server/gpgkey
https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc
sslverify = 1
sslcacert = /etc/pki/tls/certs/ca-bundle.crt
metadata_expire = 300
[ rabbitmq_server-source]
name = rabbitmq_server-source
baseurl = https://packagecloud.io/rabbitmq/rabbitmq-server/el/7/SRPMS
repo_gpgcheck = 1
gpgcheck = 0
enabled = 1
gpgkey = https://packagecloud.io/rabbitmq/rabbitmq-server/gpgkey
sslverify = 1
sslcacert = /etc/pki/tls/certs/ca-bundle.crt
metadata_expire = 300
yum install rabbitmq-server-3.7.5
1.手动设置yum
源进行安装 2.安装指定版本而不是最新版本
3.启动/查看/停止RabbitMQ
1.手动启动[ root@localhost rabbitmq3.8.8]
或
/sbin/service rabbitmq-server start
2.设置开机自动启动chkconfig rabbitmq-server on
或
systemctl enable rabbitmq-server
3.查看状态/sbin/service rabbitmq-server status
或
systemctl status rabbitmq-server
4.停止服务/sbin/service rabbitmq-server stop
或
systemctl stop rabbitmq-server
4.开启web管理插件
5.安装延迟队列插件
1.下载地址:https://www.rabbitmq.com/community-plugins.html
2.插件:rabbitmq_delayed_message_exchange-3.8.0.ez
3.上传到Linux
服务器上 4.将该插件拷贝到RabbitMQ
的插件目录下,并进入该目录 5.安装延迟队列插件并重启RabbitMQ
4.测试
1.登陆
1.需要提前关闭Linux
防火墙 2.登陆网址:服务器ip:端口号15672
3.首次登陆会提示当前只能在虚拟机登陆 4.guest
账户无法通过该方式登陆,需要创建新用户后登陆
2.查看用户角色列表
[ root@localhost rabbitmq3.8.8]
3.创建用户并设置权限
1.创建账号密码rabbitmqctl add_user 账号 密码
2.设置用户角色rabbitmqctl set_user_tags 账号 角色
3.设置用户权限rabbitmqctl set_permissions [ -p < vhostpath> ] < user> < conf> < write> < read>
rabbitmqctl set_permissions -p "/" root ".*" ".*" ".*"
用户 user_root 具有 / 这个 virtual host 中所有资源的配置、写、读权限
4.成功登陆
5.RabbitMQ集群搭建
1.将上述erlang+rabbitmq
安装包scp
到远程服务器上(方法二:克隆,需要修改ip
) 2.按照上述安装方式重新安装erlang+rabbitmq
(三台服务器) 3.修改三台服务器的主机名称(名称自定义唯一即可),需要重启
生效
vim /etc/hostname
reboot
4.配置三台服务器节点的 hosts
文件,让各个节点都能互相识别对方 5.确保三台服务器节点的 cookie
文件使用的是同一个值
1.使用node1
节点,将其上的cookie
文件远程复制到其他两台节点上 scp / var / lib/ rabbitmq/ . erlang. cookie root@node2 : / var / lib/ rabbitmq/ . erlang. cookie
scp / var / lib/ rabbitmq/ . erlang. cookie root@node3 : / var / lib/ rabbitmq/ . erlang. cookie
6.三台服务器都启动 RabbitMQ
服务,同时启动 Erlang
虚拟机和 RbbitMQ
应用服务[ root@node1 ~ ] # rabbitmq- server - detached
7.节点node2
上执行以下命令
rabbitmqctl stop_app
rabbitmqctl reset
rabbitmqctl join_cluster rabbit@node1
rabbitmqctl start_app
8.节点node3
上执行以下命令
rabbitmqctl stop_app
rabbitmqctl reset
rabbitmqctl join_cluster rabbit@node1
rabbitmqctl start_app
9.查看集群状态rabbitmqctl cluster_status
10.搭建集群后需重新创建账号
,之前创建的账号失效,创建步骤参考上述文章
,创建的账号三台服务器都可用 11.解除集群节点
7.Linux系统下安装Jenkins
1.Jenkins
需要依赖JDK
,所以先安装JDK1.8
1.安装位置
2.安装包
1.jenkins.war
或jenkins-2.395-1.1.noarch.rpm
或jenkins-2.190.3-1.1.noarch.rpm
2.下载地址https://www.jenkins.io/zh/doc/pipeline/tour/getting-started/
或https://jenkins.io/zh/download
或https://mirrors.tuna.tsinghua.edu.cn/jenkins/redhat/?C=N&O=D
或https://repo.huaweicloud.com/jenkins/redhat-stable/
3.安装步骤
1.将压缩包上传到虚拟机中
[ root@192 jenkins]
jenkins.war nohup.out
[ root@localhost jenkins]
jenkins-2.190.3-1.1.noarch.rpm
2.执行启动命令
[ root@192 jenkins]
[ 2 ] 1674
[ root@192 jenkins]
1.注意:启动jenkins
时会将密码打印到控制台上,从页面进入时需要输入该密码
3.安装并修改参数
[ root@localhost jenkins]
[ root@localhost jenkins]
JENKINS_USER = "root"
JENKINS_PORT = "8888"
[ root@localhost jenkins]
1.如果采用rpm
安装方式则需要安装并修改参数 2.该方式需要注意jdk
的版本和jenkins
版本是否兼容
4.测试连接
4.卸载
rpm -e jenkins
rpm -ql jenkins
find / -iname jenkins | xargs -n 1000 rm -rf
8.Linux系统下安装Nginx
1.安装位置
2.安装包
1.nginx-release-centos-7-0.el7.ngx.noarch.rpm
/ nginx-1.24.0.tar.gz
2.yum
下载地址https://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
3.源码下载地址http://nginx.org/en/download.html
3.安装步骤
1.yum方式安装
[ root@192 ~]
wget https://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
rpm -ivh nginx-release-centos-7-0.el7.ngx.noarch.rpm
yum info nginx
yum --showduplicates list nginx | expand
yum install nginx
which nginx
2.rpm方式安装
wget https://nginx.org/packages/centos/7/x86_64/RPMS/nginx-1.20.2-1.el7.ngx.x86_64.rpm
rpm -ivh nginx-1.20.2-1.el7.ngx.x86_64.rpm
systemctl start nginx
systemctl status nginx
curl IP
3.源码方式安装
[ root@localhost nginx]
/opt/nginx
[ root@localhost nginx]
total 1088
-rw-r--r--. 1 root root 1112471 Jul 26 09:44 nginx-1.24.0.tar.gz
[ root@localhost ~]
[ root@localhost nginx]
[ root@localhost nginx]
total 1088
drwxr-xr-x. 8 1001 1001 158 Apr 10 21 :45 nginx-1.24.0
-rw-r--r--. 1 root root 1112471 Jul 26 09:44 nginx-1.24.0.tar.gz
[ root@localhost nginx]
[ root@localhost nginx-1.24.0]
auto CHANGES CHANGES.ru conf configure contrib html LICENSE man README src
[ root@localhost nginx-1.24.0]
[ root@localhost nginx-1.24.0]
[ root@localhost local]
/usr/local
[ root@localhost local]
bin etc games include lib lib64 libexec nginx sbin share src
[ root@localhost sbin]
/usr/local/nginx/sbin
[ root@localhost sbin]
[ root@localhost sbin]
root 20371 1 0 22 :23 ? 00:00:00 nginx: master process ./nginx
nobody 20372 20371 0 22 :23 ? 00:00:00 nginx: worker process
root 20374 17654 0 22 :25 pts/1 00:00:00 grep --color = auto nginx
[ root@localhost sbin]
[ root@localhost sbin]
success
[ root@localhost sbin]
success
[ root@localhost ~]
[ root@localhost ~]
[ Unit]
Description = nginx
After = network.target remote-fs.target nss-lookup.target
[ Service]
Type = forking
PIDFile = /usr/local/nginx/logs/nginx.pid
ExecStartPre = /usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf
ExecStart = /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
ExecReload = /usr/local/nginx/sbin/nginx -s reload
ExecStop = /usr/local/nginx/sbin/nginx -s stop
ExecQuit = /usr/local/nginx/sbin/nginx -s quit
PrivateTmp = true
[ Install]
wantedBy = multi-user.target
[ root@localhost ~]
4.安装fair模块
[ root@localhost fair_module]
/opt/nginx/fair_module
[ root@localhost fair_module]
nginx-upstream-fair-master.zip
[ root@localhost fair_module]
[ root@localhost fair_module]
[ root@localhost fair_module]
nginx-upstream-fair-master nginx-upstream-fair-master.zip
[ root@localhost nginx-1.24.0]
/opt/nginx/nginx-1.24.0
[ root@localhost nginx-1.24.0]
auto CHANGES.ru configure html Makefile objs src
CHANGES conf contrib LICENSE man README
[ root@localhost nginx]
/usr/local/nginx
/usr/local/nginx/sbin/nginx
/opt/nginx
/opt/nginx/nginx-1.24.0/objs/nginx
[ root@localhost nginx]
[ root@localhost nginx]
/usr/local/nginx/logs/nginx.pid
[ root@localhost nginx]
[ root@localhost nginx]
/opt/nginx/fair_module/nginx-upstream-fair-master
[ root@localhost nginx]
[ root@localhost nginx-1.24.0] ./configure --prefix = /usr/local/nginx --sbin-path= /usr/local/nginx/nginx --conf-path= /usr/local/nginx/conf/nginx.conf --pid-path= /usr/local/nginx/nginx.pid --add-module= /usr/local/nginx/nginx-upstream-fair-master
[ root@localhost nginx-1.24.0] make
[ root@localhost nginx]
[ root@localhost nginx]
4.配置文件
5.常用命令
./nginx
./nginx -s stop
./nginx -s quit
./nginx -s reload
firewall-cmd --zone = public --add-port= 80 /tcp --permanent
firewall-cmd --list-all
firewall-cmd -reload
systemctl disable firewalld.service
6.卸载
rpm -qa | grep nginx
rpm -e nginx-1.24.0-1.el7.ngx.x86_64
9.Linux系统下安装Keepalived
1.安装位置
1.默认安装位置:/usr/sbin/keepalived
2.安装包
3.安装步骤
1.yum方式安装
yum -y install keepalived
rpm -ql keepalived
4.配置文件
1.主配置文件:/etc/keepalived/keepalived.conf
5.常用命令
systemctl start keepalived
6.卸载
[ root@localhost keepalived]
keepalived-1.3.5-19.el7.x86_64
rpm -e keepalived-1.3.5-19.el7.x86_64
10.Linux系统下安装GitLab
1.安装位置
2.安装包
1.gitlab-ce-12.4.2-ce.0.el7.x86_64.rpm
2.下载地址
3.安装步骤
[ root@localhost ~]
[ root@localhost ~]
[ root@localhost ~]
[ root@localhost ~]
[ root@localhost ~]
[ root@localhost ~]
[ root@localhost ~]
[ root@localhost ~]
[ root@localhost ~]
[ root@localhost ~]
[ root@localhost ~]
[ root@localhost jenkins]
[ root@localhost jenkins]
external_url 'http://127.0.0.1:88'
nginx[ 'listen_port' ] = 88
[ root@localhost jenkins]
[ root@localhost jenkins]
[ root@localhost jenkins]
[ root@localhost jenkins]
4.配置文件
5.常用命令
6.卸载
Linux系统下SSM项目打包部署
Linux系统下SpringBoot项目打包部署
1.简单SpringBoot项目打包部署(未连接mysql)
1.配置文件
1.pom.xml<?xml version="1.0" encoding="UTF-8"?>
< project xmlns = " http://maven.apache.org/POM/4.0.0"
xmlns: xsi= " http://www.w3.org/2001/XMLSchema-instance"
xsi: schemaLocation= " http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" >
< modelVersion> 4.0.0</ modelVersion>
< groupId> org.example</ groupId>
< artifactId> SpringBootSimple</ artifactId>
< version> 1.0-SNAPSHOT</ version>
< packaging> jar</ packaging>
< properties>
< project.build.sourceEncoding> UTF-8</ project.build.sourceEncoding>
< maven.compiler.source> 1.8</ maven.compiler.source>
< maven.compiler.target> 1.8</ maven.compiler.target>
< start-class> com.wd.SpringBootSimpleApplication</ start-class>
</ properties>
< dependencies>
< dependency>
< groupId> org.springframework.boot</ groupId>
< artifactId> spring-boot-starter-web</ artifactId>
< version> 2.6.3</ version>
</ dependency>
</ dependencies>
< build>
< plugins>
< plugin>
< groupId> org.springframework.boot</ groupId>
< artifactId> spring-boot-maven-plugin</ artifactId>
< version> 2.6.3</ version>
< executions>
< execution>
< goals>
< goal> repackage</ goal>
</ goals>
</ execution>
</ executions>
</ plugin>
</ plugins>
</ build>
</ project>
application.yamlserver:
port: 8890
servlet:
context- path: / springboot_simple
2.启动类
package com. wd ;
import org. springframework. boot. SpringApplication ;
import org. springframework. boot. autoconfigure. SpringBootApplication ;
@SpringBootApplication
public class SpringBootSimpleApplication {
public static void main ( String [ ] args) {
SpringApplication . run ( SpringBootSimpleApplication . class , args) ;
}
}
3.接口
package com. wd. controller ;
import org. springframework. stereotype. Controller ;
import org. springframework. web. bind. annotation. RequestMapping ;
import org. springframework. web. bind. annotation. ResponseBody ;
@RequestMapping ( "/user" )
@Controller
public class UserController {
@RequestMapping ( "hello" )
@ResponseBody
public String hello ( ) {
return "Hello SpringBootSimple" ;
}
}
4.打包
1.首先刷新Maven 2.清空之前的target文件夹 3.将test禁用(因为打包时会默认执行test中的代码,如果测试代码没有问题才会打包,如果测试代码有问题则打包失败) 4.打包
5.部署
1.将jar包上传到Linux中 2.执行jar包
[ root@localhost springboot]
SpringBoot-1.0-SNAPSHOT.jar中没有主清单属性
pom.xml文件加入上述插件配置
[ root@localhost springboot]
. ____ _ __ _ _
/\ \ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | ' _ | '_| | ' _ \ / _` | \ \ \ \
\ \ / ___) | | _) | | | | | || ( _| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.6.3)
2022-10-25 14:29:05.065 INFO 4411 --- [ main] com.wd.SpringBootSimpleApplication : Starting SpringBootSimpleApplication using Java 1.8.0_171 on localhost.localdomain with PID 4411 (/opt/springboot/SpringBootSimple-1.0-SNAPSHOT.jar started by root in /opt/springboot)
2022-10-25 14:29:05.084 INFO 4411 --- [ main] com.wd.SpringBootSimpleApplication : No active profile set, falling back to default profiles: default
2022-10-25 14:29:09.500 INFO 4411 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8890 (http)
2022-10-25 14:29:09.516 INFO 4411 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2022-10-25 14:29:09.516 INFO 4411 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.56]
2022-10-25 14:29:09.942 INFO 4411 --- [ main] o.a.c.c.C.[.[.[/springboot_simple] : Initializing Spring embedded WebApplicationContext
2022-10-25 14:29:09.942 INFO 4411 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 4738 ms
2022-10-25 14:29:12.303 INFO 4411 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8890 (http) with context path ' /springboot_simple'
2022-10-25 14:29:12.350 INFO 4411 --- [ main] com.wd.SpringBootSimpleApplication : Started SpringBootSimpleApplication in 8.473 seconds (JVM running for 11.126)
2022-10-25 14:29:40.114 INFO 4411 --- [nio-8890-exec-1] o.a.c.c.C.[.[.[/springboot_simple] : Initializing Spring DispatcherServlet ' dispatcherServlet'
2022-10-25 14:29:40.114 INFO 4411 --- [nio-8890-exec-1] o.s.web.servlet.DispatcherServlet : Initializing Servlet ' dispatcherServlet'
2022 -10-25 14 :29:40.115 INFO 4411 --- [ nio-8890-exec-1] o.s.web.servlet.DispatcherServlet : Completed initialization in 1 ms
jar包及其解压后文件目录 失败案例 成功案例
6.测试
2.简单SpringBoot项目打包部署(带日志,未连接mysql)
1.配置文件
1.pom.xml<?xml version="1.0" encoding="UTF-8"?>
< project xmlns = " http://maven.apache.org/POM/4.0.0"
xmlns: xsi= " http://www.w3.org/2001/XMLSchema-instance"
xsi: schemaLocation= " http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" >
< modelVersion> 4.0.0</ modelVersion>
< groupId> org.example</ groupId>
< artifactId> SpringBootSimple</ artifactId>
< version> 1.0-SNAPSHOT</ version>
< packaging> jar</ packaging>
< properties>
< project.build.sourceEncoding> UTF-8</ project.build.sourceEncoding>
< maven.compiler.source> 1.8</ maven.compiler.source>
< maven.compiler.target> 1.8</ maven.compiler.target>
< start-class> com.wd.SpringBootSimpleApplication</ start-class>
</ properties>
< dependencies>
< dependency>
< groupId> org.springframework.boot</ groupId>
< artifactId> spring-boot-starter-web</ artifactId>
< version> 2.6.3</ version>
</ dependency>
< dependency>
< groupId> org.projectlombok</ groupId>
< artifactId> lombok</ artifactId>
< version> 1.18.10</ version>
</ dependency>
</ dependencies>
< build>
< plugins>
< plugin>
< groupId> org.springframework.boot</ groupId>
< artifactId> spring-boot-maven-plugin</ artifactId>
< version> 2.6.3</ version>
< executions>
< execution>
< goals>
< goal> repackage</ goal>
</ goals>
</ execution>
</ executions>
</ plugin>
</ plugins>
</ build>
</ project>
application.yamlserver:
port: 8890
servlet:
context- path: / springboot_simple
2.启动类
package com. wd ;
import org. springframework. boot. SpringApplication ;
import org. springframework. boot. autoconfigure. SpringBootApplication ;
@SpringBootApplication
public class SpringBootSimpleApplication {
public static void main ( String [ ] args) {
SpringApplication . run ( SpringBootSimpleApplication . class , args) ;
}
}
3.接口
package com. wd. controller ;
import lombok. extern. slf4j. Slf4j ;
import org. springframework. stereotype. Controller ;
import org. springframework. web. bind. annotation. RequestMapping ;
import org. springframework. web. bind. annotation. ResponseBody ;
import java. time. Instant ;
@Slf4j
@Controller
@RequestMapping ( "/user" )
public class UserController {
@RequestMapping ( "hello" )
@ResponseBody
public String hello ( ) {
log. info ( "{} 调用hello方法" , Instant . now ( ) ) ;
return "Hello SpringBootSimple" ;
}
@RequestMapping ( "bey" )
@ResponseBody
public String bey ( ) {
log. info ( "{} 调用bey方法" , Instant . now ( ) ) ;
return "Bey SpringBootSimple" ;
}
}
4.打包
1.首先刷新Maven 2.清空之前的target文件夹 3.将test禁用(因为打包时会默认执行test中的代码,如果测试代码没有问题才会打包,如果测试代码有问题则打包失败) 4.打包
5.部署
1.将jar包上传到Linux中 2.创建日志文件 3.后台一直运行项目并实时打印日志 4.动态查看日志[ root@localhost logs]
[ root@localhost springboot]
[ 1 ] 9045
[ root@localhost springboot]
( ( ) \ ___ | '_ | ' _| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' | ____| .__| _| | _| _| | _\ __, | / / / /
== == == == = | _| == == == == == == == | ___/= /_/_/_/
:: Spring Boot :: ( v2.6.3)
2022 -10-25 16 :02:21.383 INFO 9045 --- [ main] com.wd.SpringBootSimpleApplication : Starting SpringBootSimpleApplication using Java 1.8 .0_171 on localhost.localdomain with PID 9045 ( /opt/springboot/SpringBootSimple-1.0-SNAPSHOT.jar started by root in /opt/springboot)
2022 -10-25 16 :02:21.386 INFO 9045 --- [ main] com.wd.SpringBootSimpleApplication : No active profile set, falling back to default profiles: default
2022 -10-25 16 :02:23.694 INFO 9045 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port( s) : 8890 ( http)
2022 -10-25 16 :02:23.735 INFO 9045 --- [ main] o.apache.catalina.core.StandardService : Starting service [ Tomcat]
2022 -10-25 16 :02:23.735 INFO 9045 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [ Apache Tomcat/9.0.56]
2022 -10-25 16 :02:23.887 INFO 9045 --- [ main] o.a.c.c.C.[ .[ .[ /springboot_simple] : Initializing Spring embedded WebApplicationContext
2022 -10-25 16 :02:23.887 INFO 9045 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 2377 ms
2022 -10-25 16 :02:25.659 INFO 9045 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port( s) : 8890 ( http) with context path '/springboot_simple'
2022 -10-25 16 :02:25.687 INFO 9045 --- [ main] com.wd.SpringBootSimpleApplication : Started SpringBootSimpleApplication in 5.46 seconds ( JVM running for 6.993 )
2022 -10-25 16 :03:58.634 INFO 9045 --- [ nio-8890-exec-1] o.a.c.c.C.[ .[ .[ /springboot_simple] : Initializing Spring DispatcherServlet 'dispatcherServlet'
2022 -10-25 16 :03:58.635 INFO 9045 --- [ nio-8890-exec-1] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2022 -10-25 16 :03:58.636 INFO 9045 --- [ nio-8890-exec-1] o.s.web.servlet.DispatcherServlet : Completed initialization in 1 ms
2022 -10-25 16 :03:59.577 INFO 9045 --- [ nio-8890-exec-1] com.wd.controller.UserController : 2022 -10-25T08:03:59.577Z 调用hello方法
2022 -10-25 16 :04:10.007 INFO 9045 --- [ nio-8890-exec-2] com.wd.controller.UserController : 2022 -10-25T08:04:10.007Z 调用bey方法
[ root@localhost logs]
kill -9 9045
6.测试
8.Linux系统下SpringCloud项目打包部署
安装c语言开发环境
yum groupinstall "Development tools"
安装的是开发工具组,包含c,c++等多种语言,还有gdb调试器 光安装c语言,可以按照gcc即可
yum - y install gcc
yum - y install vim-*
安装vim编辑器 编写程序实现将百分制成绩转换为等级制成绩 编译程序,运行程序 gdb调试程序 安装gdb调试程序
yum - y install gdb
编译用gcc编译器 gcc scoreGrade gcc scoreGrade.c -o score -o执行文件的名字,即重命名 运行程序 ./score 如果需要调试程序,需要在编译时加上-g选项 gcc -g scoreGrade.c -o score 调试 gdb score 运行 ./score 默认编译输出是a.out,不管编译的是哪一个c语言程序都会输出一个a.out ./a.out 执行可执行文件名用-o指定 可以同时编译多个可执行文件 gcc 文件名1 文件名2 调试内部命令: file 文件名 y l查看源码 b 行码 设置断点,注意b和行码之间有空格 r 表示运行 运行到断点会停止 n(next)会进行下一步 s(step)也是进行下一步 如果有函数存在,s会进入函数体中调试,n不会进入函数体中,没有函数调用时,s和n效果一样 q退出