HIS更新
个别jar包更新:
- 打包后的jar文件拷到远程机上
- ftp连接nfs服务器:192.168.32.179 进文件拷贝到目录:cd /data/nfs/ht-his-nfs/his/his/lib 将需要更新的包拷贝覆盖
- xshell进入nfs服务器目录:cd /data/nfs/ht-his-nfs/his/ 创建镜像:docker build -t 192.168.32.184:30080/haitai/his:2.0.0 . 推送镜像:docker image push 192.168.32.184:30080/haitai/his:2.0.0
- 登录接口工具:http://192.168.32.184:31388/查看一下【系统配置】micro_web.ldapi.path配置的端口是31380还是31381
- 登录K8s控制台,选择ht-his命名空间→选择deployment 重启ht-his或ht-his81。若当前端口是31380,那重启ht-his81,若当前端口是31381,那重启ht-his
- 等pod启动成功后,登录接口工具:http://192.168.32.184:31388/ 切换【系统配置】micro_web.ldapi.path配置的端口:31380或31381
注:镜像版本当前是his:2.0.0如果需要递增上去的,那在重启deployment前,先修改deployment拉取镜像的版本号再重启deployment
全部更新
- 打包后的rar文件拷到远程机上并解压
- ftp连接nfs服务器:192.168.32.179 进文件拷贝到目录:cd /data/nfs/ht-his-nfs/his/his 除了conf文件夹,其他文件都覆盖为新的包 后面的步骤参考下面个别jar包更新的3/4/5/6点
创建自动化更新脚本:
bash
#!/bin/bash
# update-his.sh - HIS系统更新脚本
# 配置变量
NFS_SERVER="192.168.32.179"
REGISTRY="192.168.32.184:30080"
IMAGE_NAME="haitai/his"
IMAGE_TAG="2.0.0"
NAMESPACE="ht-his"
echo "=== HIS系统更新开始 ==="
# 检查当前端口配置
echo "请手动检查当前端口配置:http://192.168.32.184:31388/"
echo "当前使用的端口是31380还是31381?"
read -p "请输入当前端口 (31380/31381): " current_port
# 确定要重启的deployment
if [ "$current_port" = "31380" ]; then
DEPLOYMENT="ht-his81"
NEW_PORT="31381"
else
DEPLOYMENT="ht-his"
NEW_PORT="31380"
fi
echo "将重启deployment: $DEPLOYMENT"
echo "新端口将是: $NEW_PORT"
# 构建新镜像
echo "构建新镜像..."
ssh user@$NFS_SERVER "cd /data/nfs/ht-his-nfs/his/ && docker build -t $REGISTRY/$IMAGE_NAME:$IMAGE_TAG ."
if [ $? -eq 0 ]; then
echo "镜像构建成功"
else
echo "镜像构建失败"
exit 1
fi
# 推送镜像
echo "推送镜像..."
ssh user@$NFS_SERVER "docker image push $REGISTRY/$IMAGE_NAME:$IMAGE_TAG"
if [ $? -eq 0 ]; then
echo "镜像推送成功"
else
echo "镜像推送失败"
exit 1
fi
# 重启deployment
echo "重启deployment: $DEPLOYMENT"
kubectl rollout restart deployment/$DEPLOYMENT -n $NAMESPACE
# 等待rollout完成
echo "等待部署完成..."
kubectl rollout status deployment/$DEPLOYMENT -n $NAMESPACE
echo "请手动切换端口配置到: $NEW_PORT"
echo "访问: http://192.168.32.184:31388/"
echo "修改 micro_web.ldapi.path 配置"
echo "=== HIS系统更新完成 ==="
#!/bin/bash
# update-his.sh - HIS系统更新脚本
# 配置变量
NFS_SERVER="192.168.32.179"
REGISTRY="192.168.32.184:30080"
IMAGE_NAME="haitai/his"
IMAGE_TAG="2.0.0"
NAMESPACE="ht-his"
echo "=== HIS系统更新开始 ==="
# 检查当前端口配置
echo "请手动检查当前端口配置:http://192.168.32.184:31388/"
echo "当前使用的端口是31380还是31381?"
read -p "请输入当前端口 (31380/31381): " current_port
# 确定要重启的deployment
if [ "$current_port" = "31380" ]; then
DEPLOYMENT="ht-his81"
NEW_PORT="31381"
else
DEPLOYMENT="ht-his"
NEW_PORT="31380"
fi
echo "将重启deployment: $DEPLOYMENT"
echo "新端口将是: $NEW_PORT"
# 构建新镜像
echo "构建新镜像..."
ssh user@$NFS_SERVER "cd /data/nfs/ht-his-nfs/his/ && docker build -t $REGISTRY/$IMAGE_NAME:$IMAGE_TAG ."
if [ $? -eq 0 ]; then
echo "镜像构建成功"
else
echo "镜像构建失败"
exit 1
fi
# 推送镜像
echo "推送镜像..."
ssh user@$NFS_SERVER "docker image push $REGISTRY/$IMAGE_NAME:$IMAGE_TAG"
if [ $? -eq 0 ]; then
echo "镜像推送成功"
else
echo "镜像推送失败"
exit 1
fi
# 重启deployment
echo "重启deployment: $DEPLOYMENT"
kubectl rollout restart deployment/$DEPLOYMENT -n $NAMESPACE
# 等待rollout完成
echo "等待部署完成..."
kubectl rollout status deployment/$DEPLOYMENT -n $NAMESPACE
echo "请手动切换端口配置到: $NEW_PORT"
echo "访问: http://192.168.32.184:31388/"
echo "修改 micro_web.ldapi.path 配置"
echo "=== HIS系统更新完成 ==="
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
3.2 使用更新脚本
bash
# 赋予执行权限
chmod +x update-his.sh
# 执行更新
./update-his.sh
# 赋予执行权限
chmod +x update-his.sh
# 执行更新
./update-his.sh
1
2
3
4
5
2
3
4
5
4. 版本管理
4.1 版本号规则
建议使用语义化版本号:
- 主版本号:重大功能变更
- 次版本号:新功能添加
- 修订号:bug修复
示例:2.1.3
4.2 版本递增更新
如果需要递增版本号:
修改镜像标签
bash# 构建新版本镜像 docker build -t 192.168.32.184:30080/haitai/his:2.1.0 .# 构建新版本镜像 docker build -t 192.168.32.184:30080/haitai/his:2.1.0 .1
2更新Deployment配置
bash# 修改deployment中的镜像版本 kubectl edit deployment ht-his -n ht-his # 或使用命令直接更新 kubectl set image deployment/ht-his his=192.168.32.184:30080/haitai/his:2.1.0 -n ht-his# 修改deployment中的镜像版本 kubectl edit deployment ht-his -n ht-his # 或使用命令直接更新 kubectl set image deployment/ht-his his=192.168.32.184:30080/haitai/his:2.1.0 -n ht-his1
2
3
4
5
5. 回滚操作
5.1 快速回滚
如果更新后出现问题,可以快速回滚:
bash
# 查看rollout历史
kubectl rollout history deployment/ht-his -n ht-his
# 回滚到上一个版本
kubectl rollout undo deployment/ht-his -n ht-his
# 回滚到指定版本
kubectl rollout undo deployment/ht-his --to-revision=2 -n ht-his
# 查看rollout历史
kubectl rollout history deployment/ht-his -n ht-his
# 回滚到上一个版本
kubectl rollout undo deployment/ht-his -n ht-his
# 回滚到指定版本
kubectl rollout undo deployment/ht-his --to-revision=2 -n ht-his
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
5.2 回滚验证
bash
# 检查回滚状态
kubectl rollout status deployment/ht-his -n ht-his
# 查看Pod状态
kubectl get pods -n ht-his
# 检查服务可用性
curl -I http://192.168.32.184:31388/ldemr/login/logout
# 检查回滚状态
kubectl rollout status deployment/ht-his -n ht-his
# 查看Pod状态
kubectl get pods -n ht-his
# 检查服务可用性
curl -I http://192.168.32.184:31388/ldemr/login/logout
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
6. 更新监控
6.1 更新过程监控
bash
# 监控Pod状态
watch kubectl get pods -n ht-his
# 监控deployment状态
watch kubectl get deployment -n ht-his
# 实时查看日志
kubectl logs -f deployment/ht-his -n ht-his
# 监控Pod状态
watch kubectl get pods -n ht-his
# 监控deployment状态
watch kubectl get deployment -n ht-his
# 实时查看日志
kubectl logs -f deployment/ht-his -n ht-his
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
6.2 性能监控
bash
# 查看资源使用情况
kubectl top pods -n ht-his
# 查看节点资源
kubectl top nodes
# 查看资源使用情况
kubectl top pods -n ht-his
# 查看节点资源
kubectl top nodes
1
2
3
4
5
2
3
4
5
7. 注意事项
重要提醒
- 备份数据:更新前务必备份重要数据和配置
- 测试验证:在测试环境先验证更新流程
- 业务时间:选择业务低峰期进行更新
- 回滚准备:准备回滚方案,确保能快速恢复
建议
- 建立更新日志记录制度
- 制定标准的更新操作流程
- 定期进行更新演练
- 监控系统性能变化
8. 故障排查
8.1 更新失败排查
bash
# 检查镜像是否存在
docker images | grep his
# 检查镜像仓库连接
docker pull 192.168.32.184:30080/haitai/his:2.0.0
# 检查Pod事件
kubectl describe pod <pod-name> -n ht-his
# 检查镜像是否存在
docker images | grep his
# 检查镜像仓库连接
docker pull 192.168.32.184:30080/haitai/his:2.0.0
# 检查Pod事件
kubectl describe pod <pod-name> -n ht-his
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
8.2 服务异常排查
bash
# 检查服务端点
kubectl get endpoints -n ht-his
# 检查网络连通性
kubectl exec -it <pod-name> -n ht-his -- netstat -tlnp
# 检查应用日志
kubectl logs <pod-name> -n ht-his --tail=100
# 检查服务端点
kubectl get endpoints -n ht-his
# 检查网络连通性
kubectl exec -it <pod-name> -n ht-his -- netstat -tlnp
# 检查应用日志
kubectl logs <pod-name> -n ht-his --tail=100
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
下一步
完成HIS更新后,如果需要更新前端,请继续进行 前端更新 步骤。
最后更新时间:2024年1月15日