Overview on Mysql Replication:
Mysql Replication is the process to copy your main Mysql server data to the many more servers. Or we can say that to keep data as backup then we can enable this mysql replication and have copy of the databases to slave servers for any recovery or backup.
Here we are going to create Master Slave Mysql Replication. So we will be using 2 servers where 1 will be the Master and 2nd will work as Slave.
Master Server: 192.168.1.2
Slave Server: 192.168.1.3
Slave Server: 192.168.1.3
Steps to Start Mysql Replication:-
1: Need to create a backup on the Master Server
2: Copy the backed up data file to the Slave.
3: Need to configure the master mysql server.
4: Now configure the slave server.
5: Then allow the privileges to the slave server on master server
6: Start mysql replication
2: Copy the backed up data file to the Slave.
3: Need to configure the master mysql server.
4: Now configure the slave server.
5: Then allow the privileges to the slave server on master server
6: Start mysql replication
Steps for setup :
Mysql installtion –
1) Master server configuration
Configuration done on Master.
2) Configuration on Slave Server
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
#On this slave server firstly we need to install the mysql server same as on master.
#then we have to create the database named as same as which we are going to replicate from master.
mysql -u root -p
create database database_name;
quit;
#Now just import the backup file taken from the master server for the same database;
mysql -u root -p database_name < database_name.sql
#Edit file my.cnf :
vi /etc/my.cnf
server-id =2 # Same as master but it should be differnt and unique
relay-log = /var/log/mysql/mysql-relay-bin.log
log_bin = /var/log/mysql/mysql-bin.log
binlog_do_db = database_name
#Save and Exit
#Just restart mysql now !
service mysql restart
#Now some configuration to make this server understand the details about master server to communicate
Mysql -u root -p
CHANGE MASTER TO MASTER_HOST='192.168.1.2', MASTER_USER='slave_username', MASTER_PASSWORD='password', MASTER_LOG_FILE='mysql-bin.000001', MASTER_LOG_POS= 103;
#Above command will make this server as slave server and also provide it the position from where it needs to start replication.
#Now activate the Slave Server
START SLAVE;
#To check slave server status:
SHOW SLAVE STATUS\G
|
0 comments:
Post a Comment