Advertisement
Guest User

Untitled

a guest
May 14th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. MASTER configuration:
  2. ---------------------
  3. my.cnf:
  4. *******
  5. server-id = 1
  6. # change the file path for windows for ex. log-bin=E:/xampp/mysql/data/mysql-bin
  7. log_bin = /var/log/mysql/mysql-bin.log
  8.  
  9. binlog_do_db = testdb
  10. #bind-address = 127.0.0.1 # note that this line should be commented if any. then only mysql listen to other hosts
  11.  
  12. # now restart mysql server on master host
  13. # now run the following command as mysql user root
  14. mysql -u root -p
  15. Enter password:
  16.  
  17. create database testdb;
  18.  
  19. # this command creates a user slave with password slavepass and provides permission for replication in master host
  20. GRANT REPLICATION SLAVE ON *.* TO 'slave'@'%' IDENTIFIED BY 'slavepass';
  21. FLUSH PRIVILEGES;
  22.  
  23. USE testdb;
  24. FLUSH TABLES WITH READ LOCK;
  25. SHOW MASTER STATUS; # this command shows the status of the master server. note the log file name and log pos for the use in slave
  26.  
  27. -------------------------------------------------------------------------------------------------------------------------
  28.  
  29.  
  30. Slave config:
  31. -------------
  32. my.cnf
  33. ******
  34. server-id=2
  35. master-host=192.168.1.100 # this is the ip of master host
  36. master-user=slave
  37. master-password=slavepass
  38. master-connect-retry=60
  39. replicate-do-db=testdb
  40.  
  41. #now restart slave server
  42. # now on slave mysql prompt, run the following query
  43.  
  44. create database testdb;
  45.  
  46. # now login as root
  47. mysql -u root -p
  48. Enter password:
  49. SLAVE STOP;
  50.  
  51. CHANGE MASTER TO MASTER_HOST='192.168.1.100', MASTER_USER='slave', MASTER_PASSWORD='slavepass', MASTER_LOG_FILE='MASTER_LOG_FILE', MASTER_LOG_POS=183;
  52.  
  53. #MASTER_LOG_FILE is the file MySQL gave back when you ran SHOW MASTER STATUS; on the master
  54. #MASTER_LOG_POS is the position MySQL gave back when you ran SHOW MASTER STATUS; on the master.
  55.  
  56. # NOW RUN
  57. START SLAVE;
  58.  
  59. Thats it....
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement