Ubuntu下运行Swarm Bee节点

1. 安装

基本安装步骤比较简单,可以直接[Swarm Bee参考官方文档](Quick Start | Swarm Bee Client (ethswarm.org))。

1.1 Bee Clef安装

在安装Bee之前,建议首先[安装Bee Clef软件包](Clef External Signer | Swarm Bee Client (ethswarm.org))。[Clef](go-ethereum/cmd/clef at master · ethereum/go-ethereum (github.com))是Go以太坊客户端使用的独立签名器(单独的一个对以太坊交易进行签名认证的服务),能够管理基于key-file的账户和硬钱包账户。[Bee-Clef](ethersphere/bee-clef: bee-clef is official ethereum clef binary wrapped and preconfigured for bee as a service (github.com))则在clef基础上针对bee做了定制化配置。Bee节点可以通过bee-clef来访问Swarm测试网或以太坊主网。当然,你也可以直接在本地运行原生的[clef](go-ethereum/cmd/clef at master · ethereum/go-ethereum (github.com)),然后增加自己的配置在运行Bee。如果确定要使用Bee-clef,必须在Bee之前先安装Bee Clef。

选择最新版本

  • 打开[Bee-clef下载页面](Releases · ethersphere/bee-clef (github.com)),查看最新版本。写当前文档时的最新版本为v0.4.12。

安装Bee-Clef

  • 下载Bee-clef

    wget https://github.com/ethersphere/bee-clef/releases/download/v0.4.12/bee-clef_0.4.12_arm64.deb
    sudo dpkg -i bee-clef_0.4.12_arm64.deb
    

配置Bee-clef

安装以后的默认配置文件在/etc/bee-clef目录下,包含4byte.jsonrules.s两个文件,已经针对Bee做了基本配置,这里不需要特别修改。

# ll /etc/bee-clef/
-rw-r--r--  1 root root  163 Feb 25 01:48 4byte.json
-rw-r--r--  1 root root  249 Feb 25 01:48 rules.js

启动Bee-Clef

在使用后台启动之前,建议先通过手工启动查看bee-clef是否正确安装。正常启动后会有一下的日志打印,其中会出现三个文件路径

  • /etc/bee-clef/4byte.json

    4byte数据库文件,包含了默认的Bee需要的一些方法。

  • /etc/bee-clef/rules.js

    签名器规则文件,定义了最基本的签名规则。比如一般来说,我们的很多交易或操作需要用户手工确认才能进行。但是也有一些操作,可以在不提示用户的情况下直接允许,比如规则文件里提到的启动、列出账户等。

    function OnSignerStartup() {return "Approve"
    }
    function OnApprovedTx() {return "Approve"
    }
    function ApproveListing() {return "Approve"
    }
    function ApproveTx() {return "Approve"
    }
    function ApproveSignData() {return "Approve"
    }
    
  • /var/lib/bee-clef/clef.ipc

    这个是bee-clef签名器与Bee节点之间进行通信的IPC通信管道,bee的所有请求都是通过这个管道发送到bee-clef。在接下来Bee的配置文件中也会用到。

    bee-clef正常启动后,一旦bee节点开始跟bee-clef交互,日志中每隔几秒或几分钟就会打印INFO [05-11|23:41:53.365] Op approved.

# bee-clef-service start
bee-clef-service /var/lib/bee-clef /var/lib/bee-clef/password /etc/bee-clef
Waiting for the clef.ipc file to show up at /var/lib/bee-clef/clef.ipcWARNING!Clef is an account management tool. It may, like any software, contain bugs.Please take care to
- backup your keystore files,
- verify that the keystore(s) can be opened with your password.Clef is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
INFO [05-11|23:35:49.197] Using stdin/stdout as UI-channel
INFO [05-11|23:35:49.925] Loaded 4byte database                    embeds=146841 locals=4 local=/etc/bee-clef/4byte.json
{"jsonrpc":"2.0","id":1,"method":"ui_onInputRequired","params":[{"title":"Master Password","prompt":"Please enter the password to decrypt the master seed","isPassword":true}]}
Waiting for the clef.ipc file to show up at /var/lib/bee-clef/clef.ipc
INFO [05-11|23:35:51.134] Rule engine configured                   file=/etc/bee-clef/rules.js
INFO [05-11|23:35:51.134] Starting signer                          chainid=5 keystore=/var/lib/bee-clef/keystore light-kdf=true advanced=false
INFO [05-11|23:35:51.135] IPC endpoint opened                      url=/var/lib/bee-clef/clef.ipc
{"jsonrpc":"2.0","method":"ui_onSignerStartup","params":[{"info":{"extapi_http":"n/a","extapi_ipc":"/var/lib/bee-clef/clef.ipc","extapi_version":"6.1.0","intapi_version":"7.0.1"}}]}
INFO [05-11|23:36:12.193] Op approved
INFO [05-11|23:36:12.203] Op approved
INFO [05-11|23:41:53.365] Op approved
INFO [05-11|23:45:04.948] Op approved
INFO [05-11|23:45:08.734] Op approved

Bee-Clef数据存储

bee-clef的密钥及其它数据默认存储在/var/lib/bee-clef/.

  • 1e4b791d7af0cf7a42a8/- bee-clef账户保险库,里边的config.json文件中会保存加密过的key/value配置文件。
  • clef.ipc- 刚才提到的IPC通信管道。
  • keystore/- bee-clef的账户地址。bee通过这个地址接入测试网或主网。
  • masterseed.json- 存放bee-clef密码
  • password账户的密钥文件
# ll /var/lib/bee-clef/
total 24
drwxr-x---  4 bee-clef bee-clef 4096 May 11 19:07 ./
drwxr-xr-x 50 root     root     4096 May 11 00:26 ../
drwx------  2 bee-clef bee-clef 4096 May 11 00:24 1e4b791d7af0cf7a42a8/
srw-rw----  1 root     root        0 May 11 19:07 clef.ipc=
drwx------  2 bee-clef bee-clef 4096 May 11 00:24 keystore/
-r--------  1 bee-clef bee-clef  868 May 11 00:24 masterseed.json
-rw-------  1 bee-clef bee-clef   32 May 11 00:24 password

1.2 Bee安装

安装完bee-clef并确保其正常启动后,我们来安装Bee。

查看最新版本

先到[Bee版本下载](Releases · ethersphere/bee (github.com))查看最新版本,当前最新版本为v0.5.3.

下载并安装Bee

wget https://github.com/ethersphere/bee/releases/download/v0.5.3/bee_0.5.3_amd64.deb
sudo dpkg -i bee_0.5.3_amd64.deb

配置Bee

安装完毕以后默认配置文件在/etc/bee/bee.yaml。也可以运行bee printconfig &> bee-default.yaml打印当前的Bee配置作为模板来自己修改。其中几个地方需要注意。

  • clef配置 - 需要根据Bee-Clef的配置设置对应的IPC路径。

    ## enable clef signer
    clef-signer-enable: true
    ## clef signer endpoint
    clef-signer-endpoint: /var/lib/bee-clef/clef.ipc
    
  • debug API地址 - 如果需要运行bee-dashboard,必须设置。默认为本机的1635端口,也可以自己修改。

    ## debug HTTP API listen address (default ":1635")
    debug-api-addr: 127.0.0.1:1635
    ## enable debug HTTP API
    debug-api-enable: true
    
  • Swap节点 - 以太坊交换节点,也就是接入以太坊的入口节点。必须设置,默认为本机的:8545端口,如果你在本机运行geth (go的以太坊客户端)。否则,推荐使用Warm官方公共节点https://rpc.slock.it/goerli。也可以自己到Ethereum API | IPFS API & Gateway | ETH Nodes as a Service | Infura 注册一个,使用自己注册的节点来减少拥堵。

    ## enable swap (default true)swap-enable: true## swap ethereum blockchain endpoint (default "http://localhost:8545")swap-endpoint: https://rpc.slock.it/goerli
    

其它配置请参考配置文件 – MoDocs (lovpia.com)。

启动运行Bee

更新完配置文件以后,可以直接通过命令行启动来检测配置是否正确。第一次启动会需要输入密码,同时需要账户有至少10gBZZ作为启动资金。

领取启动资金

先通过bee-clef-keys命令获取节点的ethernum地址(在产生的bee-clef-jey-xxxx.json文件中address字段)。

  • faucet-request (discord.com) - 通过faucet机器人领取,是好是坏,碰运气。
  • Goerli: Authenticated Faucet (mudit.blog) 需要先在Twitter上发布条信息,然后把twitter链接粘贴到页面里领取,可以一次领取37.5gETH,然后到Bzzaar (ethswarm.org)兑换即可,成功率很高,而且可以兑换不止10个gBZZ.
运行Bee

可以直接执行bee start来启动,然后查看运行日志是否正常。如果使用自定义配置文件,就加上--config <path to bee.yaml>

Bee正常启动以后,会默认监听:1633端口,当日志中出现api address: xxxx时,Bee已经启动。如果打开了debug api,也会在日志中看到debug api address: xxx:1633.

# bee start --config bee.yaml Welcome to the Swarm.... Bzzz Bzzzz Bzzzz                \     /            \    o ^ o    /              \ (     ) /   ____________(%%%%%%%)____________  (     /   /  )%%%%%%%(  \   \     )  (___/___/__/           \__\___\___)     (     /  /(%%%%%%%)\  \     )      (__/___/ (%%%%%%%) \___\__)              /(       )\            /   (%%%%%)   \                 (%%%)                   !                   INFO[2021-05-18T13:55:09+08:00] version: 0.5.3-acbd0e2                       INFO[2021-05-18T13:55:09+08:00] using swarm network address through clef: <xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> INFO[2021-05-18T13:55:09+08:00] swarm public key <xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>  INFO[2021-05-18T13:55:09+08:00] pss public key <xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> INFO[2021-05-18T13:55:09+08:00] using ethereum address <xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>INFO[2021-05-18T13:55:09+08:00] debug api address: 127.0.0.1:1635            INFO[2021-05-18T13:55:11+08:00] using default factory address for chain id 5: <xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> INFO[2021-05-18T13:55:12+08:00] using existing chequebook <xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> INFO[2021-05-18T13:55:25+08:00] database capacity: 2000000 chunks (approximately 7.8GB) INFO[2021-05-18T13:55:33+08:00] name resolver: no name resolution service provided INFO[2021-05-18T13:55:33+08:00] api address: [::]:1633...# 注意:其中的xxx为你的Bee节点对应的key和地址信息.

确保Bee可以正常启动并运行以后,就可以把Bee加入到系统服务后台运行就可以了。

查看Bee基本信息

最基本的就是在浏览器直接查看localhost:1633, 也可以在命令行用curl命令查看,如果显示Ethereum Swarm Bee就说明已经在运行了。

# curl -s localhost:1633Ethereum Swarm Bee

其它信息可以通过[bee debug api](Bee Debug API (ethswarm.org))查看。

比如自己做一个简单的bee_health_check.sh脚本,可以快速输出当前Bee节点的基本信息。

#!/usr/bin/env bash# get addresses of current nodeecho '====> 获取Bee节点地址...'echo '> curl -s localhost:1635/addresses'curl -s localhost:1635/addresses | jq# check connected peersecho '====> 获取已经建立连接的节点列表...'echo '> curl -s localhost:1635/peers'curl -s localhost:1635/peers | jq# check balance# echo '====> 获取账户基本信息...'# echo 'curl -s localhost:1635/balances'# curl -s localhost:1635/balances | jq# get chequebook balanceecho '====> 获取支票账户信息...'echo '> curl -s localhost:1635/chequebook/balance'curl -s localhost:1635/chequebook/balance | jqecho '====> 获取支票信息...'echo '> curl -s localhost:1635/chequebook/cheque'curl -s localhost:1635/chequebook/cheque | jq

另外一种方式是直接使用bee-dashboard查看,就是把bee debug api获取的状态通过图形界面可视化。需要提前打开debug api,具体参考[bee-dashboard教程](ethersphere/bee-dashboard: An app which helps users to setup their Bee node and do actions like cash out cheques (github.com))。

2. 其它注意事项

问题1:could not connect to backend at xxx

could not connect to backend at https://rpc.slock.it/goerli. In a swap-enabled network a working blockchain node (for goerli network in production) is required. Check your node or specify another node using --swap-endpoint. Error: get chain id: Post "https://rpc.slock.it/goerli": dial tcp 185.20.210.132:443: i/o timeout

因为Swap节点不可用,或者节点拥堵,建议到Ethereum API | IPFS API & Gateway | ETH Nodes as a Service | Infura 注册一个自己的节点,避免官方节点拥堵。

Ubuntu下运行Swarm Bee节点相关推荐

  1. 在Ubuntu下运行 apt-get update命令后出现错误:

    在Ubuntu下运行 apt-get update命令后出现错误: The package lists or status file could not be parsed or opened sud ...

  2. ubuntu 下运行原生的迅雷

    ubuntu 下运行原生的迅雷 2008-03-16 19:44:11 标签:迅雷 wine ubuntu [推送到技术圈 ] 版权声明: 原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出 ...

  3. Ubuntu下运行Open WebOS

    惠普放出了webOS开源首个测试版,这次发布的测试版有两个版本,其中有个可运行在Ubuntu上的版本.官方说明能在Ubuntu11.04和12.04的32位下正常运行,暂且不支持其他桌面版和Serve ...

  4. linux原生迅雷文本模式,ubuntu 下运行原生的迅雷

    ubuntu 下运行原生的迅雷 发布时间:2008-03-19 16:14:23来源:红联作者:NetFlow Linux 下的应用软件,比Windows 下的各种商用软件,目前还是要差一些.从win ...

  5. Ubuntu下运行.sh文件

    1. .sh文件是Ubuntu下可执行文件,首先需要确定它的权限是否是可执行的,运行下面的语句可添加权限: chmod a+x filename 2. 用vim打开sh文件: vi filename ...

  6. Ubuntu下运行迅雷

    Linux 下的应用软件,比Windows 下的各种商用软件,目前还是要差一些.从windows 转到Linux 下,明显感觉到软件的不顺手.其中之一就是下载软件:Windows 下迅雷下载速度最快, ...

  7. Ubuntu下运行HUGS程序,遇见的各种问题

    Ubuntu 编译     ITK 库 : ubuntu编译 ITK 库 失败 [ 30%] Building CXX object Utilities/DICOMParser/CMakeFiles/ ...

  8. ubuntu下运行.exe程序

    在远程连接服务器时用到了MobaXterm,官网下载的程序只有.exe格式,但是因为本地主机是linux,因此需要解决.exe在linux下运行的问题. 需要使用wine.Wine 是一个能够在多种操 ...

  9. Ubuntu下用devstack单节点部署Openstack

    一.实验环境 本实验是在Vmware Workstation下创建的单台Ubuntu服务器版系统中,利用devstack部署的Openstack Pike版. 宿主机:win10 1803  8G内存 ...

最新文章

  1. JavaScript PHP模仿C#中string.format效果
  2. Simple Introduction to Dirichlet Process
  3. 【Qt】QModbusResponse类
  4. AD18 KeepOut不能打孔,转成3D不显示孔的位置
  5. 2019年的前端学习计划
  6. elasticsearch存储空间不足导致索引只读,不能创建
  7. LSSS线性秘密共享方案详细构造方法与原理解释
  8. SQL server 表中如何创建索引?
  9. 7款让你时刻涨知识越变越强的在线网站分享,相见恨晚!
  10. matlab经验正交eof,经验正交函数分解(EOF).pdf
  11. SAP ByDesign Cloud 中的条形码扫描知识
  12. .net DLL反编译文件
  13. 通俗易懂解释raid0和raid5_简要阐述raid 0,raid 1,raid5 之间的区别于优缺点以及最低组建条件和可用容量...
  14. 免费资源分享(六) Unity3D 雷达实时定位插件
  15. Android进入欢迎界面前显示黑乎乎的或者白白的布局
  16. 服务器CPU型号后缀的区别,CPU后缀英文简单科普知识,若能区别字母的含义,选购好CPU不求人...
  17. 高性能计算机与网格的研究开发态势
  18. 安全生产预警系统软件解决方案
  19. 协议栈植入芯片势在必行,IPSec就是个错误
  20. java计算两个日期之间的月份差

热门文章

  1. Armhf 中安装 ROS Indigo 的方法
  2. macpro如何清理磁盘空间_Mac磁盘空间不足怎么办?苹果电脑磁盘空间清理方法
  3. 【OpenFOAM】-olaFlow-算例3- currentWaveFlume
  4. ubuntu安装后的个人简单配置
  5. vim配色方案murphy,以及多行注释插入技巧
  6. 你真的会用iCloud吗?众多隐藏功能+免费存储10W张照片
  7. 现代数字信号处理课后作业【第七章】IIR巴特沃兹FIR数字滤波器设计
  8. 闲鱼2.0:“信任”是打开闲置经济大门的唯一钥匙
  9. vercel和netlify部署代码并解决接口代理转发的问题(和Nginx功能一样)
  10. 移动端网页防止手机缩放: