eos在linux上的配置並使用快照進行主網節點快速同步
前言
該eos的安裝並不是對源碼進行編譯,只是單純的在自己的服務器上搭建eos節點並同步主網數據的。所以如果您想要進行源碼編譯安裝eos,可能這篇博客對您的幫助不是很大。
在linux上安裝eos
我在虛擬機上安裝的是ubuntu18.04,並在root目錄下創建了一個eos目錄,以後的所有操作都會在這裏進行,接下來讓我們開始安裝吧:
-
下載安裝包並進行安裝 :參考[https://github.com/EOSIO/eos/blob/master/README.md],如果你之前安裝過eos,在安裝之前需要先卸載它。下面是幾個操作系統的安裝,後面v1.8.5可以更改下載源
Ubuntu 18.04 Package 安裝( 權限不夠前面加上sudo)$ wget https://github.com/eosio/eos/releases/download/v1.8.5/eosio_1.8.5-1-ubuntu-18.04_amd64.deb $ sudo apt install ./eosio_1.8.5-1-ubuntu-18.04_amd64.deb
Ubuntu 16.04 Package 安裝
$ wget https://github.com/eosio/eos/releases/download/v1.8.5/eosio_1.8.5-1-ubuntu-16.04_amd64.deb $ sudo apt install ./eosio_1.8.5-1-ubuntu-16.04_amd64.deb
Ubuntu Package 卸載
$ sudo apt remove eosio
Mac OS X Brew 安裝
$ brew tap eosio/eosio $ brew install eosio
Mac OS X Brew 卸載
$ brew remove eosio
Centos RPM Package 安裝
$ wget https://github.com/eosio/eos/releases/download/v1.8.5/eosio-1.8.5-1.el7.x86_64.rpm $ sudo yum install ./eosio-1.8.5-1.el7.x86_64.rpm
Centos RPM Package 卸載
$ sudo yum remove eosio
安裝好之後,輸入
nodeos -v
看看是否有沒有version,如圖則安裝成功
eos的啓動和簡單命令
1.可以參考大佬寫的博客裏面的詳細的介紹了eos和命令
2.genesis.json 該文件是連接到主網節點的文件,我已經將文件拷貝到/root/eos/ 下了,你可以在linux上創建一個文件重命名之後將下面內容拷貝進去,後續我們會用到他
{
"initial_timestamp": "2018-06-08T08:08:08.888",
"initial_key": "EOS7EarnUhcyYqmdnPon8rm7mBCTnBoot6o7fE2WzjvEX2TdggbL3",
"initial_configuration": {
"max_block_net_usage": 1048576,
"target_block_net_usage_pct": 1000,
"max_transaction_net_usage": 524288,
"base_per_transaction_net_usage": 12,
"net_usage_leeway": 500,
"context_free_discount_net_usage_num": 20,
"context_free_discount_net_usage_den": 100,
"max_block_cpu_usage": 200000,
"target_block_cpu_usage_pct": 1000,
"max_transaction_cpu_usage": 150000,
"min_transaction_cpu_usage": 100,
"max_transaction_lifetime": 3600,
"deferred_trx_expiration_window": 600,
"max_transaction_delay": 3888000,
"max_inline_action_size": 4096,
"max_inline_action_depth": 4,
"max_authority_depth": 6
}
}
3.config.ini :該文件是一些nodeos的配置,文件位置 ,博客最下面會有詳細的文件配置,在這裏先不寫了,要不很佔位置,config.ini默認位置
linux: ~/.local/share/eosio/nodeos/config
mac os : ~/Library/Application Support/eosio/nodeos/config
4.nodeos 命令:這是啓動nodeos組件的命令 ,第一次啓動:
nodeos --data-dir 區塊保存路徑 --genesis-json genesis.json路徑 --config-dir config.ini路徑 --delete-all-blocks
區塊保存路徑:你的區塊數據保存到哪裏,這個數據很大,需要很大的存儲空間
genesis.json路徑:可以配置genesis.json的位置,可以自定義位置,這個第一次啓動需要用
config.ini 路徑:可以定義config.ini的加載路徑,如果沒有--config-dir 則爲默認位置
啓動之後是如下圖片則是啓動成功了
然後 cleos get info
出現下面的狀態則已經接入主鏈
chain_id爲 aca376***** 則是主鏈
停止nodeos 必須用 pkill nodeos
否則會導致異常
用快照快速同步到當前主鏈的節點
1.前提:如果用快照的話 需要將 --data-dir 裏面的blocks、state目錄刪除
2.快照地址:https://eosnode.tools/snapshots
3.下載快照:wget $(wget --quiet "https://eosnode.tools/api/snapshots?limit=1" -O- | jq -r '.data[0].s3') -O snapshot.tar.gz
4.解壓快照:tar xvzf snapshot.tar.gz
快照保存在 當前目錄/snapshots/snapshots-****************.bin
5.同步快照: nodeos --snapshot 快照文件位置 --data-dir 區塊數據指定目錄
這樣就開始進行快照同步了,同步完成之後 cleos get info 可以看到從快照的區塊高度開始同步數據了
6.快照同步完之後,後面啓動nodeos 的話就不需要加 --snapshot 快照文件位置
這個參數了
啓動錢包組件
現在wallet組件和nodeos組件是分離的,如果想調用錢包的數據需要用下面的命令
keosd
ubuntu 沒有root權限的命令前面一律加上 sudo
寫在最後的疑問
現在我用快照同步區塊,當同步100W之後,發現同步越來越慢,希望大佬們看到我的問題能夠留言,謝謝!
config.ini 內容
# blocks-dir = "blocks"
# the location of the protocol_features directory (absolute path or relative to application config dir) (eosio::chain_plugin)
# protocol-features-dir = "protocol_features"
# Pairs of [BLOCK_NUM,BLOCK_ID] that should be enforced as checkpoints. (eosio::chain_plugin)
# checkpoint =
# Override default WASM runtime (eosio::chain_plugin)
# wasm-runtime =
# Override default maximum ABI serialization time allowed in ms (eosio::chain_plugin)
# abi-serializer-max-time-ms = 15000
# Maximum size (in MiB) of the chain state database (eosio::chain_plugin)
# chain-state-db-size-mb = 1024
# Safely shut down node when free space remaining in the chain state database drops below this size (in MiB). (eosio::chain_plugin)
# chain-state-db-guard-size-mb = 128
# Maximum size (in MiB) of the reversible blocks database (eosio::chain_plugin)
# reversible-blocks-db-size-mb = 340
# Safely shut down node when free space remaining in the reverseible blocks database drops below this size (in MiB). (eosio::chain_plugin)
# reversible-blocks-db-guard-size-mb = 2
# Percentage of actual signature recovery cpu to bill. Whole number percentages, e.g. 50 for 50% (eosio::chain_plugin)
# signature-cpu-billable-pct = 50
# Number of worker threads in controller thread pool (eosio::chain_plugin)
# chain-threads = 2
# print contract's output to console (eosio::chain_plugin)
# contracts-console = false
# Account added to actor whitelist (may specify multiple times) (eosio::chain_plugin)
# actor-whitelist =
# Account added to actor blacklist (may specify multiple times) (eosio::chain_plugin)
# actor-blacklist =
# Contract account added to contract whitelist (may specify multiple times) (eosio::chain_plugin)
# contract-whitelist =
# Contract account added to contract blacklist (may specify multiple times) (eosio::chain_plugin)
# contract-blacklist =
# Action (in the form code::action) added to action blacklist (may specify multiple times) (eosio::chain_plugin)
# action-blacklist =
# Public key added to blacklist of keys that should not be included in authorities (may specify multiple times) (eosio::chain_plugin)
# key-blacklist =
# Deferred transactions sent by accounts in this list do not have any of the subjective whitelist/blacklist checks applied to them (may specify multiple times) (eosio::chain_plugin)
# sender-bypass-whiteblacklist =
# Database read mode ("speculative", "head", "read-only", "irreversible").
# In "speculative" mode database contains changes done up to the head block plus changes made by transactions not yet included to the blockchain.
# In "head" mode database contains changes done up to the current head block.
# In "read-only" mode database contains changes done up to the current head block and transactions cannot be pushed to the chain API.
# In "irreversible" mode database contains changes done up to the last irreversible block and transactions cannot be pushed to the chain API.
# (eosio::chain_plugin)
# read-mode = speculative
# Chain validation mode ("full" or "light").
# In "full" mode all incoming blocks will be fully validated.
# In "light" mode all incoming blocks headers will be fully validated; transactions in those validated blocks will be trusted
# (eosio::chain_plugin)
# validation-mode = full
# Disable the check which subjectively fails a transaction if a contract bills more RAM to another account within the context of a notification handler (i.e. when the receiver is not the code of the action). (eosio::chain_plugin)
# disable-ram-billing-notify-checks = false
# Indicate a producer whose blocks headers signed by it will be fully validated, but transactions in those validated blocks will be trusted. (eosio::chain_plugin)
# trusted-producer =
# Database map mode ("mapped", "heap", or "locked").
# In "mapped" mode database is memory mapped as a file.
# In "heap" mode database is preloaded in to swappable memory.
# In "locked" mode database is preloaded, locked in to memory, and optionally can use huge pages.
# (eosio::chain_plugin)
# database-map-mode = mapped
# Optional path for database hugepages when in "locked" mode (may specify multiple times) (eosio::chain_plugin)
# database-hugepage-path =
# Track actions which match receiver:action:actor. Actor may be blank to include all. Action and Actor both blank allows all from Recieiver. Receiver may not be blank. (eosio::history_plugin)
# filter-on =
# Do not track actions which match receiver:action:actor. Action and Actor both blank excludes all from Reciever. Actor blank excludes all from reciever:action. Receiver may not be blank. (eosio::history_plugin)
# filter-out =
# PEM encoded trusted root certificate (or path to file containing one) used to validate any TLS connections made. (may specify multiple times)
# (eosio::http_client_plugin)
# https-client-root-cert =
# true: validate that the peer certificates are valid and trusted, false: ignore cert errors (eosio::http_client_plugin)
# https-client-validate-peers = true
# The local IP and port to listen for incoming http connections; set blank to disable. (eosio::http_plugin)
# http-server-address = 127.0.0.1:8888
# The local IP and port to listen for incoming https connections; leave blank to disable. (eosio::http_plugin)
# https-server-address =
# Filename with the certificate chain to present on https connections. PEM format. Required for https. (eosio::http_plugin)
# https-certificate-chain-file =
# Filename with https private key in PEM format. Required for https (eosio::http_plugin)
# https-private-key-file =
# Configure https ECDH curve to use: secp384r1 or prime256v1 (eosio::http_plugin)
# https-ecdh-curve = secp384r1
# Specify the Access-Control-Allow-Origin to be returned on each request. (eosio::http_plugin)
# access-control-allow-origin =
# Specify the Access-Control-Allow-Headers to be returned on each request. (eosio::http_plugin)
# access-control-allow-headers =
# Specify the Access-Control-Max-Age to be returned on each request. (eosio::http_plugin)
# access-control-max-age =
# Specify if Access-Control-Allow-Credentials: true should be returned on each request. (eosio::http_plugin)
# access-control-allow-credentials = false
# The maximum body size in bytes allowed for incoming RPC requests (eosio::http_plugin)
# max-body-size = 1048576
# Maximum size in megabytes http_plugin should use for processing http requests. 503 error response when exceeded. (eosio::http_plugin)
# http-max-bytes-in-flight-mb = 500
# Append the error log to HTTP responses (eosio::http_plugin)
# verbose-http-errors = false
# If set to false, then any incoming "Host" header is considered valid (eosio::http_plugin)
# http-validate-host = true
# Additionaly acceptable values for the "Host" header of incoming HTTP requests, can be specified multiple times. Includes http/s_server_address by default. (eosio::http_plugin)
# http-alias =
# Number of worker threads in http thread pool (eosio::http_plugin)
# http-threads = 2
# The maximum number of pending login requests (eosio::login_plugin)
# max-login-requests = 1000000
# The maximum timeout for pending login requests (in seconds) (eosio::login_plugin)
# max-login-timeout = 60
# The target queue size between nodeos and MongoDB plugin thread. (eosio::mongo_db_plugin)
# mongodb-queue-size = 1024
# The maximum size of the abi cache for serializing data. (eosio::mongo_db_plugin)
# mongodb-abi-cache-size = 2048
# Required with --replay-blockchain, --hard-replay-blockchain, or --delete-all-blocks to wipe mongo db.This option required to prevent accidental wipe of mongo db. (eosio::mongo_db_plugin)
# mongodb-wipe = false
# If specified then only abi data pushed to mongodb until specified block is reached. (eosio::mongo_db_plugin)
# mongodb-block-start = 0
# MongoDB URI connection string, see: https://docs.mongodb.com/master/reference/connection-string/. If not specified then plugin is disabled. Default database 'EOS' is used if not specified in URI. Example: mongodb://127.0.0.1:27017/EOS (eosio::mongo_db_plugin)
# mongodb-uri =
# Update blocks/block_state with latest via block number so that duplicates are overwritten. (eosio::mongo_db_plugin)
# mongodb-update-via-block-num = false
# Enables storing blocks in mongodb. (eosio::mongo_db_plugin)
# mongodb-store-blocks = true
# Enables storing block state in mongodb. (eosio::mongo_db_plugin)
# mongodb-store-block-states = true
# Enables storing transactions in mongodb. (eosio::mongo_db_plugin)
# mongodb-store-transactions = true
# Enables storing transaction traces in mongodb. (eosio::mongo_db_plugin)
# mongodb-store-transaction-traces = true
# Enables storing action traces in mongodb. (eosio::mongo_db_plugin)
# mongodb-store-action-traces = true
# Enables expiring data in mongodb after a specified number of seconds. (eosio::mongo_db_plugin)
# mongodb-expire-after-seconds = 0
# Track actions which match receiver:action:actor. Receiver, Action, & Actor may be blank to include all. i.e. eosio:: or :transfer: Use * or leave unspecified to include all. (eosio::mongo_db_plugin)
# mongodb-filter-on =
# Do not track actions which match receiver:action:actor. Receiver, Action, & Actor may be blank to exclude all. (eosio::mongo_db_plugin)
# mongodb-filter-out =
# The actual host:port used to listen for incoming p2p connections. (eosio::net_plugin)
# p2p-listen-endpoint = 0.0.0.0:9876
# An externally accessible host:port for identifying this node. Defaults to p2p-listen-endpoint. (eosio::net_plugin)
# p2p-server-address =
# The public endpoint of a peer node to connect to. Use multiple p2p-peer-address options as needed to compose a network. (eosio::net_plugin)
# p2p-peer-address =
# Maximum number of client nodes from any single IP address (eosio::net_plugin)
# p2p-max-nodes-per-host = 1
# The name supplied to identify this node amongst the peers. (eosio::net_plugin)
agent-name = "Your agent name"
# Can be 'any' or 'producers' or 'specified' or 'none'. If 'specified', peer-key must be specified at least once. If only 'producers', peer-key is not required. 'producers' and 'specified' may be combined. (eosio::net_plugin)
#allowed-connection = any
# Optional public key of peer allowed to connect. May be used multiple times. (eosio::net_plugin)
# peer-key =
# Tuple of [PublicKey, WIF private key] (may specify multiple times) (eosio::net_plugin)
# peer-private-key =
# Maximum number of clients from which connections are accepted, use 0 for no limit (eosio::net_plugin)
#max-clients = 25
# number of seconds to wait before cleaning up dead connections (eosio::net_plugin)
# connection-cleanup-period = 30
# max connection cleanup time per cleanup call in millisec (eosio::net_plugin)
# max-cleanup-time-msec = 10
# DEPRECATED, needless restriction. True to require exact match of peer network version. (eosio::net_plugin)
# network-version-match = false
# Number of worker threads in net_plugin thread pool (eosio::net_plugin)
# net-threads = 1
# number of blocks to retrieve in a chunk from any individual peer during synchronization (eosio::net_plugin)
# sync-fetch-span = 100
# Enable expirimental socket read watermark optimization (eosio::net_plugin)
# use-socket-read-watermark = false
# The string used to format peers when logging messages about them. Variables are escaped with ${<variable name>}.
# Available Variables:
# _name self-reported name
#
# _id self-reported ID (64 hex characters)
#
# _sid first 8 characters of _peer.id
#
# _ip remote IP address of peer
#
# _port remote port number of peer
#
# _lip local IP address connected to peer
#
# _lport local port number connected to peer
#
# (eosio::net_plugin)
peer-log-format = ["${_name}" ${_ip}:${_port}]
# Enable block production, even if the chain is stale. (eosio::producer_plugin)
# enable-stale-production = false
# Start this node in a state where production is paused (eosio::producer_plugin)
# pause-on-startup = false
# Limits the maximum time (in milliseconds) that is allowed a pushed transaction's code to execute before being considered invalid (eosio::producer_plugin)
#max-transaction-time = 3000
# Limits the maximum age (in seconds) of the DPOS Irreversible Block for a chain this node will produce blocks on (use negative value to indicate unlimited) (eosio::producer_plugin)
# max-irreversible-block-age = -1
# ID of producer controlled by this node (e.g. inita; may specify multiple times) (eosio::producer_plugin)
# producer-name =
# (DEPRECATED - Use signature-provider instead) Tuple of [public key, WIF private key] (may specify multiple times) (eosio::producer_plugin)
# private-key =
# Key=Value pairs in the form <public-key>=<provider-spec>
# Where:
# <public-key> is a string form of a vaild EOSIO public key
#
# <provider-spec> is a string in the form <provider-type>:<data>
#
# <provider-type> is KEY, or KEOSD
#
# KEY:<data> is a string form of a valid EOSIO private key which maps to the provided public key
#
# KEOSD:<data> is the URL where keosd is available and the approptiate wallet(s) are unlocked (eosio::producer_plugin)
# Limits the maximum time (in milliseconds) that is allowed for sending blocks to a keosd provider for signing (eosio::producer_plugin)
# keosd-provider-timeout = 5
# account that can not access to extended CPU/NET virtual resources (eosio::producer_plugin)
# greylist-account =
# Limit (between 1 and 1000) on the multiple that CPU/NET virtual resources can extend during low usage (only enforced subjectively; use 1000 to not enforce any limit) (eosio::producer_plugin)
# greylist-limit = 1000
# offset of non last block producing time in microseconds. Negative number results in blocks to go out sooner, and positive number results in blocks to go out later (eosio::producer_plugin)
# produce-time-offset-us = 0
# offset of last block producing time in microseconds. Negative number results in blocks to go out sooner, and positive number results in blocks to go out later (eosio::producer_plugin)
# last-block-time-offset-us = 0
# Maximum wall-clock time, in milliseconds, spent retiring scheduled transactions in any block before returning to normal transaction processing. (eosio::producer_plugin)
# max-scheduled-transaction-time-per-block-ms = 100
# Time in microseconds allowed for a transaction that starts with insufficient CPU quota to complete and cover its CPU usage. (eosio::producer_plugin)
# subjective-cpu-leeway-us = 31000
# ratio between incoming transations and deferred transactions when both are exhausted (eosio::producer_plugin)
# incoming-defer-ratio = 1
# Number of worker threads in producer thread pool (eosio::producer_plugin)
#producer-threads = 2
# the location of the snapshots directory (absolute path or relative to application data dir) (eosio::producer_plugin)
#snapshots-dir = "/data/eosData/snapshots"
# the location of the state-history directory (absolute path or relative to application data dir) (eosio::state_history_plugin)
# state-history-dir = "state-history"
# enable trace history (eosio::state_history_plugin)
# trace-history = false
# enable chain state history (eosio::state_history_plugin)
# chain-state-history = false
# the endpoint upon which to listen for incoming connections. Caution: only expose this port to your internal network. (eosio::state_history_plugin)
# state-history-endpoint = 127.0.0.1:8080
# enable debug mode for trace history (eosio::state_history_plugin)
# trace-history-debug-mode = false
# Lag in number of blocks from the head block when selecting the reference block for transactions (-1 means Last Irreversible Block) (eosio::txn_test_gen_plugin)
# txn-reference-block-lag = 0
# Number of worker threads in txn_test_gen thread pool (eosio::txn_test_gen_plugin)
# txn-test-gen-threads = 2
# Prefix to use for accounts generated and used by this plugin (eosio::txn_test_gen_plugin)
# txn-test-gen-account-prefix = txn.test.
# Plugin(s) to enable, may be specified multiple times
# plugin =
# 點擊上面鏈接獲取到下面的數據, 粘貼到config.ini裏
# 這個默認是1024, 不夠用的話啓動nodeos就會報錯bad alloc, 改到4096之後依然不夠, 改到8192之後終於可以了
# Maximum size (in MiB) of the chain state database (eosio::chain_plugin)
#這玩意越大越好 1G大約能同步100W個區塊 如果小了的話 會停止同步 這是一個坑。。。。
chain-state-db-size-mb = 10240000
reversible-blocks-db-size-mb = 1024000
#限制鏈的DPOS不可逆塊的最大年齡(以秒爲單位)。該節點將產生塊(使用負值表示無限)。
#max-irreversible-block-age = 2292000
# 這個原來是127.0.0.1:8888, 不確定不改能不能行
http-server-address = 0.0.0.0:8888
p2p-listen-endpoint = 0.0.0.0:9876
p2p-server-address = 0.0.0.0:9876
#開啓一些功能。。。。
allowed-connection = any
#chain-state-history = true
wasm-runtime = wabt
contracts-console = false
# 這個原來是1, 也不確定不改能不能行
http-validate-host = false
#verbose-http-errors = true
#abi-serializer-max-time-ms = 2000
chain-threads = 10000
#https-client-validate-peers = 1
access-control-allow-credentials = false
access-control-allow-origin = *
access-control-allow-headers = Origin, X-Requested-With, Content-Type, Accept
max-clients = 2500
p2p-max-nodes-per-host = 1000
net-threads = 2500
#connection-cleanup-period = 30
#network-version-match = 0
sync-fetch-span = 2500
enable-stale-production = false
#pause-on-startup = false
max-transaction-time = 30000
txn-reference-block-lag = 0
mongodb-queue-size = 256
trace-history = true
# 需要的插件
plugin = eosio::chain_plugin
plugin = eosio::chain_api_plugin
plugin = eosio::net_plugin
plugin = eosio::net_api_plugin
plugin = eosio::history_plugin
plugin = eosio::history_api_plugin
plugin = eosio::http_plugin
plugin = eosio::http_client_plugin
#plugin = eosio::producer_plugin
#plugin = eosio::producer_api_plugin
filter-on = *
#filter-on = eosio.token:transfer:
#發送主鏈請求的網址api
p2p-peer-address = p2p.eoseoul.io:9876
p2p-peer-address = node1.eosnewyork.io:6987
p2p-peer-address = node2.eosnewyork.io:6987
p2p-peer-address = eosnode.b1.run:9876
p2p-peer-address = node1.zbeos.com:9876
p2p-peer-address = peer1.mainnet.helloeos.com.cn:80
p2p-peer-address = peer.eosio.sg:80
p2p-peer-address = p2p.newdex.one:9876
p2p-peer-address = eos-bp.bitfinex.com:9876
p2p-peer-address = eosbp-0.atticlab.net:9876
p2p-peer-address = eos.okpool.top:9876
p2p-peer-address = peer1.eoshuobipool.com:18181
p2p-peer-address = peer2.eoshuobipool.com:18181