285572001 发表于 2018-9-30 07:54:14

MySQL主从配置与读写分离

安装mysql  修改my.cnf,增加server-id=130和log_bin=chenshengsheng
  修改完配置文件后,启动或者重启mysqld服务
  把mysql库备份并恢复成aming库,作为测试数据
  mysqldump -uroot mysql > /tmp/asheng.sql
  mysql -uroot -e “create database asheng”
  mysql -uroot asheng < /tmp/asheng.sql
  创建用作同步数据的用户

  grant replication slave on *.* to 'asheng'@slave_ip>  flush tables with read lock;//锁表,不让它继续写
  show master status;
  +-----------------------+----------+--------------+------------------+-------------------+
  | File                  | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
  +-----------------------+----------+--------------+------------------+-------------------+
  | chenshengsheng.000001 |   656589 |            |                  |                   |
  +-----------------------+----------+--------------+------------------+-------------------+
  保留以上两个数值。配置从要用到
  /data/mysql目录下:
  chenshengsheng.index是所引,是必须要有的
  chenshengsheng.000001后面还会生成其他的

页: [1]
查看完整版本: MySQL主从配置与读写分离