在线精品99_中国九九盗摄偷拍偷看_91免费版在线观看_91.app_91高清视频在线_99热最新网站

mysql传统主从复制的部署过程

114次阅读
没有评论

共计 3496 个字符,预计需要花费 9 分钟才能阅读完成。

这篇文章主要讲解了“mysql 传统主从复制的部署过程”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着丸趣 TV 小编的思路慢慢深入,一起来研究和学习“mysql 传统主从复制的部署过程”吧!

部署过程

一、保证 Master 库和 Slave 库的数据和结构一致
可以通过 mysqldump 或者 XtraBackup 工具对 Master 库进行全备,再把备份文件传到 Slave 库,Slave 库利用改备份进行恢复,使得两者一致。
我这里的 Slave 库是直接复制 Master 库生成的,所以不需要做这一步了。

二、配置两个库的参数文件

Master 库需要打开二进制日志

Master 库需要设置与 Slave 库不同的 server-id

[root@potato data]vi /etc/my.cnf

binlog_format = mixed

server-id = 203306

log-bin = mybinlog

Slave 库只需配置 server-id 即可

[root@tomato data]vi /etc/my.cnf

server-id = 203307

三、创建用来进行复制的用户并且赋权

必须给予用户 replication slave 权限,指定 Slave 库的主机地址

点击 (此处) 折叠或打开

root@localhost:mysql.sock  05:02:32 [(none)] grant replication slave on *.* to repl@ 192.168.161.128 identified by repl

四、让 Slave 库 change 到 Master 库

查看 Master 库此时的日志位置

点击 (此处) 折叠或打开

root@localhost:mysql.sock  05:02:32 [(none)] show master status ;

+—————–+———-+————–+——————+——————-+

| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |

+—————–+———-+————–+——————+——————-+

| mybinlog.000004 | 331 | | | |

+—————–+———-+————–+——————+——————-+

1 row in set (0.00 sec)

从库开始 change 到 master 库上

点击 (此处) 折叠或打开

root@localhost:mysql.sock  04:29:15 [(none)] change master to

 – master_host= 192.168.161.128 ,

 – master_port=3306,

 – master_user= repl ,

 – master_password= repl ,

 – master_log_file= mybinlog.000004 ,

 – master_log_pos=331;

ERROR 2006 (HY000): MySQL server has gone away

No connection. Trying to reconnect…

Connection id:    2

Current database: *** NONE ***

Query OK, 0 rows affected, 2 warnings (0.17 sec)

五、Slave 库执行开始复制命令

点击 (此处) 折叠或打开

root@localhost:mysql.sock  04:40:11 [(none)] start slave;

到此,主从复制就已经配置完毕了

六、对搭建的环境进行测试测试

主库开始插入数据测试

点击 (此处) 折叠或打开

root@localhost:mysql.sock  04:40:11 [(none)] use lala;

root@localhost:mysql.sock  04:51:23 [(lala)] create table haha(id int);

root@localhost:mysql.sock  04:51:23 [(lala)] insert into haha values(1);

从库是否接受到数据

点击 (此处) 折叠或打开

root@localhost:mysql.sock  04:52:55 [(none)] select * from lala.haha;

+——+

| id |

+——+

| 1 |

+——+

1 row in set (0.00 sec)

查看 Slave 状态

点击 (此处) 折叠或打开

root@localhost:mysql.sock  04:57:23 [(none)] show slave status\G

*************************** 1. row ***************************

 Slave_IO_State: Waiting for master to send event

 Master_Host: 192.168.161.128

 Master_User: repl

 Master_Port: 3306

 Connect_Retry: 60

 Master_Log_File: mybinlog.000004

 Read_Master_Log_Pos: 620

 Relay_Log_File: mysql-relay-bin.000003

 Relay_Log_Pos: 571

 Relay_Master_Log_File: mybinlog.000004

 Slave_IO_Running: Yes

 Slave_SQL_Running: Yes

 Replicate_Do_DB:

 Replicate_Ignore_DB:

 Replicate_Do_Table:

 Replicate_Ignore_Table:

 Replicate_Wild_Do_Table:

 Replicate_Wild_Ignore_Table:

 Last_Errno: 0

 Last_Error:

 Skip_Counter: 0

 Exec_Master_Log_Pos: 620

 Relay_Log_Space: 744

 Until_Condition: None

 Until_Log_File:

 Until_Log_Pos: 0

 Master_SSL_Allowed: No

 Master_SSL_CA_File:

 Master_SSL_CA_Path:

 Master_SSL_Cert:

 Master_SSL_Cipher:

 Master_SSL_Key:

 Seconds_Behind_Master: 0

Master_SSL_Verify_Server_Cert: No

 Last_IO_Errno: 0

 Last_IO_Error:

 Last_SQL_Errno: 0

 Last_SQL_Error:

 Replicate_Ignore_Server_Ids:

 Master_Server_Id: 203306

 Master_UUID: af3609cd-b426-11e6-a997-000c29d55626

 Master_Info_File: /data/mysql/mytest_3306/data/master.info

 SQL_Delay: 0

 SQL_Remaining_Delay: NULL

 Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update it

 Master_Retry_Count: 86400

 Master_Bind:

 Last_IO_Error_Timestamp:

 Last_SQL_Error_Timestamp:

 Master_SSL_Crl:

 Master_SSL_Crlpath:

 Retrieved_Gtid_Set:

 Executed_Gtid_Set:

 Auto_Position: 0

1 row in set (0.00 sec)

主从复制部署测试成功

感谢各位的阅读,以上就是“mysql 传统主从复制的部署过程”的内容了,经过本文的学习后,相信大家对 mysql 传统主从复制的部署过程这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是丸趣 TV,丸趣 TV 小编将为大家推送更多相关知识点的文章,欢迎关注!

正文完
 
丸趣
版权声明:本站原创文章,由 丸趣 2023-08-01发表,共计3496字。
转载说明:除特殊说明外本站除技术相关以外文章皆由网络搜集发布,转载请注明出处。
评论(没有评论)
主站蜘蛛池模板: 国产区二区 | 欧美aaaa黄色一级毛片 | 少妇高潮潮喷到猛进猛出小说 | 日韩电影中文字幕在线网站 | 国产精品综合网 | 美女一级毛片无遮挡内谢 | 国产精品成人嫩妇 | 欧美啪啪一级毛片 | 色老板美国在线观看 | 97视频热人人精品免费 | 久久精品人人做人人看最新章 | 日韩欧美一区二区在线 | 特黄特黄一级高清免费大片 | 久久亚洲国产精品五月天婷 | 色婷婷亚洲一区二区三区 | 午夜小视频免费观看 | 777久久精品一区二区三区无码 | 亚洲日本视频在线观看 | 亚洲日韩中文字幕在线播放 | 欧美激情高清免费不卡 | 国产三级精品三级男人的天堂 | 色狠狠一区 | 看一级毛片国产一级毛片 | 成年网站视频在线观看 | 亚洲久久成人 | 国产色视频在线 | 亚洲熟妇少妇任你躁在线观看无码 | 欧美精品一区二区三区四区 | 伊人久久大香线蕉综合网站 | 国产亚洲精品一区久久 | 久久99亚洲精品久久 | 日韩久久精品视频 | 成人嗯啊视频在线观看 | 少妇无码av无码专区 | 一区二区三区不卡免费视频97 | 久久精品一区二区三区不卡 | 免费国产黄线在线播放 | 久久99这里只有精品 | 成视频年人黄网站免费视频 | 午夜一区二区福利视频在线 | 老鸭窝在线免费视频 |