Can't insert event

Support and queries relating to all previous versions of ZoneMinder
Locked
hemabe
Posts: 3
Joined: Wed Sep 29, 2004 1:39 pm

Can't insert event

Post by hemabe »

Hello,

after a reboot, zoneminder did not record any events anymore. I found this in the logs:

Sep 29 15:37:39 linux zma-m2[6720]: INF [Tresen: 029 - Gone into alarm state]
Sep 29 15:37:39 linux zma-m2[6720]: ERR [Can't insert event: Duplicate entry '38689' for key 1]

I had this problem once before. At that time I deleted all entries in the database, but there must be a different solution for this problem, or?

Greetings from germany,

Hermi
marmoset
Posts: 4
Joined: Fri Sep 03, 2004 5:56 am

Post by marmoset »

It sounds like your database has crashed and now has inconsistancies in it.

You'll want to shut down your database cleanly with either:

mysqladmin -u root -p shutdown

or if you can't do that for some reason:

kill -TERM <pid of mysql>

and if that still doesn't cause it to stop (corruption sometimes causes mysql to not die as it should), then:

kill -KILL <pid of mysql>

Now that mysql isn't running, you need to go into the directory that contains your database files, perhaps /var/lib/mysql/zm or wherever your distribution keeps them, and do:

myisamchk -o *.MYI

this will rebuild the indexes to all your tables.

Now start up mysqld again (/etc/init.d/mysql start or whatever) and you should be good to go.
User avatar
zoneminder
Site Admin
Posts: 5215
Joined: Wed Jul 09, 2003 2:07 pm
Location: Bristol, UK
Contact:

Post by zoneminder »

mysqlcheck should work as well and you don't need to shut down the database to use it.

Phil,
hemabe
Posts: 3
Joined: Wed Sep 29, 2004 1:39 pm

Post by hemabe »

marmoset wrote: myisamchk -o *.MYI

this will rebuild the indexes to all your tables.
Thank you for your hint. I had to do a "myisamck -r *.MYI" to get rid of the problem.

greetings,

Hermi
User avatar
fernando
Posts: 240
Joined: Thu Jul 10, 2003 6:00 pm

Post by fernando »

mysqlcheck is similar in function to myisamchk, but works differently. The main operational difference is that mysqlcheck must be used when the mysqld server is running, whereas myisamchk should be used when it is not. The benefit of using mysqlcheck is that you do not have to stop the server to check or repair your tables.


from http://dev.mysql.com/doc/mysql/en/Using_mysqlcheck.html
Fernando
Locked