It is important create a mysql user into each instance that it could exec only replication actions, in mysql shell:
create user replica@localhost;
grant replication slave on *.* to replica@localhost identified by 'replicapassword';
Minimal configuration file (/etc/my.cnf) of each mysql instance is:
master
[mysqld]
server-id=1
log-bin=/var/log/mysql/binlog.log
expire_logs_days=10
max_binlog_size=100M
datadir=/var/lib/mysql/data
socket=/var/lib/mysql/mysql.sock
innodb_flush_log_at_trx_commit=1
sync_binlog=1
slave
[mysqld]
server-id=2
master-host=ip.server.master
master-port=3306
master-user=replica
master-password=replicapassword
log-bin=/var/log/mysql/binlog.log
expire_logs_days=10
max_binlog_size=100M
datadir=/var/lib/mysql/data
socket=/var/lib/mysql/mysql.sock
innodb_flush_log_at_trx_commit=1
sync_binlog=1
relay-log-index=slave-relay-bin.index
relay-log=slave-relay-bin
Last step is initializing and starting replication. In mysql shell:
master
reset master;
slave
change master to master_host='ip.server.master',
master_user='replica',
master_password='replicapassword',
master_port=3306;
If you want resetting replication:
master
reset master;
slave
stop slave;
reset slave;
start slave;
If you want show which it is binary file and position:
show master status;
show slave status;
Reference: mysql.com