How to change the time after which unused LXD images are deleted?
When downloaded for the first time, LXD images are cached in /var/cache/lxc/download directory.
If they are unused for images.remote_cache_expiry days, they are deleted.
The default value is 10 (days).
We have a typical web application that is deployed behind a load balancer with several web servers behind.
The web servers are nearly identical - running the same OS, code, packages. But they do differ in one way - some have
a quick access to the external asset’s repository. Other web servers do have the access as well but it is much slower.
It looks something like this:
The web application is Moodle. It’s configured to use file system repository
to allow access to the assets server. One of the web servers (web1) is in a co-located network with the fast access to the storage.
Access from web2 and web3 is still possible (and configured but much slower). It would be benefictial if all the requests that trigger an access to the
external file server were routed through web1 server. Practically it means that we want to send all requests to /repository/* scripts to web1.
HAProxy can do exactly what we need:
If a request is to http:///repository/* then route it to web1.
Let’s not compromise high availablility - in case our preferred web1 is down, send the request above to web2 or web3.
Send all the other requests to web1 (no point in making web1 dedicated for the repository-requests only), web2 or web3.
We start HAProxy configuration with the frontend section. Custom acl rule called below “url_file” will match the requests
starting with the path /repository/.
If acl condition is met, we send the request to backend called “file_servers”. Otherwise the request goes to the default
backend called “all_servers”.
The definition of our backend all_servers. Nothing really unusual here - just we send a little less (16 instead of 32)
max conections to the web1 - as this one will be a bit more busy serving additional requests.
In “file_servers” backend we want to use web1 server only, unless it’s down. Only then other web servers will take over - this
is done with a “backup” option of HAProxy configuration:
The configuration works as expected. The requests to http:///repository/repository_ajax.php are handled by web1. But
when web1 is shut down, web2 and web3 are being used.
When mysqldump is created with –databases or –all-databases option, it will add “CREATE TABLE” and “USE” statements.
If you need to restore the dump into different database (different name) you need to remove those statements. For small files it’s not a problem - just edit the dump with your favourite text editor.
However huge MySQL dumps (e.g. gigabytes big) may be a challenge. Editing with vim means loading the wohle file into the memory - not a good idea.
Filter dump file with grep to ignore CREATE and USE lines on the fly, while restoring:
Edit the file by overwriting CREATE and USE lines with spaces (so file size will not change).
In hexedit use TAB to switch to ASCII editing, F2 to save, F10 to exit.
Sometimes we want to find out what has changed in the database when some application action was made. One very simple way to do that is to use MySQL data dump with “–skip-opt” option + diff. Of course if your database is very big, it may take a while.
“–skip-opt” option will cause mysqldump to write one line with INSERT for each record - something we will need for diff to work well.
Here we go, the first snapshot:
Then I’ve opened my Moodle 3.1 installation and changed “Due date” in “Default assignment settings” - from 1 week to 2 weeks.
And simple diff:
We can see straight away that:
new record has been inserted into mdl_config_log
the value in mdl_config_plugins has changed from 604800 to 1209600
timestamps in mdl_sessions and mdl_user has been updated
Let’s make another test - let’s see what happens when we enable mobile web services in Moodle (I did that using Moodle UI between first and second snapshot).
“88.100.211″ is the pattern meaning “88.100.211*”
apache’s mod_setenvif must be enabled
“order allow,deny” denies all except “Allow” rules
usual “Allow from ip” rules will not work as the load balancer rewrites the “host” header, all requests are coming from the load balancer’s IP
the load balancer should set the X-Forwarded-For header