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

溫馨提示×

溫馨提示×

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

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

MySQL5.7 - 基于GTID復制模式搭建主從復制

發布時間:2020-04-17 10:09:20 來源:網絡 閱讀:300 作者:insist_way 欄目:MySQL數據庫

環境:

MySQL5.7.24版本
CentOS release 6.5


注意:

MySQL5.7版本Slave可以不開啟binlog了,可以節省這部分的磁盤I/O消耗,而MySQL5.6版本必須開啟binlog,因為GTID信息需要在binlog中存儲(log_slave_updates),只有開啟binlog才能使用GTID的功能。MySQL5.7版本通過GTID系統表來記錄GITD信息(mysql.gtid_executed),每個事務提交時,將GTID信息插入到表中


Master配置:
[root@master ~]# cat /etc/my.cnf
server_id=1
gtid_mode=on
enforce_gtid_consistency=on
log_bin=/var/lib/mysql/binlog
binlog_format=row
character_set_server=utf8

[root@master ~]# service mysqld restart


Slave配置:

[root@slave ~]# cat /etc/my.cnf
server_id=2
gtid_mode=on
enforce_gtid_consistency=on
binlog_format=row
relay_log=/var/lib/mysql/relaylog
replicate_do_db=edusoho_e
character_set_server=utf8

[root@slave ~]# service mysqld restart

Master:
查看當前binlog情況:
mysql> show master status;
+------------------+----------+--------------+------------------+-------------------+
| File???????????? | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+-------------------+
| mysql-bin.000001 |????? 154 |????????????? |????????????????? |?????????????????? |
+------------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)

授權復制連接用戶:
mysql> grant replication slave on *.*to repliter@'192.168.32.2' identified by PASSWORD '*6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9';
Query OK, 0 rows affected, 2 warnings (0.00 sec)

mysql> show warnings;
+---------+------+---------------------------------------------------------------------------------------------------------------------------------------+
| Level?? | Code | Message?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? |
+---------+------+---------------------------------------------------------------------------------------------------------------------------------------+
| Warning | 1287 | 'IDENTIFIED BY PASSWORD' is deprecated and will be removed in a future release. Please use IDENTIFIED WITH <plugin> AS <hash> instead |
| Warning | 1287 | Using GRANT for creating new user is deprecated and will be removed in future release. Create new user with CREATE USER statement.??? |
+---------+------+---------------------------------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)

創建statistic庫:
mysql> create database statistic;
Query OK, 1 row affected (0.01 sec)

創建statistic.t1表:
CREATE TABLE `statistic`.`t1` (
`id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`xname` VARCHAR(20) NOT NULL DEFAULT '',
`address` CHAR(20) NOT NULL DEFAULT '',
`sex` TINYINT(1) NOT NULL DEFAULT '1',
`hobby` VARCHAR(30) NOT NULL DEFAULT '',
`age` TINYINT(2) DEFAULT '18',
PRIMARY KEY (`id`),
KEY `idx_name` (`xname`)
) ENGINE=INNODB DEFAULT CHARSET=utf8;

創建edusoho_e庫:
mysql> create database edusoho_e;
Query OK, 1 row affected (0.01 sec)

創建edusoho_e.t1表:
CREATE TABLE `edusoho_e`.`t1` (
`id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`xname` VARCHAR(20) NOT NULL DEFAULT '',
`address` CHAR(20) NOT NULL DEFAULT '',
`sex` TINYINT(1) NOT NULL DEFAULT '1',
`hobby` VARCHAR(30) NOT NULL DEFAULT '',
`age` TINYINT(2) DEFAULT '18',
PRIMARY KEY (`id`),
KEY `idx_name` (`xname`)
) ENGINE=INNODB DEFAULT CHARSET=utf8;

INSERT INTO `statistic`.`t1` (`xname`, `address`, `hobby`) VALUES ('statistic', '北京', '游戲');
INSERT INTO `edusoho_e`.`t1` (`xname`, `address`, `hobby`) VALUES ('edusoho_e', '上海', '開發');

查看當前binlog情況:
mysql> show master status;
+------------------+----------+--------------+------------------+------------------------------------------+
| File???????????? | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set??????????????????????? |
+------------------+----------+--------------+------------------+------------------------------------------+
| mysql-bin.000001 |???? 2443 |????????????? |????????????????? | c13c1b45-2741-11e9-abb0-000c29b85ea6:1-7 |
+------------------+----------+--------------+------------------+------------------------------------------+
1 row in set (0.00 sec)

準備復制數據:
[root@master ~]# mysqldump -uroot -p -B edusoho_e > `date +%F`.sql (警告什么信息,自行查閱幫助的)
Enter password:
Warning: A partial dump from a server that has GTIDs will by default include the GTIDs of all transactions, even those that changed suppressed parts of the database. If you don't want to restore GTIDs, pass --set-gtid-purged=OFF. To make a complete dump, pass --all-databases --triggers --routines --even

Slave導入復制數據:
[root@slave ~]# mysql -uroot -p < 2019-05-29.sql
Enter password:

Slave開始數據復制:
mysql> change master to master_auto_position=1,master_host='192.168.32.3',master_port=3306;
Query OK, 0 rows affected (0.04 sec)

mysql> start slave user='repliter' password='123456';?? (會滾動 relay log 日志文件)
Query OK, 0 rows affected, 1 warning (0.01 sec)

mysql> show slave status\G;
*************************** 1. row ***************************
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Retrieved_Gtid_Set:
Executed_Gtid_Set: c13c1b45-2741-11e9-abb0-000c29b85ea6:1-7
Auto_Position: 1


至此,MySQL5.7 基于GTID模式的主從復制搭建完畢。如果,你是MySQL5.6的環境,那么請參考 MySQL5.6 基于GTID模式的主從復制搭建,當然了,還有一些常見復制問題的介紹,需要對你有所幫助。


向AI問一下細節

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

AI

赞皇县| 潜山县| 凤城市| 临泉县| 阿尔山市| 浪卡子县| 漯河市| 玉树县| 长岭县| 沙河市| 赣州市| 攀枝花市| 乌兰浩特市| 石渠县| 嘉定区| 内乡县| 五指山市| 五峰| 金平| 永善县| 晋宁县| 陇南市| 石屏县| 临高县| 蓬溪县| 翼城县| 宝鸡市| 新乡县| 财经| 宁南县| 海宁市| 昌江| 射洪县| 阜城县| 湘潭县| 河津市| 大方县| 曲沃县| 浦城县| 湄潭县| 河间市|