ubuntu部署ETH节点(仅供学习参考)

1. git安装

sudo add-apt-repository ppa:git-core/ppa

sudo apt-get update

sudo apt-get install git

查看版本号

git --version

git version 2.19.1

2. geth安装

sudo apt-get install software-properties-common

sudo add-apt-repository -y ppa:ethereum/ethereum

sudo apt-get update

sudo apt-get install ethereum

获取geth 指令

geth --help

3. 导出配置文件

geth 
--syncmode "fast" 
--rpcapi="db,eth,net,web3,personal,web3" 
--rpc --rpcaddr 172.16.1.148 
--rpcport 3342 
--rpccorsdomain "*" 
--datadir "/mnt/www/walletdata/ethereum" 
--txpool.journal "/mnt/www/walletdata/transactions.rlp" 
--mine --miner.etherbase "0x9c5E7C546c805571e5f4ecbB414F2b529F4F63F9" 
--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.1.128 
--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"

开启挖矿:--mine

miner.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.enode

txpool.status

txpool.content

txpool.inspect

5. 转账

personal.unlockAccount('xxx')

eth.sendTransaction({
    
    from:'xxx',to:'xxx',value:web3.toWei(0.01)})

6. pending状态的单子处理

personal.unlockAccount("0xa3fe2b9c37e5865371e7d64482a3e1a347d03acd","1234567890")

tx = eth.pendingTransactions[0]

eth.resend(tx, 20000000000, 21000)

7. 分叉后geth更新

sudo apt-get update

sudo apt-get install ethereum

apt-get install --only-upgrade geth

apt-get dist-upgrade // 更新已安装的软件包(识别并处理依赖关系的改变)

出现Please check that your locale settings:

echo "export LC_ALL=C" >> /root/.bashrc

source /root/.bashrc

8. 查看已连接节点数量

net.peerCount

9. 区块浏览器查询

英文: https://etherscan.io/

中文: https://cn.etherscan.com/

10. 文档

https://ethereum.gitbooks.io/frontier-guide/content/installing_linux.html

客户端基本操作:

[https://www.tiny-calf.com/2018/02/01/GETH%E5%AE%A2%E6%88%B7%E7%AB%AF%E5%9F%BA%E6%9C%AC%E6%93%8D%E4%BD%9C/

猜你喜欢

转载自blog.csdn.net/qq_36228377/article/details/123154083