In the situation when your server fails, you need to have fast and easy migration from the one that is not operating to another server, so that you can continue producing blocks with minimum downtime.
💡 Always keep an eye on your main ICON node and determine if there is a problem. This script can help you to monitor the status of the ICON node and notify the Telegram channel if the node stops syncing or goes down.
The ICON switchover solution takes no time to setup.
First of all, you need to have a backup server. Install and launch the ICON node with a different keystore on the backup server. Add the main P-Rep keystore as a comment in the docker-compose.yml. It should the following way:
Then install P-Rep Tools.
$ sudo apt-get install -y libssl-dev build-essential automake pkg-config libtool libffi-dev libgmp-dev libyaml-cpp-dev
$ sudo apt-get install -y python3.7-dev libsecp256k1-dev python3-pip python3-venv
Create a virtualenv environment
$ python -m venv venv
$ source venv/bin/activate
(venv)$ git clone https://github.com/icon-project/preptools.git
(venv)$ cd preptools
(venv)$ ls dist
(venv) $ pip install dist/preptools-1.0.2-py3-none-any.whl
(venv) $ pip install preptools
Finally, prepare a simple script to change p2pEndpoint in P-Rep information
$ vim switch.sh
URL=”https://ctz.solidwallet.io/api/v3" # Mainnet public node URL
preptools setPRep — p2p-endpoint $BACKUP_SERVER_P2P -k $KEYSTORE — nid 1 — url $URL
$ chmod +x switch.sh
Switch to the backup server
If your main ICON node or server goes down, you can manually initiate the switch to the backup server by going through the following steps:
- Uncomment the main keystore in the docker-compose.yml on the backup server
$ vim docker-compose.yml
2. Restart the backup ICON node
$ docker-compose down && docker-compose up -d
3. Change p2p Endpoint in P-Rep information
💡 You need to enter the password for the main keystore file after this command
We’ve successfully created the switchover solution for the ICON node. Next time if your main ICON node or server goes down, you can quickly switch from one server to another, allowing a smooth continuation of block production. Now, you can fix the problem with the main node once you have time, while the second node will back you up during maintenance.