GETH tip when re-booting (export active peers & reconnect)

Cryptocurrency News and Public Mining Pools

GETH tip when re-booting (export active peers & reconnect)

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 FilesGethgeth.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 FilesGethgeth.exe" -exec "admin.addPeer(47"$1"47)" 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 FilesGethgeth.exe" -exec "admin.addPeer('enode://00ed0018cdef491b7733f4dd398593e5cc912565dd1d96fc8a6e84b89c1ba198a4e149c8870215c263cb7f118232755278725a5817aaec968a350e13ff0f9716@148.251.183.197:30303')" attach http://127.0.0.1:8545

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

"Program FilesGethgeth.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 FilesGethgeth.exe" -exec "admin.addPeer('enode://00ed0018cdef491b7733f4dd398593e5cc912565dd1d96fc8a6e84b89c1ba198a4e149c8870215c263cb7f118232755278725a5817aaec968a350e13ff0f9716@148.251.183.197:30303')" attach http://127.0.0.1:8545

true

C:Usersjusti>"Program FilesGethgeth.exe" -exec "admin.addPeer('enode://016078ee996adf9f7595fdd55d8762f540561887210a02c3cdeb55313322aca4998ec6f2aba01324e4679660048271d518aeb8ac7e126b472b61c05183eb7ef4@54.221.158.111:38562')" attach http://127.0.0.1:8545

true

C:Usersjusti>"Program FilesGethgeth.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.

submitted by /u/ggekko999
[link] [comments]