[Xu Xiaodi] Running the EOS system from scratch

To review the content of the last article, the EOS system has three main applications:

nodeos: The core process of the EOS system, the so-called "node".

cleos: A local command line tool that interacts with real users and communicates with nodes (nodeos) and wallets (keosd) through the command line. It is a bridge for users or developers to interact with the node process.

keosd: native wallet tool. Multiple wallets with private keys can be managed and encrypted.

It is required that
this tutorial is applicable to the following systems, but whether your computer is Windows or Mac, it is strongly recommended to install a virtual machine and do it on Ubuntu, because there are many pits on Mac. You can find tutorials on installing Ubuntu virtual machines on the Internet.

Amazon 2017.09 and higher.

Hundreds 7.

Fedora 25 and higher (Fedora 27 recommended).

Mint 18.

Ubuntu 16.04 (Ubuntu 16.10 recommended).

MacOS Darwin 10.12 and higher (MacOS 10.13.x recommended).

Configuration requirements:

8GB RAM

20GB hard drive free space

If the machine memory is not enough 8G, the automatic compilation script will report an error.

Running EOS requires a bit of linux and github basics, but don't be too troublesome, developing EOS contracts in the future requires a lot of knowledge in this area. It is recommended that you follow the steps first. If you do not understand, you can refer to the following articles. Don't be afraid, no one is born with everything.

Linux command base: https://linux.cn/article-6160-1.html

github base: http://www.runoob.com/w3cnote/git-guide.html

Download EOS code
If you are a Mac, you need to download git first. You can search for "Mac git" to find various articles to teach you how to install git on Mac.

First, use the cd command to enter the folder you want to install. I usually use the root directory. Execute the following command to download the EOS code:

git clone https://github.com/EOSIO/eos --recursive
Note to add the following --recursive command, because EOS has several sub-modules, so you can download them all, if you forget this command, use the following command Can be remedied:

git submodule update --init --recursive
build EOS
With the source code, we can build our local EOS program. The EOS official has prepared an automatic build script for us very considerately. Using this script can be greatly simplified. First of all, we Go to the eos directory you just downloaded and execute the build script:

cd eos
./eosio_build.sh
may take 30 minutes - 1 hour depending on the network speed and machine performance, please be patient. After the build is complete, the built product needs to be verified:

Linux system (Ubuntu etc.):

~/opt/mongodb/bin/mongod -f ~/opt/mongodb/mongod.conf &
Mac:

/usr/local/bin/mongod -f /usr/local/etc/mongod.conf &
then execute the following command for all operating systems:

cd build
make test
In order to facilitate the development of smart contracts, you also need to make install in the build directory:
if you have entered the build directory, please remove cd build.

cd build
sudo make install
建立本地单节点测试网络
构建完成后,我们进入 eos/build/programs/nodeos 目录(使用 cd 和 cd .. 命令),运行 nodeos 节点程序:

./nodeos -e -p eosio --plugin eosio::wallet_api_plugin --plugin eosio::chain_api_plugin --plugin eosio::account_history_api_plugin 
命令中, -p 参数表示使用了 eosio 账户的权限,这是本地测试系统提供的原始账户。后面的各个 plug in 参数是选择加载的插件。

成功后,如果看到类似下面的输出,就是成功建立了一个本地单节点测试网络:

1575001ms thread-0 chain_controller.cpp:235 _push_block ] initm #1 @2017-09-04T04:26:15 | 0 trx, 0 pending, exectime_ms=0
1575001ms thread-0 producer_plugin.cpp:207 block_production_loo ] initm generated block #1 @ 2017-09-04T04:26:15 with 0 trxs 0 pending
1578001ms thread-0 chain_controller.cpp:235 _push_block ] initc #2 @2017-09-04T04:26:18 | 0 trx, 0 pending, exectime_ms=0
1578001ms thread-0 producer_plugin.cpp:207 block_production_loo ] initc generated block #2 @ 2017-09-04T04:26:18 with 0 trxs 0 pending
...
eosio generated block 046b9984... #101527 @ 2018-04-01T14:24:58.000 with 0 trxs
eosio generated block 5e527ee2... #101528 @ 2018-04-01T14:24:58.500 with 0 trxs
...
说明本地的单节点已经开始正常出块了。

如上次文章所讲,我们建立的本地测试网络如下如,并没有单独的 keosd 钱包,而是使用了 nodeos 程序里的钱包插件。

 

高级设置
如果你不满足于以上,可以对节点配置进行修改,配置文件位于:

Mac OS: ~/Library/Application Support/eosio/nodeos/config

Linux: ~/.local/share/eosio/nodeos/config

上述文件夹中默认有 genesis.json 配置文件,可以直接修改它,或者在别的文件里再写一个新的配置文件,不过运行 nodeos 时,就要通过 --config-dir 命令指出新配置文件的位置。

配置文件夹还默认有一个 config.ini 文件。如果没有的话,nodeos 启动时会自动创建一个,但自动创建的 config.ini 文件是不让节点出块的,此时你需要使用 Ctrl-C 停止 nodeos,并编辑这个文件:

# Load the testnet genesis state, which creates some initial block producers with the default key
genesis-json = /path/to/eos/source/genesis.json
# Enable production on a stale chain, since a single-node test chain is pretty much always stale
enable-stale-production = true
# Enable block production with the testnet producers
producer-name = eosio
# Load the block producer plugin, so you can produce blocks
plugin = eosio::producer_plugin
# Wallet plugin
plugin = eosio::wallet_api_plugin
# As well as API and HTTP plugins
plugin = eosio::chain_api_plugin
plugin = eosio::http_plugin
# This will be used by the validation step below, to view account history
plugin = eosio::account_history_api_plugin
这样配置好后,重新启动 nodeos,就会顺利出块了。

nodeos 的运行数据文件夹(log和共享存储等数据)位于以下文件夹:

Mac OS: ~/Library/Application Support/eosio/nodeos/data

Linux: ~/.local/share/eosio/nodeos/data

但也可以使用 nodeos 的 --data-dir 命令重新指定数据文件夹。

 

圆方圆区块链汇集大批区块链名师,采取导师值班制,为学员实时解决技术疑难。请关注圆方圆区块链知识星球与导师。(培训咨询请联系船长13826054890微信手机同号)

 

作者小笛 ,专注于 EOS 技术研究与区块链智能合约开发.是圆方圆区块链的导师,更多小笛老师的文章和视频请关注圆方圆链圈公众号。


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324814145&siteId=291194637