libra部署(1)基础环境搭建

1、到github上拉代码:

git  clone  https://github.com/libra/libra.git &&cd  libra
现更改为:
git clone https://github.com/diem/diem.git && cd diem
这两个命令的执行结果是一模一样的,选哪个都无所谓

2、切换到testnet网络

git checkout testnet

3、安装依赖环境

一键下载,但可能会失败,建议单独下载
./scripts/dev_setup.sh

这里主要涉及到Rust、Golang、Protobuf、CMake的依赖环境的安装。

3.1 Rust安装

curl https://sh.rustup.rs -sSf | sh
source $HOME/.cargo/env
rustc --version 
[lj@localhost ~]$ curl https://sh.rustup.rs -sSf | sh
info: downloading installer
Warning: Not enforcing strong cipher suites for TLS, this is potentially less secure

Welcome to Rust!

This will download and install the official compiler for the Rust
programming language, and its package manager, Cargo.

Rustup metadata and toolchains will be installed into the Rustup
home directory, located at:

  /home/lj/.rustup

This can be modified with the RUSTUP_HOME environment variable.

The Cargo home directory located at:

  /home/lj/.cargo

This can be modified with the CARGO_HOME environment variable.

The cargo, rustc, rustup and other commands will be added to
Cargo's bin directory, located at:

  /home/lj/.cargo/bin

This path will then be added to your PATH environment variable by
modifying the profile files located at:

  /home/lj/.profile
  /home/lj/.bash_profile
  /home/lj/.bashrc

You can uninstall at any time with rustup self uninstall and
these changes will be reverted.

Current installation options:


   default host triple: x86_64-unknown-linux-gnu
     default toolchain: stable (default)
               profile: default
  modify PATH variable: yes

1) Proceed with installation (default)
2) Customize installation
3) Cancel installation
>

info: profile set to 'default'
info: default host triple is x86_64-unknown-linux-gnu
info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu'
info: latest update on 2022-05-19, rust version 1.61.0 (fe5b13d68 2022-05-18)
info: downloading component 'cargo'
info: downloading component 'clippy'
info: downloading component 'rust-docs'
info: downloading component 'rust-std'
info: downloading component 'rustc'
info: downloading component 'rustfmt'
info: installing component 'cargo'
info: installing component 'clippy'
info: installing component 'rust-docs'
 19.7 MiB /  19.7 MiB (100 %)   2.7 MiB/s in  6s ETA:  0s
info: installing component 'rust-std'
 26.9 MiB /  26.9 MiB (100 %)   7.2 MiB/s in  3s ETA:  0s
info: installing component 'rustc'
 55.4 MiB /  55.4 MiB (100 %)   9.4 MiB/s in  6s ETA:  0s
info: installing component 'rustfmt'
info: default toolchain set to 'stable-x86_64-unknown-linux-gnu'

  stable-x86_64-unknown-linux-gnu installed - rustc 1.61.0 (fe5b13d68 2022-05-18)


Rust is installed now. Great!

To get started you may need to restart your current shell.
This would reload your PATH environment variable to include
Cargo's bin directory ($HOME/.cargo/bin).

To configure your current shell, run:
source $HOME/.cargo/env

3.2 Golang安装

下载文件:

wget -P /usr/local https://dl.google.com/go/go1.16.linux-amd64.tar.gz

解压文件到 /usr/local(可以自行选择路径)

cd /usr/local
tar -zxvf go1.16.linux-amd64.tar.gz

配置环境

vim /etc/profile

写入

export PATH=$PATH:/usr/local/go/bin
export GOROOT=/usr/local/go
export GOPATH=/root/go/
#根据自己的路径进行修改

使环境配置生效

source /etc/profile

查看版本

go version

结果

[root@localhost ~]# vim /etc/profile
[root@localhost ~]# source /etc/profile
[root@localhost ~]# go version
go version go1.16 linux/amd64

3.3 Protobuf

下载地址:https://github.com/protocolbuffers/protobuf/releases
在这里插入图片描述

tar -xvf protobuf-all-21.1.tar.gz
cd protobuf-3.21.1
./configure --prefix=/usr/local/
make
make check
如果这一步失败FAIL: protobuf-test 解决方案是增大虚拟机内存
sudo make install
检查版本
protoc --version
[lj@localhost protobuf-3.21.1]$ protoc --version
libprotoc 3.21.1

3.4 CMake

注意:先检查本地cmake安装情况
cmake --version
如果显示已安装2.x版本,极有可能在后面的编译中将会报错版本过低,需安装3.x以上版本,所以先remove旧版本
yum remove cmake
安装
官网下载:https://cmake.org/download/ 
解压:
tar -xvzf cmake-3.23.2.tar.gz
cd cmake-3.23.2
./bootstrap
gmake
gmake install
完成查看cmake版本:
cmake --version

CentOS内置版本:

[lj@localhost protobuf-3.21.1]$ cmake --version
cmake version 2.8.12.2

新安装版本:

[lj@localhost cmake-3.23.2]$ cmake --version
cmake version 3.23.2

CMake suite maintained and supported by Kitware (kitware.com/cmake).
./scripts/dev_setup.sh

4、依赖包下载,并编译

./scripts/cli/start_cli_testnet.sh

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_40713201/article/details/125176036