Azure Database for MySQL フレキシブル サーバーのレプリケーション設定手順です。
マスターサーバーに読み取り専用レプリカを追加して、MySQLサーバーのレプリケーションします。
プライマリサーバーへのレプリカの追加から、レプリケーション停止、プライマリへの昇格までの手順を確認しています。
※本記事内では、Azure Database for MySQL Flexible ServerをAzureDatabase for MySQL フレキシブル サーバーとして表記しています。
※本記事で確認しているのは、読み取り専用レプリカを追加して利用する方法です。
# プライマリのMySQLサーバーへログイン
[root@vm-01 ~]#mysql -h mysql-zabbix-01.mysql.database.azure.com -u 管理者ユーザー名 -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 842 Server version: 8.0.40-azure Source distribution
Copyright (c) 2000, 2025, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.
Type 'help;’ or '\h’ for help. Type '\c’ to clear the current input statement.
# レプリカのMySQLサーバーへログイン
[root@vm-01 ~]# mysql -h mysql-zabbix-02.mysql.database.azure.com -u 管理者ユーザー名 -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 25 Server version: 8.0.40-azure Source distribution
Copyright (c) 2000, 2025, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.
Type 'help;’ or '\h’ for help. Type '\c’ to clear the current input statement.
MySQLサーバーの書き込み権限の設定状態を確認します。
プライマリサーバーでは、read_only が OFF となっており、読み書きが可能であることが確認できます。
一方、レプリカサーバーでは、read_only が ON となっており、読み取り専用であることが確認できます。
MySQLサーバーの書き込み権限を確認
# プライマリのMySQLサーバーで書き込み権限を確認
mysql>show global variables like 'read_only’; +—————+——-+
| Variable_name | Value |
+—————+——-+
| read_only | OFF |
+—————+——-+
1 row in set (0.01 sec)
# レプリカのMySQLサーバーで書き込み権限を確認
mysql>show global variables like 'read_only’;
+—————+——-+
| Variable_name | Value |
+—————+——-+
| read_only | ON |
+—————+——-+
1 row in set (0.01 sec)
# プライマリのMySQLサーバーで書き込み権限を確認
mysql>show global variables like 'read_only’; +—————+——-+ | Variable_name | Value | +—————+——-+ | read_only | OFF | +—————+——-+ 1 row in set (0.00 sec)
# レプリカから昇格したMySQLサーバーで書き込み権限を確認
mysql>show global variables like 'read_only’; +—————+——-+ | Variable_name | Value | +—————+——-+ | read_only | OFF | +—————+——-+ 1 row in set (0.01 sec)