0

I am settings up two new servers. One is the master and the other is the slave. Below is the config file for both. Master DB

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
innodb_file_per_table

server-id=1
binlog_do_db=data1


[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

Slave DB

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
innodb_file_per_table


server-id=2
master-host = 202.*.*.*
master-user = replicationUser1
master-password = ********
master-port = 3306
replicate-do-db=data1



[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

So first in the master I run this reset master command it gave me this error. reset master; ERROR 1186 (HY000): Binlog closed, cannot RESET MASTER. Then on the slave I first ran stop master then reset slave then start slave. THen I notice this files are generated in the slave master.info,mysqld-relay-bin.000001, mysqld-relay-bin.index and relay-log.info. In addition I have also ran this command on slave and it gave me no errors.

change master to MASTER_HOST='202.*.*.*', MASTER_USER='replicationUser1', MASTER_PASSWORD='******',

What should I do now I am quite stuck do not know how to move it next? Thank you.

1 Answer 1

1

You need a log-bin entry in your master my.cnf file

Per http://dev.mysql.com/doc/refman/5.0/en/binary-log.html


To enable the binary log, start the server with the --log-bin[=base_name] option. If no base_name value is given, the default name is the value of the pid-file option (which by default is the name of host machine) followed by -bin. If the basename is given, the server writes the file in the data directory unless the basename is given with a leading absolute path name to specify a different directory.


After setting the log-bin and restarting the master, you then can run RESET MASTER; and then SHOW MASTER STATUS; to get the correct values for your CHANGE MASTER command for your slave.

6
  • ok what happened now is that my master is running fine show master status; | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | +------------------+----------+--------------+------------------+ | mysql-bin.000001 | 21068398 | tData1 | | Now the problem is that my slave keep showing error connecting to my master. I have tried to ping to my master is healthy. So what could be wrong. On my master I could see the replication user too. What else to check out?
    – newbie14
    Jun 17, 2012 at 16:50
  • You need to set the positions to start replication from: change master to MASTER_HOST='202.*.*.*', MASTER_USER='replicationUser1', MASTER_PASSWORD='******', MASTER_LOG_FILE='mysql-bin.000001', MASTER_LOG_POS= 21068398; Adjust the values as needed. At this point, you might want to do another clean snapshot for the slave so you know the position the slave is currently at to start replication from
    – R. S.
    Jun 19, 2012 at 17:42
  • so if I start from this position wouldnt I miss the earlier data then? Thank you.
    – newbie14
    Jun 21, 2012 at 5:03
  • Yes, this is why you should do another snapshot of the master and restore that onto the slaves to get the slaves back in sync with the master.
    – R. S.
    Jun 21, 2012 at 17:29
  • so are you saying stop master first then stop slave. then reset master is it? then I backup master and dump back to slave and restart from there ? Am I doing it right?
    – newbie14
    Jun 22, 2012 at 17:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.