Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MASTER configuration:
- ---------------------
- my.cnf:
- *******
- server-id = 1
- # change the file path for windows for ex. log-bin=E:/xampp/mysql/data/mysql-bin
- log_bin = /var/log/mysql/mysql-bin.log
- binlog_do_db = testdb
- #bind-address = 127.0.0.1 # note that this line should be commented if any. then only mysql listen to other hosts
- # now restart mysql server on master host
- # now run the following command as mysql user root
- mysql -u root -p
- Enter password:
- create database testdb;
- # this command creates a user slave with password slavepass and provides permission for replication in master host
- GRANT REPLICATION SLAVE ON *.* TO 'slave'@'%' IDENTIFIED BY 'slavepass';
- FLUSH PRIVILEGES;
- USE testdb;
- FLUSH TABLES WITH READ LOCK;
- 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
- -------------------------------------------------------------------------------------------------------------------------
- Slave config:
- -------------
- my.cnf
- ******
- server-id=2
- master-host=192.168.1.100 # this is the ip of master host
- master-user=slave
- master-password=slavepass
- master-connect-retry=60
- replicate-do-db=testdb
- #now restart slave server
- # now on slave mysql prompt, run the following query
- create database testdb;
- # now login as root
- mysql -u root -p
- Enter password:
- SLAVE STOP;
- 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;
- #MASTER_LOG_FILE is the file MySQL gave back when you ran SHOW MASTER STATUS; on the master
- #MASTER_LOG_POS is the position MySQL gave back when you ran SHOW MASTER STATUS; on the master.
- # NOW RUN
- START SLAVE;
- Thats it....
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement