升级问题

    1. mysql: [Warning] Using a password on the command line interface can be insecure.
    2. ERROR 1022 (23000) at line 1237: Can't write; duplicate key in table 'xxxxxx'
    3. ERRO[0008] error waiting for container: context canceled
    4. read unix @->ar/run/docker.sock: read: connection reset by peer
    5. 数据库恢复失败,请检查数据库文件是否完整,或尝试手动恢复!
    1. ./jmsctl.sh stop
    1. docker exec -it jms_mysql /bin/bash
    1. drop database jumpserver;
    2. create database jumpserver default charset 'utf8';
    3. exit;
    4. exit
    1. ./jmsctl.sh restore_db /opt/jumpserver.sql
    2. # 注意: 确定在导入数据库的过程中没有错误
    1. ./jmsctl.sh start

    2. 升级过程提示错误

    1. Operations to perform:
    2. Apply all migrations: acls, admin, applications, assets, audits, auth, authentication, captcha, common, contenttypes, django_cas_ng, django_celery_beat, jms_oidc_rp, notifications, ops, orgs, perms, sessions, settings, terminal, tickets, users
    3. Running migrations:
    4. File "/usr/local/lib/python3.8/site-packages/django/db/backends/utils.py", line 82, in _execute
    5. return self.cursor.execute(sql)
    6. File "/usr/local/lib/python3.8/site-packages/django/db/backends/mysql/base.py", line 73, in execute
    7. return self.cursor.execute(query, args)
    8. File "/usr/local/lib/python3.8/site-packages/MySQLdb/cursors.py", line 206, in execute
    9. res = self._query(query)
    10. File "/usr/local/lib/python3.8/site-packages/MySQLdb/cursors.py", line 319, in _query
    11. db.query(q)
    12. File "/usr/local/lib/python3.8/site-packages/MySQLdb/connections.py", line 259, in query
    13. _mysql.connection.query(self, query)
    14. MySQLdb._exceptions.OperationalError: (1050, "Table 'tickets_approvalrule' already exists")
    1. Operations to perform:
    2. Apply all migrations: acls, admin, applications, assets, audits, auth, authentication, captcha, common, contenttypes, django_cas_ng, django_celery_beat, jms_oidc_rp, notifications, ops, orgs, perms, sessions, settings, terminal, tickets, users
    3. Running migrations:
    4. Applying assets.0084_auto_20220112_1959...2022-01-24 14:38:47 Perform migrate failed, exit
    5. Traceback (most recent call last):
    6. File "/usr/local/lib/python3.8/site-packages/django/db/backends/mysql/base.py", line 73, in execute
    7. return self.cursor.execute(query, args)
    8. File "/usr/local/lib/python3.8/site-packages/MySQLdb/cursors.py", line 206, in execute
    9. res = self._query(query)
    10. File "/usr/local/lib/python3.8/site-packages/MySQLdb/cursors.py", line 319, in _query
    11. db.query(q)
    12. File "/usr/local/lib/python3.8/site-packages/MySQLdb/connections.py", line 259, in query
    13. _mysql.connection.query(self, query)
    14. MySQLdb._exceptions.IntegrityError: (1215, 'Cannot add foreign key constraint')
    1. # 通过 grep 检查 sql 文件
    2. mysqldump -uroot -p jumpserver > jumpserver.sql
    3. # 检查字符集, 如果都返回 utf8 则无问题
    4. grep -r "DEFAULT CHARSET=" jumpserver.sql
    5. # 检查排序规则,正常情况下返回都是空或者唯一
    6. grep -r "COLLATE=" jumpserver.sql
    7. grep -r "COLLATE " jumpserver.sql
    8. # 如果上述结果不一致,请手动修正数据库。