以太坊经典全节点操作
安装
- 下载页面
五个可用节点软件下载地址:
https://github.com/etclabscore/go-ethereum/releases
https://github.com/paritytech/parity-ethereum/releases
https://github.com/etclabscore/multi-geth/releases
https://github.com/multi-geth/multi-geth/releases
https://github.com/hyperledger/besu/releases
这里选择 https://github.com/etclabscore/multi-geth/releases
- 注意: 下载前要选取服务器的一个合适大小的磁盘,200G+ 下新建文件夹开始全节点备份
df -h : 查看系统内存情况
du -h --max-depth=1 + 文件名 : 查看文件的大小
ps - ef | grep + ./geth : 找到./geth 进程
kill + 进程号 : 杀死对应进程
- 下载压缩包
cd apps/ethclassic
- 下载地址去github复制下载链接的
wget https://github.com/etclabscore/multi-geth/releases/download/v1.9.9-etclabscore/multi-geth-linux.zip
新版本:
wget https://github.com/etclabscore/core-geth/releases/download/v1.11.2/core-geth-linux-v1.11.2.zip
还可以选择本地下载再上传到服务器合适的文件夹,推荐可视化windows工具WinSCP上传.
解压
unzip multi-geth-linux.zip
- 检查
./geth version
启动
直接geth启动
nohup + 命令 + $ 后台运行,退出xshell还可以继续运行,
nohup ./geth --classic --datadir "/home/xiejiang/apps/data/ethclassic/ethclassic_data" --rpc --rpcaddr 0.0.0.0 --rpcport 8545 &
后台启动
nohup ./geth --classic --datadir "/data2/etc/etc_data" --rpc --rpcaddr 0.0.0.0 --rpcport 8545 &
setsid ./geth --classic --datadir "/data2/etc/etc_data" --rpc --rpcaddr 0.0.0.0 --rpcport 8545 &
du -h --max-depth=1 etc_data/
默认date目录在 /home/xiejiang/.ethereum
可添加参数指定 --datadir "/home/xiejiang/apps/data/ethclassic/ethclassic_data"
查看文件区块数据大小:
linx@eosfullnode:~/data2/etc_backup$ du -h --max-depth=1 etc_data/
geth客户端交互
![](https://i-blog.csdnimg.cn/blog_migrate/b612aa5110aa3d709fd4932eafdea872.png)
登录
./geth attach rpc:http://127.0.0.1:8545
查看状态
eth
- 查看最新区块高度
eth.blockNumber
- 查看同步状态,返回 false 未同步或同步到最新了
eth.syncing
RPC API
API与以太坊相同
例1:查询第 10000
块具体信息,先转换成十六进制 0x2710
curl -X POST -H "Content-Type":application/json --data '{"jsonrpc":"2.0", "method":"eth_getBlockByNumber", "params":["0x2710", true], "id":1}' http://127.0.0.1:8545
返回:
{
"jsonrpc":"2.0",
"id":1,
"result":{
"difficulty":"0x8b5504a130",
"extraData":"0x476574682f76312e302e302f77696e646f77732f676f312e342e32",
"gasLimit":"0x1388",
"gasUsed":"0x0",
"hash":"0xdc2d938e4cd0a149681e9e04352953ef5ab399d59bcd5b0357f6c0797470a524",
"logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"miner":"0xbf71642d7cbae8faf1cfdc6c1c48fcb45b15ed22",
"mixHash":"0xc6bf383db032101cc2101543db260602b709e5d9e38444bb71b680777185448b",
"nonce":"0xb75e5f372524d34c",
"number":"0x2710",
"parentHash":"0xb9ecd2df84ee2687efc0886f5177f6674bad9aeb73de9323e254e15c5a34fc93",
"receiptsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
"size":"0x21d",
"stateRoot":"0x4de830f589266773eae1a1caa88d75def3f3a321fbd9aeb89570a57c6e7f3dbb",
"timestamp":"0x55bb3ea3",
"totalDifficulty":"0x82f427b38eae1",
"transactions":[],
"transactionsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"uncles":[]
}
}
例2:查询第 500000
块数据,通过 blockhash
查看:
curl -X POST -H "Content-Type":application/json --data '{"jsonrpc":"2.0","method":"eth_getBlockByHash","params":["0xac8e95f7483f7131261bcc0a70873f8236c27444c940defc677f74f281220193", true],"id":1}' http://127.0.0.1:8545
返回:
{
"jsonrpc":"2.0",
"id":1,
"result":{
"difficulty":"0x6dcc051573d",
"extraData":"0xd783010203844765746887676f312e352e31856c696e7578",
"gasLimit":"0x2fefd8",
"gasUsed":"0x0",
"hash":"0xac8e95f7483f7131261bcc0a70873f8236c27444c940defc677f74f281220193",
"logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"miner":"0x580992b51e3925e23280efb93d3047c82f17e038",
"mixHash":"0x2e88e14c1a8cdf00e6252bd7303919f07b1fbe84d3767cc39e56fbd4c7b92204",
"nonce":"0x8901a71893cb3488",
"number":"0x7a120",
"parentHash":"0x794a1bef434928ce3aadd2f5eced2bf72ac714a30e9e4ab5965d7d9760300d84",
"receiptsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
"size":"0x21d",
"stateRoot":"0xb2bcfa2ffe869085c84a976435f1581a7a0eb7af64bafcbbda710661016aa3ab",
"timestamp":"0x563ceae1",
"totalDifficulty":"0x2562c18c2515e900",
"transactions":[],
"transactionsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"uncles":[]
}
}