安装运行Near节点

安装运行Near节点到测试网

官网参考:https://docs.near.org/docs/develop/node/running-a-node

运行节点

官网参考:https://docs.near.org/docs/develop/node/running-a-node

为什么要运行节点

NEAR协议在一组公共维护的计算机(或“节点”)上运行。

您可能出于以下几个原因决定运行自己的节点:

  • 为了开发和节点上部署的合同连接到MainNet,TestNet或BetaNet(†)
  • 在本地(独立和隔离)节点(有时称为“ LocalNet”)上开发和部署合约。(††)
  • 以运行“验证者节点”的验证者身份加入网络(请参见staking

LocalNet如果您希望避免在开发过程中泄露有关您的工作的信息,因为(TestNet和)BetaNet是公共网络,则(††)是正确的选择。LocalNet还可以让您完全控制帐户,经济性和其他因素,以使用更高级的用例(例如,对进行更改nearcore)。

关于nearup

如何在NEAR网络运行验证者(validator)节点(超详细)
参考URL: https://www.jianshu.com/p/d00033c83063?from=timeline

跑NEAR 节点的官方硬件条件:CPU: intel 4核8线程 内存: 16GB DDR4 储存空间: 100GB SSD。

大家可在如下网址中寻找到硬件要求 我们可以看到全分片的节点要求还是非常高的。
https://docs.near.org/docs/roles/validator/hardware

跑Near 节点所需要的几个部件:nearup, nearcore, near-cli, core-contracts。 nearup 是 用来跑Near 节点的 脚本。 nearcore是 Near 节点 的标准客户端。

near-cli 是 通用命令行工具,安装上了之后,可以用 Near + 命令 来执行一系列 登录,创建,删除账户的操作。near-cli是基于node.js的应用

core-contracts 包含质押资金池相关的智能合约

nearcore编译

nearcore编译
https://github.com/near/nearcore

因为会用到Rust编译。先安装rustup
【Rust学习一】安装、编写hello world、使用cargo
参考URL: https://www.jianshu.com/p/590548efb02b

此命令下载一个脚本并开始安装 rustup 工具,这会安装最新稳定版 Rust。

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

如果安装成功,将会出现如下内容:

Rust is installed now. Great!

To get started you need Cargo's bin directory ($HOME/.cargo/bin) in your PATH
environment variable. Next time you log in this will be done
automatically.

按照上述提示,还要将Rust 加入系统 PATH 环境变量中,在下一次登录时生效。

vi /etc/profile
文件中增加如下行

export PATH="$HOME/.cargo/bin:$PATH"
source /etc/profile
mkdir code
cd code
git clone https://github.com/nearprotocol/nearcore.git
cd nearcore
make release

nearup 安装

您可以nearup按照 https://github.com/near/nearup 上的说明进行安装。

PS: 这里不粘贴了,直接紧跟 https://github.com/near/nearup 操作即可(亲测通过)。

安装完成后运行

nearup run testnet 

nohup nearup run testnet   > nearup.output 2>&1 &

nohup nearup run localnet > nearup-localnet.output 2>&1 &
nearup run localnet

To run a validator node with validator keys, please specify the account id:
nearup run testnet --account-id testing.account

Using a locally compiled binary

PS:如何需要运行自己的编译的二进制near节点,需要你自己按照前面的,自己编译nearcore

Recommended for security critical validators or during development.
建议用于对安全至关重要的验证器或在开发期间。

Clone and compile nearcore with make release or make debug first.

nearup run betanet --binary-path path/to/nearcore/target/{debug, release}
Replace betanet with testnet if you want to use a different network.

Spawn a local network
生成本地网络

Clone and compile nearcore with make release or make debug first.

nearup run localnet --binary-path path/to/nearcore/target/{debug, release}

By default it will spawn 4 nodes validating in 1 shard. RPC ports of each nodes will be consecutive starting from 3030. Access one node status using http://localhost:3030/status

默认情况下,它将生成1个分片中有效的4个节点。 从3030开始,每个节点的RPC端口将是连续的。使用http://localhost:3030/status访问一个节点状态

操作

停止本地网络中正在运行的节点或所有正在运行的节点

nearup stop

其他选项

nearup run betanet --help

本文档其余部分中的步骤将需要 nearup

使用Docker运行官方节点

安装Docker
默认情况下,我们使用Docker运行客户端。

请按照以下说明在您的计算机上安装Docker:

  • MacOS
  • Ubuntu

注意:通过将–nodocker标志添加到nearup命令并指定已编译的二进制路径,可以在不使用Docker的情况下运行节点。 请参阅下一节中的操作方法:在没有Docker的情况下编译和运行官方节点。

Running nearup

一旦安装了closeup和Docker(按照上一节中的说明进行操作),请运行:

nearup betanet

在windows上运行节点

官方原文:https://docs.near.org/docs/develop/node/running-a-node-windows

  1. 如果未启用Linux的Windows子系统,请以管理员身份打开PowerShell并运行:
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

然后重新启动计算机。

  1. 转到您的Microsoft商店并查找Ubuntu;这是Ubuntu终端实例。安装并启动它。

  2. 现在可能会要求您输入用户名和密码,不要使用admin作为用户名。

  3. 您的Ubuntu实例需要先进行初始化,然后再进行下一步

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install build-essential pkg-config libssl-dev
  1. 您需要安装OpenSSL,您将需要运行该节点。要下载OpenSSL,请在Ubuntu终端中运行以下命令:
cd /tmp
wget https://www.openssl.org/source/openssl-1.1.1.tar.gz
tar xvf openssl-1.1.1.tar.gz
  1. 完成下载OpenSSL后,运行以下命令进行安装:
cd openssl-1.1.1
sudo ./config -Wl,--enable-new-dtags,-rpath,'$(LIBRPATH)'
sudo make
sudo make install

这些文件将位于以下目录中:/ usr / local / ssl。

  1. 完成此操作后,您必须确保Ubuntu将使用正确版本的OpenSSL。现在,更新手册页和二进制文件的路径。运行以下命令:
cd ../..
sudo nano /etc/manpath.config
  1. 将打开一个文本文件,添加以下行:
MANPATH_MAP     /usr/local/ssl/bin      /usr/local/ssl/man
  1. 要确保已安装OpenSSL,请运行:
openssl version -v

这应该显示您已安装的版本。有关更多信息,请参见此处。(https://manpages.ubuntu.com/manpages/bionic/man1/version.1ssl.html)

PS: 后面还有步骤,未完全copy,需要window安装运行的,具体参考原文,本人未验证测试!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

西京刀客

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值