91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

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

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

怎樣簡單解析mysql主從復制

發布時間:2021-10-25 15:55:49 來源:億速云 閱讀:136 作者:柒染 欄目:MySQL數據庫

怎樣簡單解析mysql主從復制,很多新手對此不是很清楚,為了幫助大家解決這個難題,下面小編將為大家詳細講解,有這方面需求的人可以來學習下,希望你能有所收獲。

mysql主從復制(冷備)

1.create repl user on master
grant replication slave on *.* to 'repl'@'10.124.110.116' identified by 'doudou123';

  1. root@(none) 10:13>grant replication slave on *.* to 'repl'@'10.124.110.116' identified by 'doudou123';

  2. Query OK, 0 rows affected (0.04 sec)

2.enable BINLOG and set server-id in my.conf and restart server
[mysqld]
log-bin = /mysql/data/3307/mysql-bin.log
server-id = 113

  1. root@(none) 10:35>show variables like '%log_bin%';

  2. +---------------------------------+-------------------------------+

  3. | Variable_name | Value |

  4. +---------------------------------+-------------------------------+

  5. | log_bin | ON |

  6. | log_bin_basename | /mysql/data/3307/mysql-bin.log| <==success

  7. | log_bin_index | /mysql/data/3307/binlog.index |

  8. | log_bin_trust_function_creators | ON |

  9. | log_bin_use_v1_row_events | OFF |

  10. | sql_log_bin | ON |

  11. +---------------------------------+-------------------------------+


  12. root@(none) 10:36>show variables like '%server_id%';

  13. +----------------+-------+

  14. | Variable_name | Value |

  15. +----------------+-------+

  16. | server_id | 113 | <==success

  17. | server_id_bits | 32 |

  18. +----------------+-------+

  19. 2 rows in set (0.00 sec)

3.flush tables
flush tables with read lock;

  1. root@(none) 10:42>flush tables with read lock;

  2. Query OK, 0 rows affected (0.00 sec)

4.show file and position
show master status;

  1. root@(none) 14:57>show master status;

  2. +------------------+----------+--------------+------------------+-------------------+

  3. | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |

  4. +------------------+----------+--------------+------------------+-------------------+

  5. | mysql-bin.000008 | 120 | | | |

  6. +------------------+----------+--------------+------------------+-------------------+

5.cold backup
tar -cvf 3307data.tar 3307

6.unlock tables on master
unlock tables;

  1. root@(none) 14:18>unlock tables;

  2. Query OK, 0 rows affected (0.02 sec)

7.set only server-id in my.conf on slave
[mysqld]
server-id = 114
vi auto.cnf
server_uuid=57735006-38f1-11e6-862c-005056beb65f

8.startup server with --skip-slave-start on slave
mysqld_multi start 3307

9.set user,ip,port,replication log and position on slave
change master to
master_host='10.124.110.113',
master_port=3307,
master_user='repl',
master_password='doudou123',
master_log_file='mysql-bin.000008',
master_log_pos=120;

  1. mysql> change master to

  2.     -> master_host='10.124.110.113',

  3.     -> master_port=3307,

  4.     -> master_user='repl',

  5.     -> master_password='doudou123',

  6.     -> master_log_file='binlog.000008',

  7.     -> master_log_pos=120;

  8. Query OK, 0 rows affected, 2 warnings (0.05 sec)

10.startup slave process
start slave;

  1. mysql> start slave;

  2. Query OK, 0 rows affected (0.01 sec)

11.show processlist on slave
show processlist \G

mysql> show processlist \G
*************************** 1. row ***************************
     Id: 1
   User: event_scheduler
   Host: localhost
     db: NULL
Command: Daemon
   Time: 10060
  State: Waiting on empty queue
   Info: NULL
*************************** 2. row ***************************
     Id: 2
   User: root
   Host: localhost
     db: NULL
Command: Query
   Time: 0
  State: init
   Info: show processlist
*************************** 3. row ***************************
     Id: 3
   User: system user
   Host:
     db: NULL
Command: Connect
   Time: 19
  State: Connecting to master   <=="Waiting for master to send event" is right. and some errors because password is wrong or server_uuid is the same.
## find errors using "show slave status \G"  and modify server_uuid using "auto.cnf" and find server_uuid using "show variables like '%server_uuid%';" ##
   Info: NULL
*************************** 4. row ***************************
     Id: 4
   User: system user
   Host:
     db: NULL
Command: Connect
   Time: 19
  State: Slave has read all relay log; waiting for the slave I/O thread to update it
   Info: NULL
4 rows in set (0.00 sec)

  1. this is all right !!!!

  2. mysql> show processlist \G

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

  4.      Id: 1

  5.    User: system user

  6.    Host:

  7.      db: NULL

  8. Command: Connect

  9.    Time: 31769

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

  11.    Info: NULL

  12. *************************** 2. row ***************************

  13.      Id: 2

  14.    User: system user

  15.    Host:

  16.      db: NULL

  17. Command: Connect

  18.    Time: 946

  19.   State: Waiting for master to send event

  20.    Info: NULL

  21. *************************** 3. row ***************************

  22.      Id: 3

  23.    User: event_scheduler

  24.    Host: localhost

  25.      db: NULL

  26. Command: Daemon

  27.    Time: 946

  28.   State: Waiting on empty queue

  29.    Info: NULL

  30. *************************** 4. row ***************************

  31.      Id: 5

  32.    User: root

  33.    Host: localhost

  34.      db: test

  35. Command: Query

  36.    Time: 0

  37.   State: init

  38.    Info: show processlist

  39. 4 rows in set (0.00 sec)

12.test change rows on master
use test
show tables;
create table repl_test(id int);
insert into repl_test values(1),(2),(3);
insert into repl_test values(4),(5),(6);
insert into repl_test values(7),(8),(9);

13.show test rows on slave
use test
show tables;

  1. select * from repl_test;


  2. +------+

  3. | id |

  4. +------+

  5. | 1 |

  6. | 2 |

  7. | 3 |

  8. | 4 |

  9. | 5 |

  10. | 6 |

  11. | 7 |

  12. | 8 |

  13. | 9 |

  14. +------+

  15. 9 rows in set (0.00 sec)

看完上述內容是否對您有幫助呢?如果還想對相關知識有進一步的了解或閱讀更多相關文章,請關注億速云行業資訊頻道,感謝您對億速云的支持。

向AI問一下細節

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

AI

军事| 曲靖市| 梁河县| 扶绥县| 宝应县| 邓州市| 阜宁县| 武夷山市| 临西县| 永吉县| 文水县| 武平县| 淮北市| 大荔县| 延寿县| 梓潼县| 九江市| 淅川县| 高淳县| 治县。| 宣化县| 潼南县| 甘德县| 司法| 育儿| 突泉县| 游戏| 宜君县| 兴仁县| 曲松县| 新兴县| 新巴尔虎左旗| 元氏县| 康马县| 十堰市| 深州市| 江安县| 河北省| 宝丰县| 大荔县| 崇义县|