zoukankan      html  css  js  c++  java
  • hyperledger 浏览器部署以及接入自己项目

    1. nodejs 8.11.3 安装 (资源链接:https://pan.baidu.com/s/1YLpNuIKbCgjQ2BDNkNY48g)

    如果在虚拟机上的应该没有问题,如果在阿里云上的最好先创建一个普通用户,赋予sudo权限,因为在后面 npm install步骤中root管理员模型执行会报错。我这里创建了账户名为 lh 的普通用户,将下载的node-v8.11.3-linux-x64.tar 放到/home/lh 目录下,执行下列命令

    node-v8.11.3-linux-x64.tar.gz
    tar -xvf node-v8.11.3-linux-x64.tar.gz //解压
    ln -s /home/lh/node-v8.11.3-linux-x64/bin/node /usr/local/bin/node //建立软链
    ln -s /home/lh/node-v8.11.3-linux-x64/bin/npm /usr/local/bin/npm //建立软链
    node -v 
    npm -v //查看是否安装成功

    2.PostgreSQL 安装

    sudo apt-get install postgresql

    3.修改postgres数据库用户的密码

    sudo -u postgres psql
    
    postgres=# ALTER USER postgres WITH PASSWORD 'password';
    
    (注意’;’)
    
    退出PostgreSQL psql客户端
    
    postgres=# q
    
    修改ubuntu操作系统的postgres用户的密码(密码要与数据库用户postgres的密码相同)
    
    切换到root用户
    
    su root
    
    删除PostgreSQL用户密码
    
    sudo passwd -d postgres
    
    passwd -d 是清空指定用户密码的意思
    
    设置PostgreSQL系统用户的密码
    
    sudo -u postgres passwd
    
    按照提示,输入两次新密码
    
    •输入新的 UNIX 密码
    
    重新输入新的 UNIX 密码
    
    •passwd:已成功更新密码

    4.修改PostgresSQL数据库配置实现远程访问,postgreSQL数据可视化工具可以用Navciat(自行百度就有)

    vi /etc/postgresql/9.6/main/postgresql.conf
    
    a.监听任何地址访问,修改连接权限  59行
    
    #listen_addresses = 'localhost' 改为 listen_addresses = '*'
    
    b.启用密码验证 88行
    
    #password_encryption = on 改为 password_encryption = on
    
    vi /etc/postgresql/9.6/main/pg_hba.conf
    
    在文档末尾加上以下内容
    
    host all all 0.0.0.0 0.0.0.0 md5

     重启服务

     /etc/init.d/postgresql restart


    如果开启了防火墙,则要开启5432端口
    ufw allow 5432 (5432为postgreSQL默认的端口)

     安装jq

     apt-get install jq

    5.把fabric-sample例子运行起来

    6.修改blockchain-explorer配置文件

    进入hyperledger目录下执行
    1)git clone https://github.com/hyperledger/blockchain-explorer.git
    
       cd blockchain-explorer/app
    
    (2)更改 explorerconfig.json 的配置
    
    "postgreSQL": {
    
        "host": "127.0.0.1",
    
        "port": "5432",
    
    "database": "fabricexplorer",
    
    "username": "postgres",
    
    "passwd": "password"
    
    }
    (注意这里的用户名称和密码是在安装postgreSQL时设置的)
    (3)运行创建数据库的脚本
    
    在 postgres 用户下执行   需要在 postgres用户下安装node
    
    app/persistence/fabric/postgreSQL/
    
    export DATABASE_HOST=127.0.0.1
    
    export DATABASE_PORT=5432
    
    export DATABASE_DATABASE=fabricexplorer
    
    export DATABASE_USERNAME=postgres
    
    export DATABASE_PASSWD=password
    
    
    
    chmod -R 775 db/
    
    sudo -s -u postgres
    
    ./createdb.sh
    
    (4)配置config.json文件
    
        cd blockchain-explorer/app/platform/fabric
    
        将所有的fabric-path更改为first-network所在的目录
    
    (5)构建Hyperledger Explorer
    
        执行以下步骤:
    
        cd blockchain-explorer
    
    npm install
    
    cd blockchain-explorer/app/test
    
    npm install
    
    npm run test
    
    如果数据库连接失败
    
    sudo sed -i -e '/local.*peer/s/postgres/all/' -e 's/peer|md5/trust/g' /etc/postgresql/*/main/pg_hba.conf
    
    sudo service postgresql restart
    
    cd client/
    
    npm install
    
    npm test -- -u --coverage
    
    npm run build
    
    (6)运行hyperledger explorer
    
    cd blockchain-explorer/
    
    ./start.sh
    
    在浏览器上输入http://localhost:8080 
    
    如果接入自己项目
    修改config.json文件,然后执行

     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

  • 相关阅读:
    zbb20181207 springboot @ConfigurationProperties使用
    zbb20181206 logback,lombok 默认日志logback配置解析
    Spring Boot (8) 全局异常处理
    Spring Boot (7) JdbcTemplate访问数据库
    Spring Boot (6) Spring Data JPA
    Spring Boot (4) 静态页面和Thymeleaf模板
    Spring Boot (3) 热部署devtools
    Spring Boot (2) Restful风格接口
    Spring Boot (1) 构建第一个Spring Boot工程
    idea使用maven搭建ssm框架实现登陆商品增删改查
  • 原文地址:https://www.cnblogs.com/sfgoto/p/10729421.html
Copyright © 2011-2022 走看看