前后端分离的启动

这种方式既可以随时和geth交互,又不影响geth在后台运行,在服务器上非常有必要。先用nohup在后台进程中跑geth
> nohup geth --syncmode full --datadir /data1/eth-sync/online --cache 512
--maxpeers 50 & INFO [09-27|07:37:04.628] Initialising Ethereum protocol
versions="[63 62]" network=1 INFO [09-27|07:37:04.629] Loaded most recent local
header number=1662235 hash=a9e294…913d4c td=25531653857731585264 age=2y4mo1d
INFO [09-27|07:37:04.629] Loaded most recent local full block number=1662235
hash=a9e294…913d4c td=25531653857731585264 age=2y4mo1d INFO
[09-27|07:37:04.629] Loaded most recent local fast block number=1662235
hash=a9e294…913d4c td=25531653857731585264 age=2y4mo1d INFO
[09-27|07:37:04.630] Loaded local transaction journal transactions=0 dropped=0
INFO [09-27|07:37:04.630] Regenerated local transaction journal transactions=0
accounts=0 INFO [09-27|07:37:04.630] Starting P2P networking INFO
[09-27|07:37:06.795] UDP listener up
self=enode://dd80bcf5bd935067e454e8b772253e3a7d745efb4a22f40a0bf865501c26b5dac[email protected][::]:30303
INFO [09-27|07:37:06.795] RLPx listener up
self=enode://dd80bcf5bd935067e454e8b772253e3a7d745efb4a22f40a0bf865501c26b5dac[email protected][::]:30303
INFO [09-27|07:37:06.797] IPC endpoint opened
url=/data1/eth-sync/online/geth.ipc INFO [09-27|07:37:56.795] Block
synchronisation started INFO [09-27|07:38:00.076] Imported new chain segment
blocks=2 txs=36 mgas=0.886 elapsed=1.137s mgasps=0.780 number=1662237
hash=f7d2f8…3920f1 age=2y4mo1d cache=105.16kB INFO [09-27|07:38:00.431]
Imported new chain segment blocks=23 txs=1055 mgas=22.973 elapsed=354.861ms
mgasps=64.737 number=1662260 hash=cc7e22…223ee9 age=2y4mo1d cache=2.23mB INFO
[09-27|07:38:00.947] Imported new chain segment blocks=141 txs=856 mgas=28.562
elapsed=478.099ms mgasps=59.741 number=1662401 hash=557a65…a61dbd age=2y4mo1d
cache=4.36mB INFO [09-27|07:38:01.508] Imported new chain segment blocks=147
txs=1068 mgas=36.480 elapsed=536.501ms mgasps=67.996 number=1662548
hash=00d1f3…827391 age=2y4mo1d cache=5.50mB INFO [09-27|07:38:02.106] Imported
new chain segment blocks=146 txs=667 mgas=39.514 elapsed=594.797ms
mgasps=66.433 number=1662694 hash=21fe04…4227cb age=2y4mo1d cache=6.10mB INFO
[09-27|07:38:04.766] Imported new chain segment blocks=141 txs=2870
mgas=271.393 elapsed=2.656s mgasps=102.177 number=1662835 hash=fbfdab…ec1102
age=2y4mo1d cache=14.44mB INFO [09-27|07:38:09.719] Imported new chain segment
blocks=924 txs=7872 mgas=410.690 elapsed=4.941s mgasps=83.117 number=1663759
hash=705b4c…2fdffb age=2y4mo1d cache=16.40mB
使用attach命令开启交互界面,geth启动时会在规定的data目录生成ipc,把attach的地址设置成该ipc所在地址,即可再次进入交互界面,用exit
退出也不会影响后台进程。
> geth attach ipc:/data1/eth-sync/online/geth.ipc #查看同步状态 > eth.syncing {
currentBlock: 1725364, highestBlock: 6407815, knownStates: 0, pulledStates: 0,
startingBlock: 1662235 } #查看同步高度 > eth.blockNumber 1725615 #查看节点数 >
net.peerCount 5 #安全退出 > exit