最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 科技 - 知识百科 - 正文

mysql数据库同步debug_MySQL

来源:动视网 责编:小采 时间:2020-11-09 18:08:19
文档

mysql数据库同步debug_MySQL

mysql数据库同步debug_MySQL:bitsCN.com 数据库的同步一直是个很重要的问题,也是一个难题,所幸mysql提供了多种方法可以用来同步 在本文中我先给出mysql本身自带的方式master-slave方式,详尽的步骤如下: 1、prepare ### 需要修改主、从服务器的my.cnf文件### 1) mas
推荐度:
导读mysql数据库同步debug_MySQL:bitsCN.com 数据库的同步一直是个很重要的问题,也是一个难题,所幸mysql提供了多种方法可以用来同步 在本文中我先给出mysql本身自带的方式master-slave方式,详尽的步骤如下: 1、prepare ### 需要修改主、从服务器的my.cnf文件### 1) mas


bitsCN.com

数据库的同步一直是个很重要的问题,也是一个难题,所幸mysql提供了多种方法可以用来同步

在本文中我先给出mysql本身自带的方式master-slave方式,详尽的步骤如下:

1、prepare

### 需要修改主、从服务器的my.cnf文件###

1) master

mysql> grant replication client,replication slave on *.* to ‘repl’@'192.168.0.*’ identified by ‘xxxxxx’

=========================================================================

### 主服务器###

# Replication Master Server (default)

# binary logging is required for replication

log-bin=/mysql/bin-log

log-bin-index=/mysql/bin-log.index

#binlog_cache_size = 1M

binlog_do_db = test1

binlog_do_db = test2

#binlog_ignore_db =

# 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 = 2370

=========================================================================

2) slave

mysql> grant replication client,replication slave on *.* to ‘repl’@'192.168.0.*’ identified by ‘xxxxxx’

=========================================================================

### 从服务器###

# required unique id between 2 and 2^32 - 1

# (and different from the master)

# defaults to 2 if master-host is set

# but will not function as a slave if omitted

server-id = 2379

#

# The replication master for this slave - required

master-host = 192.168.0.240

#

# The username the slave will use for authentication when connecting

# to the master - required

master-user = repl

#

# The password the slave will authenticate with when connecting to

# the master - required

master-password = xxxxxx

#

# The port the master is listening on.

# optional - defaults to 3306

master-port = 3306

#

# binary logging - not required for slaves, but recommended

#log-bin=/mysql/log/slavebin-log

master-info-file = /mysql/log/master.info

relay-log-info-file = /mysql/log/relay-log.info

replicate_do_db = test1

replicate_do_db = test2

#replicate_ignore_db = …

#replicate_do_table =

#replicate_ignore_table =

#replicate_wild_do_table =

#replicate_wild_ignore_table = …

#replicate_wild_ignore_table = temp/_subpost/_%

#replicate_rewrite_db=->

# 1062: dup key entry

# 10: sql syntax

#slave_skip_errors = 1062,10

slave_skip_errors = 1062

relay-log = /mysql/log/relay-log

relay-log-index = /mysql/log/relay-log.index

=========================================================================

### below step will start the work ###

=========================================================================

cd /opt/mysql/bin

ln -s /opt/mysql/share/mysql/mysql.server mysqlctl

=========================================================================

2、stop mysql

1) master: mysqlctl stop && ps auxww|grep mysql

2) slave: mysqlctl stop && ps auxww|grep mysql

3、start master’s mysql

mysqlctl start

ps auxww|grep mysql

mysql >flush tables;

mysql >show master status /G

mysql >reset master

mysqlctl stop

4、start slave’s mysql

mysqlctl start

ps auxww|grep mysql

mysql >stop slave

mysql >show slave status /G

mysql >reset slave;

mysqlctl stop

5、start master’s mysql

mysqlctl start

mysql >show master status /G

mysql >flush tables with read lock

mysql >show master status /G

## record the bin-log and positon ##

6、synchronization master’s datas to slave

rsync -avP “master’s datas” “slave’s datas directory”

7、start slave’s mysql

mysqlctl start –skip-slave-start

mysql >show slave status /G

mysql >change master to

-> MASTER_HOST=’master_host_name’,

-> MASTER_USER=’replication_user_name’,

-> MASTER_PASSWORD=’replication_password’,

-> MASTER_LOG_FILE=’recorded_log_file_name’,

-> MASTER_LOG_POS=recorded_log_position;

## Note:slave’s file and pos must be the same with with master’s ##

8、master

mysql >unlock tables;

9、slave

mysql >show slave status /G

## Note: Seconds_behind_master=0

## Slave_IO_Running=YES,Slave_SQL_Running=YES

10、checking the slave’s database updated real-time whether or not ??

本文出自 “迈小步、不停步!” 博客

bitsCN.com

文档

mysql数据库同步debug_MySQL

mysql数据库同步debug_MySQL:bitsCN.com 数据库的同步一直是个很重要的问题,也是一个难题,所幸mysql提供了多种方法可以用来同步 在本文中我先给出mysql本身自带的方式master-slave方式,详尽的步骤如下: 1、prepare ### 需要修改主、从服务器的my.cnf文件### 1) mas
推荐度:
标签: 数据库 调试 mysql
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top