简介

IBM Bluemix (http://www.ibm.com/bluemix‎)是一个基于cloud的应用开发和部署平台,提供包括多种服务和运行环境的支持。对Hyperledger应用开发者而言,IBM Bluemix提供免费的入门级区块运行环境。本文介绍了在IBM Bluemix上部署Hyperledger应用的基本过程。

第一步: 在 Bluemix中选择区块服务

登录Bluemix后,在Catalog页面中选择Application Services下的Blochain服务。

确认区块服务的名称,然后点击Create按钮以创建区块服务。

在新建的区块服务页面上点击LAUNCH按钮以启动区块服务,并显示其具体信息。

第二步: 在 Bluemix区块服务中注册用户

首先在区块服务页面中选择 APIs, 然后展开Network's Enroll IDs列表以获取预置的用户名和密码列表 。

然后向选定的区块节点发送如下请求以注册用户

    POST https://e1bb641577f249a88acca04da0272249-vp3.us.blockchain.ibm.com:444/registrar
Content-Type: application/json {
"enrollId": "admin",
"enrollSecret": "19725f3d88"
}

注册成功的响应为

  {
"OK": "Login successful for user 'admin'."
}

第三步: 在 Bluemix区块服务中发布应用代码, 前提是应用的GoLang代码必须在github.com上。

    POST https://e1bb641577f249a88acca04da0272249-vp3.us.blockchain.ibm.com:444/chaincode
Content-Type: application/json {
"jsonrpc": "2.0",
"method": "deploy",
"params": {
"type": 1,
"chaincodeID": {
"path": "https://github.com/huyouhengbc/Hyperledger/HelloWorld"
},
"ctorMsg": {
"function": "init",
"args": [
]
},
"secureContext": "admin"
},
"id": 1
}

发布成功的响应为

    {
"jsonrpc": "2.0",
"result": {
"status": "OK",
"message": "e2623e76371a16ca86d97bfb90bdab95885939bf4f2fa40133d65bca4aace27eaf94d8cd10438b80de097442916f6bfef87fb45a6cd678e3cb6ec0bd8dd008c2"
},
"id": 1
}

第四步: 测试应用代码,

Query请求

    POST https://e1bb641577f249a88acca04da0272249-vp3.us.blockchain.ibm.com:444/chaincode
Content-Type: application/json
{
"jsonrpc": "2.0",
"method": "query",
"params": {
"type": 1,
"chaincodeID": {
"name": "e2623e76371a16ca86d97bfb90bdab95885939bf4f2fa40133d65bca4aace27eaf94d8cd10438b80de097442916f6bfef87fb45a6cd678e3cb6ec0bd8dd008c2"
},
"ctorMsg": {
"function": "hello",
"args": [
]
},
"secureContext": "admin"
},
"id": 3
}

Query响应

    200 OK
access-control-allow-headers: accept, content-type
Access-Control-Allow-Origin: *
Content-Type: application/json
Date: Sun, 30 Oct 2016 05:13:58 GMT
Content-Length: 73
Server: nghttpx nghttp2/1.14.0-DEV
Via: 1.1 nghttpx
X-Firefox-Spdy: h2 {"jsonrpc":"2.0","result":{"status":"OK","message":"Hello World"},"id":3}

Invoke请求

    POST https://e1bb641577f249a88acca04da0272249-vp3.us.blockchain.ibm.com:444/chaincode
Content-Type: application/json
{
"jsonrpc": "2.0",
"method": "invoke",
"params": {
"type": 1,
"chaincodeID": {
"name": "e2623e76371a16ca86d97bfb90bdab95885939bf4f2fa40133d65bca4aace27eaf94d8cd10438b80de097442916f6bfef87fb45a6cd678e3cb6ec0bd8dd008c2"
},
"ctorMsg": {
"function": "hello",
"args": [
]
},
"secureContext": "admin"
},
"id": 3
}

Invoke响应

    200 OK
access-control-allow-headers: accept, content-type
Access-Control-Allow-Origin: *
Content-Type: application/json
Date: Sun, 30 Oct 2016 05:13:22 GMT
Content-Length: 98
Server: nghttpx nghttp2/1.14.0-DEV
Via: 1.1 nghttpx
X-Firefox-Spdy: h2 {"jsonrpc":"2.0","result":{"status":"OK","message":"d74495ff-f3d3-44ba-acc6-5fbc767bbf21"},"id":3}

后记

  • 发布应用代码中的path指向的是GoLang代码所在的目录,而不是GoLang源码文件, 错误响应如下:
    POST  https://e1bb641577f249a88acca04da0272249-vp0.us.blockchain.ibm.com:444/chaincode
Content-Type: application/json
{
"jsonrpc": "2.0",
"method": "deploy",
"params": {
"type": 1,
"chaincodeID": {
"path": "https://github.com/huyouhengbc/Hyperledger/blob/master/HelloWorld/HelloWorld.go"
},
"ctorMsg": {
"function": "init",
"args": [
]
},
"secureContext": "user_type8_0"
},
"id": 1
}
-- response --
200 OK
access-control-allow-headers: accept, content-type
Access-Control-Allow-Origin: *
Content-Type: application/json
Date: Sun, 30 Oct 2016 04:00:14 GMT
Content-Length: 721
Server: nghttpx nghttp2/1.14.0-DEV
Via: 1.1 nghttpx
X-Firefox-Spdy: h2 {"jsonrpc":"2.0","error":{"code":-32001,"message":"Deployment failure","data":"Error when deploying chaincode: Error getting chaincode package bytes: Error getting code 'go get' failed with error: 'exit status 1'\npackage github.com/huyouhengbc/Hyperledger/blob/master/HelloWorld/HelloWorld.go: cannot find package 'github.com/huyouhengbc/Hyperledger/blob/master/HelloWorld/HelloWorld.go' in any of:\n\t/usr/local/go/src/github.com/huyouhengbc/Hyperledger/blob/master/HelloWorld/HelloWorld.go (from $GOROOT)\n\t/go/_usercode_/234208637/src/github.com/huyouhengbc/Hyperledger/blob/master/HelloWorld/HelloWorld.go (from $GOPATH)\n\t/go/src/github.com/huyouhengbc/Hyperledger/blob/master/HelloWorld/HelloWorld.go\n"},"id":1}
  • Bluemix提供基于基于Hyperledger Fabric v0.5的服务,如果使用最新的Hyperledger Fabric接口, 发布应用时错误响应如下:
    {
"jsonrpc": "2.0",
"error": {
"code": -32001,
"message": "Deployment failure",
"data": "Error when deploying chaincode: Error getting chaincode package bytes: Error getting code 'go get' failed with error: 'exit status 2'\n# github.com/huyouhengbc/Hyperledger/HelloWorld\n/go/_usercode_/730749822/src/github.com/huyouhengbc/Hyperledger/HelloWorld/HelloWorld.go:15: undefined: shim.ChaincodeStubInterface\n/go/_usercode_/730749822/src/github.com/huyouhengbc/Hyperledger/HelloWorld/HelloWorld.go:21: undefined: shim.ChaincodeStubInterface\n/go/_usercode_/730749822/src/github.com/huyouhengbc/Hyperledger/HelloWorld/HelloWorld.go:27: undefined: shim.ChaincodeStubInterface\n"
},
"id": 1
}
  • 发布应用报错
    {
"jsonrpc": "2.0",
"error": {
"code": -32001,
"message": "Deployment failure",
"data": "Error when deploying chaincode: Failed loading TCerts from TCA"
},
"id": 1
}

解决方法: 在 Demo Chaincoded下发布示例应用,选择Show API details输出中使用的节点。

总结

本文介绍了在IBM Bluemix上部署Hyperledger应用的基本过程。

在IBM Bluemix上部署Hyperledger应用的更多相关文章

  1. Eclipse上开发IBM Bluemix应用程序

    林炳文Evankaka原创作品. 转载请注明出处http://blog.csdn.net/evankaka 摘要:本文主要解说了怎样使用安装EclipseIBM Bluemix插件.并在Eclipse ...

  2. 基于IBM Bluemix的数据缓存应用实例

    林炳文Evankaka原创作品.转载请注明出处http://blog.csdn.net/evankaka 摘要:IBM® Data Cache for Bluemix 是快速缓存服务.支持 Web 和 ...

  3. 使用 Bluemix™ Live Sync 高速更新 Bluemix 上执行的应用程序实例

    假设您要构建 Node.js 应用程序,那么能够使用 IBM® Bluemix® Live Sync 高速更新 Bluemix 上的应用程序实例,并像在桌面上进行操作一样进行开发,而无需又一次部署.执 ...

  4. IBM Bluemix体验:Containers

    国际版的Bluemix目前有三个region,US South,United Kingdom和Sydney.其中US South是功能最全的,UK其次,Sydney功能最少.Containers服务在 ...

  5. fedora上部署ASP.NET——(卡带式电脑跑.NET WEB服务器)

    andrew,20130601,guilin 本文记录在树莓派(fedora)上部署ASP.NET MVC2 的过程. 本文共分为六部分,分别是前置条件,Apache的安装,Mysql的安装,安装mo ...

  6. CentOS 7 上部署Mono 4 和Jexus 5.6

    概述 在这篇文章中我们将讨论如何在CentOS 7操作系统,安装 jexus. mono 和 配置 jexus,因此它将能够在这种环境中运行一个asp.net mvc 4 应用.这篇文章是描述如何在 ...

  7. deepsooncms在Ubuntu 14.04上部署教程

    deepsooncms在Ubuntu 14.04上部署教程 一.安装mono1.在命令行运行sudo apt-key adv --keyserver keyserver.ubuntu.com --re ...

  8. 基于Kubernetes在AWS上部署Kafka时遇到的一些问题

    作者:Jack47 转载请保留作者和原文出处 欢迎关注我的微信公众账号程序员杰克,两边的文章会同步,也可以添加我的RSS订阅源. 交代一下背景:我们的后台系统是一套使用Kafka消息队列的数据处理管线 ...

  9. 在 CentOS7 上部署 MySQL 主从

    在 CentOS7 上部署 MySQL 主从 通过 SecureCRT 连接至 MySQL 主服务器: 找到 my.cnf 文件所在的目录: mysql --help | grep my.cnf 一般 ...

随机推荐

  1. 【转】java.lang.OutOfMemoryError: Java heap space的解决

    原文地址:http://blog.sina.com.cn/s/blog_4b12778b0100v0bb.html Myeclipse下java.lang.OutOfMemoryError: Java ...

  2. HTML5按钮的点击态问题

    开始在网页上实现点击态是mousedown mouseup来实现但是手机HTML5实现点击态怎么就不可以了呢 经过查资料才知道手机浏览器来实现点击态是通过 touchstart touchend实现

  3. 【译】用Fragment解决屏幕旋转(状态发生变化)状态不能保持的问题

    这篇文章解决了在StackOverflow上一个经常被提到的问题. 在配置发生变化(Configuration changs)时,什么是最好的保存活动对象方法,比如运行中的线程,Sockets,Asy ...

  4. onCreateView中加载大位图

    我的一个Fragment中,加载了一个1024*1024的图片,非常卡.解决办法 1. 将图片改为512*512 2. 异步加载. final SmartImageView mizige = (Sma ...

  5. 微软承诺将在今年的 Visual C++ 更新中加入 Clang 编译器

    微软最近发布将在2015年11月 Visual C++ 更新中加入 Clang 编译器 ,Clang 开源编译器以相比GCC更快的编译速度和更优的错误提示著称. Clang关于C,C++,及Objec ...

  6. linux网络编程系列-网络连接的建立

    一个比较实用的连接函数,支持host为域名. #include <netdb.h> #include <sys/socket.h> #include <sys/types ...

  7. 微信分享调用 -- c#篇

    微信分享调用JS -- c#篇   1.前端 1.1 导入微信端的JS 如果你的网址是http,则地址为  http://res.wx.qq.com/open/js/jweixin-1.0.0.js ...

  8. http 各个状态码及对应的java 编程

    http的状态? 200 301 302 400 404 500 501 等等 如何编码? 其实这个是web服务器的范畴.服务器处理各个请求的时候,如果正常, 自然就是200 http://www.c ...

  9. Atitit  发帖机实现(1)-----UsrQBm2008 页面上下文规范

    Atitit  发帖机实现(1)-----UsrQBm2008 页面上下文规范 1.1. 网站绝对路径,页面绝对路径1 1.2. Java的javax.servlet.ServletContext1 ...

  10. 每天一个linux命令(13):less 命令

    less 工具也是对文件或其它输出进行分页显示的工具,应该说是linux正统查看文件内容的工具,功能极其强大.less 的用法比起 more 更加的有弹性.在 more 的时候,我们并没有办法向前面翻 ...