[置顶]linux下搭建mysql主从
2016-05-13 10:21
573 查看
在master上创建repl账户,用于复制。
grant replication slave on *.* to 'repl'@'%' identified by 'P@$$W0rd';
flush privileges;
与windows下搭建mysql主从的区别:
二进制日志的路径格式不一样
master:
my.cnf部分配置(master):
thread_handling = pool-of-threads
thread_pool_oversubscribe = 10
skip-name-resolve
# Replication Master Server (default)
# binary logging is required for replication
#log-bin=mysql-bin
# binary logging format - mixed recommended
binlog_format=mixed
# required unique id between 1 and 2^32 - 1
# defaults to 1 if master-host is not set
# but will not function as a master if omitted
server-id = 1
expire_logs_days = 10
max_binlog_size = 100M
log_bin = /var/lib/mysql/mysql-bin.log #确保此文件可写
read-only =0 #主机,读写都可以
binlog-do-db =yourdb #需要备份数据,多个写多行
binlog-ignore-db =mysql #不需要备份的数据库,多个写多行
slave:
master:
show variables like '%log_bin%';
show master status
slave:
stop slave;
change master to
master_host='192.168.103.56',
master_user='repl',
master_password='P@$$W0rd',
master_log_file='mysql-bin.000002',
master_log_pos=120;
start slave;
show slave status;
grant replication slave on *.* to 'repl'@'%' identified by 'P@$$W0rd';
flush privileges;
与windows下搭建mysql主从的区别:
二进制日志的路径格式不一样
master:
my.cnf部分配置(master):
thread_handling = pool-of-threads
thread_pool_oversubscribe = 10
skip-name-resolve
# Replication Master Server (default)
# binary logging is required for replication
#log-bin=mysql-bin
# binary logging format - mixed recommended
binlog_format=mixed
# required unique id between 1 and 2^32 - 1
# defaults to 1 if master-host is not set
# but will not function as a master if omitted
server-id = 1
expire_logs_days = 10
max_binlog_size = 100M
log_bin = /var/lib/mysql/mysql-bin.log #确保此文件可写
read-only =0 #主机,读写都可以
binlog-do-db =yourdb #需要备份数据,多个写多行
binlog-ignore-db =mysql #不需要备份的数据库,多个写多行
slave:
master:
show variables like '%log_bin%';
show master status
slave:
stop slave;
change master to
master_host='192.168.103.56',
master_user='repl',
master_password='P@$$W0rd',
master_log_file='mysql-bin.000002',
master_log_pos=120;
start slave;
show slave status;
相关文章推荐
- [置顶]linux常用命令
- [置顶]CentOS7下通过rpm方式安装MySQL及插入中文问题解决 [原创]
- [置顶]VMWare Workstation 11安装CentOS7,附图 [原创]
- Keepalived高可用集群搭建(转载linuxIDC)
- 在Linux上安装ant环境
- 连接linux下crt输入ctrl+s很容易死机
- Linux的小技巧
- Linux php 中文乱码的快速解决方法
- 无线信号强度解析及linux如何查看wifi信号强弱等
- linux设备驱动程序--类class的实现
- linux设备驱动程序--类class的实现
- linux设备驱动程序--类class的实现
- Linux 自动同步服务器时间
- (转载收藏用)linux sed命令详解
- Linux 下编写.sh文件运行JAR下的Class
- Linux信号(signal) 机制分析
- Linux装载配置SVN
- Linux系统下安装QT、QT Creator 和 qt-embedded-linux
- ubuntu12.04借助wine安装国际版qq(亲测成功版)
- 基于linux下的QT设计和移植到开发运行