NAS box general notes (to eventually go in user guide or installation spec)
NAS box general notes (to eventually go in user guide or installation spec)
Starting a thread for general notes about the NAS box. Some of these should probably eventually go in the user guide or installation spec. I'll make a separate post for each note to make it easier to refer to them.
Last edited by hamishmb on 02/10/2020, 16:04, edited 1 time in total.
Hamish
Re: NAS box general notes
Updating online NAS box setup files
NB: I used xz compression for all of these by compressing on the host. This saves space on the webserver, but please not you need to decompress to .tar or .tar.gz before transferring to the NAS box - it does not have xz installed (and it would run horribly slowly if it did).
You can optionally gzip these with "gzip <file>" on the NAS box before transferring to make the transfer quicker.
nas-other-root-files.tar.xz
This file is available at https://wmtprojectsforum.altervista.org ... les.tar.xz
This archive contains the SSH config, and the custom scripts, and is created by running the following after SSHing in to the NAS box:
This can then be transferred off the NAS box by linking to the HTTP server's directory temporarily:
Then download with a browser, and remove the link:
Decompress back to .tar before redeploying - the NAS box doesn't have "xz" installed.
nas-other-root-files.tar.xz
This file is available at https://wmtprojectsforum.altervista.org ... gui.tar.xz
This archive contains the engineer GUI and is created by running the following after SSHing in to the NAS box:
This can then be transferred off the NAS box by linking to the HTTP server's directory temporarily as above.
rivercontrolsystem.tar.xz
This file is available at https://wmtprojectsforum.altervista.org ... tem.tar.xz
This archive contains the river system software and is created by running the following after SSHing in to the NAS box:
This can then be transferred off the NAS box by linking to the HTTP server's directory temporarily as above.
NB: I used xz compression for all of these by compressing on the host. This saves space on the webserver, but please not you need to decompress to .tar or .tar.gz before transferring to the NAS box - it does not have xz installed (and it would run horribly slowly if it did).
You can optionally gzip these with "gzip <file>" on the NAS box before transferring to make the transfer quicker.
nas-other-root-files.tar.xz
This file is available at https://wmtprojectsforum.altervista.org ... les.tar.xz
This archive contains the SSH config, and the custom scripts, and is created by running the following after SSHing in to the NAS box:
Code: Select all
cd /mnt/HD/HD_a2
tar -cv Nas_Prog/ LICENSE reboot.sh scripts/ setup.sh shutdown.sh .git .gitconfig .ssh -f nas-other-root-files.tar
Code: Select all
ln -s /mnt/HD/HD_a2/nas-other-root-files.tar /var/www/nas-other-root-files.tar
Code: Select all
rm /var/www/nas-other-root-files.tar
nas-other-root-files.tar.xz
This file is available at https://wmtprojectsforum.altervista.org ... gui.tar.xz
This archive contains the engineer GUI and is created by running the following after SSHing in to the NAS box:
Code: Select all
cd /mnt/HD/HD_a2
tar -cv engineer-gui/ -f engineer-gui.tar
rivercontrolsystem.tar.xz
This file is available at https://wmtprojectsforum.altervista.org ... tem.tar.xz
This archive contains the river system software and is created by running the following after SSHing in to the NAS box:
Code: Select all
cd /mnt/HD/HD_a2
tar -cv rivercontrolsystem/ -f rivercontrolsystem.tar
Hamish
Re: NAS box general notes
Using the NAS box "Scan Disk" option
Don't do this unless it's absolutely necessary!
Hopefully, with the new mount options and drives that passed the extended test, all should be fine now. However, if you do find yourself needing to run a disk check on the NAS box, please note this means the RAID array has to be unmounted, which will interfere with normal operation - everything will have to be put on manual control while this is done.
Instructions for doing this safely:
Don't do this unless it's absolutely necessary!
Hopefully, with the new mount options and drives that passed the extended test, all should be fine now. However, if you do find yourself needing to run a disk check on the NAS box, please note this means the RAID array has to be unmounted, which will interfere with normal operation - everything will have to be put on manual control while this is done.
Instructions for doing this safely:
- Read through all of these instructions and make sure you understand them before you begin.
- Have somebody on site to monitor and manage the river system.
- Switch everything to manual control and make sure the system isn't in the middle of something eg pumping water to the butts.
- Re-enable the built-in SSH server on port 2222 (instructions in installation spec at https://wmtprojectsforum.altervista.org ... stallation).
- Log in using this SSH server heeding the notes in the first two posts of the thread at viewtopic.php?f=36&t=152
- Run the following commands on the NAS box:
Code: Select all
cd /mnt/HD/HD_a2
swapoff ./swapfile.img
killall python3 (this will stop the river system software!)
- Now run "Scan Disk". You will now be logged out of your SSH session and the MySQL server will stop.
- The NAS box will now be in an unusable state until it is rebooted so run this on the NAS box:
Code: Select all
./reboot.sh
- The NAS box will take around 2 minutes to reboot.
- Once it has, disable the internal SSH server again (instructions in installation spec as above)
- All done
Hamish
Re: NAS box general notes
Copying note from general software updates thread.
EDIT: scp now works the same way it does for the pis - these instructions are no longer needed. I'll keep them here anyway in case in future someone needs them.
NOTE: To scp data to the NAS box, instead of doing this:
We have to do this:
This is due to a slight misconfiguration of the updated SSH software I build for the NAS box, but I'm not exactly sure what the issue is. This has not been a problem so far. I'm happy to fix this if needed once deployed (and don't wish to delay -- workaround below), but to transfer files (eg logs) from the NAS box, we should be able to do this:
And then download the file using (on your machine):
Alternatively, you could use a web browser.
Then remove the link:
NB: Transferring files to the NAS box from the local machine is currently a PITA because the VPN doesn't allow connections from eg the NAS box to your machine. I'll work on a solution for this soon.
EDIT: scp now works the same way it does for the pis - these instructions are no longer needed. I'll keep them here anyway in case in future someone needs them.
NOTE: To scp data to the NAS box, instead of doing this:
Code: Select all
scp /path/to/file/on/local/machine [email protected]:/path/on/NAS/box
Code: Select all
ssh [email protected] (log in to NAS box)
scp localusername@localip:/path/to/file /path/on/NAS/box
Code: Select all
ssh [email protected] (log in to NAS box)
ln -s /path/to/file /var/www
Code: Select all
wget http://192.168.0.25/filename
Then remove the link:
Code: Select all
rm /var/www/file
Last edited by hamishmb on 20/05/2022, 16:07, edited 1 time in total.
Hamish
Re: NAS box general notes
Note: D-Link's built-in SSH server won't let you log in with a long password. If needed, it can be changed to something short eg "turtle" temporarily. Yet another bug in the long list of bugs. Sigh.
Hamish
Re: NAS box general notes
Backing up and restoring the database from USB
We decided to use a USB stick as a rudimentary backup system for the NAS box, as it is simple, inexpensive, and fast to set up. More bespoke solutions may arise in the future.
Currently we can take manual backups by running:
The creates a new file called backup-<date>.tar.gz on the USB sick (/mnt/USB/USB1)
And restore with:
This leaves some uncompressed backup files under /mnt/HD/HD_a2 for the moment so we can see what backup was restored later on. These can safely be deleted with:
NOTE: The database users and structure need to be present for the restore to work. See https://gitlab.com/wmtprojectsteam/nas- ... ree/master
We decided to use a USB stick as a rudimentary backup system for the NAS box, as it is simple, inexpensive, and fast to set up. More bespoke solutions may arise in the future.
Currently we can take manual backups by running:
Code: Select all
cd /mnt/HD/HD_a2/backupandrestore
python3 ./backup.py
And restore with:
Code: Select all
cd /mnt/HD/HD_a2/backupandrestore
python3 ./restore.py <path/to/file>
Code: Select all
rm -rv /mnt/HD/HD_a2/backup-<date>/
Last edited by hamishmb on 02/10/2020, 16:41, edited 1 time in total.
Hamish
Re: NAS box general notes (to eventually go in user guide or installation spec)
Backing up and restoring the database from phpMyAdmin
At noted here viewtopic.php?p=4341#p4341, this does not work - use the USB backups with the backup and restore scripts instead.
At noted here viewtopic.php?p=4341#p4341, this does not work - use the USB backups with the backup and restore scripts instead.
Hamish
Re: NAS box general notes (to eventually go in user guide or installation spec)
Seeing as it's getting hard to find, the MySQL 5.1 Reference Guide is now available on the forum webserver at https://wmtprojectsforum.altervista.org ... erence.pdf
Hamish
Re: NAS box general notes (to eventually go in user guide or installation spec)
Database set up
Beyond the rest of the database configuration, it has come to light that another change needs to be made to avoid running out of space, due to the way that D-Link set up the storage on the NAS box when you format the drives.
The following commands need to be run to move the database on to the larger partition on the HDDs. Please note that this process will stop the database server, so cannot be done while the river system is under automated control.
First copy the database to the new location:
Then delete the old files and create a symbolic link:
Confirm the symbolic link is correct:
Should give the following output:
Then, reboot the NAS box to complete the process:
Beyond the rest of the database configuration, it has come to light that another change needs to be made to avoid running out of space, due to the way that D-Link set up the storage on the NAS box when you format the drives.
The following commands need to be run to move the database on to the larger partition on the HDDs. Please note that this process will stop the database server, so cannot be done while the river system is under automated control.
First copy the database to the new location:
Code: Select all
killall mysqld
killall mysqld_safe
cd /mnt/HD/HD_a2
mkdir HD_a4
cd HD_a4/
cp -ra /mnt/HD_a4/.@database@/ ./
Code: Select all
cd /mnt/HD_a4
rm -rf .@database@/
ln -s /mnt/HD/HD_a2/HD_a4/.@database@/ ./
Code: Select all
ls -l
Code: Select all
drwx------ 2 root root 16384 Jun 17 2019 lost+found
Code: Select all
cd
./reboot.sh
Hamish
Re: NAS box general notes (to eventually go in user guide or installation spec)
Just came across this thread looking for something else. Is this stuff in the installation spec now?
Hamish