Geth的命令列介紹

左良發表於2017-12-12

前言

本文主要是分類的方式將geth的命令列引數,屬性進行介紹和解釋,如有翻譯,理解上的偏差歡迎討論交流。

總覽

$ 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.7.3-stable
   
COMMANDS:
   account     Manage accounts
   attach      Start an interactive JavaScript environment (connect to node)
   bug         opens a window to report a bug on the geth repo
   console     Start an interactive JavaScript environment
   copydb      Create a local chain from a target chaindata folder
   dump        Dump a specific block from storage
   dumpconfig  Show configuration values
   export      Export blockchain into file
   import      Import a blockchain file
   init        Bootstrap and initialize a new genesis block
   js          Execute the specified JavaScript files
   license     Display license information
   makecache   Generate ethash verification cache (for testing)
   makedag     Generate ethash mining DAG (for testing)
   monitor     Monitor and visualize node metrics
   removedb    Remove blockchain and state databases
   version     Print version numbers
   wallet      Manage Ethereum presale wallets
   help, h     Shows a list of commands or help for one command
   
ETHEREUM OPTIONS:
  --config value                        TOML configuration file
  --datadir "/home/karalabe/.ethereum"  Data directory for the databases and keystore
  --keystore                            Directory for the keystore (default = inside the datadir)
  --nousb                               Disables monitoring for and managing USB hardware wallets
  --networkid value                     Network identifier (integer, 1=Frontier, 2=Morden (disused), 3=Ropsten, 4=Rinkeby) (default: 1)
  --testnet                             Ropsten network: pre-configured proof-of-work test network
  --rinkeby                             Rinkeby network: pre-configured proof-of-authority test network
  --syncmode "fast"                     Blockchain sync mode ("fast", "full", or "light")
  --ethstats value                      Reporting URL of a ethstats service (nodename:secret@host:port)
  --identity value                      Custom node name
  --lightserv value                     Maximum percentage of time allowed for serving LES requests (0-90) (default: 0)
  --lightpeers value                    Maximum number of LES client peers (default: 20)
  --lightkdf                            Reduce key-derivation RAM & CPU usage at some expense of KDF strength
  
DEVELOPER CHAIN OPTIONS:
  --dev               Ephemeral proof-of-authority network with a pre-funded developer account, mining enabled
  --dev.period value  Block period to use in developer mode (0 = mine only if transaction pending) (default: 0)
  
ETHASH OPTIONS:
  --ethash.cachedir                         Directory to store the ethash verification caches (default = inside the datadir)
  --ethash.cachesinmem value                Number of recent ethash caches to keep in memory (16MB each) (default: 2)
  --ethash.cachesondisk value               Number of recent ethash caches to keep on disk (16MB each) (default: 3)
  --ethash.dagdir "/home/karalabe/.ethash"  Directory to store the ethash mining DAGs (default = inside home folder)
  --ethash.dagsinmem value                  Number of recent ethash mining DAGs to keep in memory (1+GB each) (default: 1)
  --ethash.dagsondisk value                 Number of recent ethash mining DAGs to keep on disk (1+GB each) (default: 2)
  
TRANSACTION POOL OPTIONS:
  --txpool.nolocals            Disables price exemptions for locally submitted transactions
  --txpool.journal value       Disk journal for local transaction to survive node restarts (default: "transactions.rlp")
  --txpool.rejournal value     Time interval to regenerate the local transaction journal (default: 1h0m0s)
  --txpool.pricelimit value    Minimum gas price limit to enforce for acceptance into the pool (default: 1)
  --txpool.pricebump value     Price bump percentage to replace an already existing transaction (default: 10)
  --txpool.accountslots value  Minimum number of executable transaction slots guaranteed per account (default: 16)
  --txpool.globalslots value   Maximum number of executable transaction slots for all accounts (default: 4096)
  --txpool.accountqueue value  Maximum number of non-executable transaction slots permitted per account (default: 64)
  --txpool.globalqueue value   Maximum number of non-executable transaction slots for all accounts (default: 1024)
  --txpool.lifetime value      Maximum amount of time non-executable transaction are queued (default: 3h0m0s)
  
PERFORMANCE TUNING OPTIONS:
  --cache value            Megabytes of memory allocated to internal caching (min 16MB / database forced) (default: 128)
  --trie-cache-gens value  Number of trie node generations to keep in memory (default: 120)
  
ACCOUNT OPTIONS:
  --unlock value    Comma separated list of accounts to unlock
  --password value  Password file to use for non-interactive password input
  
API AND CONSOLE OPTIONS:
  --rpc                  Enable the HTTP-RPC server
  --rpcaddr value        HTTP-RPC server listening interface (default: "localhost")
  --rpcport value        HTTP-RPC server listening port (default: 8545)
  --rpcapi value         API's offered over the HTTP-RPC interface
  --ws                   Enable the WS-RPC server
  --wsaddr value         WS-RPC server listening interface (default: "localhost")
  --wsport value         WS-RPC server listening port (default: 8546)
  --wsapi value          API's offered over the WS-RPC interface
  --wsorigins value      Origins from which to accept websockets requests
  --ipcdisable           Disable the IPC-RPC server
  --ipcpath              Filename for IPC socket/pipe within the datadir (explicit paths escape it)
  --rpccorsdomain value  Comma separated list of domains from which to accept cross origin requests (browser enforced)
  --jspath loadScript    JavaScript root path for loadScript (default: ".")
  --exec value           Execute JavaScript statement
  --preload value        Comma separated list of JavaScript files to preload into the console
  
NETWORKING OPTIONS:
  --bootnodes value     Comma separated enode URLs for P2P discovery bootstrap (set v4+v5 instead for light servers)
  --bootnodesv4 value   Comma separated enode URLs for P2P v4 discovery bootstrap (light server, full nodes)
  --bootnodesv5 value   Comma separated enode URLs for P2P v5 discovery bootstrap (light server, light nodes)
  --port value          Network listening port (default: 30303)
  --maxpeers value      Maximum number of network peers (network disabled if set to 0) (default: 25)
  --maxpendpeers value  Maximum number of pending connection attempts (defaults used if set to 0) (default: 0)
  --nat value           NAT port mapping mechanism (any|none|upnp|pmp|extip:<IP>) (default: "any")
  --nodiscover          Disables the peer discovery mechanism (manual peer addition)
  --v5disc              Enables the experimental RLPx V5 (Topic Discovery) mechanism
  --netrestrict value   Restricts network communication to the given IP networks (CIDR masks)
  --nodekey value       P2P node key file
  --nodekeyhex value    P2P node key as hex (for testing)
  
MINER OPTIONS:
  --mine                    Enable mining
  --minerthreads value      Number of CPU threads to use for mining (default: 8)
  --etherbase value         Public address for block mining rewards (default = first account created) (default: "0")
  --targetgaslimit value    Target gas limit sets the artificial target gas floor for the blocks to mine (default: 4712388)
  --gasprice "18000000000"  Minimal gas price to accept for mining a transactions
  --extradata value         Block extra data set by the miner (default = client version)
  
GAS PRICE ORACLE OPTIONS:
  --gpoblocks value      Number of recent blocks to check for gas prices (default: 10)
  --gpopercentile value  Suggested gas price is the given percentile of a set of recent transaction gas prices (default: 50)
  
VIRTUAL MACHINE OPTIONS:
  --vmdebug  Record information useful for VM and contract debugging
  
LOGGING AND DEBUGGING OPTIONS:
  --metrics                 Enable metrics collection and reporting
  --fakepow                 Disables proof-of-work verification
  --nocompaction            Disables db compaction after import
  --verbosity value         Logging verbosity: 0=silent, 1=error, 2=warn, 3=info, 4=debug, 5=detail (default: 3)
  --vmodule value           Per-module verbosity: comma-separated list of <pattern>=<level> (e.g. eth/*=5,p2p=4)
  --backtrace value         Request a stack trace at a specific logging statement (e.g. "block.go:271")
  --debug                   Prepends log messages with call-site location (file and line number)
  --pprof                   Enable the pprof HTTP server
  --pprofaddr value         pprof HTTP server listening interface (default: "127.0.0.1")
  --pprofport value         pprof HTTP server listening port (default: 6060)
  --memprofilerate value    Turn on memory profiling with the given rate (default: 524288)
  --blockprofilerate value  Turn on block profiling with the given rate (default: 0)
  --cpuprofile value        Write CPU profile to the given file
  --trace value             Write execution trace to the given file
  
WHISPER (EXPERIMENTAL) OPTIONS:
  --shh                       Enable Whisper
  --shh.maxmessagesize value  Max message size accepted (default: 1048576)
  --shh.pow value             Minimum POW accepted (default: 0.2)
  
DEPRECATED OPTIONS:
  --fast   Enable fast syncing through state downloads
  --light  Enable light client mode
  
MISC OPTIONS:
  --help, -h  show help
  

COPYRIGHT:
   Copyright 2013-2017 The go-ethereum Authors
複製程式碼

命令

   account     管理賬戶
   attach      啟動一個互動式的JavaScript環境,(通過連線到遠端節點) 
   bug         開啟一個視窗來反饋bug
   console     啟動一個互動式的JavaScript環境
   copydb      複製一個datadir,需要指定另一個datadir的路徑
   dump        從區塊鏈上dump指定的區塊
   dumpconfig  顯示配置資訊
   export      匯出區塊資訊到檔案
   import      從檔案匯入區塊資訊
   init        初始化一個新的創世區塊
   js          執行指定的js檔案
   license     顯示license資訊
   makecache   生成 ethash驗證資訊快取?(用於測試) 
   makedag     生成ethash挖礦DAG(用於測試)
   monitor     監控,顯示節點指標  
   removedb    刪除區塊鏈和狀態資料庫
   version     列印版本號
   wallet      管理以太坊錢包
   help, h     顯示所有的命令,和幫助資訊
複製程式碼

以太坊選項

ETHEREUM OPTIONS:
  --config value                        TOML 配置檔案
  --datadir "/home/karalabe/.ethereum"  制定datadir位置
  --keystore                            制定keystore位置(預設在datadir裡面)
  --nousb                               關閉監控usb錢包
  --networkid value                     網路識別符號(數字,1=Frontier, 2=Morden (沒有使用), 3=Ropsten, 4=Rinkeby)(預設: 1)
  --testnet                             測試網路: 預設為工作量證明模式的測試網路
  --rinkeby                             測試網路: 預設為權益證明模式的測試網路
  --syncmode "fast"                     區塊同步模式('fast','full',"light")
  --ethstats value                      ethstats伺服器的URL(nodename:secret@host:port)
  --identity value                      自定義節點名稱
  --lightserv value                     最大允許的輕量級節點服務百分比 requests (0-90) (default: 0)
  --lightpeers value                    最多允許接入的輕量級節點數量(預設:20
  --lightkdf                            減少祕鑰生成時 記憶體和cup的使用量?
複製程式碼

開發者選項

DEVELOPER CHAIN OPTIONS:
  --dev                啟動一個 權益證明 方式的網路,預先存一筆錢到開發者賬戶,並且啟動挖礦 
  --dev.period value   區塊處理時間?,在開發模式下(0=事務被處理時挖礦) (預設: 0)
複製程式碼

ETHASH演算法相關選項

部分我也瞭解的不清楚的,以後再翻譯,或你們指導下我。

ETHASH OPTIONS:
  --ethash.cachedir                         儲存ethash驗證快取的目錄(目錄:在datadir裡面 
  --ethash.cachesinmem value                ethash 儲存在記憶體中的數量,每16mb(預設2) 
  --ethash.cachesondisk value               快取在磁碟的ethash caches的百分比(預設: 3) 
  --ethash.dagdir "/home/karalabe/.ethash"  儲存ethash挖礦DAG的目錄地址,預設(home目錄) 
  --ethash.dagsinmem value                  Number of recent ethash mining DAGs to keep in memory (1+GB each) (default: 1)
  --ethash.dagsondisk value                 Number of recent ethash mining DAGs to keep on disk (1+GB each) (default: 2)
複製程式碼

事務池相關選項

TRANSACTION POOL OPTIONS:
  --txpool.nolocals             禁止對於本地提交的交易的價格豁免
  --txpool.journal value       本地事務磁碟日誌(用於磁碟重啟?)Disk journal for local transaction to survive node restarts (default: "transactions.rlp")
  --txpool.rejournal value     Time interval to regenerate the local transaction journal (default: 1h0m0s)
  --txpool.pricelimit value    Minimum gas price limit to enforce for acceptance into the pool (default: 1)
  --txpool.pricebump value     Price bump percentage to replace an already existing transaction (default: 10)
  --txpool.accountslots value  Minimum number of executable transaction slots guaranteed per account (default: 16)
  --txpool.globalslots value   Maximum number of executable transaction slots for all accounts (default: 4096)
  --txpool.accountqueue value  Maximum number of non-executable transaction slots permitted per account (default: 64)
  --txpool.globalqueue value   所有賬戶最大非執行事務槽數量  (預設: 1024)
  --txpool.lifetime value      最大非執行的事務佇列時間總量 (預設: 3h0m0s)
複製程式碼

效能調優選項

PERFORMANCE TUNING OPTIONS:
  --cache value            分配多少給內部快取(兆位元組) (最小 16MB / 資料庫要求) (預設: 128)
  --trie-cache-gens value  儲存在記憶體中的 trie node數量 (預設: 120)
複製程式碼

賬戶相關選項

ACCOUNT OPTIONS:
  --unlock value    賬戶解鎖,只有這個引數需要互動式輸入密碼
  --password value  賬戶的密碼,非互動式輸入
複製程式碼

控制檯API相關選項

API AND CONSOLE OPTIONS:
  --rpc                  啟動http-rpc 服務 
  --rpcaddr value        http rpc 位於哪一個地址(ip) (預設: "localhost")
  --rpcport value        http rpc 位於哪一個埠 (預設: 8545)
  --rpcapi value         HTTP-RPC 提供哪些服務(可選:personal,db,eth,net,web3等)
  --ws                   啟動 WS-RPC 服務
  --wsaddr value         WS-RPC 位於哪一個地址(ip) (預設: "localhost")
  --wsport value         WS-RPC 位於哪一個埠 (預設: 8546)
  --wsapi value          API's 提供哪些服務(可選:personal,db,eth,net,web3等)
  --wsorigins value      允許哪些域可以以訪問websockts服務
  --ipcdisable           禁止 IPC-RPC 服務(windows多節點可選)
  --ipcpath              ipc服務 檔案/管道地址  (轉譯後的)
  --rpccorsdomain value  prc服務允許的跨域訪問的地址。
  --jspath loadScript    執行本地js檔案的路徑 (預設 .)
  --exec value           執行JavaScript 
  --preload value        預載入到控制檯的JavaScript檔案列表(逗號分隔)
複製程式碼

網路相關選項

NETWORKING OPTIONS:
  --bootnodes value      用於P2P發現引導的節點(啟動節點),用逗號隔開(輕量級服務使用v4+v5代替) Comma separated enode URLs for P2P discovery bootstrap (set v4+v5 instead for light servers)
  --bootnodesv4 value   Comma separated enode URLs for P2P v4 discovery bootstrap (light server, full nodes)
  --bootnodesv5 value   Comma separated enode URLs for P2P v5 discovery bootstrap (light server, light nodes)
  --port value          網路監聽埠  (預設: 30303)
  --maxpeers value      最大節點數(設定為0時,網路被禁用)預設25 
  --maxpendpeers value  最大連線節點數,預設0 
  --nat value           NAT埠對映機制(any|none|upnp|pmp|extip:<IP>) (預設: "any")
  --nodiscover          禁止節點發現機制(手工新增)
  --v5disc              Enables the experimental RLPx V5 (Topic Discovery) mechanism
  --netrestrict value   Restricts network communication to the given IP networks (CIDR masks)
  --nodekey value       P2P 節點 祕鑰檔案
  --nodekeyhex value    十六進位制的P2P節點金鑰(用於測試)
複製程式碼

挖礦相關選項

MINER OPTIONS:
  --mine                    啟動挖礦
  --minerthreads value      挖礦時啟動的CPU執行緒數量(預設:8)
  --etherbase value         挖礦獎勵賬戶(預設account[0])無賬號時預設0 
  --targetgaslimit value    gas限制,低於該值的事務無法被記錄 (預設:4712388) 
  --gasprice "18000000000"  挖礦接受交易的最低gas價格
  --extradata value         礦工對區塊設定的擴充套件資料內容,預設客戶端版本號 
複製程式碼

GAS價格相關選項

GAS PRICE ORACLE OPTIONS:
--gpoblocks value      通過最近的塊數量來計算gas價格  (預設: 10)
--gpopercentile value  參考近期交易區塊gas價格的百分比來計算gas價格 (預設: 50)
複製程式碼

虛擬機器相關選項

VIRTUAL MACHINE OPTIONS:
  --vmdebug  記錄VM和合約相關的debug資訊 
複製程式碼

日誌和除錯相關選項

LOGGING AND DEBUGGING OPTIONS:
  --metrics                 啟動指標收集和報告 
  --fakepow                 關閉POW工作量證明驗證 
  --nocompaction            輸入框匯入後禁止壓縮? Disables db compaction after import
  --verbosity value         日誌等級  0=安靜, 1=錯誤, 2=警告, 3=info, 4=debug, 5=詳細 (預設: 3)
  --vmodule value           Per-module verbosity: comma-separated list of <pattern>=<level> (e.g. eth/*=5,p2p=4)
  --backtrace value         Request a stack trace at a specific logging statement (e.g. "block.go:271")
  --debug                   突出顯示呼叫位置日誌(檔名及行號)
  --pprof                   啟動pprof http服務(一種go語言的除錯伺服器) 
  --pprofaddr value         pprof HTTP 服務監聽ip (預設: "127.0.0.1")
  --pprofport value         pprof HTTP 服務監聽埠 (預設: 6060)
  --memprofilerate value    Turn on memory profiling with the given rate (default: 524288)
  --blockprofilerate value  Turn on block profiling with the given rate (default: 0)
  --cpuprofile value        將cpuWrite CPU profile to the given file
  --trace value             將錯誤資訊寫給定的檔案中
複製程式碼

WHISPER相關選項

WHISPER 是一種資訊檢索協議,它允許節點間直接以一種安全的形式互發資訊,並對第三方組織窺探者隱藏傳送者和接收者的資訊。 引用:

WHISPER (EXPERIMENTAL) OPTIONS:
  --shh                       啟動 Whisper
  --shh.maxmessagesize value  最大接收的訊息大小 (預設: 1048576)
  --shh.pow value             可接受的最小的POW (預設值: 0.2)
複製程式碼

被棄用的選項

DEPRECATED OPTIONS:
  --fast   開啟快速同步
  --light   啟用輕客戶端模式
複製程式碼

幫助和版權

MISC OPTIONS:
  --help, -h  顯示幫助
COPYRIGHT:
   Copyright 2013-2017 The go-ethereum Authors
複製程式碼

參考了http://www.h3399.cn/201711/201789.html的翻譯內容,加上自己的一些理解,無法做到信雅達,但求多交流指正。

Command-Line-Options

以太坊客戶端Geth命令用法-引數詳解

相關文章