「JumpServer」- 升级,最新版本,2.6.0+

  CREATED BY JENKINSBOT

问题描述

该笔记将记录:将 JumpServer 2.6.0+ 升级到 latest(最新版本)的方法,以及相关问题的解决方案。

解决方案

从 2.6 后,统一企业版本与开源版本安装方式,企业版和社区版可以无缝切换。今后只会维护这种安装方式(通过 jmsctl.sh 管理),其他安装方式不再提供技术支持。所以,此次升级不像以往那样复杂,非常简单。

此外根据官方文档,升级过程会自动进行数据库备份,因此我们无需再单独进行数据备份(不过我们还是进行数据备份)。而且为了备份和管理的简单化,我们未使用外置数据库,所以备份过程也很简单,直接复制数据目录即可。

要求说明

jumpserver 版本 >= v2.6.0
jumpserver 版本 < v2.6.0 的请先参考迁移文档迁移到最新版本

补充说明

该文档最初记录 从 2.8.2 升级到 2.12.0 的方法,后来由于 2.6.0+ 升级方式的变更(更加简单),因此 2.6 之后的版本升级过程都将记录到该文档中。

2.8.2⇒2.12.0

# cd /opt
# yum -y install wget
# wget https://github.com/jumpserver/installer/releases/download/v2.12.0/jumpserver-installer-v2.12.0.tar.gz
# tar -xf jumpserver-installer-v2.12.0.tar.gz
# cd jumpserver-installer-v2.12.0

# ./jmsctl.sh upgrade
是否将版本更新至 v2.12.0 ? (y/n)  (默认为 n): y

1. 检查配置变更
配置文件位置: /opt/jumpserver/config
/opt/jumpserver/config/config.txt  [ √ ]
/opt/jumpserver/config/core/config.yml  [ √ ]
/opt/jumpserver/config/koko/config.yml  [ √ ]
/opt/jumpserver/config/mariadb/mariadb.cnf  [ √ ]
/opt/jumpserver/config/mysql/my.cnf  [ √ ]
/opt/jumpserver/config/nginx/lb_http_server.conf  [ √ ]
/opt/jumpserver/config/nginx/lb_rdp_server.conf  [ √ ]
/opt/jumpserver/config/nginx/lb_ssh_server.conf  [ √ ]
/opt/jumpserver/config/redis/redis.conf  [ √ ]
/opt/jumpserver/config/nginx/cert/server.crt  [ √ ]
/opt/jumpserver/config/nginx/cert/server.key  [ √ ]
完成

2. 检查程序文件变更
完成

3. 升级镜像文件
Docker: Pulling from jumpserver/core:v2.12.0        [ OK ]
Docker: Pulling from jumpserver/koko:v2.12.0        [ OK ]
Docker: Pulling from jumpserver/nginx:v2.12.0       [ OK ]
Docker: Pulling from jumpserver/redis:6-alpine      [ OK ]
Docker: Pulling from jumpserver/mysql:5             [ OK ]
Docker: Pulling from jumpserver/lion:v2.12.0        [ OK ]
完成

4. 备份数据库
正在备份...
mysqldump: [Warning] Using a password on the command line interface can be insecure.
[SUCCESS] 备份成功! 备份文件已存放至: /opt/jumpserver/db_backup/jumpserver-2021-03-19_08:32:39.sql

5. 进行数据库变更
表结构变更可能需要一段时间, 请耐心等待
检测到 JumpServer 正在运行, 是否需要关闭并继续升级? (y/n)  (默认为 n): y

Stopping jms_core ... done
Stopping jms_koko ... done
Stopping jms_lion ... done
Stopping jms_nginx ... done
Stopping jms_celery ... done
Removing jms_core ... done
Removing jms_koko ... done
Removing jms_lion ... done
Removing jms_nginx ... done
Removing jms_celery ... done

2021-03-19 08:32:44 Collect static files
2021-03-19 08:32:44 Collect static files done
2021-03-19 08:32:44 Check database structure change ...
2021-03-19 08:32:44 Migrate model change to database ...

473 static files copied to '/opt/jumpserver/data/static'.
Operations to perform:
  Apply all migrations: acls, admin, applications, assets, audits, auth, authentication, captcha, common, contenttypes, django_cas_ng, django_celery_beat, jms_oidc_rp, ops, orgs, perms, sessions, settings, terminal, tickets, users
Running migrations:
  No migrations to apply.
  # 有时候是下方红色的提示,忽略即可,不需要做处理。
  Your models have changes that are not yet reflected in a migration, and so won't be applied.
  Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them.
完成

6. 清理镜像
是否需要清理旧版本镜像文件? (y/n)  (默认为 n): y
Untagged: jumpserver/core:v2.11.3
Untagged: jumpserver/luna:v2.11.3
Untagged: jumpserver/lina:v2.11.3
Untagged: jumpserver/koko:v2.11.3
Untagged: jumpserver/lion:v2.11.3
完成

7. 升级成功, 可以重新启动程序了
cd /opt/jumpserver-installer-v2.12.0
./jmsctl.sh start

# ./jmsctl.sh start

2.12.0⇒2.16.3

JumpServer 文档/v2.16.3/升级文档

数据备份:

# 数据备份
cd /opt/jumpserver-installer
./jmsctl.sh stop
rsync -avz /opt/jumpserver/ /srv/backup/

# 重新启动服务
./jmsctl.sh start

服务升级:

cd /opt
yum -y install wget
wget https://github.com/jumpserver/installer/releases/download/v2.16.3/jumpserver-installer-v2.16.3.tar.gz
tar -xf jumpserver-installer-v2.16.3.tar.gz
cd jumpserver-installer-v2.16.3

./jmsctl.sh upgrade
./jmsctl.sh start

2.19.2⇒2.22.2

cd /opt
yum -y install wget
wget https://github.com/jumpserver/installer/releases/download/v2.22.2/jumpserver-installer-v2.22.2.tar.gz
tar -xf jumpserver-installer-v2.22.2.tar.gz
cd jumpserver-installer-v2.22.2

./jmsctl.sh upgrade
./jmsctl.sh start

2.20.2⇒2.22.2

cd /opt
yum -y install wget
wget https://github.com/jumpserver/installer/releases/download/v2.22.2/jumpserver-installer-v2.22.2.tar.gz
tar -xf jumpserver-installer-v2.22.2.tar.gz
cd jumpserver-installer-v2.22.2

./jmsctl.sh upgrade
./jmsctl.sh start

2.22.2⇒2.28.6

环境信息:
1)我们直接使用 JumpServer 内置 MySQL 及 Redis 服务;
2)我们是通过 jumpserver-installer 进行服务部署管理;

数据备份:

/opt/jumpserver-installer-v2.22.2/jmsctl.sh down

rsync -av /opt/jumpserver/ /opt/jumpserver-backup-v2.22.2/

/opt/jumpserver-installer-v2.22.2/jmsctl.sh start

软件升级:

cd /opt
# yum -y install wget
wget https://github.com/jumpserver/installer/releases/download/v2.28.6/jumpserver-installer-v2.28.6.tar.gz
tar -xf jumpserver-installer-v2.28.6.tar.gz
cd jumpserver-installer-v2.28.6

./jmsctl.sh upgrade
./jmsctl.sh start

关于 Docker Compose 组件:
JumpServer 启动时需要使用 docker-compose 命令,所以在升级过程中,我们也对 Docker Compose 进行升级(1.29.2 to 2.14.2);

参考文献

JumpServer 文档/升级文档
JumpServer 文档/v2.16.3/升级文档