zoukankan      html  css  js  c++  java
  • mariadb主从同步配置

    1. 主库上操作

    (1)Linux命令行操作
    # 安装mariadb(Maser and Slave)
    yum -y install mariadb mariadb-server
    
    # 数据库主库配置(Master)
    sed -i '/[mysqld]/aserver-id=1 
    log-bin=mysql-bin' /etc/my.cnf
    
    # 启动数据库并加入自启动服务(Master and Slave)
    systemctl start mariadb
    systemctl enable mariadb
    
    (2) 数据库内操作
    # 授权主从同步用户和主机
    grant replication slave on *.* to tongbu@'%' identified by '123456';
    flush privileges;
    show master status;
    

    2.从库上操作

    (1)Linux命令行操作
    # 数据库从库配置(Slave)
    sed -i '/[mysqld]/aserver-id=2 ' /etc/my.cnf
    
    # 重启从数据库(Slave)
    systemctl restart mariadb
    
    (2) 数据库内操作
    # 连接主库
    change master to master_host='172.16.1.51',master_user='tongbu',master_password='123456',
    master_log_file='mysql-bin.000001',master_log_pos=462;
    
    # 启动从库IO线程
    start slave io_thread;
    # 从库跳过错误
    set global sql_slave_skip_counter=1;
    # 启动从库
    start slave;
    
  • 相关阅读:
    对我影响最大的三位导师
    global与nonlocal
    random模块
    time模块
    datetime模块
    sys模块
    os模块
    collection模块
    hashlib模块
    pickle模块
  • 原文地址:https://www.cnblogs.com/IMSCZ/p/12108571.html
Copyright © 2011-2022 走看看