In a previous post (First 2 things to do if you want to secure your Raspberry Pi on the internet) I showed simple things to do if you want to put your raspberry on the internet, now I want to show two simple things to do if you want to use your Raspberry Pi as your production server, because in this case the reliability of your Raspberry Pi must be as higher as possible.

To make your system more reliable you must act at least on two components: the SD CARD, and the Power  supply.

SD CARD

An SD Card has a limited lifetime, it depends on various factors. Normally the lifetime declared by manufacturers is very long, but I have experienced that sometimes the lifetime is very short. °v°.

So taking care of the healt status of the SD CARDs could lead to a high reliability.

One of the factors that could broke your SD Card is the write cycles. As said, this number is normally very high but you cannot say if your SD CARD will have a behaviur in the average or under the average. So you can think to reduce the number of writes.

 

 

reliable

The /var/log directory contains the log files for your services and these files are often updated, if you have a lot of services running you have a lot of writes on your SD CARD, if the log files are not essential in your system you can move them on a RAM disk and then you can backup them when you want.

In my production system I'm using a tool that does the job: Ramlog.

"Ramlog act as a system daemon. On startup it creates ramdisk, it copies files from /var/log into ramdisk and mounts ramdisk as /var/log. All logs after that will be updated on ramdisk. Logs on harddrive are kept in folder /var/log.hdd which is updated when ramlog is restarted or stopped. On shutdown it saves log files back to harddisk so logs are consistent. Ramlog 2.x is using tmpfs by default, ramfs and kernel ramdisk are suppored as well. Program rsync is used for log synchronization."

To install Ramlog on your Raspbian system run the following instructions:

# sudo apt-get install lsof

# wget http://www.tremende.com/ramlog/download/ramlog-2.0.0.tar.gz

# cp -a ramlog /etc/init.d/ramlog

# cp -a ramlog.8.gz /usr/share/man/man8/ramlog.8.gz

# cp -a ramlog.cron /etc/cron.daily    #or to other dir based on your need

# cp -a ramlog.logrotate /etc/logrotate.d/ramlog

# cp -a ramlog.conf /etc/default/ramlog

 

With your favourite editor, edit the file /etc/default/ramlog and set the value for your RAM filesystem, for example TMPFS_RAMFS_SIZE=20 means you want to use 20 mega bytes of RAM.

You can retrieve the actual size for /var/log directory issueing the following command:

# ramlog getlogsize

 

Last, reboot your system

# sudo reboot -n

 

 

 

Backup Battery

This seems obvious, but often, somebody forgets to add a backup for the power supply…. me too.

If the input power source fails, your system could have a lot of problems:

  • Your service will be unavailable
  • The filesystems could be corrupted, often they can be fixed sometimes it can be hard to fix them.
  • You can lost unsaved works

To avoid these problem I have added a little UPS with backup batteries to my Raspberry Pi. I disconnected the led for the "input source fail" and I connected a GPIO to that LED, so the Raspberry knows when the power source has failed and how much time it has before doing a clean shutdown.

Gg1