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 {

   ethnicitybeta@126.com

   }

   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 {

   ethnicitybeta@126.com

   }

   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 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

         }

}

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值