Skip to main content

项目环境模板

记录项目各环境的配置信息、访问地址及账号密码。


一、项目信息

项目信息
项目名称Laby 管理系统
项目版本v1.0.0
项目负责人张三(zhangsan@company.com
技术负责人李四(lisi@company.com
后端仓库https://gitee.com/company/laby-server
前端仓库https://gitee.com/company/laby-web

二、技术栈

后端:

技术版本说明
Spring Boot3.2.0基础框架
MyBatis Plus3.5.5ORM 框架
MySQL8.0.33关系型数据库
Redis7.0.12缓存
Nacos2.3.0注册中心 / 配置中心
Kafka3.6.0消息队列
XXL-Job2.4.0分布式任务调度
Sa-Token1.37.0权限认证

前端:

技术版本说明
Vue3.4.0前端框架
Element Plus2.5.0UI 组件库
Vite5.0.0构建工具
Pinia2.1.0状态管理

三、本地环境

3.1 中间件信息

通过项目根目录 docker-compose.yml 一键启动。

服务地址账号 / 密码
MySQLlocalhost:3306root / root123456
Redislocalhost:6379- / redis123456
Nacoslocalhost:8848nacos / nacos
Kafkalocalhost:9092-
XXL-Joblocalhost:8090admin / 123456
注意事项

如果不想在本地配置中间件环境,可以直接使用测试环境的配置。

application-local.yml 中的地址和账号密码替换为以下内容:

服务地址账号 / 密码备注
MySQL192.168.1.101:3306laby_test / Test@Laby2024数据库:laby_test
Redis192.168.1.102:6379- / Redis@Test2024db:2
Nacos192.168.1.103:8848nacos / Nacos@Test2024命名空间:test
Kafka192.168.1.104:9092-Topic 前缀:laby-test
XXL-Job192.168.1.105:8090admin / Xxl@Test2024-

请勿修改或删除测试环境数据,仅用于本地开发调试。

3.2 后端配置(application-local.yml)

yaml
1spring:
2 datasource:
3 url: jdbc:mysql://localhost:3306/laby_db?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai
4 username: root
5 password: root123456
6 redis:
7 host: localhost
8 port: 6379
9 password: redis123456
10 kafka:
11 bootstrap-servers: localhost:9092
12 cloud:
13 nacos:
14 server-addr: localhost:8848
15 username: nacos
16 password: nacos
17
18xxl:
19 job:
20 admin:
21 addresses: http://localhost:8090/xxl-job-admin
22 executor:
23 appname: laby-executor
24 port: 9999

3.3 前端配置(.env.local)

bash
1VITE_APP_BASE_API=http://localhost:8080
2VITE_PORT=3000

四、测试环境

4.1 中间件信息

服务地址账号 / 密码备注
MySQL192.168.1.101:3306laby_test / Test@Laby2024数据库:laby_test
Redis192.168.1.102:6379- / Redis@Test2024db:2
Nacos192.168.1.103:8848nacos / Nacos@Test2024命名空间:test
Kafka192.168.1.104:9092-Topic 前缀:laby-test
XXL-Job192.168.1.105:8090admin / Xxl@Test2024-

4.2 后端配置(application-test.yml)

yaml
1spring:
2 datasource:
3 url: jdbc:mysql://192.168.1.101:3306/laby_test?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai
4 username: laby_test
5 password: Test@Laby2024
6 redis:
7 host: 192.168.1.102
8 port: 6379
9 password: Redis@Test2024
10 database: 2
11 kafka:
12 bootstrap-servers: 192.168.1.104:9092
13 consumer:
14 group-id: laby-test-group
15 cloud:
16 nacos:
17 server-addr: 192.168.1.103:8848
18 username: nacos
19 password: Nacos@Test2024
20 namespace: test
21
22xxl:
23 job:
24 admin:
25 addresses: http://192.168.1.105:8090/xxl-job-admin
26 accessToken: Xxl@Test2024
27 executor:
28 appname: laby-test-executor
29 port: 9999

4.3 前端配置(.env.test)

bash
1VITE_APP_BASE_API=https://api-test.laby.com
2VITE_APP_ROUTER_MODE=history

五、生产环境

5.1 服务器集群

层级服务器内网 IP配置角色
负载均衡Nginx-1172.16.0.14核 8GB
负载均衡Nginx-2172.16.0.24核 8GB
应用层App-1172.16.0.118核 16GBlaby-server
应用层App-2172.16.0.128核 16GBlaby-server
应用层App-3172.16.0.138核 16GBlaby-server
数据库MySQL-Master172.16.1.1116核 32GB主库(写)
数据库MySQL-Slave172.16.1.1216核 32GB从库(读)
缓存Redis-1172.16.2.118核 16GBMaster
缓存Redis-2172.16.2.128核 16GBSentinel
缓存Redis-3172.16.2.138核 16GBSentinel

5.2 中间件信息

服务地址账号 / 密码备注
MySQL 主库172.16.1.11:3306laby_prod / Prod@Master#2024数据库:laby_prod,写操作
MySQL 从库172.16.1.12:3306laby_readonly / Prod@Slave#2024只读
Redis172.16.2.11~13:26379- / Prod@Redis#2024哨兵模式,Master:laby-master
Nacos172.16.3.11:8848nacos / Prod@Nacos#2024命名空间:prod
Kafka172.16.4.11~13:9092-集群模式
XXL-Job172.16.5.11:8090admin / Prod@Xxl#2024-

5.3 后端配置(application-prod.yml)

yaml
1spring:
2 datasource:
3 dynamic:
4 primary: master
5 datasource:
6 master:
7 url: jdbc:mysql://172.16.1.11:3306/laby_prod?useSSL=true
8 username: laby_prod
9 password: Prod@Master#2024
10 slave:
11 url: jdbc:mysql://172.16.1.12:3306/laby_prod?useSSL=true
12 username: laby_readonly
13 password: Prod@Slave#2024
14 redis:
15 sentinel:
16 master: laby-master
17 nodes:
18 - 172.16.2.11:26379
19 - 172.16.2.12:26379
20 - 172.16.2.13:26379
21 password: Prod@Redis#2024
22 kafka:
23 bootstrap-servers: 172.16.4.11:9092,172.16.4.12:9092,172.16.4.13:9092
24 consumer:
25 group-id: laby-prod-group
26 cloud:
27 nacos:
28 server-addr: 172.16.3.11:8848
29 username: nacos
30 password: Prod@Nacos#2024
31 namespace: prod
32
33xxl:
34 job:
35 admin:
36 addresses: http://172.16.5.11:8090/xxl-job-admin
37 accessToken: Prod@Xxl#2024
38 executor:
39 appname: laby-prod-executor
40 port: 9999

5.4 前端配置(.env.production)

bash
1VITE_APP_BASE_API=https://api.laby.com
2VITE_APP_ROUTER_MODE=history
3VITE_APP_CDN_URL=https://cdn.laby.com

六、CI/CD

6.1 流水线说明

分支触发方式部署环境审批
testpush 自动触发测试环境无需审批
mainpush 自动触发生产环境需技术负责人审批

6.2 Harbor 镜像仓库

Harbor 信息:

配置项
地址https://harbor.laby.com
账号 / 密码admin / Harbor@Laby2024
项目空间laby
测试镜像harbor.laby.com/laby/laby-server:test
生产镜像harbor.laby.com/laby/laby-server:latest

登录 / 推送镜像:

bash
1# 登录 Harbor
2docker login harbor.laby.com -u admin -p Harbor@Laby2024
3
4# 构建并推送镜像
5docker build -t harbor.laby.com/laby/laby-server:1.0.0 .
6docker push harbor.laby.com/laby/laby-server:1.0.0
7
8# 拉取镜像
9docker pull harbor.laby.com/laby/laby-server:latest

6.3 GitLab CI

GitLab Runner 信息:

配置项
Runner 地址http://gitlab.laby.com
ExecutorDocker
构建镜像maven:3.8-openjdk-17
Runner 标签laby-runner

.gitlab-ci.yml:

yaml
1stages:
2 - build
3 - deploy
4
5variables:
6 MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository"
7
8cache:
9 paths:
10 - .m2/repository/
11
12build:
13 stage: build
14 tags:
15 - laby-runner
16 script:
17 - mvn clean package -DskipTests
18 artifacts:
19 paths:
20 - target/*.jar
21 expire_in: 1 hour
22 only:
23 - test
24 - main
25
26build:image:
27 stage: build
28 tags:
29 - laby-runner
30 script:
31 - docker build -t harbor.laby.com/laby/laby-server:$CI_COMMIT_SHORT_SHA .
32 - docker login harbor.laby.com -u $HARBOR_USER -p $HARBOR_PASSWORD
33 - docker push harbor.laby.com/laby/laby-server:$CI_COMMIT_SHORT_SHA
34 only:
35 - test
36 - main
37
38deploy:test:
39 stage: deploy
40 tags:
41 - laby-runner
42 script:
43 - ssh deploy@192.168.1.100 "docker pull harbor.laby.com/laby/laby-server:$CI_COMMIT_SHORT_SHA"
44 - ssh deploy@192.168.1.100 "sh /data/scripts/restart.sh test $CI_COMMIT_SHORT_SHA"
45 only:
46 - test
47
48deploy:prod:
49 stage: deploy
50 tags:
51 - laby-runner
52 script:
53 - ssh deploy@172.16.0.11 "docker pull harbor.laby.com/laby/laby-server:$CI_COMMIT_SHORT_SHA"
54 - ssh deploy@172.16.0.11 "sh /data/scripts/restart.sh prod $CI_COMMIT_SHORT_SHA"
55 only:
56 - main
57 when: manual

6.4 Jenkins

Jenkins 信息:

配置项
地址http://jenkins.laby.com
账号 / 密码admin / Jenkins@Laby2024
JDK17
Maven3.8.8
Node.js18.18.0

流水线任务:

任务名称触发方式部署环境
laby-server-testtest 分支 push测试环境
laby-server-prod手动触发生产环境
laby-web-testtest 分支 push测试环境
laby-web-prod手动触发生产环境

七、快速入口

本地环境
服务地址账号 / 密码
前端http://localhost:3000admin / admin123
接口文档http://localhost:8080/doc.html-
Nacoshttp://localhost:8848/nacosnacos / nacos
XXL-Jobhttp://localhost:8090/xxl-job-adminadmin / 123456
测试环境
服务地址账号 / 密码
前端https://test.laby.comadmin / test123
接口文档https://api-test.laby.com/doc.htmladmin / laby@doc2024
Nacoshttp://192.168.1.103:8848/nacosnacos / Nacos@Test2024
XXL-Jobhttp://192.168.1.105:8090/xxl-job-adminadmin / Xxl@Test2024
生产环境
服务地址账号 / 密码
前端https://www.laby.comadmin / admin123
接口文档https://api.laby.com/doc.htmladmin / laby@doc2024
监控https://monitor.laby.comadmin / laby@grafana2024
日志https://log.laby.comadmin / laby@elk2024
Harborhttps://harbor.laby.comadmin / Harbor@Laby2024
安全提示

本文档包含敏感配置信息,请勿外传。如有人员变动,请及时更新账号密码。

forum

评论区 / Comments