Professional Documents
Culture Documents
How To Configure InnoDB ReplicaSet New MySQL - DBsGuru
How To Configure InnoDB ReplicaSet New MySQL - DBsGuru
com
+91-93101-67776
OTHERS SCRIPTS
0(0)
How to Configure InnoDB ReplicaSet
Only instances running MySQL version 8.0 and later are supported.
Only GTID-based replication is supported, binary log file position replication is not
compatible with InnoDB ReplicaSet.
Only Row Based Replication (RBR) is supported, Statement Based Replication (SBR) is
unsupported
Replication filters are not supported.
No automatic failover.
Installation
Hostname IP Role Server_ID Port
Link
test-
192.168.114.177 Master 1 3306 Click Here
machine01
test- Replica-
192.168.114.177 3 3307 Click Here
machine01 1
test- Replica-
192.168.114.176 2 3306 Click Here
machine02 2
test- Replica-
192.168.114.176 4 3307
machine02 3
test-machine01 Configuration
1 mysql> prompt master >
2 PROMPT set to 'master >'
3 master >
4 master >select @@server_id;
5 +-------------+
6 | @@server_id |
7 +-------------+
8 | 1 |
9 +-------------+
10 1 row in set (0.00 sec)
11
12 master >select @@port;
13 +--------+
14 | @@port |
15 +--------+
16 | 3306 |
17 +--------+
18 1 row in set (0.00 sec)
19
20 mysql> prompt replica-1 >
21 PROMPT set to 'replica-1 >'
22 replica-1 >
23 replica-1 >select @@server_id;
24 +-------------+
25 | @@server_id |
26 +-------------+
27 | 3 |
28 +-------------+
29 1 row in set (0.00 sec)
30
31 replica-1 >select @@port;
32 +--------+
33 | @@port |
34 +--------+
35 | 3307 |
36 +--------+
37 1 row in set (0.00 sec)
38
39 [root@test-machine01 ~]# cat /etc/my.cnf
40 [mysqld@inst1]
41 #General
42 user = mysql
43 port = 3306
44 server_id = 1
45 socket=/var/lib/mysql/mysql.sock
46 pid_file=/var/run/mysqld/mysqld.pid
47
48 # Data Storage
49 datadir=/var/lib/mysql
50 innodb_directories="/u01/mysql/"
51
52 #Logging
53 log_bin = /var/lib/mysql/binlog
54 log_error = /var/lib/mysql/mysqld.log
55 expire_logs_days = 7
56 relay_log = /var/lib/mysql/relay_bin01
57 relay_log_index = /var/lib/mysql/relay_bin.index
58 relay_log_recovery = on
59 master_info_repository = TABLE
60 relay_log_info_repository = TABLE
61
62 # GTID Based Replication Parameter
63 gtid-mode=on
64 enforce-gtid-consistency=1
65 log_slave_updates= 1
66
67
68 [mysqld@inst2]
69 #General
70 user = mysql
71 port=3307
72 server_id = 3
73 socket=/u01/mysql-2/mysql.sock
74 pid_file=/u01/mysql-2/mysqld.pid
75
76 # Data Storage
77 basedir=/u01/mysql-2
78 datadir=/u01/mysql-2/data
79 innodb_directories="/u01/mysql/"
80 plugin_dir=/usr/lib64/mysql/plugin
81
82 #Logging
83 log_bin = /u01/mysql-2/data/binlog
84 log_error = /u01/mysql-2/data/mysqld.log
85 expire_logs_days = 7
86 relay_log = /u01/mysql-2/data/relay_bin01
87 relay_log_index = /u01/mysql-2/data/relay_bin.index
88 relay_log_recovery = on
89 master_info_repository = TABLE
90 relay_log_info_repository = TABLE
91
92 # GTID Based Replication Parameter
93 gtid-mode=on
94 enforce-gtid-consistency=1
95 log_slave_updates= 1
96 [root@test-machine01 ~]#
test-machine02 Configuration
1 mysql> prompt replica-2>
2 PROMPT set to 'replica-2>'
3 replica-2>
4 replica-2>select @@server_id;
5 +-------------+
6 | @@server_id |
7 +-------------+
8 | 2 |
9 +-------------+
10 1 row in set (0.00 sec)
11
12 replica-2>select @@port;
13 +--------+
14 | @@port |
15 +--------+
16 | 3306 |
17 +--------+
18 1 row in set (0.00 sec)
19
20
21 mysql> prompt replica-3>
22 PROMPT set to 'replica-3>'
23 replica-3>select @@server_id;
24 +-------------+
25 | @@server_id |
26 +-------------+
27 | 4 |
28 +-------------+
29 1 row in set (0.00 sec)
30
31 replica-3>select @@port;
32 +--------+
33 | @@port |
34 +--------+
35 | 3307 |
36 +--------+
37 1 row in set (0.00 sec)
38
39 replica-3>
40
41 [root@test-machine02 ~]# cat /etc/my.cnf
42 [mysqld@inst1]
43 #General
44 user = mysql
45 port = 3306
46 server_id = 2
47 bind-address = 0.0.0.0
48 socket=/u01/mysql-8/mysql.sock
49 pid_file=/u01/mysql-8/mysqld.pid
50
51 # Data Storage
52 basedir=/u01/mysql-8
53 datadir=/u01/mysql-8/data
54 innodb_directories="/u01/mysql-8;/u01/mysql"
55
56 #Logging
57 log_bin = /u01/mysql-8/data/binlog
58 log_error = /u01/mysql-8/data/mysqld.log
59 expire_logs_days = 7
60 relay_log = /u01/mysql-8/data/relay_bin01
61 relay_log_index = /u01/mysql-8/data/relay_bin.index
62 relay_log_recovery = on
63 master_info_repository = TABLE
64 relay_log_info_repository = TABLE
65
66 # GTID Based Replication Parameter
67 gtid-mode=on
68 enforce-gtid-consistency=1
69 log_slave_updates=1
70
71 [mysqld@inst2]
72 #General
73 user = mysql
74 port = 3307
75 server_id = 4
76 socket=/u01/mysql-2/mysql.sock
77 pid_file=/u01/mysql-2/mysqld.pid
78 require_secure_transport = ON
79
80 # Data Storage
81 basedir=/u01/mysql-2
82 datadir=/u01/mysql-2/data
83 plugin_dir=/u01/mysql-8/lib/plugin
84
85 #Logging
86 log_bin = /u01/mysql-2/data/binlog
87 log_error = /u01/mysql-2/data/mysqld.log
88 expire_logs_days = 7
89 relay_log = /u01/mysql-2/data/relay_bin01
90 relay_log_index = /u01/mysql-2/data/relay_bin.index
91 relay_log_recovery = on
92 master_info_repository = TABLE
93 relay_log_info_repository = TABLE
94
95 # GTID Based Replication Parameter
96 gtid-mode=on
97 enforce-gtid-consistency=1
98 log_slave_updates= 1
99
100 [root@test-machine02 ~]#
test-machine01
test-machine02
1 [root@test-machine02 ~]# mysqlsh
2 MySQL Shell 8.0.23
3
4 Copyright (c) 2016, 2021, Oracle and/or its affiliates.
5 Oracle is a registered trademark of Oracle Corporation an
6 Other names may be trademarks of their respective owners.
7
8 Type '\help' or '\?' for help; '\quit' to exit.
9 MySQL JS > dba.configureReplicaSetInstance('root@localh
10 Configuring local MySQL instance listening at port 3306 f
11
12 This instance reports its own address as test-machine02:3
13 Clients and other cluster members will communicate with i
14 Password for new account: *********
15 Confirm password: *********
16
17 The instance 'test-machine02:3306' is valid to be used in
18 Cluster admin user 'rsadmin'@'test-machine02%' created.
19 The instance 'test-machine02:3306' is already ready to be
20 MySQL JS >
21
22
23
24
25
26 MySQL JS > dba.configureReplicaSetInstance('root@localh
27 Configuring local MySQL instance listening at port 3307 f
28
29 This instance reports its own address as test-machine02:3
30 Clients and other cluster members will communicate with i
31 Password for new account: *********
32 Confirm password: *********
33
34 The instance 'test-machine02:3307' is valid to be used in
35 Cluster admin user 'rsadmin'@'test-machine02%' created.
36 The instance 'test-machine02:3307' is already ready to be
37 MySQL JS >
Step 6. Check the status of Replication: You can also check the status from mysqlshell
with SQL mode.
1 MySQL test-machine01:3306 ssl JS >
2 MySQL test-machine01:3306 ssl JS > \sql
3 Switching to SQL mode... Commands end with ;
4 MySQL test-machine01:3306 ssl SQL >
5
6 MySQL test-machine01:3306 ssl SQL > \connect root@loca
7 Creating a session to 'root@localhost:3307'
8 Fetching schema names for autocompletion... Press ^C to s
9 Closing old connection...
10 Your MySQL connection id is 31
11 Server version: 8.0.22 MySQL Community Server - GPL
12 No default schema selected; type \use <schema> to set one
13 MySQL localhost:3307 ssl SQL > show slave status \G;
14 *************************** 1. row **********************
15 Slave_IO_State: Waiting for master to send
16 Master_Host: test-machine01
17 Master_User: mysql_innodb_rs_3
18 Master_Port: 3306
19 Connect_Retry: 60
20 Master_Log_File: binlog.000002
21 Read_Master_Log_Pos: 54063
22 Relay_Log_File: relay_bin01.000002
23 Relay_Log_Pos: 28074
24 Relay_Master_Log_File: binlog.000002
25 Slave_IO_Running: Yes
26 Slave_SQL_Running: Yes
27 Replicate_Do_DB:
28 Replicate_Ignore_DB:
29 Replicate_Do_Table:
30 Replicate_Ignore_Table:
31 Replicate_Wild_Do_Table:
32 Replicate_Wild_Ignore_Table:
33 Last_Errno: 0
34 Last_Error:
35 Skip_Counter: 0
36 Exec_Master_Log_Pos: 54063
37 Relay_Log_Space: 28279
38 Until_Condition: None
39 Until_Log_File:
40 Until_Log_Pos: 0
41 Master_SSL_Allowed: No
42 Master_SSL_CA_File:
43 Master_SSL_CA_Path:
44 Master_SSL_Cert:
45 Master_SSL_Cipher:
46 Master_SSL_Key:
47 Seconds_Behind_Master: 0
48 Master_SSL_Verify_Server_Cert: No
49 Last_IO_Errno: 0
50 Last_IO_Error:
51 Last_SQL_Errno: 0
52 Last_SQL_Error:
53 Replicate_Ignore_Server_Ids:
54 Master_Server_Id: 1
55 Master_UUID: 13ecba9c-444a-11eb-a397-00
56 Master_Info_File: mysql.slave_master_info
57 SQL_Delay: 0
58 SQL_Remaining_Delay: NULL
59 Slave_SQL_Running_State: Slave has read all relay l
Search
60 Master_Retry_Count: 86400
61 Master_Bind:
62 Last_IO_Error_Timestamp:
63 Search
Last_SQL_Error_Timestamp:
64 Master_SSL_Crl:
65 Master_SSL_Crlpath:
66 Retrieved_Gtid_Set: 13ecba9c-444a-11eb-a397-00
67 Hits by Community
Executed_Gtid_Set: 13ecba9c-444a-11eb-a397-00
68 Auto_Position: 1
69 Replicate_Rewrite_DB:
Total
70 Website Visits: 1248626
Channel_Name:
71 Master_TLS_Version:
72 Master_public_key_path:
73 Get_master_public_key: 1
74 Network_Namespace:
75 1 row in set (0.0027 sec)
76 ERROR: 1065 FEEDBACK
(42000): Query was empty
77 MySQL localhost:3307 ssl SQL >
LOGIN
REGISTRATION
Subscribe
Part II : How to perform Switchover/Failover in MySql InnoDB ReplicaSet Click here
to read more.
Part III : How To Bootstrap MySQL Router For InnoDB ReplicaSet Click here to read
more.
Achievements
This document is only for learning purpose and always validate in the LAB environment first
before applying in the LIVE environment.
Recent Posts
Steps to Apply Combo Patch (Oct 2022) on Clusterware in
Two Node RAC in Oracle
No votes so far! Be the first to rate this post.
Comments
via archive_command in PostgreSQL
5 (3)
5 (3)
Archives
Select Month
Categories
ADMINISTRATION
APPSDBA
ASM
DATABASE
DATAGUARD
DATAPUMP
EXADATA
GOLDENGATE
HIGH AVAILBILITY
ODA
OEM
OTHERS
PATCHING
PG_ADMIN
PG_BACKUP
PG_PERFORMANCE
PG_REPLICATION
POSTGRESQL
RAC
RMAN
SCRIPTS
SECURITY
TUNING
UNIX
UPGRADE
WEBLOGIC
WINDOWS
Tags
WEBLOGIC
LIVE
Follow Us
Contact Us
Phone
+91-93101-67776
Email
info@dbsguru.com