大版本升级
Oracle
# Recommended: AutoUpgrade (analyze + fixups + deploy in a single flow):
$ java -jar $NEW_ORACLE_HOME/rdbms/admin/autoupgrade.jar -config db.cfg -mode deploy
# Graphical alternative: DBUA (Database Upgrade Assistant)
$ $NEW_ORACLE_HOME/bin/dbuaAutoUpgrade 通过一条命令完成分析、预修复、升级和后续步骤;可依次处理多个数据库以缩短停机时间。DBUA 以向导界面完成同样的工作。事先进行完整备份是必须的。
PostgreSQL
# pg_upgrade to the new major version (with both clusters stopped):
$ pg_upgrade \
--old-datadir=/var/lib/pgsql/16/data \
--new-datadir=/var/lib/pgsql/17/data \
--old-bindir=/usr/pgsql-16/bin \
--new-bindir=/usr/pgsql-17/bin \
--link # fast migration with hard links
# Then gather statistics (analyze_new_cluster.sh was removed in PG14):
$ vacuumdb --all --analyze-in-stagespg_upgrade 原地执行大版本迁移(16 -> 17);--link 模式通过创建硬链接而非复制文件来缩短时间,但会使旧集群失效。迁移后必须重新收集统计信息。
MySQL
# In-place upgrade (same datadir, new binaries):
$ sudo systemctl stop mysqld
$ sudo dnf install mysql-community-server-8.4 # replacing the old package
$ sudo systemctl start mysqld # the server upgrades the dictionary automatically从 MySQL 8.x 起支持原地大版本升级:使用新二进制文件启动的服务器会自动转换数据字典和系统表(旧的单独 mysql_upgrade 步骤已被移除)。每次只升级一个大版本。
SQL Server
-- In-place major version upgrade (with setup):
-- setup.exe /q /ACTION=upgrade /INSTANCENAME=MSSQLSERVER
-- /IAcceptSQLServerLicenseTerms
-- Alternative: install a new instance side by side and move the databases (restore/attach).setup /ACTION=upgrade 将实例原地升级到新的大版本。更安全的方法是并行安装(side-by-side),再通过 backup/restore 迁移数据库,并在单独的步骤中提升兼容级别。
MongoDB
// Stepwise major upgrade (e.g. 6.0 -> 7.0), one major version at a time:
// 1) Roll the binary to 7.0 on all nodes
// 2) Once the cluster is stable, raise the FCV:
db.adminCommand({ setFeatureCompatibilityVersion: "7.0", confirm: true })MongoDB 的大版本升级分两个阶段:先将所有节点的二进制文件滚动升级到新版本,待集群稳定后再将 FCV 提升到新版本。每次只能升级一个大版本;FCV 单独管理,以保留降级能力。
Redis
# Major upgrade via a replica (no downtime):
# 1) Create a replica on the new version, wait for full sync from the master
# 2) Prepare the application; fail over the master:
redis-cli -h <new-replica> REPLICAOF NO ONE # make the new version the master
# 3) Upgrade the old master, attach it as a replica of the new masterRedis 大版本迁移(6.x -> 7.x)的做法是:在新版本上搭建副本,等其同步后提升为 master;写入停机时间因此几乎降为零。RDB 文件与后续版本兼容。
Elasticsearch
# Major versions cannot be skipped; one major at a time, via the last minor first (e.g. 6.8 -> 7.17 -> 8.x):
# 1) Upgrade to the last minor (7.17), resolve the GET _migration/deprecations warnings
# 2) Rolling upgrade, per node: set allocation to "primaries" -> update the node -> start -> wait for green
# Alternative: full-cluster restart (stop all nodes -> upgrade -> start together); this also moves only one majorElasticsearch 不支持以任何方式跳过大版本:滚动升级和全集群重启都只能升级到下一个大版本(n -> n+1),且要求源集群处于最后一个小版本(如 7.17)。两个大版本之前创建的索引(如 6.x 中创建的)无法在新版本中打开;必须在迁移前用 _reindex 重建(8.x 只能以只读 archive 索引的方式有限读取)。迁移前先做快照并解决弃用警告。