zoukankan      html  css  js  c++  java
  • mysql部署-主从搭建

    一、安装数据库

    yum -y install http://www.percona.com/downloads/percona-release/redhat/0.1-4/percona-release-0.1-4.noarch.rpm && yum -y install Percona-Server-server-56

    二、建立主从:
    1.修改my.cnf中server-id
    修改为ip地址的第四位
    2.在主库创建复制用户(注意网段)

    GRANT REPLICATION SLAVE ON *.* TO 'repl'@'环境所属网段' IDENTIFIED BY 'repl';
    flush privileges;

    3.在从库执行(ip为主的ip)

    CHANGE MASTER TO 
    MASTER_HOST='master服务器IP',
    MASTER_USER='repl',
    MASTER_PASSWORD='repl',
    MASTER_AUTO_POSITION=1;

    4.在从库开启主从

    start slave;

    5.查看主从状态

    show slave statusG;

    出现Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update it 正常

    6.mysql配置文件

    # Generated by Percona Configuration Wizard (http://tools.percona.com/) version REL5-20120208
    
    [mysql]
    
    # CLIENT #
    port                           = 3306
    socket                         = /tmp/mysql.sock
    
    [mysqld]
    
    # GENERAL #
    user                           = mysql
    default-storage-engine         = InnoDB
    socket                         = /tmp/mysql.sock
    pid-file                       = /opt/mysql_data/mysql.pid
    server-id               =102
    # MyISAM #
    key-buffer-size                = 32M
    myisam-recover                 = FORCE,BACKUP
    
    # SAFETY #
    max-allowed-packet             = 16M
    max-connect-errors             = 1000000
    sql_mode               = 
    # DATA STORAGE #
    datadir                        = /opt/mysql_data/
    
    # BINARY LOGGING #
    log-bin                        = /opt/mysql_log/mysql-bin
    expire-logs-days               = 7
    sync-binlog                    = 1lower_case_table_names                 = 1
    gtid_mode=ON
    enforce_gtid_consistency=ON
    master_info_repository=TABLE
    relay_log_info_repository=TABLE
    binlog_checksum=NONE
    log_slave_updates=ON
    binlog_format=ROW
    
    
    # CACHES AND LIMITS #
    tmp-table-size                 = 32M
    max-heap-table-size            = 32M
    query-cache-type               = 0
    query-cache-size               = 0
    max-connections                = 2000
    thread-cache-size              = 100
    open-files-limit               = 65535
    table-definition-cache         = 4096
    table-open-cache               = 4096
    
    # INNODB #
    innodb-flush-method            = O_DIRECT
    innodb-log-files-in-group      = 2
    innodb-log-file-size           = 512M
    innodb-flush-log-at-trx-commit = 1
    innodb-file-per-table          = 1
    innodb-buffer-pool-size        =8G
    # LOGGING #
    log-error                      = /opt/mysql_log/mysql-error.log
    log-queries-not-using-indexes  = 0
    slow-query-log                 = 1
    slow-query-log-file            = /opt/mysql_log/mysql-slow.log
  • 相关阅读:
    display:block;inline;inline-block大总结
    img图片inline-block总结
    定时器
    获取样式
    UmiJS
    vue 点击当前路由重新加载该路由
    Support for the experimental syntax 'decorators-legacy' isn't currently enab -- 装饰器@
    js 改变匹配到的字符串的颜色
    with
    页面从输入 URL 到页面加载显示完成
  • 原文地址:https://www.cnblogs.com/dingkailinux/p/8298651.html
Copyright © 2011-2022 走看看