Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
share
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
黄刚
share
Commits
10b0abb5
Commit
10b0abb5
authored
Feb 21, 2019
by
Hugo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改联盟链网络搭建,创建私链网络搭建
parent
ac0488a6
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
251 additions
and
0 deletions
+251
-0
私链网络搭建.md
私链网络搭建.md
+251
-0
联盟链配置.md
联盟链配置.md
+0
-0
No files found.
私链网络搭建.md
0 → 100644
View file @
10b0abb5
[
TOC
]
[
TOC
]
# 1 私链网络搭建
## 1.1 安装Go环境,Git环境
检查是否已经安装了golang和git,如果显示如下内容表示都没有安装.
```
shell
~
$
go version
The program
'go'
is currently not installed. You can
install
it by typing:
sudo
apt
install
golang-go
~
$
git
The program
'git'
is currently not installed. You can
install
it by typing:
sudo
apt
install
git
```
-
Go环境安装参考
<a
href=
"https://chain.33.cn/document/81#1.1%20Go%20%E7%8E%AF%E5%A2%83%E5%AE%89%E8%A3%85"
>
这里
</a>
-
Git环境安装参考
<a
href=
"https://chain.33.cn/document/81#1.2%20Git%20%E7%8E%AF%E5%A2%83%E5%AE%89%E8%A3%85"
>
这里
</a>
## 1.2 下载plugin源码,编译生成可执行文件
代码下载参考
<a
href=
"https://chain.33.cn/document/81#2%20%E4%BB%A3%E7%A0%81%E4%B8%8B%E8%BD%BD"
>
这里
</a>
,执行结果演示如下:
```
shell
mkdir
-p
$GOPATH
/src/github.com/33cn
git clone https://github.com/33cn/plugin.git
$GOPATH
/src/github.com/33cn/
cd
plugin
make
```
编译成功后会在build目录下面生成chain33和chain33-cli两个可执行文件,将这两个文件拷贝到所有节点的某个目录下,如/home/ubuntu/chain33,该目录需要先创建好.
```
shell
mkdir
-p
/home/ubuntu/chain33
scp chain33 /home/ubuntu/chain33/
scp chain33 ubuntu@192.168.0.107:/home/ubuntu/chain33/
scp chain33 ubuntu@192.168.0.116:/home/ubuntu/chain33/
scp chain33 ubuntu@192.168.0.137:/home/ubuntu/chain33/
scp chain33-cli /home/ubuntu/chain33/
scp chain33-cli ubuntu@192.168.0.107:/home/ubuntu/chain33/
scp chain33-cli ubuntu@192.168.0.116:/home/ubuntu/chain33/
scp chain33-cli ubuntu@192.168.0.137:/home/ubuntu/chain33/
```
## 1.3 修改配置文件
将../raft/chain33.test.toml拷贝到当前目录,配置项解释参考
<a
href=
"https://chain.33.cn/document/123"
>
这里
</a>
```
shell
cp
../chain33.test.toml
.
```
我们的4个节点都是seed节点,所以将
[
p2p
]
中的isSeed设置为true,并将节点ip:port添加进去
[
p2p
]
中seeds和
[
consensus.sub.raft
]
中peersURL字符串并保存,注意这两项端口号不同.
```
plain
[p2p]
seeds=["192.168.0.105:13802","192.168.0.107:13802","192.168.0.116:13802","192.168.0.137:13802"]
isSeed=true
[consensus.sub.raft]
注:nodeID的值必须与配置文件所在节点的ip在peersURL中的顺序一致,从1开始,如配置文件在192.168.0.105上则nodeID=1,在192.168.0.107上则nodeID=2,以此类推
nodeID=x
peersURL="http://192.168.0.105:9021,http://192.168.0.107:9021,http://192.168.0.116:9021,http://192.168.0.137:9021"
```
分别将配置好的对应节点的配置文件chain33.testx.toml拷贝到对应节点的/home/ubuntu/chain33目录下
```
shell
scp chain33.test1.toml ubuntu@192.168.0.105:/home/ubuntu/chain33/
scp chain33.test2.toml ubuntu@192.168.0.107:/home/ubuntu/chain33/
scp chain33.test3.toml ubuntu@192.168.0.116:/home/ubuntu/chain33/
scp chain33.test4.toml ubuntu@192.168.0.137:/home/ubuntu/chain33/
```
## 1.4 在每个节点上启动程序
登录到各个节点输入如下命令,启动区块链程序:
```
shell
nohup
./chain33
-f
chain33.testx.toml
>>
log.out 2>&1 &
```
> 注:raft默认会间隔2分钟产生一个空区块.
## 1.5 通过chain33-cli查看节点运行情况
### 1.5.1 查看节点同步状态,如果返回true,表示区块已同步
```
shell
./chain33-cli net is_sync
```
### 1.5.2 发送交易测试区块链是否运行正常
-
首先创建钱包及账户,具体参考
<a
href=
"https://chain.33.cn/document/80#1.3%20%E5%88%9B%E5%BB%BA%E9%92%B1%E5%8C%85%E4%BB%A5%E5%8F%8A%E8%B4%A6%E6%88%B7"
>
这里
</a>
,执行结果演示如下:
```
shell
./chain33-cli account list
{
"wallets"
:
[
{
"acc"
:
{
"balance"
:
"0.0000"
,
"frozen"
:
"0.0000"
,
"addr"
:
"1EVnGWTrC6WcaGSU8D8cuXxkFcRTPJ1Tox"
}
,
"label"
:
"node award"
}
,
{
"acc"
:
{
"balance"
:
"100000000.0000"
,
"frozen"
:
"0.0000"
,
"addr"
:
"1CbEVT9RnM5oZhWMj4fxUrJX94VtRotzvs"
}
,
"label"
:
"genesis"
}
,
{
"acc"
:
{
"balance"
:
"0.0000"
,
"frozen"
:
"0.0000"
,
"addr"
:
"1GqcbERCs872VCVb35znGk6jhYUsRc4rvm"
}
,
"label"
:
"test"
}
]
}
```
-
从genesis账户向test账户发送转账交易,具体参考
<a
href=
"https://chain.33.cn/document/80#1.4.2%20%E5%8F%91%E9%80%81%E8%BD%AC%E8%B4%A6%E4%BA%A4%E6%98%93"
>
这里
</a>
,执行结果演示如下:
```
shell
./chain33-cli send bty transfer
-a
1000
-t
1GqcbERCs872VCVb35znGk6jhYUsRc4rvm
-n
"first transfer"
-k
1CbEVT9RnM5oZhWMj4fxUrJX94VtRotzvs
0xb545a3b856105476e0fc29901ca0d0d6af3fe0fa2b6466d6fb3c2e2bc0392f7d
```
-
查询交易结果,具体参考
<a
href=
"https://chain.33.cn/document/80#1.4.3%20%E6%9F%A5%E8%AF%A2%E4%BA%A4%E6%98%93%E7%BB%93%E6%9E%9C"
>
这里
</a>
,执行结果演示如下:
```
shell
./chain33-cli tx query
-s
0xb545a3b856105476e0fc29901ca0d0d6af3fe0fa2b6466d6fb3c2e2bc0392f7d
{
"txs"
:
[
{
"tx"
:
{
"execer"
:
"coins"
,
"payload"
:
{
"transfer"
:
{
"cointoken"
:
""
,
"amount"
:
"100000000000"
,
"note"
:
"first transfer"
,
"to"
:
"1GqcbERCs872VCVb35znGk6jhYUsRc4rvm"
}
,
"ty"
: 1
}
,
............
"fee"
:
"0.0010"
,
"expire"
: 1550732383,
"nonce"
: 7996280053722898816,
"to"
:
"1GqcbERCs872VCVb35znGk6jhYUsRc4rvm"
,
"from"
:
"1CbEVT9RnM5oZhWMj4fxUrJX94VtRotzvs"
,
"hash"
:
"0xb545a3b856105476e0fc29901ca0d0d6af3fe0fa2b6466d6fb3c2e2bc0392f7d"
}
,
............
"height"
: 3,
"index"
: 0,
"blocktime"
: 1550732269,
"amount"
:
"1000.0000"
,
"fromaddr"
:
"1CbEVT9RnM5oZhWMj4fxUrJX94VtRotzvs"
,
"actionname"
:
"transfer"
,
"assets"
:
[
{
"exec"
:
"coins"
,
"symbol"
:
"BTY"
,
"amount"
: 100000000000
}
]
}
]
}
```
-
查询节点信息,高度相同表示区块链工作正常.
```
shell
./chain33-cli net peer_info
{
"peers"
:
[
{
"addr"
:
"192.168.0.137"
,
"port"
: 13802,
"name"
:
"031a4b88621e4dbf948d8659a7ae4ae254ae881b12d6cf36955e30f6ad32df04df"
,
"mempoolSize"
: 0,
"self"
:
false
,
"header"
:
{
"version"
: 0,
"parentHash"
:
"0x4593f41033c40f4068c45ef1cdda309434a2a7f8095be3dfbfc695b83bc51c35"
,
"txHash"
:
"0x0000000000000000000000000000000000000000000000000000000000000000"
,
"stateHash"
:
"0xd031c20b2adb75dd42536333cf8d2eed7e6b8a20693971076a446106630a1178"
,
"height"
: 4,
"blockTime"
: 1550732390,
"txCount"
: 0,
"hash"
:
"0xb469c9f4e03e3bdff903f23515ab26f9cc3616542589f989f5fe04148ec8f6e8"
,
"difficulty"
: 0
}
}
,
{
"addr"
:
"192.168.0.116"
,
"port"
: 13802,
"name"
:
"03d7981d1c5f7e2497ddfb30b3910881748cddc900508488485e327f487d2075f0"
,
"mempoolSize"
: 0,
"self"
:
false
,
"header"
:
{
"version"
: 0,
"parentHash"
:
"0x4593f41033c40f4068c45ef1cdda309434a2a7f8095be3dfbfc695b83bc51c35"
,
"txHash"
:
"0x0000000000000000000000000000000000000000000000000000000000000000"
,
"stateHash"
:
"0xd031c20b2adb75dd42536333cf8d2eed7e6b8a20693971076a446106630a1178"
,
"height"
: 4,
"blockTime"
: 1550732390,
"txCount"
: 0,
"hash"
:
"0xb469c9f4e03e3bdff903f23515ab26f9cc3616542589f989f5fe04148ec8f6e8"
,
"difficulty"
: 0
}
}
,
{
"addr"
:
"192.168.0.107"
,
"port"
: 13802,
"name"
:
"02eaed19dd47a011022052ba9a6f923f60ff00b5bb338d558ea9ffad0ea122b584"
,
"mempoolSize"
: 0,
"self"
:
false
,
"header"
:
{
"version"
: 0,
"parentHash"
:
"0x4593f41033c40f4068c45ef1cdda309434a2a7f8095be3dfbfc695b83bc51c35"
,
"txHash"
:
"0x0000000000000000000000000000000000000000000000000000000000000000"
,
"stateHash"
:
"0xd031c20b2adb75dd42536333cf8d2eed7e6b8a20693971076a446106630a1178"
,
"height"
: 4,
"blockTime"
: 1550732390,
"txCount"
: 0,
"hash"
:
"0xb469c9f4e03e3bdff903f23515ab26f9cc3616542589f989f5fe04148ec8f6e8"
,
"difficulty"
: 0
}
}
,
{
"addr"
:
"192.168.0.105"
,
"port"
: 13802,
"name"
:
"039a54c0b5fa2d0de1bc263796acd08316e535af2c40568f41459d1804560cc612"
,
"mempoolSize"
: 0,
"self"
:
true
,
"header"
:
{
"version"
: 0,
"parentHash"
:
"0x4593f41033c40f4068c45ef1cdda309434a2a7f8095be3dfbfc695b83bc51c35"
,
"txHash"
:
"0x0000000000000000000000000000000000000000000000000000000000000000"
,
"stateHash"
:
"0xd031c20b2adb75dd42536333cf8d2eed7e6b8a20693971076a446106630a1178"
,
"height"
: 4,
"blockTime"
: 1550732390,
"txCount"
: 0,
"hash"
:
"0xb469c9f4e03e3bdff903f23515ab26f9cc3616542589f989f5fe04148ec8f6e8"
,
"difficulty"
: 0
}
}
]
}
```
联盟链配置.md
View file @
10b0abb5
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment