-
@ ⚡️2FakTor⚡️
2025-01-21 18:42:14Some guides on MiniBolt / RaMiX have suffered some modifications and need additional instructions to migrate. Here is a summary:
🔘 New installation/update instructions of BTC RPC Explorer to avoid this issue.
🔘 New installation/update method of Node + NPM.
🔘 New installation/update method of PostgreSQL ~ > Attention! If you installed PostgreSQL after 30/09/2024, you do not need to follow these steps related to PostgreSQL.
Update Nodejs + NPM to the latest LTS version (using the new method)
Guide related: Node + NPM
Context: The installation/upgrade section of this guide has suffered some modifications, so to upgrade to the latest LTS released version using the new installation method, you need to follow the next steps:
- Stop the Nodejs + NPM dependencies:
sudo systemctl stop thunderhub btcrpcexplorer
- With user admin, update the packages and upgrade to keep up to date with the OS, press "y" and ENTER when needed or ENTER directly:
sudo apt update && sudo apt full-upgrade
- Change to a temporary directory which is cleared on reboot:
cd /tmp
- Set the environment variable of the version:
VERSION=22
- We will use the new NodeSource Node.js Binary Distributions repository instructions. Download the setup script:
curl -fsSL https://deb.nodesource.com/setup_$VERSION.x -o nodesource_setup.sh
- Run the setup script:
sudo -E bash nodesource_setup.sh
- Update the package manager and update Node.js + NPM to the latest LTS version:
sudo apt update && sudo apt full-upgrade
- Check the correct update of NodeJS:
node -v
Example of expected output:
v22.12.0
- Check the correct installation of NPM:
npm -v
Example of expected output:
10.9.0
- (Optional) Delete the setup script:
rm nodesource_setup.sh
- Start again the Nodejs + NPM dependencies:
sudo systemctl start thunderhub btcrpcexplorer
Update BTC RPC Explorer to the latest version
Guide related: 2.3 Blockchain explorer: BTC RPC Explorer
Context: After this notice, if you deleted the
deprecatedrpc=warnings
flag because it is no longer necessary, it is probably that the "Node Details" section of the BTC RPC Explorer got you this error, this is because after the Bitcoin Core v28 update, just like LND, Electrs and other services, they have needed an update to remain compatible. BTC RPC Explorer was updated on this commit, but an official version that includes this correction has not been officially released yet. To fix this, it is necessary to point to the current source code and not the one related to the last released version (3.4.0).~ > Get instructions to get this by following these steps and fix the issue ~ > HERE < ~
Update PostgreSQL (server instance migration & others)
Guide related: PostgreSQL
Attention!! If you installed PostgreSQL after 30/09/2024, you don't need to do anything, and the next steps don't apply to your case.
Context: With each major version jump of PostgreSQL, the update creates a new and dedicated cluster and folder with the number of each version. Also, the changes made between versions cause the need to migrate the database, that is, from one cluster to another, with a specific tool. This was unknown at the beginning, before creating the MiniBolt PostgreSQL installation guide, so a specific folder for the versions was not created. The installation section was changed past 30/09/2024 to use this new method, but people who followed the PostgreSQL installation before that, need to do things to be in line with the MiniBolt guide.
Following the next steps, we are going to do the necessary migrations, the summary is the next:
1. Migrate the PostgreSQL database to a new location (a dedicated folder for each version).
2. Migrate from PostgreSQL server version 16 to 17.
Verification
If you are not sure whether you installed PostgreSQL before or after the mentioned date (30/09/2024), you can check as follows:
- With user
admin
list the existing clusters:
pg_lsclusters
Expected output if you installed PostgreSQL after 30/09/2024, (you don't need do anything):
Ver Cluster Port Status Owner Data directory Log file 17 main 5432 online postgres /data/postgresdb/17 /var/log/postgresql/postgresql-17-main.log
Expected output if you installed PostgreSQL before 30/09/2024, and performed a full upgrade of the MiniBolt with
sudo apt update && sudo apt full-upgrade
, (you need to follow the next steps):Ver Cluster Port Status Owner Data directory Log file 16 main 5432 online postgres /data/postgresdb /var/log/postgresql/postgresql-16-main.log 17 main 5433 down postgres /var/lib/postgresql/17/main /var/log/postgresql/postgresql-17-main.log
Expected output if you have not performed a full upgrade of the MiniBolt with
sudo apt update && sudo apt full-upgrade
since 26/09/2024 (the PostgreSQL v17 release) (unlikely case) (you need to follow the next steps):Ver Cluster Port Status Owner Data directory Log file 16 main 5432 online postgres /data/postgresdb /var/log/postgresql/postgresql-16-main.log
Migrate the PostgreSQL database to the new location
(Only if you installed PostgreSQL following the MiniBolt guide before 30/09/2024)
- Show the existing clusters to show the current path of the database:
pg_lsclusters
~ > Expected output if you have not performed a full upgrade of the MiniBolt with
sudo apt update && sudo apt full-upgrade
since 26/09/2024 (PostgreSQL v17 release) (unlikely):Ver Cluster Port Status Owner Data directory Log file 16 main 5432 online postgres /data/postgresdb /var/log/postgresql/postgresql-16-main.log
~ > Expected output if you have performed a full upgrade of the MiniBolt with
sudo apt update && sudo apt full-upgrade
since 26/09/2024 (PostgreSQL v17 release) (most likely):Ver Cluster Port Status Owner Data directory Log file 16 main 5432 online postgres /data/postgresdb /var/log/postgresql/postgresql-16-main.log 17 main 5433 down postgres /var/lib/postgresql/17/main /var/log/postgresql/postgresql-17-main.log
~ > Check the current "Data directory" column value of the cluster 16 (/data/postgresdb) for the future, we have changed this to a dedicated folder for each version (
/data/postgresdb/16
,/data/postgresdb/17
,/data/postgresdb/18
, etc.)- Stop the PostgreSQL dependencies and the PostgreSQL version 16 cluster:
sudo systemctl stop thunderhub scbackup btcpay lnd nbxplorer nostrelay cloudflared postgresql@16-main
~ > Ensure all services are successfully stopped by monitoring the logs of each service, especially lnd ~ >
journalctl -fu lnd
.- Monitor the logs of the PostgreSQL version 16 cluster to ensure that it has been stopped gracefully:
journalctl -fu postgresql@16-main
Expected output:
minibolt systemd[1]: Stopping PostgreSQL Cluster 16-main... minibolt systemd[1]: postgresql@16-main.service: Deactivated successfully. minibolt systemd[1]: Stopped PostgreSQL Cluster 16-main.
~ > Press
Ctrl + C
to continue.- Create a temporary directory in a place out of the
/data/postgresdb
to move the data securely:
sudo mkdir /tmp/postgresdb-temp
- Sync the existing data of the current directory
/data/postgresdb
to this temporary directory:
sudo rsync -av /data/postgresdb/ /tmp/postgresdb-temp/
Example of expected output:
``` [...] pg_xact/ pg_xact/0000 [...]
sent 40,397,103 bytes received 18,619 bytes 80,831,444.00 bytes/sec total size is 40,330,914 speedup is 1.00 ```
~ > Wait until the prompt shows up again.
- Change to the user
root
temporary:
sudo su
- Delete the content of the folder that hosted the original database:
sudo rm -rf /data/postgresdb/*
- Come back to the
admin
user:
exit
- Create a new specific and dedicated folder to the version number and to be in line with the new and current storage method of the current guide:
sudo mkdir /data/postgresdb/16
- Assign as the owner to the user
postgres
:
sudo chown postgres:postgres /data/postgresdb/16
- Assign the correct permissions to the folder:
sudo chmod 700 /data/postgresdb/16
- Now you can sync the data from the temporary directory to
/data/postgresdb/16
in a secure way since this directory is not inside the source directory:
sudo rsync -av /tmp/postgresdb-temp/ /data/postgresdb/16/
Example of expected output:
``` [...] pg_xact/ pg_xact/0000 [...]
sent 40,397,103 bytes received 18,619 bytes 80,831,444.00 bytes/sec total size is 40,330,914 speedup is 1.00 ```
~ > Wait until the prompt shows up again.
- Modify the configuration file (
postgresql.conf
) of the PostgreSQL to point to the new directory folder created:
sudo nano +42 /etc/postgresql/16/main/postgresql.conf
- Replace the data directory location to match with the new path:
data_directory = '/data/postgresdb/16'
- Start again the PostgreSQL service instance:
sudo systemctl start postgresql@16-main
- Monitor the logs of the PostgreSQL version 16 cluster to ensure that it works fine:
journalctl -fu postgresql@16-main
Expected output:
minibolt systemd[1]: Starting PostgreSQL Cluster 16-main... minibolt systemd[1]: Started PostgreSQL Cluster 16-main.
~ > Press
Ctrl + C
to continue.- Check the new database location with:
pg_lsclusters
~ > Expected output if you have not performed a full upgrade of the MiniBolt with
sudo apt update && sudo apt full-upgrade
since 26/09/2024 (unlikely):Ver Cluster Port Status Owner Data directory Log file 16 main 5432 online postgres /data/postgresdb/16 /var/log/postgresql/postgresql-16-main.log
~ > Expected output if you have performed a full upgrade of the MiniBolt with
sudo apt update && sudo apt full-upgrade
since 26/09/2024 (most likely):Ver Cluster Port Status Owner Data directory Log file 16 main 5432 online postgres /data/postgresdb/16 /var/log/postgresql/postgresql-16-main.log 17 main 5433 down postgres /var/lib/postgresql/17/main /var/log/postgresql/postgresql-17-main.log
~ > Check the new path on the "Data directory" column value of the cluster version 16, now (/data/postgresdb/16).
- Start again the PostgreSQL dependencies services:
sudo systemctl start lnd nbxplorer btcpay thunderhub scb-backup nostr-relay cloudflared
~ > Check all work fine with the logs of each service, especially lnd ~ >
journalctl -fu lnd
.- Stop again the PostgreSQL dependencies services, to continue working:
sudo systemctl stop thunderhub scbackup btcpay lnd nbxplorer nostrelay cloudflared
~ > Ensure all services are successfully stopped by monitoring the logs of each service, especially lnd ~ >
journalctl -fu lnd
.Migrate from PostgreSQL server version 16 to 17
(Only if you installed PostgreSQL following the MiniBolt guide before 30/09/2024)
Context: If you fully updated your OS after 26/09/2024 (the PostgreSQL v17 launched), using
sudo apt update && sudo apt full-upgrade
, and you installed PostgreSQL before that date following the PostgreSQL MiniBolt guide, it is likely that you now are using the old version (v16) of the PostgreSQL server instance.To confirm that, follow the next steps:
Check the PostgreSQL server version in use
- With the user
admin
, enter the psql (PostgreSQL CLI):
sudo -u postgres psql
- Enter the next command to get the server version:
SELECT version();
Expected output:
``` version
PostgreSQL 16.6 (Ubuntu 16.6-1.pgdg22.04+1) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0, 64-bit (1 row) ```
~ > Check the previous version is "PostgreSQL 16.6" (an outdated version of the PostgreSQL server), the latest version is PostgreSQL 17.2. 🔧✅ We are going to fix this in the next steps.
- Come back to the
admin
user bash prompt:
\q
- List the cluster to show the state of the both PostgreSQL server instances:
pg_lsclusters
~ > Expected output if you have not performed a full upgrade of the MiniBolt with
sudo apt update && sudo apt full-upgrade
since 26/09/2024 (unlikely):Ver Cluster Port Status Owner Data directory Log file 16 main 5432 online postgres /data/postgresdb/16 /var/log/postgresql/postgresql-16-main.log
~ > Expected output if you have performed a full upgrade of the MiniBolt with
sudo apt update && sudo apt full-upgrade
since 26/09/2024 (most likely):Ver Cluster Port Status Owner Data directory Log file 16 main 5432 online postgres /data/postgresdb/16 /var/log/postgresql/postgresql-16-main.log 17 main 5433 down postgres /var/lib/postgresql/17/main /var/log/postgresql/postgresql-17-main.log
Update PostgreSQL
If you haven't done so before, make sure to update the OS (PostgreSQL included to the latest version 17):
- With user
admin
, fully update the OS with the package manager:
sudo apt update && sudo apt full-upgrade
~ > Press "y" and enter or directly enter when the prompt asks you.
PostgreSQL server migration
- Stop all existing clusters:
sudo systemctl stop postgresql@16-main postgresql@17-main
- Create a new database destination folder for the v17 cluster ready for migration from v16:
sudo mkdir /data/postgresdb/17
- Assign the owner as the postgres user:
sudo chown postgres:postgres /data/postgresdb/17
- Assign the correct permissions:
sudo chmod 700 /data/postgresdb/17
- Delete the cluster created by default for v17:
sudo -u postgres pg_dropcluster 17 main
- Update the systemd:
sudo systemctl daemon-reload
- Start the migration with the PostgreSQL migration tool:
sudo -u postgres pg_upgradecluster 16 main /data/postgresdb/17
~ > ⌛ This may take a lot of time depending on the existing database size (the nostr relay database especially) and your machine's performance; it is recommended to use tmux. Wait until the prompt shows up again.
Example of expected output:
``` Restarting old cluster with restricted connections... Notice: extra pg_ctl/postgres options given, bypassing systemctl for start operation Creating new PostgreSQL cluster 17/main ... /usr/lib/postgresql/17/bin/initdb -D /data/postgresdb/17 --auth-local peer --auth-host scram-sha-256 --no-instructions --encoding UTF8 --lc-collate en_US.UTF-8 --lc-ctype en_US.UTF-8 --locale-provider libc The files belonging to this database system will be owned by user "postgres". This user must also own the server process.
The database cluster will be initialized with locale "en_US.UTF-8". The default text search configuration will be set to "english".
Data page checksums are disabled.
fixing permissions on existing directory /data/postgresdb/17 ... ok creating subdirectories ... ok selecting dynamic shared memory implementation ... posix selecting default "max_connections" ... 100 selecting default "shared_buffers" ... 128MB selecting default time zone ... Etc/UTC creating configuration files ... ok running bootstrap script ... ok performing post-bootstrap initialization ... ok syncing data to disk ... ok Warning: systemd does not know about the new cluster yet. Operations like "service postgresql start" will not handle it. To fix, run: sudo systemctl daemon-reload
Copying old configuration files... Copying old start.conf... Copying old pg_ctl.conf... Starting new cluster... Notice: extra pg_ctl/postgres options given, bypassing systemctl for start operation Running init phase upgrade hook scripts ...
Roles, databases, schemas, ACLs... set_config
(1 row)
set_config
(1 row)
Fixing hardcoded library paths for stored procedures... Upgrading database postgres... Fixing hardcoded library paths for stored procedures... Upgrading database template1... Stopping target cluster... Stopping old cluster... Disabling automatic startup of old cluster... Starting upgraded cluster on port 5432... Warning: the cluster will not be running as a systemd service. Consider using systemctl: sudo systemctl start postgresql@17-main Running finish phase upgrade hook scripts ... vacuumdb: processing database "postgres": Generating minimal optimizer statistics (1 target) vacuumdb: processing database "template1": Generating minimal optimizer statistics (1 target) vacuumdb: processing database "postgres": Generating medium optimizer statistics (10 targets) vacuumdb: processing database "template1": Generating medium optimizer statistics (10 targets) vacuumdb: processing database "postgres": Generating default (full) optimizer statistics vacuumdb: processing database "template1": Generating default (full) optimizer statistics
Success. Please check that the upgraded cluster works. If it does, you can remove the old cluster with pg_dropcluster 16 main
Ver Cluster Port Status Owner Data directory Log file 16 main 5433 down postgres /data/postgresdb/16 /var/log/postgresql/postgresql-16-main.log Ver Cluster Port Status Owner Data directory Log file 17 main 5432 online postgres /data/postgresdb/17 /var/log/postgresql/postgresql-17-main.log ```
- Reload the systemd again:
sudo systemctl daemon-reload
- List the clusters to show the state:
pg_lsclusters
Expected output:
Ver Cluster Port Status Owner Data directory Log file 16 main 5433 down <unknown> /data/postgresdb/16 /var/log/postgresql/postgresql-16-main.log 17 main 5432 online <unknown> /data/postgresdb/17 /var/log/postgresql/postgresql-17-main.log
~> Notes: * Don't worry about the
output of the "Owner" column. * Note how the old 16 cluster has automatically gone into status "down" after the migration.
- Stop the version 17 cluster using the
pg_ctlcluster
tool, to then be able to run it and manage it withsystemd
:
sudo pg_ctlcluster 17 main stop
- List the clusters again to show the state:
pg_lsclusters
Expected output:
Ver Cluster Port Status Owner Data directory Log file 16 main 5433 down <unknown> /data/postgresdb/16 /var/log/postgresql/postgresql-16-main.log 17 main 5432 down <unknown> /data/postgresdb/17 /var/log/postgresql/postgresql-17-main.log
~> Note how the version 17 cluster has gone into status "down".
- Start the version 17 cluster with systemd:
sudo systemctl start postgresql@17-main
- Monitor the logs of the PostgreSQL version 17 cluster to ensure that it working fine with
systemd
:
journalctl -fu postgresql@17-main
Expected output:
minibolt systemd[1]: Starting PostgreSQL Cluster 17-main... minibolt systemd[1]: Started PostgreSQL Cluster 17-main.
~ > Press
Ctrl + C
to continue.- List the clusters again to show the state:
pg_lsclusters
Expected output:
Ver Cluster Port Status Owner Data directory Log file 16 main 5433 down <unknown> /data/postgresdb/16 /var/log/postgresql/postgresql-16-main.log 17 main 5432 online <unknown> /data/postgresdb/17 /var/log/postgresql/postgresql-17-main.log
~> Note how the version 17 cluster has come back into the status "online".
- Delete the version 16 (old and disused) cluster:
sudo pg_dropcluster 16 main
- List again the clusters to check the correct deletion:
pg_lsclusters
Expected output:
Ver Cluster Port Status Owner Data directory Log file 17 main 5432 online <unknown> /data/postgresdb/17 /var/log/postgresql/postgresql-17-main.log
~> Note how it no longer appears version 16 (old and disused) cluster.
Check the PostgreSQL server version in use
- With the user
admin
, enter the psql (PostgreSQL CLI):
sudo -u postgres psql
- Enter the next command to get the server version:
SELECT version();
Example of expected output:
``` version
PostgreSQL 17.2 (Ubuntu 17.2-1.pgdg22.04+1) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0, 64-bit (1 row) ```
~ > Check the previous version in use is now PostgreSQL 17.2 (the latest and current version of the PostgreSQL server at this moment).
- Come back to the
admin
user bash prompt:
\q
- Start again the PostgreSQL dependencies services:
sudo systemctl start lnd nbxplorer btcpay thunderhub scb-backup nostr-relay cloudflared
~ > Check all works fine with the logs of each service, especially lnd ~ >
journalctl -fu lnd
.- (Optional) Once you have verified that everything is working correctly, you can delete the created PostgreSQL backup and temporary directory:
sudo rm -rf /tmp/postgresdb-temp
- Delete unnecessary packages:
sudo apt autoremove
~ > Press "y" and ENTER when needed or ENTER directly when the prompts ask you.
✅ That's it! If you have any questions or issues, you can go to any RRSS available for the MiniBolt project ~ > HERE < ~
Only for MiniBolters! Enjoy it! 💙