在这里博主使用的是阿里云服务器centos7
1、安装go
通过yum安装go
yum install go
2、配置go的环境
>vim /etc/profile
//添加,在这里的先进入 cd /usr 创建gocode目录 mkdir gocode
export GOPATH="/usr/gocode"
export PATH=$pATH:$GOPATH
:wq //保存退出
>source /etc/profile
3、安装git
//阿里云服务器centos7已经自动安装了git
>yum install git
4、下载fabric和fabric-samples
//进入/usr/gocode
>go get github.com/hyperledger/fabric
//进入cd /usr/gocode/github.com/hyperledger 进行下载fabric-simple 也可以通过go get 方式下载
>git clone https://github.com/hyperledger/fabric-samples.git
5、安装docker和docker-compose
安装docker-ce
检查版本是否正确
重启docker并设置为开机自启
docker 案例列表
# step 1: 安装必要的一些系统工具
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
# Step 2: 添加软件源信息
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
# Step 3: 更新并安装 Docker-CE
sudo yum makecache fast
sudo yum -y install docker-ce
ce 是开源版本的意思
1 检查版本是否正常
[root@localhost master]# docker --version
Docker version 18.06.1-ce, build e68fc7a
2 重启docker并设置为开机自启
>systemctl start docker & systemctl enable docker
>service docker status //状态
5.1docker的镜像管理和加速配置
https://cr.console.aliyun.com/cn-beijing/instances/mirrors // 阿里云官网
进入镜像加速器:按步骤来
您可以通过修改daemon配置文件/etc/docker/daemon.json来使用加速器
>sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://0dzh3q47.mirror.aliyuncs.com"]
}
EOF
//加载进来
>sudo systemctl daemon-reload
//重启
>sudo systemctl restart docker
//开启
>service docker start
5.2安装docker-compose
>yum -y install epel-release
>yum -y install python-pip
>pip install --upgrade pip
>yum install docker-compose //安装命令
查询版本是否正确
>[root@localhost master]# docker-compose --version
>docker-compose version 1.18.0, build 8dd22a9
6、docker pull 需要的工具
>docker pull hyperledger/fabric-tools:x86_64-1.0.0
>docker tag hyperledger/fabric-tools:x86_64-1.0.0 hyperledger/fabric-tools:latest
>docker pull hyperledger/fabric-orderer:x86_64-1.0.0
>docker tag hyperledger/fabric-orderer:x86_64-1.0.0 hyperledger/fabric-orderer:latest
>docker pull hyperledger/fabric-peer:x86_64-1.0.0
>docker tag hyperledger/fabric-peer:x86_64-1.0.0 hyperledger/fabric-peer:latest
>docker pull hyperledger/fabric-baseos
>docker pull hyperledger/fabric-ca:x86_64-1.0.0
>docker tag hyperledger/fabric-ca:x86_64-1.0.0 hyperledger/fabric-ca:latest
7、配置fabric
//进入到fabric目录
>cd /usr/gocode/src/github.com/hyperledger/fabric
>/usr/gocode/src/github.com/hyperledger/fabric$:git checkout release-1.0 //选择版本
//进入到/usr/gocode/src/github.com/hyperledger/fabric/common/configtx/tool/configtxgen
>/usr/gocode/src/github.com/hyperledger/fabric/common/configtx/tool/configtxgen$:go install --tags=nopkcs11
//进入到/usr/gocode/src/github.com/hyperledger/fabric/common/tools/cryptogen
>/usr/gocode/src/github.com/hyperledger/fabric/common/tools/cryptogen$:go install --tags=nopkcs11
//两个工具都安装到/usr/gocode/bin目录下
>cd $GOPATH/bin
>bin$:ls
cryptogen configtxgen
>//进入到fabric-samples目录
>cd /usr/gocode/src/github.com/hyperledger/fabric-samples
>/usr/gocode/src/github.com/hyperledger/fabric-samples$:git checkout release-1.0 //选择版本
8.再开启fabric中遇到的问题
//进入到/usr/gocode/src/github.com/hyperledger/fabric-samples/first-network目录下面
//执行 ./byfn.sh 开启网络
genesis block, then bring up the network. e.g.:
byfn.sh -m generate -c mychannel
byfn.sh -m up -c mychannel -s couchdb
byfn.sh -m up -c mychannel -s couchdb -i 1.0.6
byfn.sh -m down -c mychannel
Taking all defaults:
byfn.sh -m generate //创世
byfn.sh -m up //开启
byfn.sh -m down //关闭
8.1执行 ./byfn.sh -m generate
出现cryptogen tool not found. exiting
//解决办法,由于cryptogen工具没有配置环境变量
cryptogen在/usr/gocode/bin目录下面
>vim /etc/profile
//执行
>source /etc/profile
//编译修改,在任意位置只用cryptogen查看是否成功
8.2 执行./byfn.sh -m up 错误
概述
本文主要介绍如何修改CentOS系统最大线程数。
详细信息
配置完成,启动服务,系统显示类似如下。
max number of threads [1024] for user [elk] is too low, increase to at least [4096]
执行如下命令,查看最大线程数,确认最大线程数为7271。
ulimit -u
在/etc/security/limits.d/20-nproc.conf文件中添加如下内容,保存文件,重新登录服务器。
* soft nproc 65535
* hard nproc 65535
//重点得重启服务器
由于阿里云服务器需要修改/etc/resolv.conf vim /etc/resolv.conf
nameserver 100.100.2.138
nameserver 100.100.2.136
//在下面这行前面添加“#” 进行注释
#options timeout:2 attempts:3 rotate single-request-reopen
再重新执行 ./byfn.sh -m up