• mysql主从备份案例—读写分离(异步主从)


    主备配置

    主:MySQL 192.168.200.115

    从:MySQL 192.168.200.116

    从:MySQL 192.168.200.113

    主:  yum -y install ntp

    cp -p /etc/ntp.conf /etc/ntp.conf/origin

    vim /etc/ntp.conf--------------------------

    server 127.127.1.0

    fudge 127.127.1.0 startum 8-------------------

    systemctl  start  ntpd

    chkconfig ntpd on

    从:yum -y install ntpdate

    ntpdate 192.168.200.115

    date  查询时间是否一致

    ------------------------------------------------------------------------------------------------------------------

    主:

    vim /etc/my.cnf---------------------------

    server-id = 1
    log-bin=mysql-bin
    log-slave-updates=true-------------------------------

    重启 /etc/init.d/mysqld restart

    进入mysql

    grant replication slave on *.* to 'myslave'@'192.168.200.%' identified by '123123';

    flush privileges;

    -------------------------------------------------------------------------------------------

    show master staus;

    从:

    vim /etc/my.cnf

    server-id = 2
    relay-log=relay-log-bin
    relay-log-index=slave-relay-bin.index

    重启 mysql

    进入mysql

    >stop slave;

    >change master to master_host='192.168.200.115',master_user='myslave',master_password='123456',master_log_file='mysql-bin.000002',master_log_pos=477;

    >start slave;

    >show slave status;

    --------------------------------------------------------------第二台同上,改一下my.cnf就好

    到此,做完

    ==================================================================

    再开一台amoeba

    rz 传jdk1.6   和  amoeba-mysql-binary-2.2.0.tar.gz

    chmod +x jdk...............

    ./jdk................

    mv jdk....../ /usr/local/jdk1.6

    vim /etc/profile---------------------

    export JAVA_HOME=/usr/local/jdk1.6
    export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
    export PATH=$PATH:$JAVA_HOME/bin:$JAVA_HOME:/jre/lib
    export AMOEBA_HOME=/usr/local/amoeba/
    export PATH=$PATH:$AMOEBA_HOME/bin

    -------------------------------------------------------------------

    rm rf /usr/local/java

    source /etc/profile

    java -version

    mkdir  /usr/local/amoeba

    tar xf amoeba................ -C /usr/local/amoeba/

    chmod -R 755 /usr/local/amoeba/

    /usr/local/amoeba/bin/amoeba

    ------------------------------------------------------------------------

    在另外三台Mysql 授权

     grant all on *.* to 'admin'@'192.168.200.%' identified by '123123';

    flush privileges;

    --------------------------------------------------------------------------------------

    amoeba机上

    cd /usr/local/amoeba/conf

    vim amoeba.xml------------------------------------------------------------------

                                            <property name="user">amoeba</property>
                                            <property name="password">123456</property>
                 <property name="LRUMapSize">1500</property>
                            <property name="defaultPool">master</property>

                        <property name="writePool">master</property>  
                          <property name="readPool">slaves</property>

    --------------------------------------------------------------------------------------------------------

    vim dbServers.xml-------------------------------------------------------------------------------------

     <property name="user">admin</property>
                            <!--  mysql password -->
                            <property name="password">123</property>
     
     <dbServer name="master"  parent="abstractServer">
                    <factoryConfig>
                            <!-- mysql ip -->
                            <property name="ipAddress">192.168.200.115</property>
                    </factoryConfig>
            </dbServer>
            <dbServer name="slave1"  parent="abstractServer">
                    <factoryConfig>
                            <!-- mysql ip -->
                            <property name="ipAddress">192.168.200.116</property>
                    </factoryConfig>
            </dbServer>
    <dbServer name="slave2"  parent="abstractServer">
                    <factoryConfig>
                            <!-- mysql ip -->
                            <property name="ipAddress">192.168.200.113</property>
                    </factoryConfig>
            </dbServer>
    <dbServer name="slaves" virtual="true">
     <property name="poolNames">slave1,slave2</property>
    -----------------------------------------------------------------------------------------------------------------
    /usr/local/amoeba/bin/amoeba start &

    jobs

    netstat -anpt|grep java

    =======================================================结束

    测试

    在mysql 里创建库表

    不断查看另外两台从mysql 对主的获取库表信息

  • 相关阅读:
    C# 模拟浏览器请求
    关于获取时间后,时间格式为几天前,几小时前格式转化
    关于通用的C#后台获取前台页面的标签的正则表达式
    关于getHTML()方法和getHtmlAjax()方法 GetHttpLength, 清除HTML标签
    性能测试术语
    聚合报告中90% Line涉及到百分位数的概念
    使用Windows的cmd运行(或通过批处理启动)Python项目(多目录项目)提示找不到模块的解决办法
    OSError: [WinError 6] 句柄无效的解决办法
    python中日志输出重复的解决办法
    截图方法get_screenshot_as_file()注意点
  • 原文地址:https://www.cnblogs.com/123456likun/p/11678890.html
Copyright © 2020-2023  润新知