We have MySQL 5.1.45 running on a RedHat box. We needed to shut the box down for maintenance last week and had an issue.
We first closed down all connections.
Then we ran the MySQLAdmin/shutdown command.
The database appeared to hang. We waited for 30 minutes before trying Ctrl-C which gave us an error and we had to end up physically cycling the box.
Most of the documentation I can find points to InnoDB problems, but we are using MyISAM.
Is there a better way to shut down MySQL than running the Shutdown command?
Is there a way to force MySQL to shut down when it appears to hang?
service mysql stop ? I'm not so sure though...
Related
When I run mysqld, it has a whole lot of information about what it's doing.
As I understand, this is not the correct way to run a mysql server and you should use service mysql start instead (on older servers at least).
Any searches for mysqld log come up with logs for queries, I want to know what the program is doing as it starts. (I'm trying to set up mariadb 10.1.14 with galera replication)
I want to be able to run service mysql start and then watch what's happening in the background.
I have a problem with my unix server. This started a week ago. One day after a backup (I used to keep 3 backup files) I visited a website on the server but it wouldn't work. I restarted the server and it seemed to be working fine except the mysql service. My attempts to restart it failed. Then I figured that was because the server was full, so I deleted one of the backups, cleaned up some space and the mysql service restarted successfully. Than I figured tables in one of the databases (MYIsam tables) were corrupt. So I repaired them through myisamchk command via ssh and all worked fine. However, the very next day I woke up they were corrupt again (despite mysql was working fine), and this time there was no disk space problem on the server. I repaired them again. The next day the same thing happenned; and this time innodb tables that were part of another database were corrupt as well. I've fixed them too, so now all is working well but I guess the same thing will happen after tonight's backup.
I can't identify the problem and I don't know what logs to look into to understand the problem. Can anyone please help me out? Thanks very much in advance.
No easy answer here. My immediate thought is that the dbase is still busy when the backups commence, possibly corrupting indexes, interferring with caches, etc. Turn on full logging and check for problems when the backup starts happens. Maybe you will find something.
Look for the my.cnf file. On my CentOs it is located in /etc/my.cnf. It will have a config setting for the location of the error log.
My strongest suspect is OOM kill by the kernel or some other issue that results from running the system out of memory. Try this:
Start top on the server and press M to sort by memory so the biggest memory user is at the top.
note the pid of mysqld
manually perform the backup as you observe the value of the RES column in the top output (resident memory size)
once the backup is over see if the pid of mysqld has changed
If the pid has changed (meaning restart took place), and you saw the memory footprint of mysqld take up something comparable to the total amount of system memory, then my suspicion is correct, and we need to lower some settings in my.cnf to make it use less memory, e.g key_buffer_size and innodb_buffer_pool_size.
EDIT - From the log you posted, there are additional issues although it is not clear how they could be contributing to the table corruption. Your server appears to be running with --skip-innodb and your backup script is not able to deal with the absence of InnoDB storage engine printing exception error messages, but nevertheless continuing. It is also attempting to do a repair, which is failing due to the lack of system privileges (error 1 is Operation not permitted). It is possible that encountering those errors triggers some faulty logic in your backup script that leaves the tables corrupted.
At this point I would recommend disabling MySQL backup using the cPanel tool, and using mysqldump or some other solution (e.g. Xtrabackup (https://www.percona.com/doc/percona-xtrabackup/2.3/index.html)) from a cron job instead.
EDIT2 - from the test results. The manual backup does not run the system out of memory and does not crash the server. The jury is still out on the automatic one.
Don't kill mysqld; shut it down gracefully.
Switch from MyISAM to InnoDB; the latter does not suffer from that 'error'.
I am new to dealing with mysql settings and admin type issues. About 4-5 hours ago, I had two power outages within 30 minutes of eachother. As a result, my computer shutdown both times, while in the middle of what I can only assume was a around 20-30 commands on mysql at the time. After the first, mysql was unaffected. But after the second, something happened. MySQL Server cannot remain open for more than a few seconds at a time (before the outage, this was not a problem). I am running MySQL Server 5.1.
I can manually start MySQL server using the admin command line (I am running this on Windows): net start mysql. I get a message saying "The MySQL service was started successfully". Then I run a command or (max) two, and then again everything stops working with a 2013 "Lost connection to MYSQL server during query". Then I have to do restart the MySQL Server all over again.
I have some important data in the database which I cannot reach because the connection times out before I can get it out. Is there a way I can fix this connection problem easily? I know my data is in there, because I have gotten a fair amount of it out.
Any help would be appreciated. Please let me know what other information you might need, and how I can get it. I have been trying to find the error log for mysql, and have not found it yet.
And, yes, if I get through this, and even if I dont, I will make sure to create a system to update the data on a regular basis so these types of failures aren't so catastrophic in the future.
Thanks in advance
I use XAMPP 1.7.3
If I try to open phpMyAdmin it will try to open but eventually I'll have only a blank page, no errors.
If I try to connect with Navicat, the same thing, it will not be able to establish a connection.
And usually this process takes between 30% and 60% of the processor for more than 20 min.
If I stop and then start again the mysql server from XAMPP Control Panel the message is 'Mysql server started'.
But If I go to http://localhost/xampp/ and then 'Status' everything is 'Activated' EXCEPT ' MySQL database', 'SMTP Service', 'FTP Service' which are 'Deactivated'.
I think I crashed the Mysql server after I tried to make a database backup BUT the laptop closed before the backup was finished (the battery was discharged).
How can I repair the connection to the Mysql server?
First, make sure to double check the obvious, most likely these are not the issues since it happened after you closed your laptop, but it doesn't hurt to double check:
Make sure the MySQL service is running...
Also make sure that a firewall is not blocking port 3306...
This guide covers both MyISAM and InnoDB: http://www.softwareprojects.com/resources/programming/t-how-to-fix-mysql-database-myisam-innodb-1634.html
Now, assuming that the tables are MyISAM, you can repair them by following this guide:
http://colekcolek.com/2011/11/02/repair-corrupted-mysql-myisam-table/
Here is a way to do it for InnoDB: http://code.google.com/p/innodb-tools/
have some problems with server which run 5 years stable.
there is a vbulletin 3 forum running on the server.
i get crashed tables and MySQL server has gone away errors. not sure if lost connection can cause crashed tables or there is another reason for it.
there is no my.cnf file, so must be default mysql config, no big load. sometimes if i click a link i immediately get a white page, after reload page works fine - in log there is then a MySQL server has gone away error.
No a lost connection can not do that. But if MySQL crashes then you can get server has gone away, and the crash can corrupt the table.
You need to find out why MySQL is crashing. Worst case scenario is a bad hard disk - I hope you have good backups. If not do it NOW!