この連載では,
オープンソースカンファレンス (OSC) 東京での 「多様性時代のDB選択」 の開催中止
今回の
[MySQL] 2020年2月の主な出来事
2020年2月の製品リリースはありませんでした。1月の原稿締め切り後,
MySQL InnoDB ReplicaSetの登場
マイナーバージョンアップでもどんどん新機能を追加してくるMySQL 8.
InnoDB ReplicaSetは,
下記はMySQL Shellからレプリケーション環境を構築した例です。事前にMySQLサーバー
$ mysqlsh # 3つのインスタンス作成 出力略 MySQL JS > dba.deploySandboxInstance(3310) MySQL JS > dba.deploySandboxInstance(3320) MySQL JS > dba.deploySandboxInstance(3330) # マスターになる端末に接続 MySQL JS > \c root@localhost:3310 # レプリカセットの作成 MySQL localhost:3310 ssl JS > dba.createReplicaSet("repl1") A new replicaset with instance '127.0.0.1:3310' will be created. * Checking MySQL instance at 127.0.0.1:3310 This instance reports its own address as 127.0.0.1:3310 127.0.0.1:3310: Instance configuration is suitable. * Updating metadata... ReplicaSet object successfully created for 127.0.0.1:3310. Use rs.addInstance() to add more asynchronously replicated instances to this replicaset and rs.status() to check its status. <ReplicaSet:repl1> # レプリカセットへスレーブとなるノードの追加 MySQL localhost:3310 ssl JS > dba.getReplicaSet().addInstance("root@localhost:3320") You are connected to a member of replicaset 'repl1'. Adding instance to the replicaset... * Performing validation checks This instance reports its own address as 127.0.0.1:3320 127.0.0.1:3320: Instance configuration is suitable. * Checking async replication topology... * Checking transaction state of the instance... 〈略〉 Please select a recovery method [C]lone/[I]ncremental recovery/[A]bort (default Clone): C * Updating topology Waiting for clone process of the new member to complete. Press ^C to abort the operation. * Waiting for clone to finish... NOTE: 127.0.0.1:3320 is being cloned from 127.0.0.1:3310 ** Stage DROP DATA: Completed ** Clone Transfer FILE COPY #################################################### 100% Compl PAGE COPY #################################################### 100% Compl REDO COPY ################################################## 100% In Progress NOTE: 127.0.0.1:3320 is shutting down... * Waiting for server restart... ready * 127.0.0.1:3320 has restarted, waiting for clone to finish... ** Stage RESTART: Completed * Clone process has finished: 61.11 MB transferred in about 1 second (~inf TB/s) ** Configuring 127.0.0.1:3320 to replicate from 127.0.0.1:3310 ** Waiting for new instance to synchronize with PRIMARY... The instance '127.0.0.1:3320' was added to the replicaset and is replicating from 127.0.0.1:3310. MySQL localhost:3310 ssl JS > dba.getReplicaSet().addInstance("root@localhost:3320") 〈略〉
途中で追加するノードへのデータのコピーをクローンプラグインを利用するか,
MySQL localhost:3310 ssl JS > dba.getReplicaSet().status() You are connected to a member of replicaset 'repl1'. { "replicaSet": { "name": "repl1", "primary": "127.0.0.1:3310", "status": "AVAILABLE", "statusText": "All instances available.", "topology": { "127.0.0.1:3310": { "address": "127.0.0.1:3310", "instanceRole": "PRIMARY", "mode": "R/W", "status": "ONLINE" }, "127.0.0.1:3320": { "address": "127.0.0.1:3320", "instanceRole": "SECONDARY", "mode": "R/O", "replication": { "applierStatus": "APPLIED_ALL", "applierThreadState": "Slave has read all relay log; waiting for more updates", "receiverStatus": "ON", "receiverThreadState": "Waiting for master to send event", "replicationLag": null }, "status": "ONLINE" }, "127.0.0.1:3330": { 〈略〉 } }
レプリケーションの遅延はこの出力のreplicationLagで確認できるほか,
登場から20年近く経つ定番機能のレプリケーションにも構築運用の新しい仕組みが加わり進化を続けています。ぜひお試しください。