第一步:挂载云盘
fdisk -l
Disk /dev/vda: 40 GiB, 42949672960 bytes, 83886080 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x77ba45a4
Device Boot Start End Sectors Size Id Type
/dev/vda1 * 2048 83884031 83881984 40G 83 Linux
Disk /dev/vdb: 200 GiB, 214748364800 bytes, 419430400 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
root@ethtest:~# fdisk /dev/vdb
Welcome to fdisk (util-linux 2.27.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0xd0785c25.
Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-419430399, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-419430399, default 419430399):
Created a new partition 1 of type 'Linux' and of size 200 GiB.
Command (m for help): wq
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
root@ethtest:~# fdisk -l
root@ethtest:~# mkfs.ext3 /dev/vdb1
mke2fs 1.42.13 (17-May-2015)
Creating filesystem with 52428544 4k blocks and 13107200 inodes
Filesystem UUID: 4c3dc94b-836a-4a31-a6ad-9bb2b15eb254
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
root@ethtest:~# echo /dev/vdb1 /.ethereum ext3 defaults 0 0 >> /etc/fstab
root@ethtest:~# mkdir -m 777 .ethereum
root@ethtest:~# mount /dev/vdb1 /root/.ethereum
第二步:安装以太坊
apt-get update
apt-get install software-properties-common
add-apt-repository -y ppa:ethereum/ethereum
apt-get update
apt-get install ethereum
第三步:同步数据
nohup geth -syncmode="fast" --rpc --rpccorsdomain "*" --port 30304 --rpcapi "personal,db,eth,net,web3" --rpcaddr="0.0.0.0" --rpcport 12345 >> geth.log 2>&1 &
测试网的加一个testnet选项即可
查看数据同步情况,tail -f geth.log 即可!!!
下面是区块同步完成的几个标志:
1. 执行eth.syncing,提示false
2.日志打印不在意只是Imported new state entries,而是Imported new chain segment
3. 执行eth.blockNumber,显示当前的区块高度
4. 执行web3.eth.getBlockNumber(console.log),正确返回该地址的以太币数,不再是0
QQ:13348167 群:275426192