Today I had to fix a MySQL replication, where the slave process suddenly stopped working.
The show slave status output showed the following error:
Last_SQL_Error: Error 'Table './DB1/table_32' is marked as crashed and last (automatic?) repair failed' on query. Default database: 'DB1'. Query: 'ALTER TABLE table_32 DISABLE KEYS'
On a "normal" MySQL server I'd repair the table with myisamchk, but would this also work on the Slave? Yes it does.
Checking MyISAM file: table_32
Data records: 0 Deleted blocks: 0
myisamchk: warning: Table is marked as crashed and last repair failed
- check file-size
myisamchk: warning: Size of indexfile is: 2189487104 Should be: 1024
- check record delete-chain
- check key delete-chain
- check index reference
- check data record references index: 1
MyISAM-table 'table_32' is usable but should be fixed
So that's pretty much the same result as also seen in the replication status error. The table can be repaired with the -r parameter:
myisamchk -r table_32
- recovering (with sort) MyISAM-table 'table_32'
Data records: 0
- Fixing index 1
- Fixing index 2
- Fixing index 3
- Fixing index 4
Data records: 36841845
Afterwards the slave process was started again:
mysql> START SLAVE;
And it worked again:
mysql> show slave status\G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
No comments yet.
Personal Internet VMware PHP Linux Shell Bluecoat Proxy Windows Hardware Virtualization Nagios MySQL DB Monitoring Mail Android Network Wyse Hacks Tomcat Postgres Apple Mac Backup BSD ZFS Solaris SmartOS Unix Multimedia Perl Database MongoDB CMS OTRS FreeBSD Wordpress LXC Nginx Proxmox DNS Graphics GlusterFS Security Chef HAProxy Icinga Ansible HTML MariaDB Containers Rancher Docker AWS ELK Kibana Logstash Filebeat Varnish PGSQL PostgreSQL ElasticSearch CouchDB Bash Macintosh Container Minio Grafana InfluxDB Databases NFS OSSEC SystemD Java Zoneminder Surveillance Elasticsearch SSL TLS Icingaweb2 Cloud Wireless Kubernetes Ubuntu