feat(contract): 采购合同对比agent
Signed-off-by: sophie <sophie> Signed-off-by: sophie <sophie>
This commit is contained in:
1 parent
ffccf19ba2
commit
0503ff76a6
90 files changed
+16729
-1344
No files matched your search
@@ -1,35 +1,42 @@
|
||||
# 固资履历共享盘挂载(Linux 运维命令)
|
||||
|
||||
> 适用:Linux 宿主机 + Docker Compose 部署的 hxops-backend。
|
||||
> 已在 test 环境验证:`smbclient` 可达后,用「CIFS 挂共享根 + bind 履历子目录」方式成功。
|
||||
> **不要使用** `subdir=履历`(部分内核会报 `mount error(22): Invalid argument`)。
|
||||
> test / prod **各自**按本文在宿主机执行一次(凭据、挂载不会随代码自动同步到另一台机)。
|
||||
> 已验证方式:**CIFS 挂共享根 + `mount --bind` 履历子目录**。
|
||||
> **不要使用** `subdir=履历`(易报 `mount error(22): Invalid argument`)。
|
||||
> 首次挂载建议**不要加 `ro`**(正式环境曾出现误导性报错 `cannot mount ... read-only`)。
|
||||
|
||||
## 1. 背景
|
||||
|
||||
| 项 | 值 |
|
||||
| --- | --- |
|
||||
| Windows 源路径 | `\\192.168.100.130\设备履历记录\履历` |
|
||||
| 业务变量 | `FIXED_ASSET_HISTORY_LOCAL_ROOT`(优先于 UNC) |
|
||||
| 业务变量 | `FIXED_ASSET_HISTORY_LOCAL_ROOT`(优先于 UNC;Linux 必须配) |
|
||||
| test 本地根 | `/mnt/hxops-fixed-asset-history-test` |
|
||||
| prod 本地根 | `/mnt/hxops-fixed-asset-history-prod` |
|
||||
| 共享根挂载点 | test: `/mnt/hxops-fixed-asset-history-test-share`<br>prod: `/mnt/hxops-fixed-asset-history-prod-share` |
|
||||
| 凭据文件(每台宿主机各一份) | `/etc/smbcredentials/hxops-fixed-asset-history` |
|
||||
| 部署目录示例 | test: `~/ai/platform/hxops`<br>prod: `/data/ai-platform/hxops` |
|
||||
|
||||
挂载顺序:
|
||||
|
||||
1. CIFS 挂载共享根 `设备履历记录` → `*-share`
|
||||
2. `mount --bind` 把其中的 `履历` 挂到 `FIXED_ASSET_HISTORY_LOCAL_ROOT`
|
||||
3. 重建 `hxops-backend`,使容器内能看到该目录
|
||||
1. 在本机创建 SMB 凭据文件(`chmod 600`,属主 root)
|
||||
2. `sudo smbclient` 探测共享可达
|
||||
3. CIFS 挂载共享根 `设备履历记录` → `*-share`(先不加 `ro`)
|
||||
4. `mount --bind` 把其中的 `履历` 挂到 `FIXED_ASSET_HISTORY_LOCAL_ROOT`
|
||||
5. 重建 `hxops-backend`,并确认容器内已注入 `FIXED_ASSET_HISTORY_LOCAL_ROOT`
|
||||
|
||||
---
|
||||
|
||||
## 2. 公共准备(test / prod 各做一次即可)
|
||||
## 2. 公共准备(test / prod 每台宿主机各做一次)
|
||||
|
||||
```bash
|
||||
# 安装工具
|
||||
sudo apt update
|
||||
sudo apt install -y cifs-utils smbclient
|
||||
|
||||
# 凭据文件(密码与 .env.shared / .env.<env> 中 FIXED_ASSET_HISTORY_SHARE_* 一致)
|
||||
# 凭据文件:密码取自本机仓库 .env.shared / .env.<env>
|
||||
# grep FIXED_ASSET_HISTORY_SHARE_ .env.shared .env.prod
|
||||
sudo mkdir -p /etc/smbcredentials
|
||||
sudo tee /etc/smbcredentials/hxops-fixed-asset-history >/dev/null <<'EOF'
|
||||
username=SBLL00001
|
||||
@@ -38,25 +45,26 @@ domain=WORKGROUP
|
||||
EOF
|
||||
sudo chmod 600 /etc/smbcredentials/hxops-fixed-asset-history
|
||||
|
||||
# 连通性探测(应能列出目录)
|
||||
smbclient //192.168.100.130/设备履历记录 -A /etc/smbcredentials/hxops-fixed-asset-history -c "ls"
|
||||
# 连通性探测(凭据为 root:600,必须加 sudo,否则会 Unable to open credentials file)
|
||||
sudo smbclient //192.168.100.130/设备履历记录 \
|
||||
-A /etc/smbcredentials/hxops-fixed-asset-history -c "ls"
|
||||
```
|
||||
|
||||
`uid/gid` 默认按 `1001`;不一致时先执行 `id`,替换下面命令中的数值。
|
||||
说明:
|
||||
|
||||
若 `vers=3.0` 报 `Invalid argument`,将命令中的 `vers=3.0` 改为 `vers=2.1` 再试。
|
||||
- `uid/gid` 默认 `1001`;不一致时先执行 `id`,替换下文命令中的数值。
|
||||
- 若 `vers=3.0` 报 `Invalid argument`,改为 `vers=2.1` 再试。
|
||||
- 正式机若从未建过凭据文件,`dmesg` 常见 `STATUS_LOGON_FAILURE` / `cifs_mount failed ... -13`。
|
||||
|
||||
---
|
||||
|
||||
## 3. Test 环境命令(已验证)
|
||||
|
||||
在 hxops 仓库所在宿主机执行:
|
||||
|
||||
```bash
|
||||
# 1) 挂共享根
|
||||
# 1) 挂共享根(首次不加 ro)
|
||||
sudo mkdir -p /mnt/hxops-fixed-asset-history-test-share
|
||||
sudo mount -t cifs //192.168.100.130/设备履历记录 /mnt/hxops-fixed-asset-history-test-share \
|
||||
-o credentials=/etc/smbcredentials/hxops-fixed-asset-history,vers=3.0,iocharset=utf8,uid=1001,gid=1001,file_mode=0755,dir_mode=0755,ro
|
||||
-o credentials=/etc/smbcredentials/hxops-fixed-asset-history,vers=3.0,iocharset=utf8,uid=1001,gid=1001,file_mode=0755,dir_mode=0755
|
||||
|
||||
# 2) 确认有「履历」
|
||||
ls /mnt/hxops-fixed-asset-history-test-share
|
||||
@@ -68,23 +76,28 @@ sudo mount --bind /mnt/hxops-fixed-asset-history-test-share/履历 /mnt/hxops-fi
|
||||
# 4) 确认履历文件可见
|
||||
ls /mnt/hxops-fixed-asset-history-test | head
|
||||
|
||||
# 5) 重建后端并检查容器内路径(必须带 COMPOSE_ENV_BASENAME,否则读不到 LOCAL_ROOT)
|
||||
cd /path/to/hxops # 换成实际部署目录,例如 ~/ai/platform/hxops
|
||||
# 5) 重建后端(必须带 COMPOSE_ENV_BASENAME,否则读不到 LOCAL_ROOT,会回退 UNC 导致 503)
|
||||
cd ~/ai/platform/hxops # 按实际部署目录调整
|
||||
export COMPOSE_SHARED_ENV_BASENAME=.env.shared
|
||||
export COMPOSE_ENV_BASENAME=.env.test
|
||||
docker compose --env-file .env.test up -d hxops-backend
|
||||
docker exec hxops-backend printenv | grep FIXED_ASSET_HISTORY
|
||||
docker exec hxops-backend ls -la /mnt/hxops-fixed-asset-history-test
|
||||
docker exec hxops-backend ls -la /mnt/hxops-fixed-asset-history-test | head
|
||||
```
|
||||
|
||||
### Test 开机自动挂载(可选,写入 /etc/fstab)
|
||||
期望 `printenv` 含:
|
||||
|
||||
```text
|
||||
FIXED_ASSET_HISTORY_LOCAL_ROOT=/mnt/hxops-fixed-asset-history-test
|
||||
```
|
||||
|
||||
### Test 开机自动挂载(可选)
|
||||
|
||||
```bash
|
||||
echo '//192.168.100.130/设备履历记录 /mnt/hxops-fixed-asset-history-test-share cifs credentials=/etc/smbcredentials/hxops-fixed-asset-history,vers=3.0,iocharset=utf8,uid=1001,gid=1001,file_mode=0755,dir_mode=0755,ro,nofail,_netdev 0 0' | sudo tee -a /etc/fstab
|
||||
echo '//192.168.100.130/设备履历记录 /mnt/hxops-fixed-asset-history-test-share cifs credentials=/etc/smbcredentials/hxops-fixed-asset-history,vers=3.0,iocharset=utf8,uid=1001,gid=1001,file_mode=0755,dir_mode=0755,nofail,_netdev 0 0' | sudo tee -a /etc/fstab
|
||||
|
||||
echo '/mnt/hxops-fixed-asset-history-test-share/履历 /mnt/hxops-fixed-asset-history-test none bind,nofail 0 0' | sudo tee -a /etc/fstab
|
||||
|
||||
# 验证 fstab(勿在已挂载时盲目 umount 生产业务目录)
|
||||
sudo mount -a
|
||||
findmnt /mnt/hxops-fixed-asset-history-test
|
||||
```
|
||||
@@ -93,13 +106,19 @@ findmnt /mnt/hxops-fixed-asset-history-test
|
||||
|
||||
## 4. Prod 环境命令
|
||||
|
||||
与 test 相同,仅路径与 compose env 不同:
|
||||
与 test 相同,仅路径与 compose env 不同。**正式机必须单独再建一份凭据**(不会从测试机自动带过来)。
|
||||
|
||||
```bash
|
||||
# 1) 挂共享根
|
||||
# 0) 若尚未建凭据,先完成「§2 公共准备」,并用 sudo smbclient 测通
|
||||
|
||||
# 1) 挂共享根(首次不加 ro;正式机加 ro 曾报 cannot mount ... read-only)
|
||||
sudo mkdir -p /mnt/hxops-fixed-asset-history-prod-share
|
||||
sudo mount -t cifs //192.168.100.130/设备履历记录 /mnt/hxops-fixed-asset-history-prod-share \
|
||||
-o credentials=/etc/smbcredentials/hxops-fixed-asset-history,vers=3.0,iocharset=utf8,uid=1001,gid=1001,file_mode=0755,dir_mode=0755,ro
|
||||
-o credentials=/etc/smbcredentials/hxops-fixed-asset-history,vers=3.0,iocharset=utf8,uid=1001,gid=1001,file_mode=0755,dir_mode=0755
|
||||
|
||||
# 若仍失败:
|
||||
# sudo dmesg | tail -n 40
|
||||
# 再试 vers=2.1
|
||||
|
||||
# 2) 确认有「履历」
|
||||
ls /mnt/hxops-fixed-asset-history-prod-share
|
||||
@@ -111,19 +130,25 @@ sudo mount --bind /mnt/hxops-fixed-asset-history-prod-share/履历 /mnt/hxops-fi
|
||||
# 4) 确认履历文件可见
|
||||
ls /mnt/hxops-fixed-asset-history-prod | head
|
||||
|
||||
# 5) 重建后端并检查容器内路径(必须带 COMPOSE_ENV_BASENAME,否则读不到 LOCAL_ROOT)
|
||||
cd /path/to/hxops
|
||||
# 5) 重建后端
|
||||
cd /data/ai-platform/hxops # 按实际部署目录调整
|
||||
export COMPOSE_SHARED_ENV_BASENAME=.env.shared
|
||||
export COMPOSE_ENV_BASENAME=.env.prod
|
||||
docker compose --env-file .env.prod up -d hxops-backend
|
||||
docker exec hxops-backend printenv | grep FIXED_ASSET_HISTORY
|
||||
docker exec hxops-backend ls -la /mnt/hxops-fixed-asset-history-prod
|
||||
docker exec hxops-backend ls -la /mnt/hxops-fixed-asset-history-prod | head
|
||||
```
|
||||
|
||||
### Prod 开机自动挂载(可选,写入 /etc/fstab)
|
||||
期望 `printenv` 含:
|
||||
|
||||
```text
|
||||
FIXED_ASSET_HISTORY_LOCAL_ROOT=/mnt/hxops-fixed-asset-history-prod
|
||||
```
|
||||
|
||||
### Prod 开机自动挂载(可选)
|
||||
|
||||
```bash
|
||||
echo '//192.168.100.130/设备履历记录 /mnt/hxops-fixed-asset-history-prod-share cifs credentials=/etc/smbcredentials/hxops-fixed-asset-history,vers=3.0,iocharset=utf8,uid=1001,gid=1001,file_mode=0755,dir_mode=0755,ro,nofail,_netdev 0 0' | sudo tee -a /etc/fstab
|
||||
echo '//192.168.100.130/设备履历记录 /mnt/hxops-fixed-asset-history-prod-share cifs credentials=/etc/smbcredentials/hxops-fixed-asset-history,vers=3.0,iocharset=utf8,uid=1001,gid=1001,file_mode=0755,dir_mode=0755,nofail,_netdev 0 0' | sudo tee -a /etc/fstab
|
||||
|
||||
echo '/mnt/hxops-fixed-asset-history-prod-share/履历 /mnt/hxops-fixed-asset-history-prod none bind,nofail 0 0' | sudo tee -a /etc/fstab
|
||||
|
||||
@@ -151,42 +176,41 @@ sudo umount /mnt/hxops-fixed-asset-history-prod-share
|
||||
|
||||
## 6. 排障
|
||||
|
||||
| 现象 | 处理 |
|
||||
| 现象 | 原因 / 处理 |
|
||||
| --- | --- |
|
||||
| `asset history share is unreachable` | 宿主机 `LOCAL_ROOT` 未挂载,或容器未 recreate / compose 未 bind 该路径 |
|
||||
| `Unable to open credentials file` / `Failed to set parse authentication file` | 凭据不存在,或用普通用户读 `root:600` 文件。先建文件,探测时用 **`sudo smbclient`** |
|
||||
| `STATUS_LOGON_FAILURE` / `cifs_mount failed ... -13`(见 `dmesg`) | 账号密码错误,或凭据文件缺失/读失败。核对 `/etc/smbcredentials/hxops-fixed-asset-history` 与 `.env.*` |
|
||||
| `cannot mount ... read-only` | 多为误导文案。去掉 `ro` 再挂,并看 `dmesg \| tail -n 40` |
|
||||
| `mount error(22): Invalid argument` | 勿用 `subdir=`;或改 `vers=2.1` / `vers=2.0` |
|
||||
| `smbclient` 失败 | 查网络、账号密码、Windows 共享权限 |
|
||||
| 宿主机有文件、容器内没有 | `docker compose --env-file .env.<env> up -d hxops-backend` 重建后再 `docker exec ... ls` |
|
||||
| 容器 `ls` 正常但仍 503 `unreachable` | 应用未读到 `FIXED_ASSET_HISTORY_LOCAL_ROOT`,回退到 UNC。执行 `docker exec hxops-backend printenv \| grep FIXED_ASSET`;重建时必须带上 env:见下方「重建后端」 |
|
||||
| 目录存在但为空 | 可能 Docker 先创建了空目录;先 `umount`/清错挂,再按本文重新 mount |
|
||||
| `smbclient` 超时 / Host is down | 正式机到 `192.168.100.130` 网络未放通(需 SMB 445) |
|
||||
| `asset history share is unreachable`(API 503) | 宿主机未挂载,或容器未注入 `FIXED_ASSET_HISTORY_LOCAL_ROOT`(回退到 UNC)。按 §3/§4 重建并检查 `printenv` |
|
||||
| 容器 `ls` 正常,API 200,但提示「未找到履历文件」 | 共享盘已通,但文件名/路径未命中该资产编号或名称;属检索/归档命名问题,不是挂载问题 |
|
||||
| 宿主机有文件、容器内没有 | 挂载后 recreate backend;确认 `docker-compose.yml` 已 bind `LOCAL_ROOT` |
|
||||
| 目录存在但为空 | 可能 Docker 先创建了空目录;先正确 CIFS/bind,再 recreate 容器 |
|
||||
|
||||
### 重建后端(重要)
|
||||
|
||||
compose 默认 `env_file` 指向 `.env.dev`(无 LOCAL_ROOT)。手动重建时请显式指定:
|
||||
### 快速自检清单
|
||||
|
||||
```bash
|
||||
cd /path/to/hxops
|
||||
export COMPOSE_SHARED_ENV_BASENAME=.env.shared
|
||||
export COMPOSE_ENV_BASENAME=.env.test # prod 改成 .env.prod
|
||||
docker compose --env-file .env.test up -d hxops-backend
|
||||
# 凭据
|
||||
sudo ls -l /etc/smbcredentials/hxops-fixed-asset-history
|
||||
sudo smbclient //192.168.100.130/设备履历记录 -A /etc/smbcredentials/hxops-fixed-asset-history -c "ls"
|
||||
|
||||
# 确认容器内已注入 LOCAL_ROOT(不应为空,且不是 UNC)
|
||||
# 挂载
|
||||
findmnt /mnt/hxops-fixed-asset-history-prod-share # 或 test-share
|
||||
findmnt /mnt/hxops-fixed-asset-history-prod # 或 test
|
||||
ls /mnt/hxops-fixed-asset-history-prod | head
|
||||
|
||||
# 容器
|
||||
docker exec hxops-backend printenv | grep FIXED_ASSET_HISTORY
|
||||
docker exec hxops-backend ls /mnt/hxops-fixed-asset-history-prod | head
|
||||
```
|
||||
|
||||
期望类似:
|
||||
|
||||
```text
|
||||
FIXED_ASSET_HISTORY_LOCAL_ROOT=/mnt/hxops-fixed-asset-history-test
|
||||
FIXED_ASSET_HISTORY_SHARE_ROOT=\\192.168.100.130\设备履历记录\履历
|
||||
```
|
||||
|
||||
|
||||
相关配置:
|
||||
### 相关配置
|
||||
|
||||
- `.env.test` / `.env.prod`:`FIXED_ASSET_HISTORY_LOCAL_ROOT`
|
||||
- `docker-compose.yml`:已把 test/prod 两个 `LOCAL_ROOT` 只读挂进 `hxops-backend`
|
||||
- 可选脚本:`scripts/mount_fixed_asset_history.sh`(封装同上逻辑)
|
||||
- `.env.shared` / `.env.<env>`:`FIXED_ASSET_HISTORY_SHARE_USERNAME` / `PASSWORD`
|
||||
- `docker-compose.yml`:已把 test/prod 两个 `LOCAL_ROOT` 只读挂进 `hxops-backend`,并注入 `FIXED_ASSET_HISTORY_LOCAL_ROOT`
|
||||
- 可选脚本:`scripts/mount_fixed_asset_history.sh`(封装同上逻辑;执行用 `sudo bash scripts/...`)
|
||||
|
||||
---
|
||||
|
||||
@@ -194,4 +218,6 @@ FIXED_ASSET_HISTORY_SHARE_ROOT=\\192.168.100.130\设备履历记录\履历
|
||||
|
||||
1. 宿主机:`ls $LOCAL_ROOT` 能看到履历文件
|
||||
2. 容器:`docker exec hxops-backend ls $LOCAL_ROOT` 同样可见
|
||||
3. 前端:聊天页点击资产编号,不再出现 503 / `asset history share is unreachable`
|
||||
3. 容器:`FIXED_ASSET_HISTORY_LOCAL_ROOT` 已注入且指向上述本地路径(不是 UNC)
|
||||
4. 前端:点击资产编号不再出现 503 / `asset history share is unreachable`
|
||||
5. 若仍提示「未找到履历文件」:挂载已正常,需核对共享盘是否存在该资产对应文件(编号或设备名)
|
||||
Reference in new issue
Block a user