Main steps
Note: Consider server1 as master and server2
as slave and replicating database as exampledb.
On
Server 1(Master)
1) Configuring the Master
1) Configuring the Master
ü
To make sure that the
replication can work, we must make MySQL listen on all interfaces on the master (server1), therefore we comment out the line bind-address
= 127.0.0.1 in /etc/mysql/my.cnf:
Eg: #bind-address
= 127.0.0.1
ü We have to tell MySQL for which database it should write logs
(these logs are used by the slave to see what has changed on the master), which
log file it should use, and we have to specify that this MySQL server is the
master. We want to replicate the database exampledb
Eg:
server-id = 1
log_bin = /var/log/mysql/mysql-bin.log
expire_logs_days = 10
max_binlog_size = 100M
binlog_do_db = exampledb
2) Restart MySQL server
3) Set up a replication user slave_user that can be used by server2 to access the MySQL database on server1:
mysql> GRANT REPLICATION SLAVE ON *.* TO 'slave_user'@'%'
IDENTIFIED BY 'slave_password';
mysql> FLUSH PRIVILEGES;
4)
Find out the
master status of the server1 and create a SQL dump of the database.
mysql> USE
exampledb;
mysql> FLUSH
TABLES WITH READ LOCK;
mysql> SHOW
MASTER STATUS;
In another shell,
Ex:
Shell> mysqldump -u root -pyourrootsqlpassword --opt exampledb
> snapshot.sql
5) Unlock tables
mysql> UNLOCK TABLES;
On
server 2(Slave)
1)
Configure
slave server by changing my.cnf file
Ex:
server-id=2
master-connect-retry=60
replicate-do-db=exampledb
2) Restart MySQL server
3) Import the SQL dump
Ex:
Shell> mysql -u root
-pyourrootsqlpassword exampledb < snapshot.sq
4) Give slave
parameters
Ex:
mysql> CHANGE
MASTER TO MASTER_HOST='192.168.0.100',
MASTER_USER='slave_user', MASTER_PASSWORD='slave_password',
MASTER_LOG_FILE='mysql-bin.000001', MASTER_LOG_POS=19467;
MASTER_USER='slave_user', MASTER_PASSWORD='slave_password',
MASTER_LOG_FILE='mysql-bin.000001', MASTER_LOG_POS=19467;
5) Start slave
mysql> START SLAVE;
6) Check
slave status (It is important that both Slave_IO_Running and Slave_SQL_Running
have the value Yes in the output. And also Slave_IO_State should be Waiting
for master to send event)
mysql> SHOW SLAVE STATUS \G
Ex:
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.0.100
Master_User: slave_user
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000001
Read_Master_Log_Pos: 19467
Relay_Log_File: mysqld-relay-bin.000002
Relay_Log_Pos: 251
Relay_Master_Log_File: mysql-bin.000001
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB: exampledb
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 19467
Relay_Log_Space: 407
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.0.100
Master_User: slave_user
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000001
Read_Master_Log_Pos: 19467
Relay_Log_File: mysqld-relay-bin.000002
Relay_Log_Pos: 251
Relay_Master_Log_File: mysql-bin.000001
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB: exampledb
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 19467
Relay_Log_Space: 407
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
I believe Web time sheet software makes the complete employee time clock tracking task easier. Its easy to update, approve and maintain the time sheets in no time.Time Attendance Software
ReplyDeleteReally? Comment spam? Geez.
DeleteHi,
ReplyDeleteI have taken 2 windows server 2008 r2 machines and joined into domain
Installed the "mysql-installer-community-5.6.12.0" in both the servers
i have followed your above mentioned steps
Problem1 is:
I have executed the "SHOW MASTER STATUS;" command
Result:It has shown as "empty set"
Problem2 is:
In slave i have executed the comand as "mysql> change master to MASTER_HOST='10.0.0.18',MASTER_USER='repl',MASTER_PASSWO
RD='slave',MASTER_LOG_FILE='',MASTER_LOG_POS=;"
Result:ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near '' at
line 1
Could you please help me.
i have changed the my_default text file in master and slave servers;there is no my.cnf ile.
ReplyDeleteKAYLAN@
ReplyDeleteYou need to put bin log file e.g; MASTER_LOG_FILE=mysql-bin.000001 and MASTER_LOG_POS=3344 <--(result from mysql command: SHOW MASTER STATUS)
I have executed the "SHOW MASTER STATUS;" command
ReplyDeleteResult:It has shown as "empty set(0.00 sec)"
I have followed the below steps:
ReplyDelete1.I have taken 2 windows server 2008 r2 machines and joined into domain(consider master as C1 and slave as C2)
2.Installed the "mysql-installer-community-5.6.12.0" in both the servers
3.In Master(C1) machine:
1.go to(C:\Programfiles\MYsqL\mYsql server 5.6) and edited my_default file
added the below lines into the file
server-id = 1
log_bin = /var/log/mysql/mysql-bin.log
expire_logs_days = 10
max_binlog_size = 100M
binlog_do_db = exampledb
(I have restarted the machine)
4.Open the command prompt in master(C1) and navigate to mysql bin path and connected to the mysql with the credentials
5.create a user using the below command
create user 'username'@'slave machine ipaddress' identified by 'user password';
6.Grent permissions to the user using the below command
GRANT REPLICATION SLAVE ON *.* TO 'username'@'slave ipaddress' IDENTIFIED BY 'user password';
7.typed the command 'Show master status;'
it has shown as "empty set(0.00 sec)"
7.Go to slave machine and edited my_default file
added the below lines into the file
erver-id=2
master-connect-retry=60
replicate-do-db=exampledb
(I have restarted the machine)
8.Open the cmd in slave,navigate to mysql bin path and connected to the mysql with the credentials, typed the below command:
CHANGE MASTER TO
MASTER_HOST='10.0.0.18',
MASTER_USER='k',
MASTER_PASSWORD='slave',
MASTER_LOG_FILE='mysql-bin.000001',
MASTER_LOG_POS=3344;
I appreciate if you can help in this task
ReplyDeletesorry for the inconvinience..I have resolved the issue myself ..the above issue
ReplyDeleteBut i am facing another problem:
>Show slave status;
Last_IO_Error: error connecting to master 'repl@10.0.0.20:3306' - retry-time: 60 retries: 3
the above error has shown
The above issue also resolved..Let me know How can i identify the replication is done between master and slave.
ReplyDeletemake a change on the master database and see if its reflected in the slave database
ReplyDeleteInteresting color concept:
ReplyDeletedark-black text on a light-black background.
thankfully, readability.com can fix that.
hello sir
ReplyDeleteI want to create clone data base from an existing database int that same mysql server
in that same system
I want to know the process in both window & Linux
Hi Amigoes... Can u explane how push data from local to central server in spaecific time ...help me ..asap...
ReplyDeletehow can i write in java... help me
ReplyDeletehow to english?
ReplyDeleteHow to sync local mysql database to live server database in offline / online mode
ReplyDeleteWonderful post. Thanks for sharing with us.
ReplyDeleteMysql DBA Training
Business users may choose the product according to their business level. Other product by the antivirus is for different categories and users across the world rely on it to secure their data.
ReplyDeleteFor More information Visit Our Site:
norton.com/setup
office.com/setup
office.com/setup
mcafee.com/activate
Spirit Airlines Reservations A good Blog gives a lot more knowledge about this. I will continue to support your work. Thank you.
ReplyDeleteThanks for sharing the useful information. You have mentioned all essential points for getting Assignment Help easily.Spirit Airlines Cancellation
ReplyDeletewww.hulu.com/activate A good Blog gives a lot more knowledge about this. I will continue to support your work Thank you.
ReplyDeleteAllegiant Airlines Reservations Thanks for sharing such a nice blog. I really appreciate that please keep on posting more Blogs like this Thank you.
ReplyDeleteAllegiant Airlines Reservations It's wonderful as your other blog posts And thank you for posting.
ReplyDeleteThanks for sharing such type of information you can also check my post about
ReplyDeleteAmerican Airlines Book Flight
ReplyDeleteThanks for sharing such type of information you can also check my post about
Qatar Airways Cancellation Fee
Very interesting post, I have complete solution about Qatar Airways Booking
ReplyDeleteNice blog, I also want to suggest something about
ReplyDeleteAllegiant Airlines Reservations
ReplyDeleteNice blog, I also want to suggest something about
Allegiant Airline Cancellation Policy
Very interesting post, I have complete solution about Airlines ticket reservations
ReplyDelete
ReplyDeleteNice blog, I also want to suggest something about
Allegiant Airlines reservations
Very interesting post, I have complete solution about Korean Air Cancellation Refund
ReplyDeleteNice blog, I also want to suggest something about
ReplyDeleteSwiss Airlines Reservations
Thanks for sharing such type of information you can also check my post about
ReplyDeleteSwiss Airlines reservations official site
ReplyDeleteNice blog, I also want to suggest something about
Qantas book flights
ReplyDeleteVery interesting post, I have complete solution about Japan Airlines reservations official site
ReplyDeleteThanks for sharing such type of information you can also check my post about
Finnair Airlines book flight
ReplyDeleteThanks for sharing such type of information you can also check my post about
Kenya Airways online booking
Nice blog, I also want to suggest something about
ReplyDeleteKuwait Airways booking
Thanks for sharing such type of information you can also check my post about
ReplyDeleteKorean Air book seats
ReplyDeleteNice blog, I also want to suggest something about
Ryanair book flights
ReplyDeleteThanks for sharing such type of information you can also check my post about
Royal Jordanian customer service
ReplyDeleteNice blog, I also want to suggest something about
ANA flight booking
ReplyDeleteNice blog, I also want to suggest something about
Avianca Reservation
ReplyDeleteThanks for sharing such type of information you can also check my post about
TUI Airways reservations
ReplyDeleteThanks for sharing such type of information you can also check my post about
Turkish airlines booking flight
Airlines-gethuman.org is a platform where you can Find Contact Information for all the airlines, Assistance with booking your flights, and vacation packages easily. It helps you to save both, your money and your time.
Southwest Airlines Reservations
Southwest Airlines Flights
ReplyDeleteThanks for sharing such type of information you can also check my post about
Ethiopian Airlines booking
ReplyDeleteThanks for sharing such type of information you can also check my post about
Singapore Airlines booking
Thanks for sharing such type of information you can also check my post about
ReplyDeleteWestjet book a flight
Nice blog, I also want to suggest something about
ReplyDeleteEtihad Airways Online Booking
Very interesting post, I have complete solution about Hawaiian Airlines vacation phone number
ReplyDelete
ReplyDeleteThanks for sharing such type of information you can also check my post about
Hawaiian Airlines vacations
Thanks for sharing such type of information you can also check my post about
ReplyDeleteKorean Air Cancellation Fee
Nice blog, I also want to suggest something about
ReplyDeleteSouthwest Airlines Ticket Cancelation Policy
ReplyDeleteThanks for sharing such type of information you can also check my post about
Air France booking
ReplyDeleteThanks for sharing such type of information you can also check my post about
Air France book a flight
ReplyDeleteNice blog, I also want to suggest something about Air France Reservations
ReplyDeleteThanks for sharing such type of information you can also check my post about British Airways Cancellation Fee
Very interesting post, I have complete solution about United vacation phone number
ReplyDelete
ReplyDeleteThanks for sharing such type of information you can also check my post about United Airways Cancellation Fee
Air France Reservation
ReplyDeleteLufthansa Airlines Reservations
Copa Airlines Reservations
American Airlines Manage Booking
Turkish Airlines Manage Booking
Turkish Airlines Booking
Hawaiian Airlines Reservations
United Airlines Booking
Tubi.tv/activate is an online platform that is a creation of Fox Corporation and stream the latest content and videos of your interest.
ReplyDeleteFor More Information Visit Our Site:
tubi tv
tubi.tv/activate
Roadrunner email login
American Airlines Reservations are the best option for the people and you can reserve American airlines tickets Under the very affordable budget for the reservations. Reservations are no expensive thing for you once you're opting American flights.
ReplyDelete