亚洲AVI,黑人巨茎大战欧美白妇,初高中生洗澡自慰高清网站,欧美日韩无砖专区一中文字

重慶分公司,新征程啟航

為企業(yè)提供網(wǎng)站建設(shè)、域名注冊、服務(wù)器等服務(wù)

MySQL+Amoeba+MySQLMMM高可用群集-創(chuàng)新互聯(lián)

一、MySQL-MMM(Master-Master MySQL)

MMM概述

  • 雙主故障切換和日常管理的腳本程序
  • 由多個mysql主服務(wù)器和多個mysql從服務(wù)器組成
  • 雖然叫做雙主復(fù)制,但是業(yè)務(wù)上同一時刻只允許對一個主進行寫入,另一臺備選主上提供部分讀服務(wù),
  • MMM使用Perl語言開發(fā),主要用來監(jiān)控和管理MySQL Master-Master(雙主)復(fù)制
  • 其內(nèi)部附加的工具腳本也可以實現(xiàn)多個slave的read負載均衡。

注:

成都創(chuàng)新互聯(lián)專注于企業(yè)營銷型網(wǎng)站、網(wǎng)站重做改版、向陽網(wǎng)站定制設(shè)計、自適應(yīng)品牌網(wǎng)站建設(shè)、html5、商城網(wǎng)站定制開發(fā)、集團公司官網(wǎng)建設(shè)、成都外貿(mào)網(wǎng)站建設(shè)、高端網(wǎng)站制作、響應(yīng)式網(wǎng)頁設(shè)計等建站業(yè)務(wù),價格優(yōu)惠性價比高,為向陽等各大城市提供網(wǎng)站開發(fā)制作服務(wù)。
  • 同一時刻只允許一個主進行寫入,額外主提供部分讀的服務(wù)

  • 不適用于要求數(shù)據(jù)一致性很高的場合(可替換產(chǎn)品為:Heartbeat+DRBD+MySQL高可用方案)

MMM組成

  • mmm_mond:監(jiān)控進程,負責(zé)所有的監(jiān)控、決定和處理所有節(jié)點
  • mmm_agentd:運行在每個MySQL數(shù)據(jù)庫的代理進程,完成監(jiān)控本地狀態(tài)并于監(jiān)控端通信
  • mmm_control:一個腳本,提供mmm_mond進程的命令

二、案例

實驗環(huán)境:
六臺Centos6,兩臺主mysql(master01、master02),兩臺從mysql(slave01、slave02),一臺監(jiān)控(mmm_mond),一臺讀寫調(diào)度器(amoeba)

先部署主主(master01與master02)復(fù)制

Master01

1.準備工作
vim /etc/sysconfig/network-scripts/ifcfg-eth0
    DEVICE=eth0
    TYPE=Ethernet
    ONBOOT=yes
    NM_CONTROLLED=no
    BOOTPROTO=static
    IPADDR=192.168.1.10
    NETMASK=255.255.255.0
vim /etc/sysconfig/network-scripts/ifcfg-eth2
    DEVICE=eth2
    TYPE=Ethernet
    ONBOOT=yes
    NM_CONTROLLED=no
    BOOTPROTO=dhcp
vim /etc/hosts
    192.168.1.10    db1
    192.168.1.20    db2
    192.168.1.30    db3
    192.168.1.40    db4
vim /etc/sysconfig/network
    HOSTNAME=db1
reboot
2.YUM源配置并安裝MMM
rm -rf /etc/yum.repos.d/*
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
yum -y install epel-release
yum -y install mysql-mmm* mysql mysql-server mysql-devel
3.MySQL配置
/etc/init.d/mysqld start && chkconfig --level 35 mysqld on
mysqladmin -uroot password "123"
cp /usr/share/doc/mysql-server-5.1.73/my-medium.cnf /etc/my.cnf
vim /etc/my.cnf
    [mysqld]
    50 log-slave-updates
/etc/init.d/mysqld restart
4.授權(quán)并主主同步
mysql -u root -p
mysql> grant replication slave on *.* to 'slave'@'192.168.1.%' identified by '123';
mysql> show master status;
+------------------+----------+--------------+------------------+
| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000001 |      647 |              |                  |
+------------------+----------+--------------+------------------+
1 row in set (0.00 sec)
mysql> change master to master_host='192.168.1.20',master_user='slave',master_password='123',master_log_file='mysql-bin.000001',master_log_pos=481;
//所跟IP、log、pos等信息都為第二臺主的信息
mysql> start slave;
mysql> show slave status\G;
//查看同步狀態(tài),I/0和SQL線程狀態(tài)為yes則正確

Master02

1.準備工作
vim /etc/sysconfig/network-scripts/ifcfg-eth0
    DEVICE=eth0
    TYPE=Ethernet
    ONBOOT=yes
    NM_CONTROLLED=no
    BOOTPROTO=static
    IPADDR=192.168.1.20
    NETMASK=255.255.255.0
vim /etc/sysconfig/network-scripts/ifcfg-eth2
    DEVICE=eth2
    TYPE=Ethernet
    ONBOOT=yes
    NM_CONTROLLED=no
    BOOTPROTO=dhcp
vim /etc/hosts
    192.168.1.10    db1
    192.168.1.20    db2
    192.168.1.30    db3
    192.168.1.40    db4
vim /etc/sysconfig/network
HOSTNAME=db2
reboot
2.YUM源配置并安裝MMM
rm -rf /etc/yum.repos.d/*
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
yum -y install epel-release
yum -y install mysql-mmm* mysql mysql-server mysql-devel
3.MySQL配置
/etc/init.d/mysqld start && chkconfig --level 35 mysqld on
mysqladmin -uroot password "123"
cp /usr/share/doc/mysql-server-5.1.73/my-medium.cnf /etc/my.cnf
vim /etc/my.cnf
    [mysqld]
    50 log-slave-updates
    58 server-id = 2
/etc/init.d/mysqld restart
4.授權(quán)并主主同步
mysql -u root -p
mysql> grant replication slave on *.* to 'slave'@'192.168.1.%' identified by '123';
mysql> show master status;
+------------------+----------+--------------+------------------+
| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000001 |      481 |              |                  |
+------------------+----------+--------------+------------------+
1 row in set (0.00 sec)
mysql> change master to master_host='192.168.1.10',master_user='slave',master_password='123',master_log_file='mysql-bin.000001',master_log_pos=647;
//所跟IP、log、pos等信息都為第一臺主的信息
mysql> start slave;
mysql> show slave status\G;

再部署兩對主從復(fù)制(m1與s1,m2與s2)

Slave01

1.準備工作
vim /etc/sysconfig/network-scripts/ifcfg-eth0
    DEVICE=eth0
    TYPE=Ethernet
    ONBOOT=yes
    NM_CONTROLLED=no
    BOOTPROTO=static
    IPADDR=192.168.1.30
    NETMASK=255.255.255.0
vim /etc/sysconfig/network-scripts/ifcfg-eth2
    DEVICE=eth2
    TYPE=Ethernet
    ONBOOT=yes
    NM_CONTROLLED=no
    BOOTPROTO=dhcp
vim /etc/hosts
    192.168.1.10    db1
    192.168.1.20    db2
    192.168.1.30    db3
    192.168.1.40    db4
vim /etc/sysconfig/network
    HOSTNAME=db3
reboot
2.YUM源配置并安裝MMM
rm -rf /etc/yum.repos.d/*
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
yum -y install epel-release
yum -y install mysql-mmm* mysql mysql-server mysql-devel
3.MySQL配置
/etc/init.d/mysqld start && chkconfig --level 35 mysqld on
mysqladmin -uroot password "123"
cp /usr/share/doc/mysql-server-5.1.73/my-medium.cnf /etc/my.cnf
vim /etc/my.cnf
    [mysqld]
    50 relay-log=relay-log-bin
    51 relay-log-index=slave-relay-bin.index
    59 server-id = 3
/etc/init.d/mysqld restart
4.授權(quán)并主從同步(m1,s1)
mysql -u root -p
mysql> change master to master_host='192.168.1.10',master_user='slave',master_password='123',master_log_file='mysql-bin.000001',master_log_pos=647;
//所跟IP、log、pos等信息都為第一臺主的信息
mysql> start slave;
mysql> show slave status\G;

Slave02

1.準備工作
vim /etc/sysconfig/network-scripts/ifcfg-eth0
    DEVICE=eth0
    TYPE=Ethernet
    ONBOOT=yes
    NM_CONTROLLED=no
    BOOTPROTO=static
    IPADDR=192.168.1.40
    NETMASK=255.255.255.0
vim /etc/sysconfig/network-scripts/ifcfg-eth2
    DEVICE=eth2
    TYPE=Ethernet
    ONBOOT=yes
    NM_CONTROLLED=no
    BOOTPROTO=dhcp
vim /etc/hosts
    192.168.1.10    db1
    192.168.1.20    db2
    192.168.1.30    db3
    192.168.1.40    db4
2.YUM源配置并安裝MMM
rm -rf /etc/yum.repos.d/*
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
yum -y install epel-release
yum -y install mysql-mmm* mysql mysql-server mysql-devel
3.MySQL配置
/etc/init.d/mysqld start && chkconfig --level 35 mysqld on
mysqladmin -uroot password "123"
cp /usr/share/doc/mysql-server-5.1.73/my-medium.cnf /etc/my.cnf
vim /etc/my.cnf
    [mysqld]
    50 relay-log=relay-log-bin
    51 relay-log-index=slave-relay-bin.index
    59 server-id = 4
/etc/init.d/mysqld restart
4.授權(quán)并主從同步(m2,s2)
mysql -u root -p
mysql> change master to master_host='192.168.1.20',master_user='slave',master_password='123',master_log_file='mysql-bin.000001',master_log_pos=647;
//所跟IP、log、pos等信息都為第二臺主的信息
mysql> start slave;
mysql> show slave status\G;

配置高可用MySQL-MMM

Master01

1.新建授權(quán)用戶
mysql> grant super,replication client,process on *.* to 'mmm_agent'@'192.168.1.%' identified by '123';//主服務(wù)器授權(quán),從服務(wù)器自動同步
mysql> grant replication client on *.* to 'mmm_monitor'@'192.168.1.%' identified by '123';           //主服務(wù)器授權(quán),從服務(wù)器自動同步
mysql> grant all on *.* to 'test'@'192.168.1.%' identified by '123';                    //新建測試用戶
2.配置MMM_COMMON
vim /etc/mysql-mmm/mmm_common.conf
    active_master_role      writer
    
            cluster_interface       eth0                    //集群IP承載的接口
            pid_path                /var/run/mysql-mmm/mmm_agentd.pid       //PID文件位置(存放MMM的進程號)
            bin_path                /usr/libexec/mysql-mmm/         //運行命令位置
            replication_user        slave                   //需使用主從同步時授權(quán)用戶
            replication_password    123
            agent_user              mmm_agent                   //代理連接
            agent_password          123
    
    
            ip      192.168.1.10
            mode    master
            peer    db2                     //當(dāng)db1主機不能使用,自動切換到db2
    
    
            ip      192.168.1.20
            mode    master                  //當(dāng)前服務(wù)器作為主服務(wù)器(寫)
            peer    db1                     //當(dāng)db2主機不能使用,自動切換到db1
    
    
            ip      192.168.1.30
            mode    slave
    
    
            ip      192.168.1.40
            mode    slave                   //當(dāng)前主機作為從服務(wù)器(讀)
    
    
            hosts   db1, db2
            ips     192.168.1.250               //寫服務(wù)器VIP
            mode    exclusive                   //只有一個host可以writer
    
    
            hosts   db3, db4
            ips     192.168.1.251, 192.168.1.252        //讀服務(wù)器VIP
            mode    balanced                    //多個host可以reader
    
3.配置MMM_AGENT
vim /etc/mysql-mmm/mmm_agent.conf
include mmm_common.conf
this db1
4.拷貝文件給其余主機
scp /etc/mysql-mmm/mmm_common.conf root@192.168.1.20:/etc/mysql-mmm/
scp /etc/mysql-mmm/mmm_common.conf root@192.168.1.30:/etc/mysql-mmm/
scp /etc/mysql-mmm/mmm_common.conf root@192.168.1.40:/etc/mysql-mmm/
/etc/init.d/mysql-mmm-agent restart && chkconfig --level 35 mysql-mmm-agent on

Master02

配置MMM_AGENT
vim /etc/mysql-mmm/mmm_agent.conf
this db2
/etc/init.d/mysql-mmm-agent restart && chkconfig --level 35 mysql-mmm-agent on

Slave01

配置MMM_AGENT
vim /etc/mysql-mmm/mmm_agent.conf
this db3
/etc/init.d/mysql-mmm-agent restart && chkconfig --level 35 mysql-mmm-agent on

Slave02

配置MMM_AGENT
vim /etc/mysql-mmm/mmm_agent.conf
this db4
/etc/init.d/mysql-mmm-agent restart && chkconfig --level 35 mysql-mmm-agent on

監(jiān)控配置(mmm_mon)

1.準備工作
vim /etc/sysconfig/network-scripts/ifcfg-eth0
    DEVICE=eth0
    TYPE=Ethernet
    ONBOOT=yes
    NM_CONTROLLED=no
    BOOTPROTO=static
    IPADDR=192.168.1.50
    NETMASK=255.255.255.0
vim /etc/sysconfig/network-scripts/ifcfg-eth2
    DEVICE=eth2
    TYPE=Ethernet
    ONBOOT=yes
    NM_CONTROLLED=no
    BOOTPROTO=dhcp
vim /etc/hosts
    192.168.1.10    db1
    192.168.1.20    db2
    192.168.1.30    db3
    192.168.1.40    db4
reboot
2.YUM源配置并安裝MMM
rm -rf /etc/yum.repos.d/*
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
yum -y install epel-release
yum -y install mysql-mmm* mysql
3.配置MMM_COMMON
scp 192.168.1.10:/etc/mysql-mmm/mmm_common.conf /etc/mysql-mmm/
4.配置MMM_MON
vim /etc/mysql-mmm/mmm_mon.conf
    include mmm_common.conf
    
            ip                  127.0.0.1
            ping_ips            192.168.1.10,192.168.1.20,192.168.1.30,192.168.1.40
    
    
            monitor_user        mmm_monitor
            monitor_password    123
    
    debug 0
5.啟動服務(wù)并驗證
/etc/init.d/mysql-mmm-monitor restart && chkconfig --level 35 mysql-mmm-monitor on  //監(jiān)控端啟動
mmm_control show                                    //查看節(jié)點狀態(tài)
mysql -u test -p -h 192.168.1.250

報錯解決方案:

[root@localhost ~]# mysql -u test -p -h 192.168.1.250
Enter password:
ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.1.254' (113)

主服務(wù)器:

grant super,replication client,process on *.* to 'mmm_agent'@'db1' identified by '123';
grant super,replication client,process on *.* to 'mmm_agent'@'db2' identified by '123';
grant super,replication client,process on *.* to 'mmm_agent'@'db3' identified by '123';
grant super,replication client,process on *.* to 'mmm_agent'@'db4' identified by '123';

日志查看:

tail -f /var/log/mysql-mmm/mmm_agentd.log                       //MySQL端的Agent日志
tail -f /var/log/mysql-mmm/mmm_mond.log                     //監(jiān)控機端的Monitor日志

部署讀寫調(diào)度器Amoeba

1.環(huán)境準備
vim /etc/sysconfig/network-scripts/ifcfg-eth0
    DEVICE=eth0
    TYPE=Ethernet
    ONBOOT=yes
    NM_CONTROLLED=no
    BOOTPROTO=static
    IPADDR=192.168.1.254
    NETMASK=255.255.255.0
2.安裝jdk與amoeba
yum -y erase java-*
chmod +x jdk-6u14-linux-x64.bin
./jdk-6u14-linux-x64.bin
mv jdk1.6.0_14/ /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=$JAVA_HOME/lib:$JAVA_HOME/jre/bin/:$PATH:$HOME/bin
export AMOEBA_HOME=/usr/local/amoeba
export PATH=$PATH:$AMOEBA_HOME/bin
source /etc/profile && java -version
mkdir /usr/local/amoeba
tar zxvf amoeba-mysql-binary-2.2.0.tar.gz -C /usr/local/amoeba/
chmod -R 755 /usr/local/amoeba/
3.在主Mysql數(shù)據(jù)庫新建授權(quán)用戶
mysql -u root -p
    mysql> grant all on *.* to haha@'192.168.1.%' identified by '123';
4.編輯amoeba配置文件
vim /usr/local/amoeba/conf/amoeba.xml
 30                hehe            //設(shè)置連接Amoeba用戶
 31
 32                123         //設(shè)置連接Amoeba用戶
115                 slaves
116
117                 master        注意刪除的注釋
118                 slaves         //定義讀服務(wù)器池
vim /usr/local/amoeba/conf/dbServers.xml
 25                         
 26                         haha               //設(shè)置連接Mysql的用戶
 27
 28                         123                //設(shè)置連接mysql的密碼
注意刪除的注釋
 43         
 44                 
 45                         
 46                         192.168.1.254         //定義寫服務(wù)器IP
 47                 
 48         
 49         
 50                 
 51                         
 52                         192.168.1.30          //定義讀服務(wù)器IP
 53                 
 54         
 55         
 56                 
 57                         
 58                         192.168.1.40          //定義讀服務(wù)器IP
 59                 
 60
 61         
 62         
 68                         slave1,slave2     //定義輸入slaves讀服務(wù)器池的主機
 69                 
amoeba start &
netstat -utpln | grep 8066
5.連接測試
client:mysql -u hehe -p -h 192.168.1.254 -P 8066

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機、免備案服務(wù)器”等云主機租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。


當(dāng)前題目:MySQL+Amoeba+MySQLMMM高可用群集-創(chuàng)新互聯(lián)
分享URL:http://news.spvevtbd.cn/article/dosdjc.html

其他資訊

在線咨詢
服務(wù)熱線
服務(wù)熱線:028-86922220
TOP