步骤0 切换root,根据提示输入root权限密码

root@iZ8vbgcelr86h0i2rbfshaZ:/# su root

步骤一 通过docker pull hpbbc/go-hpb下载镜像。

root@iZ8vbgcelr86h0i2rbfshaZ:~# docker pull hpbbc/go-hpb
Using default tag: latest
latest: Pulling from hpbbc/go-hpb
Digest: sha256:3ecb483ca70883c390c55ceada92f7c0726e13afaebea2029dfe1c208dbe0094
Status: Image is up to date for hpbbc/go-hpb:latest
root@iZ8vbgcelr86h0i2rbfshaZ:~#

步骤二 运行如下命令
输入docker images,查看镜像文件hpbbc/go-hpb是否已经安装好。

root@iZ8vbgcelr86h0i2rbfshaZ:~# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
hpbbc/go-hpb        latest              a3ebf0866f79        5 weeks ago         42MB
ghpb                v1.0.2.3            a3ebf0866f79        5 weeks ago         42MB

步骤3 新建gensis.json

root@iZ8vbgcelr86h0i2rbfshaZ:~# vi gensis.json

在弹出的页面按下字母I键即可切换至INSERT输入状态,然后用鼠标右键粘贴入下方代码。
完成后按一下ESC键,并输入:wq即可保存文件并退出。
提示:按一下ESC键,并输入:q!为不保存文件并退出。

 {

 “config”: {

 “chainId”: 100,

 “prometheus”: {

 “period”: 10,

 “epoch”: 200

 }

 },

 “nonce”: “0x0”,

 “timestamp”: “0x5b7eba85”,

 “extraData”: “0x68706200000000000000000000000000000000000000000000000000000000000926f045887401883a8d9c6e9878b1b900a5be19405dd40aa9298448a58fa679ec4295eac8472a0d58c163703d46edcfc1b99abd4f2c4801d3c997a75bf42ea1b9b03e6f3980beba7216d14813c30d7069bd0d853df157ee0e05f1f3749996e5dcdc80407cc4e0cc326756155d4afb2e780bdd13a17d4434bb078d7d587ef5db12918ff775fe26cb54006fc4f29a056080cb3a804945e136594ead53e8589478f8282f019c753fb2410a50e2c4789bf96b7061140000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000”,

 “gasLimit”: “0x5f5e100”,

 “difficulty”: “0x1”,

 “mixHash”: “0x0000000000000000000000000000000000000000000000000000000000000000”,

 “coinbase”: “0x0000000000000000000000000000000000000000”,

 “alloc”: {

 “269bBC5Cf30795a5FdF6aB7165D3DCb9Ef736808”: {

 “balance”: “20000000000000000000000000”

 },

 “A1960FA87733F1B9ffbfB95d9d692471Aa691c9C”: {

 “balance”: “18000000000000000000000000”

 },

 “dAB62F5145EE529cF1c89371615256a5d151016c”: {

 “balance”: “12000000000000000000000000”

 },

 “172B49140D31A034bE7f358FDdD9db25A71A402A”: {

 “balance”: “10800000000000000000000000”

 },

 “4604801FaF9cC8C4443B269D1A10bcDE7fB19c39”: {

 “balance”: “37000000000000000000000000”

 },

 “de3Fd4fC583b6d7e06Db0bE6A35467f33046Ad27”: {

 “balance”: “2200000000000000000000000”

 }

 },

 “number”: “0x0”,

 “gasUsed”: “0x0”,

 “parentHash”: “0x0000000000000000000000000000000000000000000000000000000000000000”,

 “hardwareRandom”: “0x0000000000000000000000000000000000000000000000000000000000000000”

 }

步骤三 新建/home/ghpb-bin/node/目录

输入mkdir -p /home/ghpb-bin/node/,把gensis.json放到/home/ghpb-bin/node/目录下,可通过cp命令完成,也可后台完成。

root@iZ8vbgcelr86h0i2rbfshaZ:/# mkdir -p /home/ghpb-bin/node/
root@iZ8vbgcelr86h0i2rbfshaZ:/# 

步骤四 新建keystore目录

输入mkdir -p /home/ghpb-bin/node/datafull/keystore,上传一个keystore文件到该目录下(任何keystore文件,该加密私钥文件用于启动节点,没任何用途,可以任意新建一个)。

root@iZ8vbgcelr86h0i2rbfshaZ:/# mkdir -p /home/ghpb-bin/node/datafull/keystore

步骤五 初始化配置
​ 输入docker run -it --rm --privileged=true -v /home/ghpb-bin/node/:/root/node/ --name ghpbinit ghpb:v1.0.2.3 --datadir /root/node/data init /root/node/gensis.json
来初始化创世配置。

root@iZ8vbgcelr86h0i2rbfshaZ:/# docker run -it --rm --privileged=true  -v /home/ghpb-bin/node/:/root/node/ --name ghpbinit ghpb:v1.0.2.3 --datadir /root/node/data init /root/node/gensis.json
INFO [11-01|09:48:41]  HPB : Create New HpbConfig object 
INFO [11-01|09:48:41]  HPB : Allocated cache and file handles  database=/root/node/data/ghpb/chaindata cache=16 handles=16
INFO [11-01|09:48:41]  HPB : Writing custom genesis block 
INFO [11-01|09:48:41]  HPB : Successfully wrote genesis state  database=chaindata                      hash=9c3704…f39966

步骤六 启动节点
​ 输入docker run -itd --privileged=true --restart=always -v /home/ghpb-bin/node/:/root/node/ -p 8545:8545 -p 30303:30303 -p 8546:8546 --name ghpb1 ghpb:v1.0.2.3 --datadir /root/node/data --networkid 100 --verbosity 3 --rpc --rpcaddr 0.0.0.0 --rpcapi hpb,web3,admin,txpool,debug,personal,net,miner,prometheus --nodetype synnode console来启动节点

root@iZ8vbgcelr86h0i2rbfshaZ:/# docker run -itd --privileged=true --restart=always -v /home/ghpb-bin/node/:/root/node/ -p 8545:8545 -p 30303:30303 -p 8546:8546 --name ghpb1 ghpb:v1.0.2.3 --datadir /root/node/data --networkid 100 --verbosity 3 --rpc --rpcaddr 0.0.0.0 --rpcapi hpb,web3,admin,txpool,debug,personal,net,miner,prometheus --nodetype synnode console
ccab756a76b13a720b41c0bb7dd35383d36169dc3074e22d0b220170da7826ff

步骤七 进入控制台
​ 输入docker attach ghpb1可以进入控制台。

root@iZ8vbgcelr86h0i2rbfshaZ:/# docker attach ghpb1 
INFO [11-01|09:55:46]  HPB : UDP listener up                   self=hnode://e25f1e2aafcec4525e6c65c5b7dc8fb6e683711aa9b58bee92ab1651f9fa6bbeb37de7b0a61b8b533eb19e2e57f2decfca6bb9eb338e9926dbf8f30e64f1c1b3@[::]:30303
INFO [11-01|09:55:46]  HPB : Server start with type.           NodeType=SynNode
INFO [11-01|09:55:46]  HPB : Start server of bandwidth test.   port=30403
INFO [11-01|09:55:46]  HPB : IPC endpoint opened               url=/root/node/data/ghpb.ipc
INFO [11-01|09:55:46]  HPB : HTTP endpoint opened              url=http://0.0.0.0:8545      cors= vhosts=localhost,localhost
Welcome to the GHPB JavaScript console!

instance: 
coinbase: 0xaed85c944a8a96c2714532b00676337e0d986811
at block: 0 (Thu, 23 Aug 2018 13:45:41 UTC)
 datadir: /root/node/data
 modules: admin:1.0 debug:1.0 hpb:1.0 miner:1.0 net:1.0 personal:1.0 prometheus:1.0 rpc:1.0 txpool:1.0 web3:1.0

>

步骤八 退出docker控制台

按下键盘Ctrl+p+q可以退出当前docker容器控制台。

INFO [11-01|10:08:10]  HPB : Inserted new block                number=656094 hash=67a92f…8b7b1a
INFO [11-01|10:08:10]  HPB : Imported new chain segment        blocks=1  txs=0 mgas=0.000 elapsed=7.058ms  mgasps=0.000 number=656094 hash=67a92f…8b7b1a
######### peers length is: 2
read escape sequence

步骤九 查看节点日志
​ 输入docker logs -f ghpb1可以查看节点的日志。

root@iZ8vbgcelr86h0i2rbfshaZ:/# docker logs -f ghpb1
Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐