从0搭建Fabric

1 Linux系统准备(Ubuntu18.04)

        初始root密码: sudo passwd root 

1.1 更换源

切换到源文件所在目录
cd /etc/apt

备份之前的源文件
sudo cp sources.list sources.list.backup

替换源,将下边文件复制到sources.list文件中,替换之前的文件。
vim sources.list

阿里云源:

deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

更新源
sudo apt-get update
sudo apt-get upgrade

1.2 安装golang

        1下载 Download and install - The Go Programming Language

        2 解压 sudo tar -C opt/ -xzf Downloads/go1.21.1.linux-amd64.tar.gz
        3 配置环境变量 

                 sudo gedit /etc/profile

                 添加export PATH=$PATH:/home/chi/opt/go/bin

                  sudo gedit ~/.bashrc
                  添加 source /etc/profile

1.3 安装docker

安装docker、docker-compose
        sudo apt install docker docker-compose
        sudo systemctl enable docker
        sudo usermod -a -G docker <username>

坑:docker 版本问题,下载1.27以上版本后(https://github.com/docker/compose/releases/download/

         sudo cp /home/chi/Downloads/docker-compose  /usr/local/bin/

         sudo chmod +x /usr/local/bin/docker-compose

        

1.4 docker 加速器

2 安装fabric-sample

        

1、手动创建脚本,安装samples、docker
https://github.com/hyperledger/fabric/blob/main/scripts/bootstrap.sh
修改binaries=false
sudo chmod u+x bootstrap.sh
./bootstrap.sh

2、安装binaries
https://github.com/hyperledger/fabric/releases/download/v2.4.1/hyperledger-fabric-linux-amd64-2.4.1.tar.gz
https://github.com/hyperledger/fabric-ca/releases/download/v1.5.2/hyperledger-fabric-ca-linux-amd64-1.5.2.tar.gz

 解压到fabric-samples下,成功后会出现bin和config:

sudo tar -xzvf /home/chi/Downloads/hyperledger-fabric-ca-linux-amd64-1.5.2.tar.gz  -C ./

sudo tar -xzvf /home/chi/Downloads/hyperledger-fabric-linux-amd64-2.4.1.tar.gz  -C ./
 

3、配置go代理
go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.cn,direct
 

4 启动测试网络

        创建channnel

        启动chaincode   

./network.sh deployCC -ccn basic -ccp ../asset-transfer-basic/chaincode-go -ccl go

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值