在IBM Bluemix上部署Hyperledger应用
简介
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应用的更多相关文章
- Eclipse上开发IBM Bluemix应用程序
林炳文Evankaka原创作品. 转载请注明出处http://blog.csdn.net/evankaka 摘要:本文主要解说了怎样使用安装EclipseIBM Bluemix插件.并在Eclipse ...
- 基于IBM Bluemix的数据缓存应用实例
林炳文Evankaka原创作品.转载请注明出处http://blog.csdn.net/evankaka 摘要:IBM® Data Cache for Bluemix 是快速缓存服务.支持 Web 和 ...
- 使用 Bluemix™ Live Sync 高速更新 Bluemix 上执行的应用程序实例
假设您要构建 Node.js 应用程序,那么能够使用 IBM® Bluemix® Live Sync 高速更新 Bluemix 上的应用程序实例,并像在桌面上进行操作一样进行开发,而无需又一次部署.执 ...
- IBM Bluemix体验:Containers
国际版的Bluemix目前有三个region,US South,United Kingdom和Sydney.其中US South是功能最全的,UK其次,Sydney功能最少.Containers服务在 ...
- fedora上部署ASP.NET——(卡带式电脑跑.NET WEB服务器)
andrew,20130601,guilin 本文记录在树莓派(fedora)上部署ASP.NET MVC2 的过程. 本文共分为六部分,分别是前置条件,Apache的安装,Mysql的安装,安装mo ...
- CentOS 7 上部署Mono 4 和Jexus 5.6
概述 在这篇文章中我们将讨论如何在CentOS 7操作系统,安装 jexus. mono 和 配置 jexus,因此它将能够在这种环境中运行一个asp.net mvc 4 应用.这篇文章是描述如何在 ...
- deepsooncms在Ubuntu 14.04上部署教程
deepsooncms在Ubuntu 14.04上部署教程 一.安装mono1.在命令行运行sudo apt-key adv --keyserver keyserver.ubuntu.com --re ...
- 基于Kubernetes在AWS上部署Kafka时遇到的一些问题
作者:Jack47 转载请保留作者和原文出处 欢迎关注我的微信公众账号程序员杰克,两边的文章会同步,也可以添加我的RSS订阅源. 交代一下背景:我们的后台系统是一套使用Kafka消息队列的数据处理管线 ...
- 在 CentOS7 上部署 MySQL 主从
在 CentOS7 上部署 MySQL 主从 通过 SecureCRT 连接至 MySQL 主服务器: 找到 my.cnf 文件所在的目录: mysql --help | grep my.cnf 一般 ...
随机推荐
- 在Linux上用supervisor运行ASP.NET Core站点的一个坑
将一个ASP.NET Core站点在Linux服务器上以self-contained部署方式发布出来后,直接在终端上运行下面的命令,站点可以正常运行. /data/AboutUs/bin/Debug/ ...
- [stm32] STM32 Interrupts and events 系统了解(EXTI)及槽型光电开关tp850电路研究
中断和事件 1 嵌套向量中断控制器 特性: ● 68个可屏蔽中断通道(不包含16个Cortex™-M3的中断线):● 16个可编程的优先等级(使用了4位中断优先级):● 低延迟的异常和中断处理:● 电 ...
- No resource found that matches the given name 'android:Widget.Material.A解决方案
1:首先新建空白工作区 2:先import appcompat_v7 appcompat_v7在一个类似这样的地方, C:\mywork\android\android-sdk-windows\ext ...
- Gradle中的buildScript代码块
在编写Gradle脚本的时候,在build.gradle文件中经常看到这样的代码: build.gradle 1 2 3 4 5 6 7 8 9 buildScript { repositories ...
- IOS 基础-define、const、extern、全局变量
这里介绍一下define.const.extern的用法.优劣以及要注意的地方. 1.define 宏define是定义一个变量,没有类型信息.define定义的常量在内存中有若干个拷贝. defin ...
- IOS Runtime-初识runtime(一)
苹果公布了runtime的源码,可以从地址下载:http://www.opensource.apple.com/tarballs/objc4/ object-c程序在启动的时候,需要一个准备时间,这个 ...
- 每天一个linux命令(59):rcp命令
rcp代表“remote file copy”(远程文件拷贝).该命令用于在计算机之间拷贝文件.rcp命令有两种格式.第一种格式用于文件到文件的拷贝:第二种格式用于把文件或目录拷贝到另一个目录中. 1 ...
- redis常用命令小结
转载于:http://www.itxuexiwang.com/a/shujukujishu/redis/2016/0216/107.html?1455867352 1.redis-benchmarkr ...
- python面向对象随笔
传送门:http://www.runoob.com/python/python-object.html
- settimeout里面函数有无双引号的区别
在写定时器时很容易搞混,所以记下防止忘记. 双引号中的作用域不捕捉局部变量,不用双引号包着的是捕捉局部作用域 var a = function() { alert(1111) } function a ...