ubuntu
1. Create the file repository configuration:
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
2. Import the repository signing key:
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
3. Update the package lists:
sudo apt-get update
4. Install the latest version of PostgreSQL. If you want a specific version, use ‘postgresql-12’ or similar instead of ‘postgresql’:
sudo apt-get install postgresql
如果太慢,使用国内源
explorer
参考官方文档:https://github.com/hyperledger/blockchain-explorer
1、nodejs安装(nodejs 8.11.x (Note that v9.x is not yet supported)),由于上一篇博客已经安装了nvm,所以只需用nvm安装指定版本即可(此处安装8.11.4版本)
root@ubuntu:~# nvm install 8.11.4
Downloading and installing node v8.11.4…
Downloading https://nodejs.org/dist/v8.11.4/node-v8.11.4-linux-x64.tar.xz…
################################################################################################################################################################################### 100.0%
Computing checksum with sha256sum
Checksums matched!
Now using node v8.11.4 (npm v5.6.0)
root@ubuntu:~# node -v
v8.11.4
root@ubuntu:~#
2、postgresql安装(PostgreSQL 9.5 or greater),这里以docker的形式进行安装
docker pull postgres:9.5
docker run --name postgres1 -e POSTGRES_PASSWORD=postgres -p 5432:5432 -d postgres:9.5 #postgres镜像默认的用户名为postgres,设置一个密码postgres
3、安装jq
sudo apt-get install jq
二、具体步骤
1、下载blockchain-explorer源码
cd /root/demo
git clone https://github.com/hyperledger/blockchain-explorer.git
cd blockchain-explorer
2、数据库初始化
root@iZq0c7mivu8vrvZ:~# docker exec -it b88997d1aad3 /bin/bash #进入postgresql容器:b88997d1aad3
root@b88997d1aad3:/# su postgres #切换用户
postgres@b88997d1aad3:/$ psql #进入命令行客户端
psql (9.5.15)
Type “help” for help.
postgres=# CREATE DATABASE fabricexplorer owner postgres; #创建fabricexplorer数据库并指定用户fabricexplorer
数据库创建好后执行初始化sql语句(也可以用postgresql相关桌面客户端连接数据库),以下数据库脚本参考官方https://github.com/hyperledger/blockchain-explorer/blob/master/app/persistence/fabric/postgreSQL/db/explorerpg.sql&#