阿里云安装同步以太坊ethereum

本文指导如何在阿里云服务器上安装以太坊,并通过挂载云盘加速数据同步。首先,使用fdisk创建新的分区并格式化为ext3文件系统,然后将其挂载到.ethereum目录。接着,通过添加PPA源安装以太坊软件包。最后,使用nohup启动geth进程,选择快速同步模式并设置RPC接口,以便监控同步进度。同步完成的标志包括eth.syncing返回false,日志显示导入新链段,eth.blockNumber显示区块高度,以及能获取到正确的以太币数量。
摘要由CSDN通过智能技术生成

第一步:挂载云盘

 

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值