解压文件
Administrator@DESKTOP-TPPG8VO MINGW64 /d/nyy_work/new_code/tmp
$ ls -l
big-devops_backend_2023-12-17.tar.gz # 后端golang代码
big-devops_front_2023-12-17.tar.gz # 前端vue3代码
doc_2023-12-17.tar.gz # 7模块的全部文档和截图
大运维平台前后端代码和文档_2023-12-17.tar.gz # 微信群里给你的压缩包
00 前置软件
- linux环境:VMware虚拟机 + ubuntu22.04
- xshell
- ide
- golang :goland
- vue : webstorm
- 数据库:mysql
- 数据库连接软件:Navicat
- git tortoisegit : 类linux的命令行
01 查看文档
- 个人习惯 :用goland打开,但是耗资源
02 启动后端
安装golang
下载golang 包 https://go.dev/dl/
$ go version
go version go1.20.5 windows/amd64
- 设置环境变量
- GOPATH = D:\nyywork\gopath\src\
- GOPROXY=https://goproxy.cn 加速依赖包的下载
- PATH 里面 加 C:\Program Files\Go\bin goroot的bin目录 go二进制可以被找到
安装ide 我这里选择的goland
用ide打开后端代码目录
下载项目的依赖包
执行 go mod tidy
准备mysql
mysql这里 选择linux虚拟机的systemd启动docker本地启动k8s集群中启动都可以我这里选择的是k8s :如何搭建k8s集群请看 【模块1底座10.4 搭建k8s1.27最新版本集群】虚拟机ubuntu22.04 安装mysql
apt install mysql-server -y
# 编辑mysql配置文件 修改bind地址 到 0.0.0.0
vim /etc/mysql/mysql.conf.d/mysqld.cnf
# 授权
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '1234';
CREATE USER 'root'@'%' IDENTIFIED BY '1234';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;
# 重启服务
systemctl restart mysql
# 测试联通
# 创建数据库
drop database bigdevops; CREATE DATABASE IF NOT EXISTS bigdevops default charset utf8 COLLATE utf8_general_ci;
# 修改 server.yml中 mysql dns配置 ,ip 地址端口 账号密码改为你自己的
# mysql:
# dsn: "root:1234@tcp(192.168.0.81:3306)/bigdevops?charset=utf8&parseTime=True&loc=Local"
启动后端服务:表结构会自动同步
D:\nyywork\newcode\tmp\bigdevops\cmd\server\main.go 执行就可以了
原始数据 在后端代码中也会mock
检查后端数据
在数据库中查看表
查看日志 :控制台和 本地json文件都会打印
D:\nyywork\newcode\tmp\bigdevops\json.log
03 启动前端
基础环境准备
安装 tortoisegit https://gitforwindows.org/安装 https://tortoisegit.org/ide webstorm
安装 nvm 管理nodejs
- https://github.com/coreybutler/nvm-windows
- 看这里 https://segmentfault.com/a/1190000020807954
- 设置nvm 用国内的源
- settings文件位置 D:\nyy_work\nvm
npm_mirror: https://npm.taobao.org/mirrors/npm/
node_mirror: https://npm.taobao.org/mirrors/node/
使用nvm 安装nodejs v18.17.0
Administrator@DESKTOP-TPPG8VO MINGW64 ~
$ nvm install --lts
"--" prefixes are unnecessary in NVM for Windows!
attempting to install "lts" instead...
Downloading node.js version 18.17.0 (64-bit)...
Extracting node and npm...
Complete
npm v9.6.7 installed successfully.
Installation complete. If you want to use this version, type
nvm use 18.17.0
Administrator@DESKTOP-TPPG8VO MINGW64 ~
$ nvm use 18.17.0
Now using node v18.17.0 (64-bit)
Administrator@DESKTOP-TPPG8VO MINGW64 ~
$ npm -v
9.6.7
Administrator@DESKTOP-TPPG8VO MINGW64 ~
$ npx -v
9.6.7
Administrator@DESKTOP-TPPG8VO MINGW64 ~
$ node -v
v18.17.0
Administrator@DESKTOP-TPPG8VO MINGW64 ~
$
给npm配置淘宝镜像
npm config set registry https://registry.npm.taobao.org --global
npm config set disturl https://npm.taobao.org/dist --global
安装pnmp
$ npm install pnpm
added 1 package in 1s
cd到前端目录下 下载依赖并启动服务
pnpm i
npm run dev
04 环境解释
- 前端访问地址 http://localhost:3100/
- 后端地址 localhost:80
- k8s和Prometheus
- 去看课程里面的依赖项目