原因是我在启动geth时,多加了一个console
正确的命令应该是:
nohup geth --datadir node1/ --networkid 1009 --http --http.addr 127.0.0.1 --http.port 8545 --http.api db,net,eth,web3,miner,personal,admin --http.corsdomain "*" --nodiscover 2>1.log &
里面没有console。
另外,要关闭防火墙。
systemctl stop firewalld
验证防火墙是否关闭
查看防火状态
systemctl status firewalld
启动geth后,查看geth进程是否运行
ps aux|grep geth
如果看到有geth进程,说明启动节点了。
再输入命令,进入控制台
geth attach http://localhost:8545