1. 程式人生 > >Mysql 之 主從復制

Mysql 之 主從復制

ges start row RoCE star 系統 網絡 format binlog日誌

一、數據庫主從復制基本要求:
1、操作系統版本一致(建議)。
2、數據庫版本一致(建議)。
3、配置文件參數一致(是指一些性能參數)。

二、網絡拓撲

技術分享圖片

三、主數據庫配置文件

[mysqld]
user = mysql
basedir = /app/mysql
datadir = /app/mysql/data
port=3306
server-id = 1                             #要與從庫區別出來
log-bin = mysql-bin                  #必須啟用binlog日誌功能,主從基於日誌同步
binlog_format = mixed             #binlog日誌格式
expire_logs_days = 7               
#slave_skip_errors=1028

三、在主庫上授權從庫用戶進行復制

mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> grant replication slave on *.* to ‘mysync‘@‘10.3.150.199‘ identified by ‘123456‘;
Query OK, 0 rows affected, 1 warning (0.04 sec)

Mysql 之 主從復制