中文字幕av专区_日韩电影在线播放_精品国产精品久久一区免费式_av在线免费观看网站

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

mysql數據庫同步debug的示例分析

發布時間:2022-01-14 16:13:40 來源:億速云 閱讀:169 作者:小新 欄目:數據庫

小編給大家分享一下mysql數據庫同步debug的示例分析,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!

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

# 1064: sql syntax

#slave_skip_errors = 1062,1064

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 ??

以上是“mysql數據庫同步debug的示例分析”這篇文章的所有內容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內容對大家有所幫助,如果還想學習更多知識,歡迎關注億速云行業資訊頻道!

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

育儿| 岐山县| 青河县| 奉化市| 莲花县| 博爱县| 弥渡县| 柘城县| 郸城县| 二连浩特市| 大田县| 贡嘎县| 高尔夫| 金华市| 无为县| 土默特右旗| 乌拉特前旗| 东源县| 西藏| 赤壁市| 广南县| 邯郸市| 太湖县| 广东省| 神木县| 林周县| 合阳县| 杂多县| 札达县| 广州市| 象州县| 佛山市| 盘锦市| 阜城县| 陇川县| 黄石市| 读书| 博客| 贵州省| 洪湖市| 潼关县|