Golang最低版本要求:1.10.x,当前安装版本:1.11;至于go的下载地址去其官网即可。
tar zxvpf go1.11.linux-amd64.tar.gz
mv go /usr/local/
vim /etc/profile
打开 /etc/profile 配置文件,在末尾加入如下配置:
export GOPATH=/opt/gopath
export GOROOT=/usr/local/go
export PATH=$PATH:$GOROOT/bin:$GOPATH
加载环境变量配置
source /etc/profile
docker最低版本要求:Docker version 17.06.2-ce or greater
下载地址:
https://download.docker.com/linux/centos/7/x86_64/stable/Packages/ docker-ce-18.03.1.ce-1.el7.centos.x86_64.rpm
执行以下命令安装:
rpm -ivh --nodeps docker-ce-18.03.1.ce-1.el7.centos.x86_64.rpm
查看docker版本信息,检查是否安装成功:
docker -v
docker 版本必须满足最低版本;
cp docker-compose-Linux-x86_64 /usr/local/bin/docker-compose
chmod a+x /usr/local/bin/docker-compose
systemctl restart docker
chmod a+rw /var/run/docker.sock
systemctl restart docker
vim /usr/lib/systemd/system/docker.service
编辑 /usr/lib/systemd/system/docker.service 配置文件,增加斜体部分,如下:
[Service]
#ExecStart=/usr/bin/dockerd
ExecStart=/usr/bin/dockerd –iptables=false
ExecReload=/bin/kill -s HUP $MAINPID
LimitNOFILE=infinity
刷新配置并重启docker
systemctl daemon-reload
systemctl restart docker
systemctl enable docker.service
systemctl restart docker
service docker status
systemctl stop firewalld.service
systemctl disable firewalld.service
firewall-cmd --state
注:关闭后显示notrunning,开启后显示running
下载链接:https://npm.taobao.org/mirrors/node/v8.11.4/node-v8.11.4-linux-x64.tar.gz
sudo tar -xvf node-v8.11.4-linux-x64.tar.xz
mv node-v8.11.4-linux-x64 /usr/local/node
打开 /etc/profile 配置文件,
vim /etc/profile
在末尾加入如下配置
添加一下行:
export NODE_HOME=/usr/local/node
修改以下行(增加红色内容):
export PATH= $NODE_HOME/bin:PATH
更新环境变量配置
source /etc/profile
yum install https://download.postgresql.org/pub/repos/yum/9.5/redhat/rhel-7-x86_64/pgdg-centos95-9.5-2.noarch.rpm
yum install postgresql95-server postgresql95-contrib
/usr/pgsql-9.5/bin/postgresql95-setup initdb
systemctl enable postgresql-9.5.service
systemctl start postgresql-9.5.service
yum install epel-release
安装完EPEL源后,可以查看下jq包是否存在。
yum list jq
yum install jq
当然这是在本地已有镜像的情况下,没有的话可以直接docker pull下载:
docker load < fabric-orderer.tar
docker load < fabric-tools.tar
docker load < fabric-baseos.tar
docker load < fabric-ccenv.tar
docker load < fabric-peer.tar
docker tag hyperledger/fabric-tools:1.2.0 hyperledger/fabric-tools:latest
docker tag hyperledger/fabric-ccenv:1.2.0 hyperledger/fabric-ccenv:latest
docker tag hyperledger/fabric-orderer:1.2.0 hyperledger/fabric-orderer:latest
docker tag hyperledger/fabric-peer:1.2.0 hyperledger/fabric-peer:latest
从fabric官方下载fabric-sample源码文件(TODO,修改为从gitlab拉取),如下:
cd $GOPATH/src/github.com/hyperledger
git clone https://github.com/hyperledger/fabric-samples.git
cd fabric-samples/
git branch -a
git checkout release-1.2 (若已是1.2可省略)
在fabric-samples目录中,下载自动化部署脚本并执行:
curl -sSL https://raw.githubusercontent.com/hyperledger/fabric/master/scripts/bootstrap.sh | bash -s 1.2.0 1.2.0 0.4.10
如果上一步下载失败,则直接从10.1.53.60主机上/opt/gopath/src/github.com/hyperledger/目录下直接拉取整个fabric-samples目录的内容,替换当前主机的fabric-samples目录,并接着执行。
打开 /etc/profile 配置文件,在末尾加入如下配置
vim /etc/profile
添加一下行:
FABRIC_SAMPLES=$GOPATH/src/github.com/hyperledger/fabric-samples
修改以下行(增加红色内容):
export PATH=$FABRIC_SAMPLES/bin:$PATH
更新环境变量配置
source /etc/profile
cd $GOPATH/src/github.com/hyperledger/fabric-samples/first-network
./byfn.sh up
从fabric官方下载blockchain-explorer源码文件,如下:
git clone https://github.com/hyperledger/blockchain-explorer.git
这里采用默认配置,直接启动即可,如下:
chmod -R 775 blockchain-explorer/app/persistence/fabric/postgreSQL/db
cd blockchain-explorer/app/persistence/fabric/postgreSQL/db
./createdb.sh
NPM 国内被墙,需要配置淘宝的镜像。
vim root/.npmrc
添加以下内容
registry = https://registry.npm.taobao.org
注:本机是以root用户登陆,故修改root/.npmrc,其他用户登陆时修改~/.npmrc
项目编译:
cd blockchain-explorer
npm install
cd blockchain-explorer/app/test
npm install
npm run test
cd client/
npm install
npm test -- -u --coverage
npm run build
启动区块链浏览器服务:
cd blockchain-explorer
./start.sh
注:停止服务为在blockchain-explorer目录下执行./stop.sh。
在浏览器访问区块链浏览器服务:http://10.252.79.17:8080/
在执行./start.sh之后服务并没有启动,检查日志发现无法加载grpc_node模块。
解决:
cd blockchain-explorer
npm rebuild --unsafe-perm
./start.sh
在执行./start.sh之后服务并没有启动,检查日志发现数据库连接报错,报错信息如下:
db error { error: Ident authentication failed for user “hppoc”
解决方案:
(1)修改数据库权限配置:
/var/lib/pgsql/9.5/data/pg_hba.conf
修改之后的配置文件情况如下:
#"local" is for Unix domain socket connections only
local all all trust
#IPv4 local connections:
host all all 127.0.0.1/32 trust
#IPv6 local connections:
host all all ::1/128 trust
#Allow replication connections from localhost, by a user with the
#replication privilege.
local replication postgres trust
host replication postgres 127.0.0.1/32 trust
host replication postgres ::1/128 trust
(2)重启数据库服务:
systemctl restart postgresql-9.5.service
在执行npm install时,报用户权限不足的错,报错信息如下:
gyp WARNWARN EACCESEACCES attempting to reinstall using temporary dev dir "/usr/local/lib/node_modules/node-inspector/node_modules/v8-debug/.node-gyp"
attempting to reinstall using temporary dev dir "/usr/local/lib/node_modules/node-inspector/node_modules/v8-debug/.node-gyp"
gyp WARN EACCES user "root" does not have permission to access the dev dir "/usr/local/lib/node_modules/node-inspector/node_modules/v8-debug/.node-gyp/10.6.0"
解决方案:
安装的时候增加–unsafe-perm 参数即可
npm install -g --unsafe-perm