Wednesday 13 November 2013

MySQL 5.6 GTID replication "doesn't exists on query" error fix


Master-slave environment encounter error 1858, it's happening when drop an object on master, but the object doesn't on slave , this is the error:
 Last_SQL_Error: Error 'Can't drop database 'dba1'; database doesn't exist' on query. Default database: 'dba1'. Query: 'drop database dba1'
firstly I try to skip this error:
mysql> set global sql_slave_skip_counter=1;
ERROR 1858 (HY000): sql_slave_skip_counter can not be set when the server is running with @@GLOBAL.GTID_MODE = ON. Instead, for each transaction that you want to skip, generate an empty transaction with the same GTID as the transaction

Oops, GTID can't use sql_slave_skip_counter any more, try to generate a null transaction to skip the error, check the binlog file and get the last gtid
mysql> show binary logs;
+----------------+-----------+
| Log_name       | File_size |
+----------------+-----------+
| log-bin.000020 |       196 |
| log-bin.000021 |      1119 |
+----------------+-----------+
2 rows in set (0.00 sec)
mysql> exit
Bye
[dbaroot@dba ~]$ su -
Password:
[root@dba ~]# mysqlbinlog /usr/local/mysql/data/log-bin.000021





Run next on slave MySql
mysql> stop slave;
Query OK, 0 rows affected (0.00 sec)
mysql> set session gtid_next='6433e872-0fad-11e3-a916-00155d01c300:24';
Query OK, 0 rows affected (0.00 sec)
mysql> begin;commit;
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
mysql> set session gtid_next=AUTOMATIC;
Query OK, 0 rows affected (0.00 sec)
mysql> START SLAVE;
Query OK, 0 rows affected (0.00 sec)
Show slave status\G again, that error transaction skip already, master-slave working fine.
-------------------------------the end-------------------------------------------

Wednesday 6 November 2013

Installing EPEL repository on Centos 6

[root@dba local]# wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
--2013-11-07 13:17:22--  http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
Resolving dl.fedoraproject.org... 209.132.181.26, 209.132.181.27, 209.132.181.23, ...
Connecting to dl.fedoraproject.org|209.132.181.26|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 14540 (14K) [application/x-rpm]
Saving to: “epel-release-6-8.noarch.rpmâ€

100%[=======================================================================================================================================>] 14,540      --.-K/s   in 0.002s
2013-11-07 13:17:22 (5.76 MB/s) - “epel-release-6-8.noarch.rpmâ€
[root@dba local]# ls -la
total 297256
drwxr-xr-x. 13 root  root       4096 Nov  7 13:17 .
drwxr-xr-x. 13 root  root       4096 Nov  5 07:53 ..
drwxr-xr-x.  2 root  root       4096 Sep 23  2011 bin
-rw-r--r--.  1 root  root      14540 Nov  5  2012 epel-release-6-8.noarch.rpm
drwxr-xr-x.  2 root  root       4096 Sep 23  2011 etc
drwxr-xr-x.  2 root  root       4096 Sep 23  2011 games
drwxr-xr-x.  2 root  root       4096 Sep 23  2011 include
drwxr-xr-x.  2 root  root       4096 Sep 23  2011 lib
drwxr-xr-x.  2 root  root       4096 Sep 23  2011 lib64
drwxr-xr-x.  2 root  root       4096 Sep 23  2011 libexec
drwxr-xr-x. 13 mysql mysql      4096 Nov  7 11:39 mysql
drwxr-xr-x.  2 root  root       4096 Sep 23  2011 sbin
drwxr-xr-x.  5 root  root       4096 Nov  5 07:53 share
drwxr-xr-x.  2 root  root       4096 Sep 23  2011 src
[root@dba local]# rpm -Uvh epel-release-6-8.noarch.rpm
warning: epel-release-6-8.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY
Preparing...                ########################################### [100%]
   1:epel-release           ########################################### [100%]
[root@dba local]# ls -lah /etc/yum.repos.d/ | grep epel
-rw-r--r--.  1 root root  957 Nov  5  2012 epel.repo
-rw-r--r--.  1 root root 1.1K Nov  5  2012 epel-testing.repo

------------------The end-------------------------------------------------------------------