/etc/my.cnf or /etc/mysql/my.cnf
depending on which distribution of Linux you have.
server-id = 1
log-bin = /var/log/mysql/bin.log
These settings you need to add to the [mysqld] header in your .cnf file
server-id = 2
master-host = 192.168.0.1
master-port = 3306
master-user = root
master-password = passwod
log-bin = /var/log/mysql/bin.log
log-bin-index = /var/log/mysql/log-bin.index
log-error = /var/log/mysql/error.log
relay-log = /var/log/mysql/relay.log
relay-log-info-file = /var/log/mysql/relay-log.info
relay-log-index = /var/log/mysql/relay-log.index
GRANT REPLICATION SLAVE, REPLICATION CLIENT
ON *.*
TO 'root'@'192.168.0.2
IDENTIFIED BY 'password';
The IP address is that of the slave server and password is password identified in my.cnf on the slave server.
mysql>SHOW MASTER STATUS;
+---------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+---------------+----------+--------------+------------------+
| bin.log.001 | 29 | test | |
+---------------+----------+--------------+------------------+
CHANGE MASTER TO MASTER_HOST='192.168.0.1', MASTER_USER='root', MASTER_PASSWORD='password', MASTER_LOG_FILE=bin.log.001', MASTER_LOG_POS=29;
mysql>[b]SLAVE START[/b]; a mysql>[b]SHOW SLAVE STATUS\G[/b];
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.0.1
Master_User: root
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: bin.log.001
Read_Master_Log_Pos: 29
Relay_Log_File: mysql-relay-bin.000002
Relay_Log_Pos: 558
Relay_Master_Log_File: mysql-bin.000075
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
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: 47514905
Relay_Log_Space: 558
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
1 row in set (0.00 sec)
Have a question about something in this article? You can receive help directly from the article author. Sign up for a free trial to get started.
Comments (2)
Author
Commented:Commented:
Congratulations! Your article has been published.
ericpete
Page Editor