成都创新互联网站制作重庆分公司

mysql+keepalived的安装配置方法-创新互联

本篇内容主要讲解“mysql+keepalived的安装配置方法”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“mysql+keepalived的安装配置方法”吧!

“专业、务实、高效、创新、把客户的事当成自己的事”是我们每一个人一直以来坚持追求的企业文化。 创新互联是您可以信赖的网站建设服务商、专业的互联网服务提供商! 专注于成都网站设计、成都做网站、软件开发、设计服务业务。我们始终坚持以客户需求为导向,结合用户体验与视觉传达,提供有针对性的项目解决方案,提供专业性的建议,创新互联建站将不断地超越自我,追逐市场,引领市场!

注意:keepalived在每一台的服务器上都需要安装

环境介绍:

master_mysql: 10.20.20.51
slave_mysql : 10.20.20.61
virtual_ip :  10.20.20.201

注意:关闭防火墙、selinux
一、安装keepalived

下载地址:
1、 http://www.keepalived.org/software/keepalived-1.1.20.tar.gz

3、安装C编译器
yum install popt-devel openssl-devel popt-devel 
yum install gcc gcc-c++ autoconf automake


4、编译安装
[root@node1 ~]# tar zxvf keepalived-1.2.13.tar.gz
[root@node1 keepalived-1.2.13]# cd keepalived-1.2.13
[root@node1 keepalived-1.2.13]# ./configure --prefix=/usr/local/keepalived --disable-fwmark
[root@node1 keepalived-1.2.13]# make
[root@node1 keepalived-1.2.13]# make install
[root@node1 keepalived-1.2.13]# cp /usr/local/keepalived/sbin/keepalived /usr/sbin/
[root@node1 keepalived-1.2.13]# cp /usr/local/keepalived/etc/sysconfig/keepalived /etc/sysconfig/
[root@node1 keepalived-1.2.13]# cp /usr/local/keepalived/etc/rc.d/init.d/keepalived /etc/init.d/
[root@node1 keepalived-1.2.13]# cd /etc/init.d/
[root@node1 init.d]# chkconfig --add keepalived
[root@node1 init.d]# chkconfig keepalived on
[root@node1 init.d]# mkdir -p /etc/keepalived

5、配置keepalived文件
1)主库的keepalived配置文件
vim /etc/keepalived/keepalived.conf
global_defs {


router_id Hadb_1


}


vrrp_sync_group VGM {


group {


VI_HA


}


}


vrrp_script chk_mysql {




script "

interval 1


}


# vvrp_instance define #


vrrp_instance VI_HA {


state MASTER


interface eth0


virtual_router_id 54


priority 100


advert_int 1


authentication {


auth_type PASS


auth_pass hamysql


}


virtual_ipaddress {


10.20.20.201


}


track_script {


chk_mysql


}


}


2)从库的keepalived的配置文件
vim /etc/keepalived/keepalived.conf


global_defs {


router_id Hadb_1


}


vrrp_sync_group VGM {


group {


VI_HA


}


}


vrrp_script chk_mysql {




script "

interval 1


}


# vvrp_instance define #


vrrp_instance VI_HA {


state BACKUP


interface eth0


virtual_router_id 54


priority 50


advert_int 1


authentication {


auth_type PASS


auth_pass hamysql


}


virtual_ipaddress {


10.20.20.201


}


track_script {


chk_mysql


}


}
6、启动keepalived服务
service keepalived start



二、配置mysql的AB复制(互相的AB复制)




1、1.主库配置(master服务器)


 #vi /etc/my.cnf
       [mysqld]
       log-bin=mysql-bin   //[必须]启用二进制日志
       server-id=51       //[必须]服务器唯一ID,默认是1,一般取IP最后一段


2.修改从服务器slave:


   #vi /etc/my.cnf
       [mysqld]
       log-bin=mysql-bin   //[必须]启用二进制日志
       server-id=61       //[必须]服务器唯一ID,默认是1,一般取IP最后一段
3、重启两台服务器的mysql
/etc/init.d/mysql restart


4、在主服务器上建立帐户并授权slave:
10.20.20.51:
mysql>GRANT REPLICATION SLAVE ON *.* to 'repler'@'%' identified by '123.com';


10.20.20.61:
mysql>GRANT REPLICATION SLAVE ON *.* to 'repler'@'%' identified by '123.com';


5、登录主服务器的mysql,查询master的状态
mysql>show master status;
   +------------------+----------+--------------+------------------+
   | File             | Position | Binlog_Do_DB | Binlog_Ignore_DB |
   +------------------+----------+--------------+------------------+
   | mysql-bin.000004 |      308 |              |                  |
   +------------------+----------+--------------+------------------+
   
 6、配置从服务器Slave:
10.20.20.61: 
 mysql>change master to master_host='10.20.20.51',master_user='repler',master_password='123.com',
         master_log_file='mysql-bin.000004',master_log_pos=308;  
   
 10.20.20.51:   
  mysql>change master to master_host='10.20.20.61',master_user='repler',master_password='123.com',
         master_log_file='mysql-bin.000004',master_log_pos=308;    
 7、启动从服务器复制功能  
  mysql>start slave;   
   
  8、检查从服务器复制功能状态:
   mysql> show slave status\G 

到此,相信大家对“mysql+keepalived的安装配置方法”有了更深的了解,不妨来实际操作一番吧!这里是创新互联网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!


当前题目:mysql+keepalived的安装配置方法-创新互联
浏览地址:http://cxhlcq.com/article/ighjd.html

其他资讯

在线咨询

微信咨询

电话咨询

028-86922220(工作日)

18980820575(7×24)

提交需求

返回顶部