技术开发 频道

Replication安装配置

  IT168技术资讯1.确保master和slave安装了相同的mysql版本

  2.在master上创建复制使用的用户,并授予 replication slave权限

  mysql> grant replication slave on *.* to 'repl'@'192.168.60.4' identified by 'hunter0';

  Query OK, 0 rows affected (0.01 sec)

  mysql> flush privileges;

  Query OK, 0 rows affected (0.00 sec)

  3.修改master上的my.cnf,开启binlog,并设置server-id

  # The MySQL server

  [mysqld]

  server-id=1

  port = 3306

  socket = /var/lib/mysql/mysql.sock

  datadir = /usr/local/mysql/data

  log-error = /var/lib/mysql/test2_mysqld.err

  #log-bin

  log-bin = /var/lib/mysql/test2_log-bin

  #query-log

  #log = /var/lib/mysql/query_log.log

  #slow-query-log

  log-slow-queries = /var/lib/mysql/slow_query_log.log

  skip-innodb

  ...................

  4.在master上设置读锁定有效

  mysql> flush tables with read lock;

  Query OK, 0 rows affected (0.00 sec)

  5.查看binlog和偏移量值,目的是为了使slave启动后,从这点开始数据恢复操作

  mysql> show master status;

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

  | File | Position | Binlog_Do_DB | Binlog_Ignore_DB |

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

  | test2_log-bin.000002 | 311 | | |

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

  1 row in set (0.00 sec)

0
相关文章