zoukankan      html  css  js  c++  java
  • Mysql+keepalived

    测试环境

    192.168.2.201  master slave

    192.168.2.202  master slave

    配置流程:安装MySQL->优化系统->优化配置my.cnf->初始化mysqld->添加同步用户->开始同步->查看同步状态。

    1.先关闭master

    2.配置 /etc/my.cnf

    [mysql]
    default-character-set=utf8
    
    [mysqld]
    default-storage-engine=INNODB
    character_set_server=utf8
    basedir=/opt/mysql
    datadir=/data/mysql/data
    socket=/data/mysql/mysql.sock
    skip_ssl
    
    server-id = 1                    #backup这台设置2
    binlog-ignore-db = mysql,information_schema,sys      #忽略写入binlog日志的库
    binlog-ignore-db = mysql
    replicate-do-db = test
    replicate-do-db = test2
    
    
    relay_log = mysql-relay-bin
    gtid-mode=on
    enforce_gtid_consistency = 1
    log_slave_updates =1
    
    auto_increment_offset=1         #自增ID起始值
    auto_increment_increment=2      #每次自增数字
    log-bin=mysql-bin               #开启二进制功能,主服务器必须打开
    max_binlog_size=1024M           #binlog单文件最大值
    
    slave_skip_errors=1396
    slave_skip_errors=all
    symbolic-links=0
    
    [mysqld_safe]
    log-error=/data/mysql/log/mysqld.log
    pid-file=/var/run/mysqld/mysqld.pid
    

    3. 启动master

    4. 创建复制账户

    create user repl@'%' identified by '123456';  
    grant replication slave on *.* to repl@'%' ;
    flush privileges;
    

    5.  启动slave

    6.启动复制 

      change master to master_host='192.168.2.201', master_user='repl',master_password='123456',master_auto_position=1;

      start slave;

    7. 查看状态

      show slave status;

  • 相关阅读:
    当Django模型迁移时,报No migrations to apply 问题时
    django--各个文件的含义
    django--创建项目
    1013. Battle Over Cities (25)
    1011. World Cup Betting (20)
    1009. Product of Polynomials (25)
    1007. Maximum Subsequence Sum (25)
    1006. Sign In and Sign Out (25)
    1008. Elevator (20)
    1004. Counting Leaves (30)
  • 原文地址:https://www.cnblogs.com/ZHUJIBlogs/p/10454837.html
Copyright © 2011-2022 走看看