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.
Configuration
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:
PRIVATE_KEY_FILENAME: “SOME_KEYSTORE”
PRIVATE_PASSWORD: “SOME_KEY_PASSWORD”
#PRIVATE_KEY_FILENAME: “MAIN_P-Rep_KEYSTORE”
#PRIVATE_PASSWORD: “MAIN_P-Rep_PASSWORD”
Then install P-Rep Tools.
Install dependencies
$ 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
Install
(venv)$ git clone https://github.com/icon-project/preptools.git
(venv)$ cd preptools
(venv)$ ./build.sh
(venv)$ ls dist
preptools-1.0.2-py3-none-any.whl
(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
```
#!/bin/bash
VENV_DIR=”/path/to/virtual/environment/directory”
KEYSTORE=”/path/to/main/keystore/file”
BACKUP_SERVER_P2P=”1.1.1.1:7100"
URL=”https://ctz.solidwallet.io/api/v3" # Mainnet public node URL
source $VENV_DIR/venv/bin/activate
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
```
#PRIVATE_KEY_FILENAME: “SOME_KEYSTORE”
#PRIVATE_PASSWORD: “SOME_KEY_PASSWORD”
PRIVATE_KEY_FILENAME: “MAIN_P-Rep_KEYSTORE”
PRIVATE_PASSWORD: “MAIN_P-Rep_PASSWORD”
```
2. Restart the backup ICON node
$ docker-compose down && docker-compose up -d
3. Change p2p Endpoint in P-Rep information
$ ./switch.sh
💡 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.
* * * * *
Every single vote matters for us, allowing us to continue developing tools for ICON blockchain and supporting the East European community. If you have any questions, feel free to reach out to our ICON Blockchain Manager on Twitter.
Staking with ICONex Web Wallet