CentOS之MYSQL主从同步配置(二)

2015-01-23 22:07:19 · 作者: · 浏览: 10
aster_Host: 192.168.1.222

Master_User: repl

Master_Port: 3306

Connect_Retry: 60

Master_Log_File: log.000003

Read_Master_Log_Pos: 98

Relay_Log_File: mysqld-relay-bin.000002

Relay_Log_Pos: 229

Relay_Master_Log_File: log.000003

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: 229

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)

显示红色那两行,说明配置成功。

?

?

?

五、测试主从服务器是否能同步

在主服务器上面新建一个表,必须在repl数据下

mysql> use repl

Database changed

mysql> create table test(id int,namechar(10));

Query OK, 0 rows affected (0.00 sec)


mysql> insert into test values(1,'zaq');

Query OK, 1 row affected (0.00 sec)


mysql> insert into test values(1,'xsw');

Query OK, 1 row affected (0.00 sec)


mysql> select * from test;

+------+------+

| id |name |

+-------+------+

| 1 |zaq |

| 1 | xsw |

+-------+------+

2 rows in set (0.00 sec)

?


在从服务器查看是否同步过来

mysql> use repl;

Database changed

mysql> select * from test;

+------+------+

| id |name |

+------+------+

| 1 | zaq |

| 1 | xsw |

+------+------+

2 rows in set (0.00 sec)


flush privileges;
然后
show grants for 'slave'@'10.169.6.133';

登录数据库遇到
遇到 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
重启 service mysql restart

错误:Starting MySQL..The server quit without updating PID file ([FAILED]al/mysql/data/iZ23xrasgttZ.pid).
解决方式:
删除 /etc/mysql文件夹
并且修改配置文件中的mstart项 注释掉

注意事项(出现错误)
Mysql版本从5.1.7以后开始就不支持“master-host”类似的参数
在从库上执行如下命令;
change master to master_host='masterIP', master_user='slave', master_password='slvaePASS';

change master to master_host='10.171.244.109',

master_user='slave',

master_password='admin',

master_log_file="mysql-bin.000006",

master_log_pos=107 ;