##Block[1]
!sudo apt-get update
!sudo apt-get install software-properties-common
!sudo add-apt-repository -y ppa:ethereum/ethereum
!sudo add-apt-repository -y ppa:ethereum/ethereum-dev
!sudo apt-get update
!sudo apt-get install ethereum
!geth -h
/home/[YOUR_NAME]/eth
##Block[2]
cd /
##Block[3]
cd home
##Block[4]
mkdir zzy
##Block[5]
cd zzy
##Block[6]
mkdir eth
##Block[7]
cd eth
##Block[8]
%%writefile genesis.json
{
"config": {
"chainId": 666,
"homesteadBlock": 0,
"eip150Block": 0,
"eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"eip155Block": 0,
"eip158Block": 0,
"byzantiumBlock": 0,
"constantinopleBlock": 0,
"petersburgBlock": 0,
"istanbulBlock": 0,
"ethash": {
}
},
"nonce": "0x0",
"timestamp": "0x5ddf8f3e",
"extraData": "0x0000000000000000000000000000000000000000000000000000000000000000",
"gasLimit": "0x47b760",
"difficulty": "0x00002",
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0x0000000000000000000000000000000000000000",
"alloc": {
},
"number": "0x0",
"gasUsed": "0x0",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
}
tmux
并准备多终端操作# block[9]
!sudo apt-get install tmux
fullnode1
的终端窗口。# blcok[10]
!tmux new -s fullnode1
'''通过创世块准备创建文件夹fullnode1'''
#geth --datadir fullnode1 --networkid 20140628 --rpc --rpccorsdomain "*" init ./genesis.json
'''创建完全链fullnode1并放置于端口16333 rpc端口为8546 rpc地址为0.0.0.0'''
'''创可以使其他的链能过连接上''
#geth --syncmode "full" --rpcaddr 0.0.0.0 --datadir fullnode1 --networkid 20140628 --rpc --rpccorsdomain "*" --nodiscover --port 16333 --rpcport 8546 console
'''-----下面只是供测试使用------'''
#personal.newAccount("123")
#eth.coinbase
#eth.accounts
#[Stop the block]
终止
这个区块的运行,它仍然会在后台工作。tmux
运行了哪些终端# block[11]
!tmux ls
fullnode1: 1 windows (created Sat Mar 20 09:14:15 2021) [80x23]
enode
供第一个节点添加peer# block[12]
!tmux new -s fullnode2
#geth --datadir fullnode2 --networkid 20140628 --rpc --rpccorsdomain "*" init ./genesis.json
#geth --syncmode "full" --rpcaddr 0.0.0.0 --datadir fullnode2 --networkid 20140628 --rpc --rpccorsdomain "*" --nodiscover --port 16334 --rpcport 8547 console
#admin.nodeInfo.enode
## [get output:"enode://accdbb60692a8fcc149e2de2d9727c11bbeea46c5ea11f94a81be8f838f81d26c0311c02eb4b0c4865332e4f567ac2816ecf991c14350e498a64cb71c08f063d@127.0.0.1:16334?discport=0"]
## [Stop the block]
fullnode1
并添加fullnode2
作为peer# block[13]
!tmux attach -t fullnode1
#admin.addPeer("enode://accdbb60692a8fcc149e2de2d9727c11bbeea46c5ea11f94a81be8f838f81d26c0311c02eb4b0c4865332e4f567ac2816ecf991c14350e498a64cb71c08f063d@127.0.0.1:16334?discport=0")
#admin.peers
## [Stop the block]
net.peerCount
,则会返回一个1
,表明已经成功添加了。fullnode3
# block[14]
!tmux new -s fullnode3
#geth --datadir fullnode3 --networkid 20140628 --rpc --rpccorsdomain "*" init ./genesis.json
#geth --syncmode "full" --rpcaddr 0.0.0.0 --datadir fullnode3 --networkid 20140628 --rpc --rpccorsdomain "*" --nodiscover --port 16335 --rpcport 8548 console
#admin.nodeInfo.enode
##[get output:"enode://466572b8a5953ad4b67a85cdfc2739fac6b7c62f8720fc3ef25d41078069f4a7782a5d01914b4088cc98dc5f59ee38bc711edcc8839ed805e8a539149403c33a@127.0.0.1:16335?discport=0"]
## [Stop the block]
lightnode1
light.sever
这一个参数,本文轻节点占总共的25%
(三全一轻),所以你需要让你的值大于25
。# block[14]
!tmux new -s lightnode1
#geth --datadir lightnode1 --networkid 20140628 --rpc --rpccorsdomain "*" init ./genesis.json
#geth --light.serve 50 --rpcaddr 0.0.0.0 --datadir lightnode1 --networkid 20140628 --rpc --rpccorsdomain "*" --nodiscover --port 16336 --rpcport 8549 console
#admin.nodeInfo.enode
##[get output:"enode://60d3936ac28149ae94fa3cb446d1a14902356455bf9fec0b2024a738eb97c1b276ce9ffe0acf3438d856cbf8f30e9fec130b753aef52bc824dd31db33cbac426@127.0.0.1:16336?discport=0"]
## [Stop the block]
# block [15]
!tmux attach -t fullnode1
#admin.addPeer("enode://466572b8a5953ad4b67a85cdfc2739fac6b7c62f8720fc3ef25d41078069f4a7782a5d01914b4088cc98dc5f59ee38bc711edcc8839ed805e8a539149403c33a@127.0.0.1:16335?discport=0")
#admin.addPeer("enode://967821ce21d2ddefef3575558f83ec4161eb9e00b41041d5ac90e2c854cc88b2a072a439b938d528e0849e7b737a947cb332dbcd6a07f013bafecb1f7136843a@127.0.0.1:16336?discport=0")
#admin.peers
#net.peerCount