server-id = 1 log-bin set-variable=binlog-ignore-db=mysql |
mysql>GRANT REPLICATION SLAVE ON *.* TO rep@rep2 IDENTIFIED BY 'rep'; |
mysql>GRANT FILE,SELECT,REPLICATION SLAVE ON *.* TO rep@rep2 IDENTIFIED BY 'rep'; |
mysql>FLUSH TABLES WITH READ LOCK; |
root$cd /usr/local/mysql root$tar zcf data.tar.gz ./data (在这里也可能是 "var" 等其它实际存放数据文件的目录,根据实情而定) |
server-id = 2 master-host = rep1 #主服务器名 master-user = rep #同步账户名,默认是test master-password = rep #同步帐户密码,默认是空 master-port = 3306 #主服务器的 TCP/IP 端口号,默认是3306 set-variable=replicate-ignore-db=mysql #略过同步的数据库名,如果有多个,请设置多次 set-variable=replicate-do-db=yejr #想要同步的数据库名,如果有多个,请设置多次 |
root$mysql -hrep1 -urep -prep mysql>SHOW GRANTS; +------------------------------------------------------------------------------+ | Grants for [email=rep@rep2]rep@rep2[/email] | +------------------------------------------------------------------------------+ | GRANT SELECT, FILE, REPLICATION SLAVE ON *.* TO 'rep'@'rep2' IDENTIFIED BY PASSWORD '*9FF2C222F44C7BBA5CC7E3BE8573AA4E1776278C' | +------------------------------------------------------------------------------+ |
mysql -hlocalhost -uroot mysql>SHOW SLAVE STATUS\G *************************** 1. row *************************** Slave_IO_State: Waiting for master to send event Master_Host: rep1 Master_User: rep Master_Port: 3306 Connect_Retry: 60 Master_Log_File: binlog.000001 Read_Master_Log_Pos: 98 Relay_Log_File: relay.000003 Relay_Log_Pos: 232 Relay_Master_Log_File: binlog.000001 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: 98 Relay_Log_Space: 232 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) |
欢迎光临 MariaDB社区 (http://123.56.88.72/) | Powered by Discuz! X3.2 |