ubuntu部署ETH节点(仅供学习参考)
文章目录
- 1. git安装
- 2. geth安装
- 3. 导出配置文件
- 4. 启动脚本
- 5. 转账
- 6. pending状态的单子处理
- 7. 分叉后geth更新
- 8. 查看已连接节点数量
- 9. 区块浏览器查询
- 10. 文档
1. git安装
sudo add-apt-repository ppa:git-core/ppasudo apt-get updatesudo apt-get install git
查看版本号
git --versiongit version 2.19.1
2. geth安装
sudo apt-get install software-properties-commonsudo add-apt-repository -y ppa:ethereum/ethereumsudo apt-get updatesudo apt-get install ethereum
获取geth 指令
geth --help
3. 导出配置文件
geth
--syncmode "fast"
--rpcapi="db,eth,net,web3,personal,web3"
--rpc --rpcaddr 192.168.0.1(内网ip)
--rpcport 3342
--rpccorsdomain "*"
--datadir "/mnt/www/walletdata/ethereum"
--txpool.journal "/mnt/www/walletdata/transactions.rlp"
--mine --miner.etherbase "0x000000"(miner地址)
--verbosity 3
--maxpeers 200
--maxpendpeers 200
--allow-insecure-unlock
--cache=8192 dumpconfig > "/mnt/www/walletdata/geth.toml"
下次直接使用下面指向来启动
--config /mnt/www/walletdata/geth.toml
4. 启动脚本
nohup geth
--syncmode "light"
--rpcapi="db,eth,net,web3,personal,web3"
--rpc
--rpcaddr 192.168.0.1
--rpcport 3342
--rpccorsdomain "*"
--datadir "/mnt/walletdata/ethereum"
--verbosity 3
--maxpeers 200
--maxpendpeers 200
--allow-insecure-unlock
--cache=8192 >eth.log 2>&1 &
全节点:--syncmode "fast"轻节点:--syncmode "light"开启挖矿:--mineminer.start(1)miner.stop()
挖矿默认指定地址:--miner.etherbase "0x00000000......"
指定txpool的存储目录,下次节点重启会再次广播交易池的交易:
--txpool.journal "/mnt/www/walletdata/transactions.rlp"
控制台启动:
geth attach ipc:walletdata/ethereum/geth.ipc
查看链接的节点:
admin.peers
查看节点的地址列表:
admin.peers.forEach(function(p) {console.log(p.network.remoteAddress);})
查看本地节点信息,为了让其他节点链接:
admin.nodeInfo.enodetxpool.statustxpool.contenttxpool.inspect
5. 转账
personal.unlockAccount('xxx')eth.sendTransaction({from:'xxx',to:'xxx',value:web3.toWei(0.01)})
6. pending状态的单子处理
personal.unlockAccount("0x1111111111111111111","1234567890")tx = eth.pendingTransactions[0]eth.resend(tx, 20000000000, 21000)
7. 分叉后geth更新
sudo apt-get updatesudo apt-get install ethereumapt-get install --only-upgrade gethapt-get dist-upgrade // 更新已安装的软件包(识别并处理依赖关系的改变)出现Please check that your locale settings:echo "export LC_ALL=C" >> /root/.bashrcsource /root/.bashrc
8. 查看已连接节点数量
net.peerCount
9. 区块浏览器查询
英文: https://etherscan.io/
中文: https://cn.etherscan.com/
10. 文档
节点配置参数
https://ethereum.gitbooks.io/frontier-guide/content/installing_linux.html
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
