Help needed raspberry pi emoncms stopped working. Settings.php error

My emoncms setup has been working great for some time now but five days ago the data it was storing from my emontx was totally unrealistic more like noise than data. As I was at the other end of the country I got my GF to powercycle the Emontx, Pi and router as this usually sorts out any crashes or hangs. This time it didn't work and since then I can't access emoncms I just get this error message:  

Can't connect to database, please verify credentials/configuration in settings.php

I have accessed the pi with putty and winscp and found a setting.php file in  var/www/emoncms but it looks normal ie all the usernames and passwords etc are still at there default settings.

Can anybody point me in the right direction to sort this out.

Mattia Rossi's picture

Re: Help needed raspberry pi emoncms stopped working. Settings.php error

Is the mysql instance running ? You should be able to log in from the console using the same user/password as the ones in settings.php
If you sren't able to log in restart the mysql service and check the error log

ngbod's picture

Re: Help needed raspberry pi emoncms stopped working. Settings.php error

I can't get the mysql service to start.    > service msqld restart   (and start) gives an error and then shuts down. I haven't managed to find the error log yet, where is it located?

I've loaded a backup image from July on a spare card and it is working but I've lost two months of changes and data so I'd like to get the original working again If possible.

I'll have another try tonight when I get in from work.

 

Mattia Rossi's picture

Re: Help needed raspberry pi emoncms stopped working. Settings.php error

If you haven't changed the defaults errors should go to /var/log/syslog ...

 

ngbod's picture

Re: Help needed raspberry pi emoncms stopped working. Settings.php error

The error I get when trying to start mysql is ....pi@raspberrypi /var/log $ sudo service mysql start

[FAIL] /etc/init.d/mysql: ERROR: The partition with /var/lib/mysql is too full! ... failed!    which is different to the error I was getting this morning IIRC.

The error in syslog is......

Sep 23 14:07:53 raspberrypi mysqld: 130923 14:07:53  InnoDB: Error: Write to file ./ibdata1 failed at offset 0 1721761792.
Sep 23 14:07:53 raspberrypi mysqld: InnoDB: 1048576 bytes should have been written, only 634880 were written.
Sep 23 14:07:53 raspberrypi mysqld: InnoDB: Operating system error number 0.
Sep 23 14:07:53 raspberrypi mysqld: InnoDB: Check that your OS and file system support files of this size.
Sep 23 14:07:53 raspberrypi mysqld: InnoDB: Check also that the disk is not full or a disk quota exceeded.
Sep 23 14:07:53 raspberrypi mysqld: InnoDB: Error number 0 means 'Success'.
Sep 23 14:07:53 raspberrypi mysqld: InnoDB: Some operating system error numbers are described at
Sep 23 14:07:53 raspberrypi mysqld: InnoDB: http://dev.mysql.com/doc/refman/5.5/en/operating-system-error-codes.html
Sep 23 14:07:53 raspberrypi mysqld: 130923 14:07:53 [ERROR] /usr/sbin/mysqld: The table 'feed_23' is full

I have the 4gb image on an 8gb micro SD card which has been in use for about 4 months.  Does this mean the card has failed?  would expanding the image to fit the card help?

TrystanLea's picture

Re: Help needed raspberry pi emoncms stopped working. Settings.php error

If you run df -h in terminal what does it show?

If the SD card is full it should say 100%. how many feeds do you have? filling a 4gb card in a few months would be good going.

 

Mattia Rossi's picture

Re: Help needed raspberry pi emoncms stopped working. Settings.php error

Either the sd is full (doubt it unless you use the pi for other tasks) or the filesystem has errors and mounts in read only mode ....

You can check how much free space you have with df -h and you can try and see whether the file system is read only by trying to create  a file with touch myfile ....

Mattia Rossi's picture

Re: Help needed raspberry pi emoncms stopped working. Settings.php error

Nm ... Trystan was faster than me ...

ngbod's picture

Re: Help needed raspberry pi emoncms stopped working. Settings.php error

it looks like the card is full, but what's filled it? or is it corrupted?

I don't use the pi for anything other than a standard emoncms service, modified slightly for pvoutput posting. 

I have about 30 feeds.

df -h gives......

Last login: Mon Sep 30 18:40:16 2013 from lifebook.lan
pi@raspberrypi ~ $ df -h
Filesystem      Size  Used Avail Use% Mounted on
rootfs          3.6G  3.6G     0 100% /
/dev/root       3.6G  3.6G     0 100% /
devtmpfs        235M     0  235M   0% /dev
tmpfs            49M  244K   49M   1% /run
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs            98M     0   98M   0% /run/shm
/dev/mmcblk0p1   56M   19M   38M  34% /boot
tmpfs            98M     0   98M   0% /tmp
pi@raspberrypi ~ $

TrystanLea's picture

Re: Help needed raspberry pi emoncms stopped working. Settings.php error

I'd first backup your existing feed data, either by copying the mysql data directly from the mysql directory /var/lib/mysql you will need to use sudo or an alternative approach is to create an image from your SD card, that way you have a saved exact copy of your SD card you can write back to a second SD card later if you want.

If you cant start mysql then you wont be able to use the backup procedure i blogged about yesterday but if you can save some space by removing anything say in your home directory you may be able to use this approach:
http://openenergymonitor.blogspot.com/2013/09/backing-up-your-raspberrypi-emoncms-or.html

Once backed up I would go for the expand partition to fill SD Card option see if that works.

Mattia Rossi's picture

Re: Help needed raspberry pi emoncms stopped working. Settings.php error

.. or you could use du to find where you are filling the sd card (and check that indeed mysql is using all the space)

root@raspberrypi:/var/lib/mysql# cd /

root@raspberrypi:/# du --max-depth=1 -h
4.0K ./selinux
8.0K ./srv
19M ./boot
0 ./dev
6.2M ./sbin
50M ./lib
12K ./tmp
4.0K ./media
5.2M ./bin
11M ./root
0 ./proc
5.9M ./etc
29G ./var
0 ./sys
15M ./home
240K ./run
1.5G ./usr
4.0K ./mnt
195M ./opt
16K ./lost+found
31G .

I know that of the 29G in /var all the space used is in /var/lib/mysql so if I 

root@raspberrypi:/# cd /var/lib/mysql

root@raspberrypi:/var/lib/mysql# du --max-depth=1 -h

0 ./test
27G ./AB
256M ./swpi
602M ./Backup
0 ./wview
4.0K ./wugraphs
48M ./tmo
197M ./old
212K ./performance_schema
436M ./emoncms
1.1M ./mysql
784K ./weather
116K ./emoncmsv6
29G .

please disregard my numbers, what counts is that with this command you can find out which directory is filling your sd card. If the dir in question is /var/lib/mysql/emoncms then your emoncms install has filled the disk .. the reason I doubt it is that I have had  about 70 feeds running for three months (only 30 of them writing every 5s, the others about once in 5 mins) and have an occupation of ~450M ...

 

Anyway, try and find out what has filled the disk, and if it is indeed the mysql data then you'll have to follow Trystan's advice

ngbod's picture

Re: Help needed raspberry pi emoncms stopped working. Settings.php error

Looking at the card on my android tablet I can see the following

/var/lib/mysql/mysql = 870KB

But /var/lib/mysql/Ibdata1 = 1.6GB

I'll take an image of the whole card first but then if i delete ibdata1 how I do I stop the recreated version growing again?

Mattia Rossi's picture

Re: Help needed raspberry pi emoncms stopped working. Settings.php error

DON'T

Sorry for the shouting but if you do that chances are you'll never be able to restart the db....
Read this:
http://www.mysqlperformanceblog.com/2013/08/20/why-is-the-ibdata1-file-c...
Then check with the described procedure what's in it and see what options you have ...

ngbod's picture

Re: Help needed raspberry pi emoncms stopped working. Settings.php error

Thanks, I've been googling and reading about using mysqldump etc to backup? and rebuild the db without the large ibdata1 file. This looks a lot more complicated than I expected. 

TrystanLea's picture

Re: Help needed raspberry pi emoncms stopped working. Settings.php error

thats interesting, maybe switching to myisam could be a good solution:

http://openenergymonitor.blogspot.co.uk/2013/06/load-stats-for-myisam-vs...

http://openenergymonitor.org/emon/node/2608

Could there also be any logs eating disk space under /var/log/mysql or /var/log/apache2?

ngbod's picture

Re: Help needed raspberry pi emoncms stopped working. Settings.php error

I think I've messed the card up now by deleting unused files with card in android tablet in an attempt to free up some space. When I got back home and tried it in the Rpi again I can't ssh in anymore as the Rpi is now refusing my key. 

I think I'll call it a day trying to resurrect this version and switch the card over to the read only version developed by Martin Harizanov as described in the new emoncms docs page here    http://emoncms.org/site/docs/raspberrypigateway.

I wonder if the RO version can be configured to send data to two servers eg emoncms.org and pvoutput.org?

Thanks for the help guys.

TrystanLea's picture

Re: Help needed raspberry pi emoncms stopped working. Settings.php error

Yes oem_gateway has this concept of listeners and buffers (outputs) and if I understand correctly you can configure the buffers to point to multiple locations. You may have to create a buffer type though that works with PV output. Im not familiar enough yet with the oem_gateway code to know how though.

ngbod's picture

Re: Help needed raspberry pi emoncms stopped working. Settings.php error

I gave the oemgateway image from the emoncms site a go and it worked straight away, however setting it up was not as straightforward as the old system. I struggled to get ssh to work and WiFi dongle drivers are not included anymore. I've given up for now and gone back to my july backup image which is working well so far.

To stop the disk filling up again I've tried switching mysql to myisam on my restored system using the script on Trystan's blog post but I can't get it to work. I get "unexpected  token" errors and syntax errors.  I saved the script as a .php file and ran chmod 755 on it and then tried running the file from various locations but so far can't figure out what I'm doing wrong. 

Jérôme's picture

Re: Help needed raspberry pi emoncms stopped working. Settings.php error

Yes, Trystan, the point of OEM Gateway's design was to allow sending to different servers. Currently, only emoncms is implemented. One limitation to this logic is the fact that OEM's design paradigm is to make as most processing in emoncms as possible, while other platforms expect ready-to-display data.

Now, with the Pi's calculation power, we could do some processing before sending. But that kinda breaks OEM's logic. And this is another story.

Anyway, if the data can be displayed as is, then it is just a matter of sending it to pvoutput.org as well. To do so, you need to create a new kind of output (called buffer). This needs a bit of python programming, not complicated. Just copy emoncms's buffer and adapt all the URL to the API.

I could help for that, please ask if needed. If I don't answer here, please open a feature request on OEM Gateway's GitHub project, to keep track of this.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.