DBAtlas · データベース運用アトラス

パッチを適用

Oracle

# 1) Shut down the database, apply the binary patch with OPatch:
$ $ORACLE_HOME/OPatch/opatch apply
# 2) Open the database and load the SQL layer changes:
$ $ORACLE_HOME/OPatch/datapatch -verbose

opatch apply は Oracle Home のバイナリを更新する。その後 datapatch がオープン中のデータベースにディクショナリ/SQL の変更を適用し、dba_registry_sqlpatch に記録する。RAC ではローリング適用可能なパッチをノードごとに適用できる。

PostgreSQL

# Minor version patch = replace binaries + restart (no dump needed):
$ sudo systemctl stop postgresql-16
$ sudo dnf update postgresql16-server   # or apt upgrade
$ sudo systemctl start postgresql-16

同じメジャーバージョン系列内のマイナーパッチ(16.3 -> 16.4)はデータ形式を変更しない。パッケージを更新してサービスを再起動するだけでよく、pg_upgrade やダンプ/リストアは不要。

MySQL

# Minor/patch update: update the package and restart the service
$ sudo systemctl stop mysqld
$ sudo dnf update mysql-community-server   # or apt upgrade
$ sudo systemctl start mysqld

MySQL 8.0+ は起動時にデータディクショナリを自動的にアップグレードするため、個別の mysql_upgrade の手順は不要。レプリケーションでは、先にレプリカ、次にソースにパッチを適用する。

SQL Server

-- Run the Cumulative Update (CU) or GDR security update installer:
-- SQLServer2022-KB<no>-x64.exe /quiet /IAcceptSQLServerLicenseTerms
--   /Action=Patch /InstanceName=MSSQLSERVER
-- The instance then restarts; verify the version with SERVERPROPERTY.

CU (Cumulative Update) と GDR (General Distribution Release) の更新は setup インストーラで適用し、インスタンスの再起動が必要。Always On グループでは、ダウンタイムを最小化するため、先にセカンダリレプリカにパッチを適用してからフェイルオーバーする。

MongoDB

// 'Rolling' patch on a replica set: one node at a time
// 1) Stop mongod, replace the binary with the new patch version, restart
// 2) Secondaries first, the primary last
// Step down the primary manually before patching it:
rs.stepDown()

同じメジャーバージョン内(7.0.x)のパッチ更新は、セカンダリから順にローリング方式で行う。プライマリは rs.stepDown() で役割を引き渡してからパッチを適用し、書き込みのダウンタイムを最小化する。

Redis

# Patch via rolling restart in a replicated deployment:
# 1) Stop one replica node, install the new version, start it, wait for sync
# 2) Repeat for the remaining replicas
# 3) Finally, fail over the master and patch it:
redis-cli -h <replica> REPLICAOF NO ONE   # promote the upgraded replica

パッチバージョン(7.2.x)はローリング再起動で適用する。先にレプリカをアップグレードして再同期し、次にレプリカを master に昇格させて旧 master にパッチを適用する。Sentinel/Cluster はフェイルオーバーを自動化する。

Elasticsearch

# Rolling upgrade (patch within the same major version), per node:
PUT _cluster/settings
{ "persistent": { "cluster.routing.allocation.enable": "primaries" } }
# -> stop the node, update the package, start the node, then:
PUT _cluster/settings
{ "persistent": { "cluster.routing.allocation.enable": null } }

パッチ/マイナーアップグレードはローリングアップグレードで行う。シャードの割り当てを制限し、ノードを 1 台ずつ更新して再起動した後、割り当てを再度有効にし、クラスタが green に戻るのを待つ。

DBAtlas で開く →