Linux下MySQL+Keepalived高可用性配置
前言*在mysql高可用配置中,我们会看到有很多的方法,每种方法都有各自优缺点,那今天我们来看参看一下Mysql+Keepalived高可用配置。
一、安装环境:
系统版本:CentOS6.0 x86_64
Mysql版本:mysql-5.1.61
Mysqlserver_1: 192.9.117.140
Mysqlserver_2: 192.9.117.141
Keepalived-VIP:192.9.117.142
二、正式安装:
在两台服务器上分别安装mysql,这里直接采用yum安装,如下:
- yum install –y mysql mysql-devel mysql-server mysql-libs
安装完后,配置MySQL配置文件,mysql采用主主模式:
1) 192.9.117.140的配置文件如下:vi /etc/my.cnf
- [mysqld]
- datadir=/data/mysql
- socket=/var/lib/mysql/mysql.sock
- user=mysql
- # Disabling symbolic-links is recommended to prevent assorted security risks
- symbolic-links=0
- log-bin=mysql-bin
- server-id = 1
- auto_increment_offset=1
- auto_increment_increment=2
- [mysqld_safe]
- log-error=/var/log/mysqld.log
- pid-file=/var/run/mysqld/mysqld.pid
- master-host =192.9.117.141
- master-user=tongbu
- master-pass=123456
- master-port =3306
- master-connect-retry=60
- replicate-do-db =map
2) 192.9.117.141的配置文件如下:vi /etc/my.cnf
- [mysqld]
- datadir=/data/mysql
- socket=/var/lib/mysql/mysql.sock
- user=mysql
- # Disabling symbolic-links is recommended to prevent assorted security risks
- symbolic-links=0
- log-bin=mysql-bin
- server-id = 2
- auto_increment_offset=2
- auto_increment_increment=2
- [mysqld_safe]
- log-error=/var/log/mysqld.log
- pid-file=/var/run/mysqld/mysqld.pid
- master-host =192.9.117.140
- master-user=tongbu
- master-pass=123456
- master-port =3306
- master-connect-retry=60
- replicate-do-db =map
- 如上设置bin-log文件,并都设置对方为自己的主服务器,配置同步的数据库为map
相关推荐
CoderToy 2020-11-16
emmm00 2020-11-17
王艺强 2020-11-17
ribavnu 2020-11-16
bianruifeng 2020-11-16
wangshuangbao 2020-11-13
苏康申 2020-11-13
vivenwan 2020-11-13
moyekongling 2020-11-13
云中舞步 2020-11-12
要啥自行车一把梭 2020-11-12
aydh 2020-11-12
kuwoyinlehe 2020-11-12
minerk 2020-11-12
vitasfly 2020-11-12
jazywoo在路上 2020-11-11
敏敏张 2020-11-11
世樹 2020-11-11