zoukankan      html  css  js  c++  java
  • mariadb主从

    ----------------------------------------------------------------主-----------------------------------------------------------------------------

    vim /etc/my.cnf +10

    i

    log-bin=mysql-bin            /file名称

    binlog-ignore-db=information_schema    /不同步的数据库

    binlog-ignore-db=mysql

    binlog-ignore-db=performance_schema

    server-id= 1                //id必须唯一

    ----------------------------------------------------------------从-----------------------------------------------------------------------------

    vim /etc/my.cnf +10

    i

    server-id=2  //id必须唯一

    read_only = 1       //只读

     ----------------------------------------------------------------重启服务-----------------------------------------------------------------------------

    systemctl restart mariadb

     ----------------------------------------------------------------主库-----------------------------------------------------------------------------

    mysql -p123qwe

    CREATE USER 'abc'@'%' IDENTIFIED BY '123qwe';                           /创建用户

    grant replication slave on *.* to 'abc'@'172.16.0.227' identified by '123qwe';              //授权用户

    flush privileges;            //刷新权限

    show master status;          //show master 的文件名和偏移量

     ----------------------------------------------------例表---------------------------------------------------------------------------------

    MariaDB [(none)]> show master status;                                      

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

    | File             | Position | Binlog_Do_DB | Binlog_Ignore_DB                            |

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

    | testsql.000001 |      5416 |              | information_schema,mysql,performance_schema |

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

    1 row in set (0.00 sec)

     ----------------------------------------------------------------从-----------------------------------------------------------------------------

    mysql -p123qwe

    stop slave;

    CHANGE MASTER TO MASTER_HOST='172.16.0.226', MASTER_USER='abc',  MASTER_PASSWORD='123qwe', MASTER_LOG_FILE='testsql.000001', MASTER_LOG_POS=5416;

    start slave;        //启动之前手动复制一下数据库,备份,恢复操作

    show slave statusG;

     主库查权限

    select host,user from mysql.user;   

    delete from mysql.user where user='xxx';

    排错查询

    show master status;

    show variables like 'server_id';

     ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    stop slave;
    set GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
    start slave;

  • 相关阅读:
    修改mysql root账户登录密码
    taglib的uri问题
    encoding/path可能引起无数奇怪的问题
    查看JSTL的doc解决问题
    matlab 读取nc
    matlab fread
    用matlab将nc数据读出来,写成二进制文件,然后用grads画图
    matlab 三维绘制
    flex label 换行
    Struts2的使用以及Spring整合Struts2
  • 原文地址:https://www.cnblogs.com/Leaders543/p/12532628.html
Copyright © 2011-2022 走看看