MySQL高可用解决方案之keepalive+lvs+mysql

解决configure: error: Popt libraries is required

这个错误是因为没有安装popt的开发包导致的,解决方法也很简单,只要yum install popt-devel,就可以安装好popt的开发包了。重新./configure.

Grant replication slave,file on *.* to ‘slave’@’%’identified by ‘slave’;

Master-master 配置

Master1:192.168.2.54

nano /etc/my.cnf

 

log-bin=mysql-bin

server-id=1

binlog-do-db=test

binlog-ignore-db=mysql

replicate-do-db=test

replicate-ignore-db=mysql

log-slave-updates

slave-skip-errors=all

sync_binlog=1

auto_increment_increment=2

auto_increment_offset=1

 

master2:192.168.2.60

log-bin=mysql-bin

server-id=2

binlog-do-db=test

binlog-ignore-db=mysql

replicate-do-db=test

replicate-ignore-db=mysql

log-slave-updates

slave-skip-errors=all

sync_binlog=1

auto_increment_increment=2

auto_increment_offset=1

 

操作master1 ,同时作为master2slave

change master to master_host='192.168.2.60',master_user=’slave’,master_password='slave',master_log_file='mysql-bin.000001', master_log_pos=98;

 

master2 进行操作

change master to master_host='192.168.2.54',master_user=’slave’,master_password='slave',master_log_file='mysql-bin.000001', master_log_pos=98;

查看master状态 show master status\G

查看slave状态 show slave status\G

Slave stop,slave start

 show processlist 查看执行状态

 

安装keepalived

wget http://www.keepalived.org/software/keepalived-1.2.1.tar.gz

./configure

Make&&make install

在主备节点上都执行

mkdir /etc/keepalived

cp /usr/local/etc/keepalived/keepalived.conf /etc/keepalived/keepalived.conf

cp /usr/local/etc/sysconfig/keepalived /etc/sysconfig/keepalived

cp /usr/local/sbin/keepalived  /usr/sbin/keepalived

cp /usr/local/etc/rc.d/init.d/keepalived  /etc/init.d/keepalived

 

在主节点上:

vi /etc/keepalived/keepalived.conf

 

! Configuration File for keepalived

 

global_defs {

   notification_email {

   [email protected]

   }

   notification_email_from Alexandre.Cassen@firewall.loc

   smtp_server 192.168.1.195

   smtp_connect_timeout 30

   router_id LVS_DEVEL

}

vrrp_script chk_mysql {

         script "killall -0 mysqld"

         interval 5

}

 

vrrp_instance VI_1 {

    state MASTER

    interface eth0

    virtual_router_id 51

    priority 100

    advert_int 1

    authentication {

        auth_typePASS

        auth_pass 1111

    }

    virtual_ipaddress {

        192.168.1.200

    }

 track_script {

                 chk_mysql

         }

}

 

在备用节点上

 vi /etc/keepalived/keepalived.conf

 

! Configuration File for keepalived

 

global_defs {

   notification_email {

   [email protected]

   }

   notification_email_from [email protected]

   smtp_server 192.168.1.195

   smtp_connect_timeout 30

   router_id LVS_DEVEL

}

vrrp_script chk_mysql {

         script "killall -0 mysqld"

         interval 5

}

 

vrrp_instance VI_1 {

    state BACKUP

    interface eth0

    virtual_router_id 51

    priority 90

    advert_int 1

    authentication {

        auth_typePASS

        auth_pass 1111

    }

    virtual_ipaddress {

        192.168.1.200

    }

 track_script {

                 chk_mysql

         }

}

 

 

猜你喜欢

转载自418684644-qq-com.iteye.com/blog/1446747