zoukankan      html  css  js  c++  java
  • windows mysql主 Linux mysql 从 主从同步,读写分离

    Mysql 读写分离

    YIi 配置

    <?php

    return [
        'class' => 'yiidbConnection',
        'masterConfig' => [
                   // 'dsn' => 'mysql:host=localhost;dbname=studyyii',
                    'username' => 'root',
                    'password' => 'caesar',
                    'charset' => 'utf8',
                    'attributes' => [
                        // use a smaller connection timeout
                        PDO::ATTR_TIMEOUT => 10,
                    ],
        ],

        // 配置主服务器组
        'masters' => [
            ['dsn' => 'mysql:host=172.31.80.31;dbname=studyyii'],
          //  ['dsn' => 'dsn for master server 2'],
        ],

        // 配置从服务器
        'slaveConfig' => [
            'username' => 'root',
            'password' => 'root',
            'charset' => 'utf8',
            'attributes' => [
                // use a smaller connection timeout
                PDO::ATTR_TIMEOUT => 10,
            ],
        ],
        // 配置从服务器组
        'slaves' => [
            ['dsn' => 'mysql:host=localhost;dbname=studyyii'],
        ],
    ];

    Linux mysql master

    My.cnf:

    server_id = 1   #从服务器标识,范围1---2E32-1

    log_bin = mysql_bin

    binlog_do_db = studyyii

    binlog_do_db = mysql

     mysql service restart

    windows mysql slave

    mysql.ini:

    [mysqld]

    port=3306

    server-id = 2

    replicate-do-db = study

     

    重启mysql

    登陆mysql

    mysql> stop slave;

    mysql> change master to master_host='192.168.1.200',master_user='root',master_password='123456';

    mysql> start slave;

    mysql> show slave statusG;

     

    查看这两项是否为YES,yes为正常。

    Slave_IO_Running: Yes

    Slave_SQL_Running: Yes

     

    Ok 了 读写分离,主从同步

  • 相关阅读:
    Dependency Injection in ASP.NET Web API 2
    js, lambada? 在chrome和node下可以使用
    jquery text
    bugs view:
    支持 gRPC 长链接,深度解读 Nacos 2.0 架构设计及新模型
    阿里云 ecs云主机 静默安装oracle11g
    mysql1033错误 InnoDB临时表空间报错
    8888. Distance Between 2 Nodes in BST
    783. Minimum Distance Between BST Nodes
    530. Minimum Absolute Difference in BST
  • 原文地址:https://www.cnblogs.com/already/p/4538927.html
Copyright © 2011-2022 走看看