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;
    
  • 相关阅读:
    通过存储过程的游标修改某个字段的全部数据
    spring cloud配置注册中心显示服务的ip地址和端口
    git几个必知托管平台
    hdu5790
    hdu5794
    hdu5739
    hdu5829
    线性规划初探
    bzoj4199
    bzoj4197
  • 原文地址:https://www.cnblogs.com/IMSCZ/p/12108571.html
Copyright © 2011-2022 走看看