如何成为一个见证人?见证人节点搭建教程

in STEEM CN/中文4 years ago (edited)

本文大量参考@ety001的文章,原文链接,感谢

最近运行了一个见证人节点,遇到了不少坑,总结一下经验教训。

教程将以Ubuntu16.04作为操作环境。

一 首先第一步是需要把账号升级为见证人账号。

你首先需要安装python3,如果你觉得安装麻烦,也可以考虑直接安装Anaconda3,安装方法请自行搜索,很多教程。

账号升级为见证人建议使用Conductor ,当然你使用别的库也是可以的,比如beem之类。

1.安装必要的依赖

sudo apt install libffi-dev libssl-dev python3 python3-dev python3-pip

2.安装 steem-python

pip3 install -U git+git://github.com/Netherdrake/steem-python

3.安装 conductor

pip3 install -U git+https://github.com/Netherdrake/conductor

4.使用 steem-python 创建本地钱包,并导入你的账号

$ steempy addkey

然后会提示你输入active key(注意linux输入密码是看不到的)

Private Key (wif) [Enter to quit]:

输入完毕后会提示你建立一个本地密码,用于加密你的私匙

Please provide a password for the new wallet

比如我们输入一个密码“123456”
然后会提示Private Key (wif) [Enter to quit]: 这时候就成功添加了,可以按回车退出。

5.初始化见证人

conductor init

回车后会依次让你输入下面的内容

What is your witness account name?: maiyude(你的见证人名字)
Witness liuye does not exist. Would you like to create it? [y/N]: y
What should be your witness URL? [https://steemdb.com/witnesses]: https://steemit.com/@maiyude(见证人主页)
How much do you want the account creation fee to be (STEEM)? [0.500 STEEM]: 3.000 STEEM(新账户创建费用)
What should be the maximum block size? [65536]: 
What should be the SBD interest rate? [0]: 
BIP38 Wallet Password: 
Witness liuye created!

其中 account creation fee是新账户创建费用,maximum block sizeSBD interest rate这几个参数不知道是什么,

然后会提示 BIP38 Wallet Password 就是上一步里设置的钱包密码,即那个 123456

6.生成打包区块所要用的公私钥对

conductor keygen

这里生成了公私钥对,麻烦抄写下来,一会要用的

+-----------------------------------------------------+-------------------------------------------------------+
| Private (install on your witness node)              | Public (publish with 'conductor enable' command)      |
+-----------------------------------------------------+-------------------------------------------------------+
| 5JcMxxxxxxxxxxxxxxxxxxxxxxxxxxx2xxxxxxxxxxxxxxx| STMxxxxxxxxxxxxxxxxxxxxxxxxxxx2xxxxxxxxxxxxxxx |
+-----------------------------------------------------+-------------------------------------------------------+

7.激活见证人

conductor enable STMxxxxxxxxxxxxxxxxxxxxxxxxxxx2xxxxxxxxxxxxxxx (这是刚才抄的公钥)

回车后会要求输入钱包密码,等看到一堆信息后,如果 block_signing_key里是你设置的公钥,
那么就激活成功了。

8.临时关闭见证人

conductor disable

如果你见证人节点还没开机,或者有事维护,不想丢块,你可以先暂时关闭见证人。

按照提示输入完信息后,当看到一堆信息后,其中的 block_signing_key 变为 STM1111111111111111111111111111111114T1Anm 则表明见证人临时关闭成功。
如果想要开机,就是上面的步骤7

二、 账号升级完毕,下面是重头戏建见证人节点。

使用mira版大概10G内存就够了,不用mira版大概要60G内存左右。(随着区块变多,这个数字会更大)

本教程使用Someguy123的一个傻瓜化 Docker 镜像 来完成。

  • 1.更新系统,安装依赖,获取 steem-docker 的安装脚本。
sudo apt update
sudo apt install git curl wget
git clone https://github.com/Someguy123/steem-docker.git
cd steem-docker
  • 2.安装 Docker,如果你的系统目前已经安装,则跳过该步
./run.sh install_docker
  • 3.build 镜像

你可以自己build一个镜像,也可以直接pull别人做好的镜像。这里我们从头build一个。

docker build --build-arg="STEEM_SOURCE=https://github.com/steemitofficial/steem.git" --build-arg="steemd_version=0.22.5"  -t steem .

如果要用mira版,就这样打

docker build --build-arg="STEEM_SOURCE=https://github.com/steemitofficial/steem.git" --build-arg="steemd_version=0.22.5" --build-arg="ENABLE_MIRA=ON"  -t steem .

注意选择你想要的版本

  • 4.同步区块数据,目前区块数据大约200-300GB左右,该步是从大佬@gtg 维护的节点下载已经打包好的区块数据(同步和解压都需要很久,尤其是解压)。
./run.sh dlblocks
  • 5.调整内存。默认内存是机器的一半,我们需要调大一点儿。默认是使用 /dev/shm 来作为 shared-file-dir,假设你的的服务器是64GB的,那就可以调整到62G,留下2GB给系统自己。/dev/shm相当于机器内存,可以加快数据读取速度。当然你用mira版可以无视这个。
sudo ./run.sh shm_size 62G
  • 6.修改 config.ini 配置文件

config.ini文件的目录在这里,打开修改之

vim /root/steem-docker/data/witness_node_data_dir/config.ini

只需要参照下面的内容修改几项即可,

p2p-endpoint = 0.0.0.0:2001 # 做种子
shared-file-size = 60G
shared-file-dir = /shm # mira版就直接注释掉这行
witness = "maiyude"  # 这里填写你的 steem 账号,注意要加双引号!!
private-key = 5JcMxxxxxxxxxxxxxxxxxxxxxxxxxxx2xxxxxxxxxxxxxxx # 这里填写 前面让你抄的私钥,不需要引号。注意默认文件witness和private-key前面有注释的#号,要去掉哦。
  • 7.启动见证人节点
./run.sh replay

运行成功后,可以通过 ./run.sh logs查看运行日志,这一步要同步所有区块数据,看你机器性能,可能会需要一到几天的时间。


最后显示大概这个样子,就是开始运行了。

8.写个见证人公告,加标签witness-category ,说说你为啥开节点,以及拉拉票。

补充一些命令:
./run.sh stop --关闭节点
./run.sh start --开启节点
./run.sh replay --重新replay(时间很长的)
./run.sh logs --查看运行日志

  • 关于喂价

见证人的一个重要工作就是喂价,喂价对于系统内价格的稳定有重要意义。

我喂价的python代码是这样写的,仅供参考:

from steem import Steem

nodes = ['https://steem.61bts.com',
    'https://steemd.minnowsupportproject.org',
    'https://steemd.pevo.science',
]
s = Steem(nodes,
    keys=["5KSBxxxx","5Hq76xxxxx"]
)

price_usd=0.222
print("喂价为:",price_usd)
tx=s.commit.witness_feed_publish(price_usd, quote=1.000, account="maiyude")
print(tx)

Sort:  



Join the community in our migration to Hive, a community built blockchain for the community. All Steem account holders will receive equivalent stake on the new Hive blockchain.

Please see this post on SteemPeak for more information.

拍拍拍,技术性文章。

谢谢总结,收藏了

啪啪

Source
Spamming comments is frowned upon by the community. Continued comment spamming may result in the account being Blacklisted.

More Information:
The Art of Commenting

!sc ban
Mass plagiarism and spam.

Hi @maiyude!

Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your UA account score is currently 8.170 which ranks you at #17 across all Steem accounts.
Your rank has improved 18 places in the last three days (old rank 35).

In our last Algorithmic Curation Round, consisting of 66 contributions, your post is ranked at #9.

Evaluation of your UA score:
  • Your follower network is great!
  • The readers like your work!
  • Try to work on user engagement: the more people that interact with you via the comments, the higher your UA score!

Feel free to join our @steem-ua Discord server

五拍👏

Coin Marketplace

STEEM 0.28
TRX 0.12
JST 0.033
BTC 70245.15
ETH 3761.26
USDT 1.00
SBD 3.99