当前位置: 首页 > article >正文

Linux——应用软件的生命周期

  1. 功能开发
  2. 测试:
    1. 功能性测试
      • 对应开发框架的测试用例
    2. 代码的漏洞扫描
      • Web服务器版本
      • 应用开发语言的依赖关系和版本信息
      • 是否会造成类似内存泄露等影响系统性能的问题
    3. 压力测试
  3. 应用的部署
    1. 获取应用代码以及应用静态文件的代码包
    2. 将安装包中的文件按照服务器配置的架构,将代码文件上传到指定的位置

传统应用开发生命周期中,使用一个名为“瀑布式开发”的概念。各个部门的人员,各司其职,互相之间的工作联系并不紧密。

“敏捷开发”:开发人员一边开发,一边对已经开发完成的部分,进行测试和集成,提升开发效率。

持续集成:开发人员一边进行开发,同时及时进行应用的集成

  1. 一旦检测到代码发生变化,立刻运行测试(自动化出发)
  2. 测试无误的情况下,继续进行代码的打包发布(自动完成,无需人工操作)
  3. 如果测试出现问题,将问题通知给相关人员(无需人工操作,根据测试结果,自动发生)。继续修改
  4. 相关开发人员针对测试中出现的问题进行修改后,此时代码发生变化,回到第一步。

持续部署:一定那检测到新版本程序包的发布,就立刻按照提前规划好的方式进行应用的更新部署。

  1. 可以利用puppet chef ansible 等自动化管理软件,配置应用的自动化部署
  2. 应用更新策略的选择:
    1. 滚动更新:以K8S中部署的具有10个副本数量要求的deployment为例:
      • K8S中如果没有设置更新比例的情况下,默认使用25%作为控制值
      • 10 * 0.25 = 2.5 取整3 每次更新3个副本的pod
      • 更新的批次安排: 3   3   3   1
      • K8S维持本身的10个pod不变,新调度3个pod,新调度的pod使用新发布的应用 ,此时deployment控制的pod数量为13, 10 个旧版本应用 3 个新版本应用
      • 等待新调度的3个pod返回状态为running之后,移除原本10个pod中的3个 此时deployment控制的pod数量为10,3个新应用 7 旧的应用
        1. 如果新调度的3个pod在指定的时间内,没有返回running状态,则此时更新中止,对应的deployment继续控制10个运行旧版本应用的pod
      • 然后回到第三步,以3个pod为单位,依次更新,最后deployment控制到的pod都是新版本的应用

滚动更新是一种更新策略,在滚动更新的过程中如果出现任何问题,可以进行回滚以实现应用版本回溯,恢复到没有问题的版本。而这种更新策略所规划的更新部署可以通过任意方式实现。Shell 剧本 应答文件

    1. 灰度发布:生产环境下的服务器将被分为两个集群。一个集群用来部署灰度发布的应用,一个集群用来部署正常更新的应用。

灰度发布和滚动更新都是为了避免同一个问题,即新版本代码发布到生产环境下,出现问题后,不应该影响用户对于应用的正常访问

    1. 蓝绿发布:生产环境下服务器被分为两个集群,一个集群使用绿色表示,一个集群使用蓝色表示,这两套集群环境一致,一般同时只有一个集群开放给用户访问。
      • 蓝色集群部署了稳定版本的应用,绿色集群部署了开发版本的应用
      • 绿色集群中的新版本应用经过测试稳定运行后,将用户的访问全部转发给绿色集群处理
      • 此时蓝色集群不再用户的访问,但是蓝色集群可以用来部署最新版本的应用,并测试其稳定性。

金丝雀测试:在应用更新部署前,一定要在生产环境下进行测试,以验证没有任何问题,才可以进行大规模的应用更新。

代码仓库:保存代码的集中仓库。

代码仓库可以使用传统的文件共享协议进行部署,也可以使用专门的代码仓库软件进行部署。目前大部分公司的代码仓库都是用了支持版本控制功能的应用来进行管理。

常见的版本控制软件:

  1. Git
  2. Mercuril
  3. SVN

Git :

git add //文件提交到暂存区,已经被追踪的文件,也可以提交未追踪的文件

git commit // 将暂存区的文件提交到本地仓库

git log // 查看git commit的提交次数和记录

git rm // 将文件从本地目录和仓库中移除

git mv //对文件进行重命名的操作,同时发生在本地和仓库中

Git status // 显示本地目录中文件的状态,

文件状态显示: 未追踪  //在本地git仓库中不存在该文件

已修改未提交 // 文件的修改已使用git add 命令同步至暂存区,但是未提交到比本地git仓库

已修改未暂存 // 文件的修改未提交到暂存区

git reset // 将文件从暂存区移除

git restore // 从本地仓库恢复文件到本地

Git checkout -- 文件名  // 将文件未提交的变更全部移除

课堂演示记录:

[student@harbor ~]$ sudo yum -y install git		// 包含下面所有的功能,同时支持tab 键自动补齐子命令和选项
[student@harbor ~]$ rpm -qa | grep git-core   //git核心功能,功能完善,不影响使用
git-core-2.43.5-1.el9.x86_64
git-core-doc-2.43.5-1.el9.noarch
[student@harbor ~]$
[student@harbor ~]$ sudo git config --system  user.email  admin@123.com
[student@harbor ~]$ cat /etc/gitconfig
[user]
        email = admin@123.com
[student@harbor ~]$ git config --list
user.email=admin@123.com
[student@harbor ~]$ git config --list  --show-origin
file:/etc/gitconfig     user.email=admin@123.com
[student@harbor ~]$ git config --global user.email student@123.com
[student@harbor ~]$ git config --list
user.email=admin@123.com
user.email=student@123.com
[student@harbor ~]$ git config --list  --show-origin
file:/etc/gitconfig     user.email=admin@123.com
file:/home/student/.gitconfig   user.email=student@123.com
[student@harbor ~]$ cat .gitconfig
[user]
        email = student@123.com
[student@harbor ~]$ git config --global core.editor vim
[student@harbor ~]$ git config --global user.name student
[student@harbor ~]$ git config --list
user.email=admin@123.com
user.email=student@123.com
user.name=student
core.editor=vim
[student@harbor ~]$ git config user.name
student
[student@harbor ~]$ git config user.email
student@123.com
[student@harbor ~]$ git config help
error: key does not contain a section: help
[student@harbor ~]$ git help config
[student@harbor ~]$
[student@harbor ~]$ cd practice/demo/
[student@harbor demo]$
[student@harbor demo]$ ls
Dockerfile  HELP.md  mvnw  mvnw.cmd  pom.xml  src  target
[student@harbor demo]$ cd ..
[student@harbor practice]$ cp -r demo demo_1
[student@harbor practice]$ cd demo
[student@harbor demo]$ ls
Dockerfile  HELP.md  mvnw  mvnw.cmd  pom.xml  src  target
[student@harbor demo]$ ls -a
.  ..  Dockerfile  .gitignore  HELP.md  .mvn  mvnw  mvnw.cmd  pom.xml  src  target
[student@harbor demo]$ rm -rf .gitignore
[student@harbor demo]$
[student@harbor demo]$ git init
hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint:
hint:   git config --global init.defaultBranch <name>
hint:
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint:
hint:   git branch -m <name>
Initialized empty Git repository in /home/student/practice/demo/.git/
[student@harbor demo]$ ls
Dockerfile  HELP.md  mvnw  mvnw.cmd  pom.xml  src  target
[student@harbor demo]$ ls .git/
branches  config  description  HEAD  hooks  info  objects  refs
[student@harbor demo]$
[student@harbor demo]$ git status
On branch master

No commits yet

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        .mvn/
        Dockerfile
        HELP.md
        mvnw
        mvnw.cmd
        pom.xml
        src/
        target/

nothing added to commit but untracked files present (use "git add" to track)
[student@harbor demo]$ git add Dockerfile
[student@harbor demo]$ git status
On branch master

No commits yet

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)
        new file:   Dockerfile

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        .mvn/
        HELP.md
        mvnw
        mvnw.cmd
        pom.xml
        src/
        target/

[student@harbor demo]$ git rm --cached Dockerfile
rm 'Dockerfile'
[student@harbor demo]$ ls
Dockerfile  HELP.md  mvnw  mvnw.cmd  pom.xml  src  target
[student@harbor demo]$ git status
On branch master

No commits yet

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        .mvn/
        Dockerfile
        HELP.md
        mvnw
        mvnw.cmd
        pom.xml
        src/
        target/

nothing added to commit but untracked files present (use "git add" to track)
[student@harbor demo]$ vim Dockerfile
[student@harbor demo]$ git status
On branch master

No commits yet

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        .mvn/
        Dockerfile
        HELP.md
        mvnw
        mvnw.cmd
        pom.xml
        src/
        target/

nothing added to commit but untracked files present (use "git add" to track)
[student@harbor demo]$ git add Dockerfile
[student@harbor demo]$
[student@harbor demo]$ git status
On branch master

No commits yet

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)
        new file:   Dockerfile

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        .mvn/
        HELP.md
        mvnw
        mvnw.cmd
        pom.xml
        src/
        target/

[student@harbor demo]$ vim Dockerfile
[student@harbor demo]$ git status
On branch master

No commits yet

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)
        new file:   Dockerfile

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   Dockerfile

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        .mvn/
        HELP.md
        mvnw
        mvnw.cmd
        pom.xml
        src/
        target/

[student@harbor demo]$ git add Dockerfile
[student@harbor demo]$ git commit
[master (root-commit) 6072b75] Add container image build file
 1 file changed, 6 insertions(+)
 create mode 100644 Dockerfile
[student@harbor demo]$ git status
On branch master
Untracked files:
  (use "git add <file>..." to include in what will be committed)
        .mvn/
        HELP.md
        mvnw
        mvnw.cmd
        pom.xml
        src/
        target/

nothing added to commit but untracked files present (use "git add" to track)
[student@harbor demo]$ tree src
src
├── main
│   ├── java
│   │   └── com
│   │       └── example
│   │           └── demo
│   │               ├── Application.java
│   │               └── HelloController.java
│   └── resources
│       └── application.properties
└── test
    └── java
        └── com
            └── example
                └── demo
                    ├── HelloControllerITest.java
                    └── HelloControllerTest.java

11 directories, 5 files
[student@harbor demo]$ ls
Dockerfile  HELP.md  mvnw  mvnw.cmd  pom.xml  src  target
[student@harbor demo]$ vim .gitignore
# maven's working directory
target/
#project default mvn program
mvnw*
#project help file
HELP.md
#but track all readme file
!readme.txt
!README.txt
!README.md
!readme.md

[student@harbor demo]$ git status
On branch master
Untracked files:
  (use "git add <file>..." to include in what will be committed)
        .gitignore
        .mvn/
        pom.xml
        src/

nothing added to commit but untracked files present (use "git add" to track)
[student@harbor demo]$ ls .mvn/
wrapper
[student@harbor demo]$ ls .mvn/wrapper/
maven-wrapper.properties
[student@harbor demo]$ vim  .gitignore
# ignore git-ignore file
.gitignore
# maven's working directory
target/
#project default mvn program
mvnw*
.mvn/
#project help file
HELP.md
#but track all readme file
!readme.txt
!README.txt
!README.md
!readme.md

[student@harbor demo]$ git status
On branch master
Untracked files:
  (use "git add <file>..." to include in what will be committed)
        pom.xml
        src/

nothing added to commit but untracked files present (use "git add" to track)
[student@harbor demo]$ ls
Dockerfile  HELP.md  mvnw  mvnw.cmd  pom.xml  src  target
[student@harbor demo]$ git add .
[student@harbor demo]$ git commit
[master 78aa0f9] source code and project maven configuration
 6 files changed, 170 insertions(+)
 create mode 100644 pom.xml
 create mode 100644 src/main/java/com/example/demo/Application.java
 create mode 100644 src/main/java/com/example/demo/HelloController.java
 create mode 100644 src/main/resources/application.properties
 create mode 100644 src/test/java/com/example/demo/HelloControllerITest.java
 create mode 100644 src/test/java/com/example/demo/HelloControllerTest.java
[student@harbor demo]$ git status
On branch master
nothing to commit, working tree clean
[student@harbor demo]$ vim readme.txt
[student@harbor demo]$ git status -s
?? readme.txt
[student@harbor demo]$ git add readme.txt
[student@harbor demo]$ git commit "add readme file"
error: pathspec 'add readme file' did not match any file(s) known to git
[student@harbor demo]$ git commit -m "add readme file"
[master 6acb2a6] add readme file
 1 file changed, 2 insertions(+)
 create mode 100644 readme.txt
[student@harbor demo]$ vim readme.txt
[student@harbor demo]$ git status -s
 M readme.txt
[student@harbor demo]$ git diff readme.txt
diff --git a/readme.txt b/readme.txt
index a3365b1..2bf0964 100644
--- a/readme.txt
+++ b/readme.txt
@@ -1,2 +1,4 @@
 project purpose:
 practice how to deploy an app base on springboot development infrustracture
+
+this project run on port 8080
[student@harbor demo]$ git add readme.txt
[student@harbor demo]$ git diff readme.txt
[student@harbor demo]$ git diff readme.txt
[student@harbor demo]$ git diff readme.txt --staged
fatal: option '--staged' must come before non-option arguments
[student@harbor demo]$ git diff --staged  readme.txt
diff --git a/readme.txt b/readme.txt
index a3365b1..2bf0964 100644
--- a/readme.txt
+++ b/readme.txt
@@ -1,2 +1,4 @@
 project purpose:
 practice how to deploy an app base on springboot development infrustracture
+
+this project run on port 8080
[student@harbor demo]$ vim Dockerfile
[student@harbor demo]$ vim readme.txt
[student@harbor demo]$ git status
On branch master
Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        modified:   readme.txt

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   Dockerfile
        modified:   readme.txt

[student@harbor demo]$ git commit -am "add all changes to repository"
[master b7abcf7] add all changes to repository
 2 files changed, 7 insertions(+), 1 deletion(-)
[student@harbor demo]$ git status
On branch master
nothing to commit, working tree clean
[student@harbor demo]$ echo "test " >> test.txt
[student@harbor demo]$ git add test.txt
[student@harbor demo]$ git commit -m 'test'
[master 1b64891] test
 1 file changed, 1 insertion(+)
 create mode 100644 test.txt
[student@harbor demo]$ git status
On branch master
nothing to commit, working tree clean
[student@harbor demo]$ ls
Dockerfile  HELP.md  mvnw  mvnw.cmd  pom.xml  readme.txt  src  target  test.txt
[student@harbor demo]$ rm -f test.txt
[student@harbor demo]$ git status
On branch master
Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        deleted:    test.txt

no changes added to commit (use "git add" and/or "git commit -a")
[student@harbor demo]$ ls
Dockerfile  HELP.md  mvnw  mvnw.cmd  pom.xml  readme.txt  src  target
[student@harbor demo]$ git restore test.txt
[student@harbor demo]$ ls
Dockerfile  HELP.md  mvnw  mvnw.cmd  pom.xml  readme.txt  src  target  test.txt
[student@harbor demo]$ git rm test.txt
rm 'test.txt'
[student@harbor demo]$ ls
Dockerfile  HELP.md  mvnw  mvnw.cmd  pom.xml  readme.txt  src  target
[student@harbor demo]$ git status
On branch master
Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        deleted:    test.txt

[student@harbor demo]$ git commit
[master 5066a6f] delete unraleted files
 1 file changed, 1 deletion(-)
 delete mode 100644 test.txt
[student@harbor demo]$ mv readme.txt README.txt
[student@harbor demo]$ git status
On branch master
Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        deleted:    readme.txt

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        README.txt

no changes added to commit (use "git add" and/or "git commit -a")
[student@harbor demo]$ git mv readme.txt README.txt
fatal: bad source, source=readme.txt, destination=README.txt
[student@harbor demo]$ git mv  readme.txt README.txt
Dockerfile  pom.xml     readme.txt  README.txt  src/
[student@harbor demo]$ ls
Dockerfile  HELP.md  mvnw  mvnw.cmd  pom.xml  README.txt  src  target
[student@harbor demo]$
[student@harbor demo]$ mv README.txt readme.txt
[student@harbor demo]$ git status
On branch master
nothing to commit, working tree clean
[student@harbor demo]$ git mv readme.txt README.txt
[student@harbor demo]$ git status
On branch master
Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        renamed:    readme.txt -> README.txt

[student@harbor demo]$ ls
Dockerfile  HELP.md  mvnw  mvnw.cmd  pom.xml  README.txt  src  target
[student@harbor demo]$ git commit
[master 8150f9a] rename readme to README
 1 file changed, 0 insertions(+), 0 deletions(-)
 rename readme.txt => README.txt (100%)
[student@harbor demo]$ git log
commit 8150f9ac7721a074a7bea55f1fa9a321482cfee1 (HEAD -> master)
Author: student <student@123.com>
Date:   Fri Oct 18 15:03:04 2024 +0800

    rename readme to README

commit 5066a6f4e44521ca7ae92f48a482e90d644b8c85
Author: student <student@123.com>
Date:   Fri Oct 18 14:58:28 2024 +0800

    delete unraleted files

commit 1b648917cc774f1239a6be2b8ccae2b6a7ca1ac6
Author: student <student@123.com>
Date:   Fri Oct 18 14:55:54 2024 +0800

    test

commit b7abcf70832a81e796e1a16a3548038d1d169577
Author: student <student@123.com>
Date:   Fri Oct 18 14:54:14 2024 +0800

    add all changes to repository

commit 6acb2a653db83193e4b7b51ecff39d6d252af457
Author: student <student@123.com>
Date:   Fri Oct 18 14:45:55 2024 +0800

    add readme file

commit 78aa0f986c5e4084969b674bea50b20949966250
Author: student <student@123.com>
Date:   Fri Oct 18 14:39:25 2024 +0800

    source code and project maven configuration

commit 6072b75fed80c8ab6777dd52c7955ead217e5f8e
Author: student <student@123.com>
Date:   Fri Oct 18 14:20:53 2024 +0800

    Add container image build file
[student@harbor demo]$ git log -2
commit 8150f9ac7721a074a7bea55f1fa9a321482cfee1 (HEAD -> master)
Author: student <student@123.com>
Date:   Fri Oct 18 15:03:04 2024 +0800

    rename readme to README

commit 5066a6f4e44521ca7ae92f48a482e90d644b8c85
Author: student <student@123.com>
Date:   Fri Oct 18 14:58:28 2024 +0800

    delete unraleted files
[student@harbor demo]$ vim README.txt
[student@harbor demo]$ git status -s
 M README.txt
[student@harbor demo]$ git add  README.txt
[student@harbor demo]$ vim pom.xml
[student@harbor demo]$ git status -s
M  README.txt
 M pom.xml
[student@harbor demo]$ git commit -m 'modify readme'
[master bde40f3] modify readme
 1 file changed, 2 insertions(+)
[student@harbor demo]$ git commit --amend
[master 0ae7c5d] modify readme
 Date: Fri Oct 18 15:13:04 2024 +0800
 1 file changed, 2 insertions(+)
[student@harbor demo]$ git add pom.xml
[student@harbor demo]$ git commit --amend
[master 4516228] modify readme and pom.xml
 Date: Fri Oct 18 15:13:04 2024 +0800
 2 files changed, 3 insertions(+), 1 deletion(-)
[student@harbor demo]$ git log -3
commit 451622813a89a19b12be78dd6aa9e364bb891164 (HEAD -> master)
Author: student <student@123.com>
Date:   Fri Oct 18 15:13:04 2024 +0800

    modify readme and pom.xml

commit 8150f9ac7721a074a7bea55f1fa9a321482cfee1
Author: student <student@123.com>
Date:   Fri Oct 18 15:03:04 2024 +0800

    rename readme to README

commit 5066a6f4e44521ca7ae92f48a482e90d644b8c85
Author: student <student@123.com>
Date:   Fri Oct 18 14:58:28 2024 +0800

    delete unraleted files


http://www.kler.cn/news/356619.html

相关文章:

  • 基于SpringBoot+Vue+uniapp的诗词学习系统的详细设计和实现(源码+lw+部署文档+讲解等)
  • 自由学习记录(11)
  • pc轨迹回放制作
  • 【DevOps工具篇】Docker的DNS原理
  • Snowflake算法js(实现)
  • Python线性回归算法:面向对象的实现与案例详解
  • 牛客编程初学者入门训练——BC53 判断是元音还是辅音
  • 驱动开发系列21 - 编译内核模块的Makefile解释
  • Qt键盘按下事件和定时器事件及事件的接收和忽略
  • Javaweb基础-axios
  • ElasticSearch+Kibana 8.1.0安装部署
  • 今日总结10.18
  • 反向传播和优化 pytorch
  • 为什么在 Vue 中处理 Excel 文件
  • MySQL 数据的持久化
  • 进入 Searing-66 火焰星球:第一周游戏指南
  • 昇腾CANN 8.0正式发布,多项核心技术引领大模型原生创新
  • chrome清除https状态
  • 简单谈谈mysql中的日志 undo log
  • 【原创】java+springboot+mysql在线课程学习网设计与实现