Coming soon - Get a detailed view of why an account is flagged as spam!
view details
6
GETH tip when re-booting (export active peers & reconnect)
Post Body

Just a hobbyist in this space, hopefully this will help someone.

When I want to shutdown GETH to reboot windows or take a backup (the DB is easily corrupted), this seems to help get the node back up and running with a large number of peers quickly...

(I'm using a mix of Windows & Linux here, though the concept is OS agnostic).

1) Export the existing connected peers into a file:

"\Program Files\Geth\geth.exe" --exec "admin.peers" attach http://127.0.0.1:8545 > geth-nodes.txt

2) Now you can shutdown GETH, re-boot the host, take backups & generally do whatever you need to do.

3) In Windows Subsystem for Linux (WSL2) we re-format the output into a batch file:

cat /mnt/c/Users/{username}/geth-nodes.txt | grep enode | awk -F '"' '{ print $2 }' | awk '{ print "\"\\Program Files\\Geth\\geth.exe\" -exec \"admin.addPeer(\047"$1"\047)\" attach http://127.0.0.1:8545" }' | sort -u > /mnt/c/Users/{username}/add-geth-nodes.bat

This command creates a windows batch file:

"\Program Files\Geth\geth.exe" -exec "admin.addPeer('enode://00ed0018cdef491b7733f4dd398593e5cc912565dd1d96fc8a6e84b89c1ba198a4e149c8870215c263cb7f118232755278725a5817aaec968a350e13ff0f9716@148.251.183.197:30303')" attach http://127.0.0.1:8545

"\Program Files\Geth\geth.exe" -exec "admin.addPeer('enode://016078ee996adf9f7595fdd55d8762f540561887210a02c3cdeb55313322aca4998ec6f2aba01324e4679660048271d518aeb8ac7e126b472b61c05183eb7ef4@54.221.158.111:38562')" attach http://127.0.0.1:8545

"\Program Files\Geth\geth.exe" -exec "admin.addPeer('enode://016078ee996adf9f7595fdd55d8762f540561887210a02c3cdeb55313322aca4998ec6f2aba01324e4679660048271d518aeb8ac7e126b472b61c05183eb7ef4@54.221.158.111:49114')" attach http://127.0.0.1:8545

etc.

4) Restart GETH and run the above created batch file, the output will look like this:

"\Program Files\Geth\geth.exe" -exec "admin.addPeer('enode://00ed0018cdef491b7733f4dd398593e5cc912565dd1d96fc8a6e84b89c1ba198a4e149c8870215c263cb7f118232755278725a5817aaec968a350e13ff0f9716@148.251.183.197:30303')" attach http://127.0.0.1:8545

true

C:\Users\justi>"\Program Files\Geth\geth.exe" -exec "admin.addPeer('enode://016078ee996adf9f7595fdd55d8762f540561887210a02c3cdeb55313322aca4998ec6f2aba01324e4679660048271d518aeb8ac7e126b472b61c05183eb7ef4@54.221.158.111:38562')" attach http://127.0.0.1:8545

true

C:\Users\justi>"\Program Files\Geth\geth.exe" -exec "admin.addPeer('enode://016078ee996adf9f7595fdd55d8762f540561887210a02c3cdeb55313322aca4998ec6f2aba01324e4679660048271d518aeb8ac7e126b472b61c05183eb7ef4@54.221.158.111:49114')" attach http://127.0.0.1:8545

true

In my experience, this gets the node back up and running with a large number of peers within minutes.

Author
Account Strength
100%
Account Age
6 years
Verified Email
Yes
Verified Flair
No
Total Karma
27,561
Link Karma
20,656
Comment Karma
6,157
Profile updated: 1 day ago
Posts updated: 8 months ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
3 years ago