以太坊同步主网
代码下载
git clone https://github.com/ethereum/go-ethereum.git
编译
make geth
ethereum/go-ethereum/build/bin目录下生成二进制文件
执行文件放系统目录
sudo ln -s /gopath/src/github.com/ethereum/go-ethereum/build/bin/geth /usr/local/bin/ sudo cp /gopath/src/github.com/ethereum/go-ethereum/build/bin/geth /usr/local/bin/
同步主网区块
sudo nohup geth --datadir /data/ethereum_mainNetwork_data --syncmode "fast" --rpc --rpcaddr 0.0.0.0 --rpcport 7545 --rpccorsdomain "*" --rpcapi web3,personal,admin,db,net,eth,miner,rpc,txpool,clique --ws --wsaddr 0.0.0.0 --wsorigins "*" --wsapi web3,personal,admin,db,net,eth,miner,rpc,txpool,clique > /data/ethereum_mainNetwork_data/ethRunning.log &
连接geth
可通过另一个终端查看
sudo geth attach /data/ethereum_mainNetwork_data/geth.ipc
以太坊同步测试网
若要同步测试网数据(ropsten或rinkeby)
先清除
geth --nousb --testnet removedb --datadir /home/user_dev/ethereum/ethereum_ropstenNetwork_data
数据目录设置
mkdir ethereum_rinkebyNetwork_data mkdir ethereum_ropstenNetwork_data sudo chown user_dev ethereum_rinkebyNetwork_data sudo chgrp user_dev ethereum_rinkebyNetwork_data sudo chown user_dev ethereum_ropstenNetwork_data sudo chgrp user_dev ethereum_ropstenNetwork_data
同步rinkeby测试网
sudo nohup geth-rinkeby --datadir /data/ethereum_rinkebyNetwork_data --rinkeby --syncmode "fast" --rpc --port 30313 --rpcaddr 0.0.0.0 --rpcport 18545 --rpccorsdomain "*" --rpcapi web3,personal,admin,db,net,eth,miner,rpc,txpool,clique --ws --wsaddr 0.0.0.0 --wsport 18546 --wsorigins "*" --wsapi web3,personal,admin,db,net,eth,miner,rpc,txpool,clique --nousb > /data/ethereum_rinkebyNetwork_data/ethRunning.log &
同步ropsten测试网
sudo nohup geth-ropsten --datadir /data/ethereum_ropstenNetwork_data --testnet --syncmode "fast" --rpc --port 30323 --rpcaddr 0.0.0.0 --rpcport 28545 --rpccorsdomain "*" --rpcapi web3,personal,admin,db,net,eth,miner,rpc,txpool,clique --ws --wsaddr 0.0.0.0 --wsport 28546 --wsorigins "*" --wsapi web3,personal,admin,db,net,eth,miner,rpc,txpool,clique --nousb > /data/ethereum_ropstenNetwork_data/ethRunning.log &
备注
在home目录下,同步ropsten测试网
nohup geth --datadir /home/user_dev/ethereum/ethereum_ropstenNetwork_data --testnet --syncmode "fast" --rpc --rpcaddr 0.0.0.0 --rpcport 8545 --rpccorsdomain "*" --rpcapi web3,personal,admin,db,net,eth,miner,rpc,txpool,clique --ws --wsaddr 0.0.0.0 --wsorigins "*" --wsapi web3,personal,admin,db,net,eth,miner,rpc,txpool,clique --nousb > /home/user_dev/ethereum/ethereum_ropstenNetwork_data/ethRunning.log &
另一个终端查看
sudo geth attach /data/ethereum_mainNetwork_data/geth.ipc
geth运行日志查看
tail -f ethRunning.log