利用MySQL-Proxy进行MySQL数据库的读写分离
实验系统:CentOS 6.6_x86_64实验前提:防火墙和selinux都关闭实验说明:本实验共有4台主机,IP分配如拓扑实验软件:mariadb-10.
实验系统:CentOS 6.6_x86_64
实验前提:防火墙和selinux都关闭
实验说明:本实验共有4台主机,IP分配如拓扑
实验软件:mariadb-10.0.20 mysql-proxy-0.8.5-linux-el6-x86-64bit
下载地址:
MySQL Proxy读写分离实战
在CentOS 5.2下安装最新的MySQL Proxy
RHEL5.5下MySQL Proxy 安装
mysql proxy、mysql-mmm实现读写分离高可用性
实验拓扑:
一、准备工作:
1.将主机名称改为如下所示:
2.将hosts文件添加如下内容:
3.master、slave1和slave2安装mariadb:
tar xf mariadb-10.0.20-linux-x86_64.tar.gz -C /usr/local/
cd /usr/local/
ln -sv mariadb-10.0.20-linux-x86_64 mysql
useradd -r mysql
mkdir -pv /mydata/data
chown -R mysql.mysql /mydata/data/
cd mysql/
chown -R root.mysql .
scripts/mysql_install_db --user=mysql --datadir=/mydata/data/
cp support-files/my-large.cnf /etc/my.cnf
cp support-files/mysql.server /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on
二、配置主从复制
1.master上配置my.cnf:
[mysqld]
server-id = 1
datadir = /mydata/data
log-bin = /mydata/data/master-bin
binlog_format = ROW
sync_binlog = 1 //确保每次事务提交之前都能将二进制日志同步磁盘上
2.slave1上配置my.cnf:
[mysqld]
#log-bin=mysql-bin
#binlog_format=mixed
server-id = 2
datadir = /mydata/data
relay_log = /mydata/data/relay-log
read_only = 1
sync_master_info = 1 //及时同步master文件
sync_relay_log = 1 //及时同步relay-log文件
sync_relay_log_info = 1 //及时同步relay-log-info文件
3.slave2上配置my.cnf:
[mysqld]
#log-bin=mysql-bin
#binlog_format=mixed
server-id = 3
datadir = /mydata/data
relay_log = /mydata/data/relay-log
read_only = 1
sync_master_info = 1
sync_relay_log = 1
sync_relay_log_info = 1
4.在master上创建复制用户:
service mysqld start
/usr/local/mysql/bin/mysql
------------------------------------------->
GRANT REPLICATION SLAVE,REPLICATION CLIENT ON *.* TO 'slave'@'192.168.19.%' IDENTIFIED BY '123456';
FLUSH PRIVILEGES;
5.在master上查看二进制日志位置:
SHOW MASTER LOGS;
6.两台slave上操作:
CHANGE MASTER TO MASTER_HOST='master',MASTER_USER='slave',MASTER_PASSWORD='123456',MASTER_LOG_FILE='master-bin.000001',MASTER_LOG_POS=637;
START SLAVE;
SHOW SLAVE STATUS\G
更多详情见请继续阅读下一页的精彩内容:
,上一篇: rem绝对自适应方案解析
推荐阅读