1 Ubuntu users can choose how to install geth Online by executing the following commands in the terminal:
$ sudo add-apt-repository-y ppa:ethereum/ethereum
$ sudo apt-get update
$ sudo apt-get install Ethereum
After the installation is complete, use Geth Help to verify that the installation is successful
ubuntu@i-umw7lzvn:~$ Geth help
NAME:
geth-the go-ethereum command line interface
Copyright 2013-2017 the Go -ethereum Authors
USAGE:
geth [options] command [command options] [arguments ...]
VERSION:
**1.6.6-stable-10a45cb5**
COMMANDS:
init Bootstrap and initialize a new Genesis block
Import Import a blockchain file
"'
2 Following the start of the private Ethereum network : The Ethereum node can link each other to meet 1) the same protocol version 2) the same networkid, so the most convenient way to build a private network is through the Geth command in the –networkid option, Set a networkid that is different from the main network (the Networkid of the main network is 1), which is also the official recommendation
ubuntu@i-umw7lzvn:~$ mkdir private-geth
ubuntu@i-umw7lzvn:~$ cd private-geth/
Century block file, is a JSON-formatted file:
Vim Genesis.json
Ethereum supports custom creation blocks, to run a private chain, we need to define our own creation block, and the creation block information is written in a JSON-formatted configuration file. First, save the following to a JSON file, such as Genesis.json (which involves permissions issues so go to root)
root@i-nhmyceuh:/home/ubuntu/private-geth# vim Genesis.json
{"
config": {
"Chainid":
" Homesteadblock ": 0,
" Eip155block ": 0,
" Eip158block ": 0
},
" Coinbase ":" 0x0000000000000000000000000000000000000000 ",
" difficulty ":" 0x40000 ",
" Extradata ":" ",
" Gaslimit ":" 0xFFFFFFFF ",
" nonce ":" 0x0000000000000042 ",
" Mixhash ":" 0x0000000000000000000000000000000000000000000000000000000000000000 ",
" Parenthash ":" 0x0000000000000000000000000000000000000000000000000000000000000000 ",
" timestamp ":" 0x00 ",
" Alloc ": {}
}
Once the creation block configuration file is ready, you need to initialize the blockchain and write the creation block information above into the blockchain. The first is to create a new directory to hold the blockchain data, assuming that the new data directory is ~/private-geth/app/chain,genesis.json saved in ~/private-geth, the directory structure should be this:
Private-geth
├──app
└──genesis.json
Next go into Private-geth and execute the initialization command:
root@i-nhmyceuh:/home/ubuntu/private-geth# geth--datadir data0 init genesis.json
WARN [06-26|10:54:33] No Etherbase set and no accounts found as default
INFO [06-26|10:54:33] Allocated cache and file handles Database=/ho Me/ubuntu/private-geth/data0/geth/chaindata cache=16 handles=16
INFO [06-26|10:54:33] Writing Custom Genesis Block
INFO [06-26|10:54:33] successfully wrote Genesis State Database=chaindata hash=a0e580 echnical 5e82e
INFO [06-26|10:54:33] Allocated cache and file handles database=/home/ubuntu/private-geth/data0/geth/ Lightchaindata cache=16 handles=16
info [06-26|10:54:33] Writing custom Genesis block
INFO [06-26|10:54:33] * *successfully** wrote Genesis State Database=lightchaindata hash=a0e580 echnical 5e82e
After the initialization succeeds, the Geth and KeyStore two folders are generated in the data Catalog App/cahin, and the directory structure is as follows:
root@i-nhmyceuh:/home/ubuntu/private-geth# CD data0/
root@i-nhmyceuh:/home/ubuntu/private-geth/data0# ll
Total
drwx------4 root root 4096 June 10:54./
drwxr-xr-x 3 root root 4096 June 26 10:54. /
drwxr-xr-x 4 root root 4096 June 10:54 geth/
drwx------2 root root 4096 June-10:54 Keystore/
Where Geth/chaindata is stored in block data, KeyStore is the account data.
Start the node, plus the console indicates that the command line is enabled after startup:
root@i-nhmyceuh:/home/ubuntu/private-geth/data0# Geth--datadir/data0--networkid one console WARN [06-26|10:56:58] No Etherbase set and no accounts found as default INFO [06-26|10:56:58] starting Peer-to-peer node Instance=ge th/v1.6.6-stable-10a45cb5/linux-amd64/go1.8.1 INFO [06-26|10:56:58] Allocated cache and file handles Database=/hom E/ubuntu/private-geth/data0/data0/geth/chaindata cache=128 handles=1024 INFO [06-26|10:56:58] Writing default Main-net Genesis Block INFO [06-26|10:56:59] initialised chain configuration config= "{chainid:1 homestead:1150 dao:1920000 daosupport:true eip150:2463000 eip155:2675000 eip158:2675000 metropolis:9223372036854775807 Engine: Ethash} "INFO [06-26|10:56:59] Disk storage enabled for Ethash caches Dir=/home/ubuntu/private-geth/data0/data0/geth/et Hash count=3 INFO [06-26|10:56:59] Disk storage enabled for Ethash DAGs Dir=/root/.ethash count=2 WARN [06-26|10:56:59] UPgrading DB Log Bloom Bins Info [06-26|10:56:59] bloom-bin upgrade completed elapsed=71.646 Lu s INFO [06-26|10 : 56:59] initialising Ethereum protocol versions= "[[+]]" network=11 INFO [06-26|10:56:59] Loaded most recent lo Cal Header number=0 hash=d4e567 echnical b8fa3 td=17179869184 INFO [06-26|10:56:59] Loaded most recent local full block number=0 hash=d4e567 echnical b8fa3 td=17179869184 INFO [06-26|10:56:59] Loaded most recent local fast block number=0 have h=d4e567 echnical b8fa3 td=17179869184 info [06-26|10:56:59] starting Peer Networking info [06-26|10:57:01] UDP listener up self=enode://51ebb32b131ac52c9caca88396a3d0f77f89bd4cfceb9f59bca6615557d5f7b6333cdfad20ec2d1bb26feb211e 0abf8ba11a1a1e9c3f4d2987aca4be7e855020@[::]:30303 INFO [06-26|10:57:01] rlpx listener up Self=enod e:// 51ebb32b131ac52c9caca88396a3d0f77f89bd4cfceb9f59bca6615557d5f7b6333cdfad20ec2d1bb26feb211e0abf8ba11a1a1e9c3f4d2987aca4be7 e855020@[::]:30303 inFO [06-26|10:57:01] IPC endpoint opened:/HOME/UBUNTU/PRIVATE-GETH/DATA0/DATA0/GETH.IPC Welcome to the Geth JavaScript Co
nsole! instance:geth/v1.6.6-stable-10a45cb5/linux-amd64/go1.8.1 modules:admin:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0 "" View account > eth.accounts [] Create account password for 123 > Personal.newaccount ("123") " 0x04db853fe43494022f7f961091c1764709aa5f87 "> INFO [06-26|10:57:57] New wallet appeared url=keysto Re:///home/ubuntu/private echnical? [32mstatus=locked Start mining > Miner.start () info [06-26|10:14:06] Updated Mining threads threads=0 INFO [0
6-26|10:14:06] Transaction Pool price threshold updated price=18000000000 INFO [06-26|10:14:06] starting mining operation Null > Info [06-26|10:14:06] Commit new mining work number=1 txs=0 uncles=0 elapsed=444.165 lu s INFO [06-26|10:14:10]
Generating DAG in progress