-
Ubuntu20.04.06
-
sudo apt update # 更新系统中已安装软件包的列表
-
安装
sudo apt-get install git curl docker.io docker-compose jq
-
安装docker
# 安装并检查版本 sudo apt-get -y install docker-compose docker --version docker-compose --version # 提示,以后只要碰到docker有关的错误,先执行2.3.1步骤 #1.重启docker sudo systemctl start docker #设置系统启动时docker启动,可选 sudo systemctl enable docker #2.将用户添加到docker组,确保在用户命令下可以执行 sudo gpasswd -a $USER docker #3.更新用户组 newgrp docker # docker信息 docker info
[Service] Environment="HTTP_PROXY=http://127.0.0.1:7890" Environment="HTTPS_PROXY=https://127.0.0.1:7890" sudo systemctl daemon-reload sudo systemctl restart docker
-
安装GOlang
cd ~ && mkdir go && cd go wget https://golang.google.cn/dl/go1.22.4.linux-amd64.tar.gz # 下载golang tar xvf go1.22.4.linux-amd64.tar.gz # 解压 sudo vim ~/.bashrc # 配置环境变量,修改.bashrc文件,添加下面两行的命令 export GOPATH=$HOME/go/go/bin export PATH=$PATH:$GOPATH # 在 Linux 系统中,`.bashrc` 文件是一个用来初始化新终端会话的脚本文件。它包含了用户环境的配置,如路径、别名、环境变量等。使用 `source .bashrc` 命令可以手动加载或重新加载这些配置,而不必重新启动终端 source ~/.bashrc go version # 查看golang版本 # 配置goproxy 可选 go env -w GOPROXY=https://goproxy.cn,direct
cd ~ && mkdir fabric && cd fabric # 创建fabric文件夹 # 使用github安装 可以访问github则使用github安装 curl -sSLO https://raw.githubusercontent.com/hyperledger/fabric/main/scripts/install-fabric.sh && chmod +x install-fabric.sh # 下载安装脚本 # 仅在首次使用执行:下载Fabric Docker镜像。如果拉取速度过慢或失败请检查是否完成docker换源,或者更换一个其他的镜像源再试。 ./install-fabric.sh -f 2.5.6 d # 使用gitee安装 github 安装失败后尝试 wget https://gitee.com/snowrain_wjh/fabric/raw/main/install-fabric.sh && chmod +x install-fabric.sh # 下载安装脚本 ./install-fabric.sh samples binary docker # 安装
export http_proxy=http://127.0.0.1:7890
export https_proxy=http://127.0.0.1:7890go env -w GOPROXY=http://127.0.0.1:7890
./network.sh deployCC -ccn basic -ccp …/asset-transfer-basic/chaincode-go -ccl go
异常
Error: proposal failed (err: bad proposal response 500: cannot create ledger from genesis block: ledger [mychannel] already existchaincode:
# The id is used by the Chaincode stub to register the executing Chaincode
# ID with the Peer and is generally supplied through ENV variables
# the `path` form of ID is provided when installing the chaincode.
# The `name` is used for all other requests and can be any string.
id:
path:
name:
# Generic builder environment, suitable for most chaincode types
builder: $(DOCKER_NS)/fabric-ccenv:$(TWO_DIGIT_VERSION) [ACTIVE])
./network.sh down
docker system prune --volumes
docker rmi -f $(docker images -q)
docker build
–build-arg “HTTP_PROXY=http://proxy.example.com:8080/”
–build-arg “HTTPS_PROXY=http://proxy.example.com:8080/”
–build-arg “NO_PROXY=localhost,127.0.0.1,.example.com” .
代理链接被拒绝
Error: chaincode install failed with status: 500 - failed to invoke backing implementation of ‘InstallChaincode’: could not build chaincode: docker build failed: docker image build failed: docker build failed: Error returned from build: 1 "go: github.com/golang/protobuf@v1.3.2: Get “https://proxy.golang.org/github.com/golang/protobuf/@v/v1.3.2.mod”: dial tcp 172.217.24.17:443: connect: connection refused
————————————————
将所需要的依赖包提前下载下来。
使用命令:
go mod tidy
go mod vendor
深入理解 Go 模块管理:探讨 go mod tidy
和 go mod vendor
_go mod tidy作用-优快云博客
这篇文章讲述了这两个命令的作用