一、 按照以前关机重来以后操做一轮,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).