一、 按照以前關機重來以後操做一輪,mysql> show slave status\G; 發現 Error No query specifed! 二、Slave_IO_Running 一直是 connecting ! 難道主服務器關掉了?stop了? 三、確認如下鏈接 mysql -h192.168.0.188 -uslave -p123456 use zjbr168; show tables; 均正常! 四、重複以上操做一次試試,檢查發現開始鏈接的數據庫錯了,應該是鏈接本地mysql mysql -hlocalhost -uslave -p123456 而後,再記錄一次操做 1)、mysql> stop slave; 2)、mysql> change master to master_host='192.168.0.188',master_user='slave',master_password='123456', MASTER_AUTO_POSITION = 1; 3)、mysql> start slave; 4)、mysql> show slave status\G (這個不 分號 ;) Slave_IO_Running Yes Slave_SQL_Runnin Yes 四、開始恢復以前,特地先再主mysql 修改了test20180522幾條數據 name 增長了一條記錄 增長了一個表 test0913 稍後看看有沒有同步完成過來! ** 檢查結果! name 表看到了增長的 2 個記錄!OK! wzh091301 test091301 五、教訓: 下次在發現錯誤,先冷靜一下,別再着急連錯了mysql!
一、再次開機沒查看狀態 Slave_IO_Running Slave_SQL_Runnin 都是 No 二、啓動命令行,並連接mysql 以後,執行如下命令 1)、mysql> stop slave; 2)、mysql> change master to master_host='192.168.0.188',master_user='slave',master_password='123456', MASTER_AUTO_POSITION = 1; 3)、mysql> start slave; 4)、mysql> show slave status\G (這個不 分號 ;) Slave_IO_Running Slave_SQL_Runnin 都是 Yes 了!等等看看結果!
Winoidws Server R2 2008 護衛神套件安裝 一、PHP 7.0.5(FastCGI) 二、MySQL 5.6.14(MyISAM) 三、MyODBC 5.2.6 四、PhpMyAdmin 4.0.6 五、MySQL密碼重置工具 ** Master(主)服務器: 192。168。0。188 ** Slave(從)服務器: 192。168。0。189 ** 我努力學習了 mysql M/S 基於bin log 方式主從複製以後,改用 GTID 方式 本文先不包括 Master(主)服務器 配置複製用戶 slave 以及權限部分 ** 待補充 基於bin log 方式主從複製
我直接使用 "任務管理器" 找到 mysql 服務,選擇"中止服務"和"啓動服務"
mysql -hlocalhost -uroot -p123456
mysql -h192.168.0.188 -uslave -p123456
單獨備份 mysqldump -uroot -p123456 --databases zjbr168 >d:\\test\\wzh0180521.sql 備份所有 mysqldump -uroot -p123456 --all-databases >d:\test\wzh018052101.sql
在 mysql 命令行 單個導入還原 mysql> use zjbr168 source d:\test\wzh0180521.sql; 所有導入還原 source d:\test\wzh018052101.sql;
mysql> stop slave;
change master to master_host='192.168.0.188',master_user='slave',master_password='123456', MASTER_AUTO_POSITION = 1;
mysql> start slave;
mysql> show master status;
mysql> show slave status\G;
mysql> FLUSH TABLES WITH READ LOCK;
CREATE DATABASE `zjbr168`;
USE `zjbr168`;
DROP TABLE IF EXISTS `test1`;
CREATE TABLE `test` ( `test` varchar(255) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; insert 記錄 INSERT INTO `test1` VALUES ('6660521'); ** 主要用於確認是否同步複製,因此,創建一個最簡單的 table,插入一條最簡單的記錄
參考 https://stackoverflow.com/questions/37856155/mysql-upgrade-failed-innodb-tables-doesnt-existphp
原來是 這 5 個表有問題mysql
爲了防止以上鍊接打不開,我抄寫一下(抱歉)sql
Drop table innodb_index_stats Drop table innodb_table_stats Drop table slave_master_info Drop table slave_relay_log_info Drop table slave_worker_info
** 我這裏的位置在 D:\Huweishen.com\PHPWEB\MySQL Server 5.6\data\mysql
CREATE TABLE `innodb_index_stats` ( `database_name` varchar(64) COLLATE utf8_bin NOT NULL, `table_name` varchar(64) COLLATE utf8_bin NOT NULL, `index_name` varchar(64) COLLATE utf8_bin NOT NULL, `last_update` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `stat_name` varchar(64) COLLATE utf8_bin NOT NULL, `stat_value` bigint(20) unsigned NOT NULL, `sample_size` bigint(20) unsigned DEFAULT NULL, `stat_description` varchar(1024) COLLATE utf8_bin NOT NULL, PRIMARY KEY (`database_name`,`table_name`,`index_name`,`stat_name`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin STATS_PERSISTENT=0; CREATE TABLE `innodb_table_stats` ( `database_name` varchar(64) COLLATE utf8_bin NOT NULL, `table_name` varchar(64) COLLATE utf8_bin NOT NULL, `last_update` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `n_rows` bigint(20) unsigned NOT NULL, `clustered_index_size` bigint(20) unsigned NOT NULL, `sum_of_other_index_sizes` bigint(20) unsigned NOT NULL, PRIMARY KEY (`database_name`,`table_name`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin STATS_PERSISTENT=0; CREATE TABLE `slave_master_info` ( `Number_of_lines` int(10) unsigned NOT NULL COMMENT 'Number of lines in the file.', `Master_log_name` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT 'The name of the master binary log currently being read from the master.', `Master_log_pos` bigint(20) unsigned NOT NULL COMMENT 'The master log position of the last read event.', `Host` char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '' COMMENT 'The host name of the master.', `User_name` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The user name used to connect to the master.', `User_password` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The password used to connect to the master.', `Port` int(10) unsigned NOT NULL COMMENT 'The network port used to connect to the master.', `Connect_retry` int(10) unsigned NOT NULL COMMENT 'The period (in seconds) that the slave will wait before trying to reconnect to the master.', `Enabled_ssl` tinyint(1) NOT NULL COMMENT 'Indicates whether the server supports SSL connections.', `Ssl_ca` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The file used for the Certificate Authority (CA) certificate.', `Ssl_capath` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The path to the Certificate Authority (CA) certificates.', `Ssl_cert` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The name of the SSL certificate file.', `Ssl_cipher` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The name of the cipher in use for the SSL connection.', `Ssl_key` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The name of the SSL key file.', `Ssl_verify_server_cert` tinyint(1) NOT NULL COMMENT 'Whether to verify the server certificate.', `Heartbeat` float NOT NULL, `Bind` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'Displays which interface is employed when connecting to the MySQL server', `Ignored_server_ids` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The number of server IDs to be ignored, followed by the actual server IDs', `Uuid` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The master server uuid.', `Retry_count` bigint(20) unsigned NOT NULL COMMENT 'Number of reconnect attempts, to the master, before giving up.', `Ssl_crl` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The file used for the Certificate Revocation List (CRL)', `Ssl_crlpath` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The path used for Certificate Revocation List (CRL) files', `Enabled_auto_position` tinyint(1) NOT NULL COMMENT 'Indicates whether GTIDs will be used to retrieve events from the master.', PRIMARY KEY (`Host`,`Port`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 STATS_PERSISTENT=0 COMMENT='Master Information'; CREATE TABLE `slave_relay_log_info` ( `Number_of_lines` int(10) unsigned NOT NULL COMMENT 'Number of lines in the file or rows in the table. Used to version table definitions.', `Relay_log_name` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT 'The name of the current relay log file.', `Relay_log_pos` bigint(20) unsigned NOT NULL COMMENT 'The relay log position of the last executed event.', `Master_log_name` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT 'The name of the master binary log file from which the events in the relay log file were read.', `Master_log_pos` bigint(20) unsigned NOT NULL COMMENT 'The master log position of the last executed event.', `Sql_delay` int(11) NOT NULL COMMENT 'The number of seconds that the slave must lag behind the master.', `Number_of_workers` int(10) unsigned NOT NULL, `Id` int(10) unsigned NOT NULL COMMENT 'Internal Id that uniquely identifies this record.', PRIMARY KEY (`Id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 STATS_PERSISTENT=0 COMMENT='Relay Log Information'; CREATE TABLE `slave_worker_info` ( `Id` int(10) unsigned NOT NULL, `Relay_log_name` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, `Relay_log_pos` bigint(20) unsigned NOT NULL, `Master_log_name` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, `Master_log_pos` bigint(20) unsigned NOT NULL, `Checkpoint_relay_log_name` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, `Checkpoint_relay_log_pos` bigint(20) unsigned NOT NULL, `Checkpoint_master_log_name` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, `Checkpoint_master_log_pos` bigint(20) unsigned NOT NULL, `Checkpoint_seqno` int(10) unsigned NOT NULL, `Checkpoint_group_size` int(10) unsigned NOT NULL, `Checkpoint_group_bitmap` blob NOT NULL, PRIMARY KEY (`Id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 STATS_PERSISTENT=0 COMMENT='Worker Information';
** 好在我執行 2 ) Delete *.frm and *.ibd 都放到了回收站 ** 直接所有選中 *.frm and *.ibd ,還原,選擇不覆蓋 (剛纔 drop/create 過程當中,又新建了一些 .frm,ibd 文件) ** 再去啓動 mysql ,ok了!
# add by wzh 20180521 for M/S GTID #主庫id server-id=1 #開啓gtid模式 gtid_mode=on #強制gtid enforce_gtid_consistency=on #binlog log_bin=master-binlog log-slave-updates=1 binlog_format=row #relay log skip_slave_start=1
#從庫id server-id=2 #GTID: gtid_mode=on enforce_gtid_consistency=on #binlog log-bin=slave-binlog log-slave-updates=1 binlog_format=row #relay log skip_slave_start=1
** 以前已經存在的同名數據庫。同名table等數據,都會被 drop
mysql -hlocalhost -uroot -p123456
mysql> stop slave;
change master to master_host='192.168.0.188',master_user='slave',master_password='123456', MASTER_AUTO_POSITION = 1;
mysql> start slave;
mysql> show slave status\G; 重點關注如下 3 個 Slave_IO_State: Waiting for master to send event Slave_IO_Running: Yes Slave_SQL_Running: Yes
** 打開 Master(主)服務器 (192.168.0.188) 的 phpAdmin 在 Master(主)服務器,找到 zjbr168 , INSERT INTO `test1` VALUES ('123456'); ** 打開 Slave(從)服務器 (192.168.0.189) 的 phpAdmin 在 Slave(從)服務器 ,找到 zjbr168 ,看看 test1 裏面是否增長了該記錄
** 打開 Master(主)服務器 (192.168.0.188) 的 phpAdmin 1)CREATE DATABASE test22; 2)CREATE TABLE test22(name VARCHAR( 50 )) 3)INSERT INTO `test22` VALUES ('wwzzhh166',222); INSERT INTO `test22` VALUES ('cjq123'); ** 打開 Slave(從)服務器 (192.168.0.189) 的 phpAdmin 在 Slave(從)服務器 ,找到 test22 ,看看 test22 表 裏面是否存在該記錄 wwzzhh166,cjq123
** 打開 Master(主)服務器 (192.168.0.188) 的 phpAdmin delete from test22 where name = 'wwzzhh166'; ** 打開 Slave(從)服務器 (192.168.0.189) 的 phpAdmin 在 Slave(從)服務器 ,找到 test22 ,看看 test22 表 裏面也刪除了該記錄 wwzzhh166
** 打開 Master(主)服務器 (192.168.0.188) 的 phpAdmin ALTER TABLE test22 ADD i INT; INSERT INTO `test22` VALUES ('zxc456',100); ** 打開 Slave(從)服務器 (192.168.0.189) 的 phpAdmin 在 Slave(從)服務器 ,找到 test22 ,看看 test22 表 裏面也多出來一條記錄 ('zxc456',100)
** 打開 Master(主)服務器 (192.168.0.188) 的 phpAdmin 先新建一個表 test22_bak ,做爲 test22 的備份,只要 test22 插入一條數據,觸發器執行插入一樣數據到 test22_bak CREATE TABLE test22_bak( id INT , name VARCHAR(50) ) 建立一個觸發器 DROP TRIGGER IF EXISTS `trigerTest` ; CREATE DEFINER = `root`@`localhost` TRIGGER `trigerTest` AFTER INSERT ON `test22` FOR EACH ROW INSERT INTO test22_bak( name, id ) VALUES ( new.name, new.i ) 在 test22 插入一條記錄 INSERT INTO `test22` VALUES ('wzh123',456); 查看 test22_bak 是否也生成了該條記錄 ** 打開 Slave(從)服務器 (192.168.0.189) 的 phpAdmin 查看是否也建立了觸發器 trigerTest SELECT * FROM information_schema.`TRIGGERS` 查看 test22 和 test22_bak 表中是否也存在剛纔的記錄
phpAdmin 老是提示 "您的session已過時,請再次登陸",很煩人! 找到 D:\Huweishen.com\PHPWEB\php 裏面的 php.ini,打開 找到 session.auto_start = 0 改爲 session.auto_start = 1
stop slave start slave change master to master_host='192.168.0.188',master_user='slave',master_password='dhbm*20140729', MASTER_AUTO_POSITION = 1; 重啓 mysql 仍是不行
189 服務器 [auto] server-uuid=235f721f-1c15-11e7-8f50-00155d5aa189 188 服務器 [auto] server-uuid=235f721f-1c15-11e7-8f50-00155d5aa603
Last_IO_Error: Fatal error: The slave I/O thread stops because m aster and slave have equal MySQL server ids; these ids must be different for rep lication to work (or the --replicate-same-server-id option must be used on slave but this does not always make sense; please check the manual before using it).