跳转至

1.4.4 版本升级到 1.4.5

升级及迁移请保持 SECRET_KEY 与旧版本一致, 否则会导致数据库加密数据无法解密

  • 更新前请一定要做好备份 数据库 和 JumpServer 源代码的工作
cp -r /opt/jumpserver /opt/jumpserver_1.4.4_bak
mysqldump -uroot -p jumpserver > /opt/jumpserver_1.4.4.sql

升级步骤

请务必认真详细阅读每一个文字并理解后才能操作升级事宜

请先检查自己各组件的当前版本
本文档仅适合 1.4.4 的版本升级教程
从 1.4.x 版本开始, mysql 版本需要大于等于 5.6, mariadb 版本需要大于等于 5.5.56
更新配置文件需要把对应旧版本的设置复制到新的配置文件

1. 停止 core

cd /opt/jumpserver
source /opt/py3/bin/activate
./jms stop

自行替换 /opt 为你实际安装目录

2. 更新代码

cd /opt/jumpserver
git fetch
git checkout 1.4.5
git pull
如果执行 git pull 提示 error, 请按照提示自行处理

提示 error: Your local changes to the following file would be overwritten by merge

git reset --hard
git pull

3. 更新配置文件

mv config.py config_1.4.4.bak
cp config_example.py config.py
BOOTSTRAP_TOKEN=`cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 16`
sed -i "s/BOOTSTRAP_TOKEN = 'PleaseChangeMe'/BOOTSTRAP_TOKEN = '$BOOTSTRAP_TOKEN'/g" config.py
vi config.py

把旧配置文件 config_1.4.4.bak 的相关内容填到新的配置文件 config.yml 里面

请勿照抄, 以下模板仅供参考

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
    jumpserver.config
    ~~~~~~~~~~~~~~~~~
    Jumpserver project setting file
    :copyright: (c) 2014-2017 by Jumpserver Team
    :license: GPL v2, see LICENSE for more details.
"""
import os

BASE_DIR = os.path.dirname(os.path.abspath(__file__))


class Config:
    """
    Jumpserver Config File
    Jumpserver 配置文件
    Jumpserver use this config for drive django framework running,
    You can set is value or set the same envirment value,
    Jumpserver look for config order: file => env => default
    Jumpserver使用配置来驱动Django框架的运行,
    你可以在该文件中设置,或者设置同样名称的环境变量,
    Jumpserver使用配置的顺序: 文件 => 环境变量 => 默认值
    """
    # SECURITY WARNING: keep the secret key used in production secret!
    # 加密秘钥 生产环境中请修改为随机字符串,请勿外泄
    SECRET_KEY = '2vym+ky!997d5kkcc64mnz06y1mmui3lut#(^wd=%s_qj$1%x'

    # SECURITY WARNING: keep the bootstrap token used in production secret!
    # 预共享Token coco和guacamole用来注册服务账号,不在使用原来的注册接受机制
    BOOTSTRAP_TOKEN = 'PleaseChangeMe'

    # Development env open this, when error occur display the full process track, Production disable it
    # DEBUG 模式 开启DEBUG后遇到错误时可以看到更多日志
    # DEBUG = True

    # DEBUG, INFO, WARNING, ERROR, CRITICAL can set. See https://docs.djangoproject.com/en/1.10/topics/logging/
    # 日志级别
    # LOG_LEVEL = 'DEBUG'
    # LOG_DIR = os.path.join(BASE_DIR, 'logs')

    # Session expiration setting, Default 24 hour, Also set expired on on browser close
    # 浏览器Session过期时间,默认24小时, 也可以设置浏览器关闭则过期
    # SESSION_COOKIE_AGE = 3600 * 24
    # SESSION_EXPIRE_AT_BROWSER_CLOSE = False

    # Database setting, Support sqlite3, mysql, postgres ....
    # 数据库设置
    # See https://docs.djangoproject.com/en/1.10/ref/settings/#databases

    # SQLite setting:
    # 使用单文件sqlite数据库
    # DB_ENGINE = 'sqlite3'
    # DB_NAME = os.path.join(BASE_DIR, 'data', 'db.sqlite3')

    # MySQL or postgres setting like:
    # 使用Mysql作为数据库
    DB_ENGINE = 'mysql'
    DB_HOST = '127.0.0.1'
    DB_PORT = 3306
    DB_USER = 'jumpserver'
    DB_PASSWORD = ''
    DB_NAME = 'jumpserver'

    # When Django start it will bind this host and port
    # ./manage.py runserver 127.0.0.1:8080
    # 运行时绑定端口
    HTTP_BIND_HOST = '0.0.0.0'
    HTTP_LISTEN_PORT = 8080

    # Use Redis as broker for celery and web socket
    # Redis配置
    REDIS_HOST = '127.0.0.1'
    REDIS_PORT = 6379
    # REDIS_PASSWORD = ''
    # REDIS_DB_CELERY_BROKER = 3
    # REDIS_DB_CACHE = 4

    # Use OpenID authorization
    # 使用OpenID 来进行认证设置
    # BASE_SITE_URL = 'http://localhost:8080'
    # AUTH_OPENID = False  # True or False
    # AUTH_OPENID_SERVER_URL = 'https://openid-auth-server.com/'
    # AUTH_OPENID_REALM_NAME = 'realm-name'
    # AUTH_OPENID_CLIENT_ID = 'client-id'
    # AUTH_OPENID_CLIENT_SECRET = 'client-secret'

    def __init__(self):
        pass

    def __getattr__(self, item):
        return None


class DevelopmentConfig(Config):
    pass


class TestConfig(Config):
    pass


class ProductionConfig(Config):
    pass


# Default using Config settings, you can write if/else for different env
config = DevelopmentConfig()

4. 更新依赖

pip install wheel
pip install --upgrade pip setuptools
pip install -r requirements/requirements.txt

5. 处理升级

cd utils
sh make_migrations.sh
如果执行 sh make_migrations.sh 有错误, 请参考此处进行处理

You have an error in your SQL syntax; check the manual than corresponds to your MySql server version for the right syntax to use near '(6) NOT NULL'

# 这是因为你的数据库版本不对,1.4.x 版本开始 mysql 版本需要大于等于 5.6, mariadb 版本需要大于等于 5.5.56
# 请升级数据库后重新操作

升级前版本小于 1.1.0 需要执行此步骤

sh 2018_04_11_migrate_permissions.sh

升级前版本小于 1.4.0 需要执行此步骤

sh 2018_07_15_set_win_protocol_to_ssh.sh

5. 启动 core

cd /opt/jumpserver
./jms start

确定启动没有错误