libra测试网环境详细搭建

libra测试网环境详细搭建

环境

1、linux系统(centos 7)
2、需安装有yum命令,其他相关命令自己去yum install
3、git(没有请使用yum install git 安装)

基础拷贝

参考 https://developers.libra.org/docs/my-first-transaction 来搭建 Libra 环境。

1、clone libra

git clone https://github.com/libra/libra.git

2、libra依赖软件安装

cd libra

注意涉及到的依赖安装主要有Rust、Golang、Protobuf、CMake。
官网文档使用 ./scripts/dev_setup.sh 进行一键安装,但不建议使用,因为涉及到的相互依赖复杂,而且并没有检查,一个小错就有可能导致后面编译运行遇到一些很难排查莫名的错误,本人使用分步安装。

Rust

curl https://sh.rustup.rs -sSf | sh
到这里:
Current installation options:
   default host triple: x86_64-unknown-linux-gnu
     default toolchain: stable
               profile: default
  modify PATH variable: yes
1) Proceed with installation (default)
2) Customize installation
3) Cancel installation
选择1默认安装
执行:
source $HOME/.cargo/env
完成检查版本:
rustc --version
rustc 1.38.0 (625451e37 2019-09-23)
rustup --version
rustup 1.20.2 (13979c968 2019-10-16)

Golang

下载golang:
wget https://studygolang.com/dl/golang/go1.12.5.linux-amd64.tar.gz
解压安装:
tar -C /usr/local -zxvf go1.12.5.linux-amd64.tar.gz 
修改环境变量:
vim /etc/profile
末尾添加:
export GOROOT=/usr/local/go
export PATH=$PATH:$GOROOT/bin
export GOPATH=$HOME/gopath 
立即生效:
source /etc/profile
查看版本:
go version
成功:
go version go1.12.5 linux/amd64

Protobuf

下载地址:https://github.com/protocolbuffers/protobuf/releases/tag/v3.6.1
解压安装
tar -xvf protobuf-all-3.6.1.tar.gz
cd protobuf-3.6.1
./configure
make
make check
sudo make install
检查版本
protoc --version
成功:
libprotoc 3.6.1
注意:
1、如果遇到类似错误
configure: error: no acceptable C compiler found in $PATH
或者
Cannot find appropriate C compiler on this system.
Please specify one using environment variable CC.
-->执行命令安装gcc套件
yum install gcc
2、如果遇到类似error: 
C++ preprocessor "/lib/cpp" fails sanity check错误,表示缺少必要的C++库
或者
Cannot find a C++ compiler that supports both C++11 and the specified C++ flags.
Please specify one using environment variable CXX.
-->执行命令安装C++套件
yum install gcc-c++

CMake

注意:先检查本地cmake安装情况
cmake --version
如果显示已安装2.x版本,极有可能在后面的编译中将会报错版本过低,需安装3.x以上版本,所以先remove旧版本
yum remove cmake
安装
官网下载:https://cmake.org/download/ 
解压:
tar -xvzf cmake-3.16.0-rc3.tar.gz
cd cmake-3.16.0-rc3
./bootstrap
【
注意:此步骤如果遇到错误,如果没有请忽略此段
-- Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR (missing: OPENSSL_CRYPTO_LIBRARY OPENSSL_INCLUDE_DIR) 
CMake Error at Utilities/cmcurl/CMakeLists.txt:454 (message):
  Could not find OpenSSL.  Install an OpenSSL development package or
  configure CMake with -DCMAKE_USE_OPENSSL=OFF to build without OpenSSL.
说明缺少openssl组件,安装openssl组件:
官网下载:https://www.openssl.org/source/
解压:
tar -xzf openssl-1.0.2t.tar.gz
cd openssl-1.0.2t
指定安装目录:
./config --prefix=/usr/local/openssl
./config -t
执行编译:
make
注意,如果此时遇到以下错误:
make[1]: Entering directory `/root/openssl-1.0.2t/crypto'
/usr/bin/perl ../util/mkbuildinf.pl "gcc -I. -I.. -I../include  -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -Wa,--noexecstack -m64 -DL_ENDIAN -O3 -Wall -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DRC4_ASM -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM -DECP_NISTZ256_ASM" "linux-x86_64" >buildinf.h
/bin/sh: /usr/bin/perl: No such file or directory
make[1]: *** [buildinf.h] Error 127
make[1]: Leaving directory `/root/openssl-1.0.2t/crypto'
make: *** [build_crypto] Error 1
表示Perl句柄类型的变量操作文件环境的缺失的问题,执行命令安装perl相关组件:
yum -y install gcc gcc-c++ perl make kernel-headers kernel-devel
完成后执行:
make clean
再来重复:
./config --prefix=/usr/local/openssl
./config -t
make
make install
至此,根目录下执行:
cd /usr/local
ldd /usr/local/openssl/bin/openssl
可以看到:
 linux-vdso.so.1 =>  (0x00007ffe907a9000)
 libdl.so.2 => /lib64/libdl.so.2 (0x00007fe30dd43000)
 libc.so.6 => /lib64/libc.so.6 (0x00007fe30d975000)
 /lib64/ld-linux-x86-64.so.2 (0x00007fe30df47000)
回到cmake安装,继续
./bootstrap
此时仍然会报上述找不到OpenSSL错误,因为OpenSSL还未正确配置环境变量:
vim /etc/profile
末尾添加:
export LD_LIBRARY_PATH=/usr/local/openssl/include/openssl:/usr/lib:/usr/local/lib:/usr/lib/pkgconfig:/usr/local/include/wx-2.8/wx:$LD_LIBRARY_PATH
export PKG_CONFIG_PATH=/usr/lib/pkgconfig
export OPENSSL_ROOT_DIR=/usr/local/openssl
export OPENSSL_LIBRARIES=/usr/local/openssl/lib/
export PATH=/usr/local/openssl/bin:$PATH
保存,立即生效:
source /etc/profile
查看版本:openssl version
OpenSSL 1.0.2t  10 Sep 2019
至此OpenSSL安装完成。
再次回到cmake目录下执行:
./bootstrap
】
完成:
---------------------------------------------
CMake has bootstrapped.  Now run gmake.
继续:
gmake
gmake install
完成查看cmake版本:
cmake --version
成功:
cmake version 3.16.0-rc3
CMake suite maintained and supported by Kitware (kitware.com/cmake).

至此依赖安装完成,回到libra目录下

cd libra
再次编译安装依赖:
./scripts/dev_setup.sh
成功:
Installing Rust......
Rust is already installed
info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu'
info: syncing channel updates for 'beta-x86_64-unknown-linux-gnu'
info: checking for self-updates
  stable-x86_64-unknown-linux-gnu unchanged - rustc 1.38.0 (625451e37 2019-09-23)
    beta-x86_64-unknown-linux-gnu unchanged - rustc 1.39.0-beta.9 (5242afe81 2019-11-02)
info: component 'rustfmt' for target 'x86_64-unknown-linux-gnu' is up to date
info: component 'clippy' for target 'x86_64-unknown-linux-gnu' is up to date
Installing CMake......
CMake is already installed
Installing Protobuf......
Protobuf is already installed
Finished installing all dependencies.

运行脚本连接测试网

./scripts/cli/start_cli_testnet.sh

这时稍加等待,如果成功你会看到:

Building and running client in debug mode.
    Finished dev [unoptimized + debuginfo] target(s) in 0.42s
     Running `target/debug/client --host ac.testnet.libra.org --port 8000 -s ./scripts/cli/consensus_peers.config.toml`
Connected to validator at: ac.testnet.libra.org:8000
usage: <command> <args>

Use the following commands:

account | a 
        Account operations
query | q 
        Query operations
transfer | transferb | t | tb 
        <sender_account_address>|<sender_account_ref_id> <receiver_account_address>|<receiver_account_ref_id> <number_of_coins> [gas_unit_price_in_micro_libras (default=0)] [max_gas_amount_in_micro_libras (default 140000)] Suffix 'b' is for blocking. 
        Transfer coins (in libra) from account to another.
help | h 
        Prints this help
quit | q! 
        Exit this client


Please, input commands: 

libra% 

OK,开始你的libra cli操作吧
但是。。。如果你遇到的是以下:

Building and running client in debug mode.
    Finished dev [unoptimized + debuginfo] target(s) in 8.42s
     Running `target/debug/client --host ac.testnet.libra.org --port 8000 -s ./scripts/cli/consensus_peers.config.toml`
Not able to connect to validator at ac.testnet.libra.org:80, error RpcFailure(RpcStatus{status:DeadlineExceeded, details: Some("Deadline Exceeded") })

不要急,libra目录下执行命令

vim client/src/grpc_client.rs

找到:

 fn get_default_grpc_call_option() -> CallOption {
        CallOption::default()
            .wait_for_ready(true)
            .timeout(std::time::Duration::from_millis(5000))
    }

==》将5000改为30000

 fn get_default_grpc_call_option() -> CallOption {
        CallOption::default()
            .wait_for_ready(true)
            .timeout(std::time::Duration::from_millis(30000))
    }

再次运行

./scripts/cli/start_cli_testnet.sh

OK,至此告一段落。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值