zoukankan      html  css  js  c++  java
  • mysql 主从笔记

    主库配置
    一、修改主库配置文件
    开启binlog,并设置server-id,每次修改配置文件后都要重启mysql服务才会生效
    server-id                = 100
    log-bin                  = mysql-bin
    binlog_format           = mixed #默认是mixed
    binlog_do_db=  #这里写需要同步的数据库名称
    开启binlog  从机不用开启 
    binlog-ignore-db = mysql 不同步mysql库和test库
    binlog-ignore-db = test
    expire_logs_days                = 5 #设置binlog过期时间为5天
    
    二、创建同步账号密码
    授权给从数据库服务器
     mysql>create user repl; //创建新用户
    //repl用户必须具有REPLICATION SLAVE权限,除此之外没有必要添加不必要的权限,密码为mysql。说明一下192.168.0.%,这个配置是指明repl用户所在服务器,这里%是通配符,表示192.168.113.0-192.168.113.255的Server都可以以repl用户登陆主服务器。
    3 mysql> GRANT REPLICATION SLAVE ON *.* TO 'repl'@'192.168.0.%' IDENTIFIED BY 'mysql';
    查看用户权限:show grants for 'repl'@'192.168.113.%';
    查看master状态:show master status;
    
    重置master,初次可以忽略此步骤:mysql> reset master;
    从库配置
    一、从库配置文件同主库一样只需修改 server-id    即可,binlog可开可不开,看你心情了,因为是从,没必要开
    连接到master
    change master to master_host='192.168.113.130',
    master_password='123456',
    master_port=3306,
    master_user='repl',
    master_log_file='mysql-bin.000001',  
    master_log_pos=120;
    Query OK,
    0 rows affected, 2 warnings (0.09 sec) mysql> start slave; mysql> show slave status; 看到如图所示表示已经成功连接到了master 清除binlog 命令 PURGE MASTER LOGS BEFORE DATE_SUB(CURRENT_DATE, INTERVAL 5 DAY);

    改行去放羊
  • 相关阅读:
    一定要在3 20前完成所有的程序开发工作
    浅谈图像处理方向的就业前景[转)
    期待牛人指教的问题?
    vc6 7工程转vc8时的问题
    今天的工作计划
    定点数与浮点数区别
    difference between texRECT and tex2D
    Render to Texture
    不明白gluperpective的fovy参数
    批处理程序教程(转)
  • 原文地址:https://www.cnblogs.com/musen/p/11459511.html
Copyright © 2011-2022 走看看