Hyperledger Fabric 1.3 官方文档翻译(四)入门 (Getting Started)

文章目录

  • 入门(Getting Started)
    • 先决条件(Prerequisites)
      • Install cURL???
      • Docker and Docker Compose
      • Go Programming Language
      • Node.js Runtime and NPM
        • Python
      • Windows附加功能(Windows extras)
    • Install Samples, Binaries and Docker Images
    • Hyperledger Fabric SDKs
    • Hyperledger Fabric CA

入门(Getting Started)

Before we begin, if you haven’t already done so, you may wish to check that you have all the Prerequisites installed on the platform(s) on which you’ll be developing blockchain applications and/or operating Hyperledger Fabric.
在我们开始之前,如果你还没有这样做,你可能希望检查你是否已在将要开发区块链应用程序和/或运行Hyperledger Fabric的平台上安装了所有先决条件

Once you have the prerequisites installed, you are ready to download and install HyperLedger Fabric. While we work on developing real installers for the Fabric binaries, we provide a script that will Install Samples, Binaries and Docker Images to your system. The script also will download the Docker images to your local registry.
安装必备组件后,即可下载并安装HyperLedger Fabric。 在我们为Fabric二进制文件开发真正的安装程序时,我们提供了一个脚本,它将安装样本、二进制文件和Docker镜像到你的系统。 该脚本还将Docker镜像下载到本地注册表。

先决条件(Prerequisites)

Before we begin, if you haven’t already done so, you may wish to check that you have all the prerequisites below installed on the platform(s) on which you’ll be developing blockchain applications and/or operating Hyperledger Fabric.
在我们开始之前,如果你还没有这样做,你可能希望检查以下所有先决条件是否已安装在你将开发区块链应用程序和/或运行Hyperledger Fabric的平台上。

Install cURL???

Download the latest version of the cURL tool if it is not already installed or if you get errors running the curl commands from the documentation.
下载最新版本的cURL工具(如果尚未安装)或者运行文档中curl命令时出错。

If you’re on Windows please see the specific note on Windows extras below.
如果你使用的是Windows,请参阅以下Windows附加内容中的特定说明。

Docker and Docker Compose

You will need the following installed on the platform on which you will be operating, or developing on (or for), Hyperledger Fabric:
你需要在将要运行或在(或为)Hyperledger Fabric上开发的平台上安装以下内容:

你将需要在将要运行或在(或为)Hyperledger Fabric上开发的平台上安装以下内容:

  • MacOSX, *nix, or Windows 10: Docker Docker version 17.06.2-ce or greater is required.
    MacOSX,*nix或Windows 10:Docker需要Docker版本17.06.2-ce或更高版本。
  • Older versions of Windows: Docker Toolbox - again, Docker version Docker 17.06.2-ce or greater is required.
    较旧版本的Windows:Docker Toolbox ,Docker版本Docker 17.06.2-ce或更高版本。
    (也就是说Windows 7要先装Docker Toolbox)

You can check the version of Docker you have installed with the following command from a terminal prompt:
你可以使用终端提示符中的以下命令检查已安装的Docker的版本:

docker --version

Installing Docker for Mac or Windows, or Docker Toolbox will also install Docker Compose. If you already had Docker installed, you should check that you have Docker Compose version 1.14.0 or greater installed. If not, we recommend that you install a more recent version of Docker.
安装Docker for Mac或Windows,或Docker Toolbox也将同时安装Docker Compose。 如果你已安装Docker,则应检查是否已安装Docker Compose版本1.14.0或更高版本。 如果没有,我们建议你安装更新版本的Docker。
(也就是说Linux要另外安装Docker Compose)
You can check the version of Docker Compose you have installed with the following command from a terminal prompt:
你可以使用终端提示符中的以下命令检查已安装的Docker Compose的版本:

docker-compose --version

Go Programming Language

Hyperledger Fabric uses the Go Programming Language for many of its components.
Hyperledger Fabric对其许多组件使用Go编程语言。

  • Go version 1.10.x is required.
    (如果打不开可以使用这个地址:https://golang.google.cn/dl/。)

Given that we will be writing chaincode programs in Go, there are two environment variables you will need to set properly; you can make these settings permanent by placing them in the appropriate startup file, such as your personal ~/.bashrc file if you are using the bash shell under Linux.
鉴于我们将在Go中编写链代码程序,你需要正确设置两个环境变量; 你可以通过将它们放在适当的启动文件中来永久保存这些设置,例如你的个人~/.bashrc文件,如果你在Linux下使用bash shell。

First, you must set the environment variable GOPATH to point at the Go workspace containing the downloaded Fabric code base, with something like:
首先,必须将环境变量“GOPATH”设置为指向包含下载的Fabric代码库的Go工作空间,具体如下:

export GOPATH=$HOME/go

You must set the GOPATH variable
你必须设置GOPATH变量

Even though, in Linux, Go’s GOPATH variable can be a colon-separated list of directories, and will use a default value of $HOME/go if it is unset, the current Fabric build framework still requires you to set and export that variable, and it must contain only the single directory name for your Go workspace. (This restriction might be removed in a future release.)
即使在Linux中,Go的GOPATH变量可以是以冒号分隔的目录列表,如果未设置,将使用默认值$ HOME/go,当前的Fabric构建框架仍然需要你设置和导出该变量,它必须只包含Go工作区的单个目录名称。 (此限制可能会在将来的版本中删除。)

Second, you should (again, in the appropriate startup file) extend your command search path to include the Go bin directory, such as the following example for bash under Linux:
其次,你应该(再次,在相应的启动文件中)扩展你的命令搜索路径以包含Go bin目录,例如Linux下的bash的以下示例:

export PATH=$PATH:$GOPATH/bin

While this directory may not exist in a new Go workspace installation, it is populated later by the Fabric build system with a small number of Go executables used by other parts of the build system. So even if you currently have no such directory yet, extend your shell search path as above.
虽然此目录可能不存在于新的Go工作区安装中,但稍后由Fabric构建系统填充,其中构建系统的其他部分使用少量Go可执行文件。 因此,即使你目前还没有此类目录,也可以像上面那样扩展shell搜索路径。

Node.js Runtime and NPM

If you will be developing applications for Hyperledger Fabric leveraging the Hyperledger Fabric SDK for Node.js, you will need to have version 8.9.x of Node.js installed.
如果你将利用针对Node.js的Hyperledger Fabric SDK开发Hyperledger Fabric的应用程序,则需要安装版本8.9.x的Node.js.

Node.js version 9.x is not supported at this time.
**目前不支持Node.js版本9.x. **

  • Node.js - version 8.9.x or greater
    ** Node.js - 版本8.9.x或更高版本**

Installing Node.js will also install NPM, however it is recommended that you confirm the version of NPM installed. You can upgrade the npm tool with the following command:
安装Node.js也会安装NPM,但建议你确认安装的NPM版本。 你可以使用以下命令升级npm工具:

npm install [email protected] -g

Python

The following applies to Ubuntu 16.04 users only.
以下内容仅适用于Ubuntu 16.04用户。

By default Ubuntu 16.04 comes with Python 3.5.1 installed as the python3 binary. The Fabric Node.js SDK requires an iteration of Python 2.7 in order for npm install operations to complete successfully. Retrieve the 2.7 version with the following command:
默认情况下,Ubuntu 16.04附带了作为python3二进制文件安装的Python 3.5.1。 Fabric Node.js SDK需要Python 2.7才能成功完成npm install操作。 使用以下命令检索2.7版本:

sudo apt-get install python

Check your version(s):

python --version

Windows附加功能(Windows extras)

If you are developing on Windows 7, you will want to work within the Docker Quickstart Terminal which uses Git Bash and provides a better alternative to the built-in Windows shell.
如果你在Windows 7上进行开发,则需要在使用Git Bash的Docker Quickstart Terminal中工作,并提供内置Windows shell的更好替代方案。

However experience has shown this to be a poor development environment with limited functionality. It is suitable to run Docker based scenarios, such as Getting Started, but you may have difficulties with operations involving the make and docker commands.
然而,经验表明这是一个功能有限的可怜开发环境。 它适合运行基于Docker的方案,但是你可能涉及makedocker命令这些不同的操作。

On Windows 10 you should use the native Docker distribution and you may use the Windows PowerShell. However, for the binaries command to succeed you will still need to have the uname command available. You can get it as part of Git but beware that only the 64bit version is supported.
在Windows 10上,你应该使用本机Docker发行版,并且可以使用Windows PowerShell。 但是,要使binaries命令成功,你仍需要使用uname命令。 你可以把它作为Git的一部分,但要注意只支持64位版本。

Before running any git clone commands, run the following commands:
在运行任何git clone命令之前,请运行以下命令:

git config --global core.autocrlf false
git config --global core.longpaths true

You can check the setting of these parameters with the following commands:
你可以使用以下命令检查这些参数的设置:

git config --get core.autocrlf
git config --get core.longpaths

These need to be false and true respectively.
这些分别需要是falsetrue

The curl command that comes with Git and Docker Toolbox is old and does not handle properly the redirect used in Getting Started. Make sure you install and use a newer version from the cURL downloads page
Git和Docker Toolbox附带的curl命令很旧,无法正确处理重定向。 确保从cURL下载页面安装并使用较新版本

For Node.js you also need the necessary Visual Studio C++ Build Tools which are freely available and can be installed with the following command:
对于Node.js,你还需要免费提供的必要Visual Studio C ++构建工具,可以使用以下命令进行安装:

npm install --global windows-build-tools

See the NPM windows-build-tools page for more details.
有关详细信息,请参阅NPM windows-build-tools页面。

Once this is done, you should also install the NPM GRPC module with the following command:
完成此操作后,还应使用以下命令安装NPM GRPC模块:

npm install --global grpc

Your environment should now be ready to go through the Getting Started samples and tutorials.
你的环境现在应该已准备好通过入门样例和教程。

If you have questions not addressed by this documentation, or run into issues with any of the tutorials, please visit the Still Have Questions? page for some tips on where to find additional help.
如果你有本文档未解决的问题,或遇到任何教程的问题,请访问仍有疑问? 有关如何寻找其他帮助的一些提示的页面。

Install Samples, Binaries and Docker Images

While we work on developing real installers for the Hyperledger Fabric binaries, we provide a script that will download and install samples and binaries to your system. We think that you’ll find the sample applications installed useful to learn more about the capabilities and operations of Hyperledger Fabric.
在我们为Hyperledger Fabric二进制文件开发真正的安装程序时,我们提供了一个脚本,可以下载并安装样本和二进制文件到你的系统。我们认为你会发现安装的样例应用程序非常有用,可以了解有关Hyperledger Fabric的功能和操作的更多信息。

If you are running on Windows you will want to make use of the Docker Quickstart Terminal for the upcoming terminal commands. Please visit the Prerequisites if you haven’t previously installed it.
如果你在Windows上运行,你将需要使用Docker Quickstart Terminal来执行即将发布的终端命令。如果你之前没有安装过,请看上面的“先决条件”。

If you are using Docker Toolbox on Windows 7 or macOS, you will need to use a location under C:\Users (Windows 7) or /Users (macOS) when installing and running the samples.
如果你在Windows 7或macOS上使用Docker Toolbox,则在安装和运行样例时,你需要使用“C:\ Users”(Windows 7)或“/ Users”(macOS)下的位置。

If you are using Docker for Mac, you will need to use a location under /Users, /Volumes, /private, or /tmp. To use a different location, please consult the Docker documentation for file sharing.
如果你使用的是Docker for Mac,则需要使用/Users/Volumes/private/tmp下的位置。要使用其他位置,请参阅Docker文档以获取文件共享。

If you are using Docker for Windows, please consult the Docker documentation for shared drives and use a location under one of the shared drives.
如果你使用的是Docker for Windows,请参阅Docker文档的共享驱动器并使用其中一个位置共享驱动器。

Determine a location on your machine where you want to place the fabric-samples repository and enter that directory in a terminal window. The command that follows will perform the following steps:
确定计算机上要放置fabric-samples存储库的位置,并在终端窗口中输入该目录。后面的命令将执行以下步骤:

  1. If needed, clone the hyperledger/fabric-samples repository
    如果需要,克隆hyperledger/fabric-samples存储库
  2. Checkout the appropriate version tag
    签出相应的版本标签
  3. Install the Hyperledger Fabric platform-specific binaries and config files for the version specified into the root of the fabric-samples repository
    将指定版本的Hyperledger Fabric平台特定二进制文件和配置文件安装到fabric-samples存储库的根目录中
  4. Download the Hyperledger Fabric docker images for the version specified
    下载指定版本的Hyperledger Fabric docker镜像

Once you are ready, and in the directory into which you will install the Fabric Samples and binaries, go ahead and execute the following command:
准备好后,在要安装Fabric Samples和二进制文件的目录中,继续执行以下命令:

curl -sSL http://bit.ly/2ysbOFE | bash -s 1.3.0

If you want to download Fabric, Fabric-ca and thirdparty Docker images you must pass the version identifier to the script.
如果要下载Fabric,Fabric-ca和第三方Docker镜像,则必须将版本标识符传递给脚本。

curl -sSL http://bit.ly/2ysbOFE | bash -s   
curl -sSL http://bit.ly/2ysbOFE | bash -s 1.3.0 1.3.0 0.4.13

If you get an error running the above curl command, you may have too old a version of curl that does not handle redirects or an unsupported environment.
如果运行上述curl命令时出错,则可能是旧版本的curl版本太旧,无法处理重定向或在不受支持的环境。

Please visit the Prerequisites page for additional information on where to find the latest version of curl and get the right environment. Alternately, you can substitute the un-shortened URL: https://github.com/hyperledger/fabric/blob/master/scripts/bootstrap.sh
请看“先决条件”,了解有关在何处查找最新版curl并获得正确环境的其他信息。 或者,你可以替换未缩短的URL:https://github.com/hyperledger/fabric/blob/master/scripts/bootstrap.sh

(bit.ly好像在国内访问不了,把上面这个bootstrap.sh保存到你的项目目录,如$GOPATH/src/github.com/hyperledger,chmod +x 成可执行文件,在命令行执行./bootstrap.sh

You can use the command above for any published version of Hyperledger Fabric. Simply replace 1.3.0 with the version identifier of the version you wish to install.
你可以对任何已发布的Hyperledger Fabric版本使用上述命令。 只需将1.3.0替换为你要安装的版本的版本标识符。

The command above downloads and executes a bash script that will download and extract all of the platform-specific binaries you will need to set up your network and place them into the cloned repo you created above. It retrieves the following platform-specific binaries:
上面的命令下载并执行一个bash脚本,该脚本将下载并提取设置网络所需的所有特定于平台的二进制文件,并将它们放入你在上面创建的克隆仓库中。 它检索以下特定于平台的二进制文件:

  • cryptogen,
  • configtxgen,
  • configtxlator,
  • peer,
  • orderer,
  • idemixgen, and
  • fabric-ca-client
    and places them in the bin sub-directory of the current working directory.
    并将它们放在当前工作目录的bin子目录中。

You may want to add that to your PATH environment variable so that these can be picked up without fully qualifying the path to each binary. e.g.:
你可能希望将其添加到PATH环境变量中,以便在不完全限定每个二进制文件的路径的情况下拾取这些变量。 例如。:

export PATH=/bin:$PATH

Finally, the script will download the Hyperledger Fabric docker images from Docker Hub into your local Docker registry and tag them as ‘latest’.
最后,该脚本会将Docker Hub中的Hyperledger Fabric docker映像下载到本地Docker注册表中,并将其标记为“最新”。

The script lists out the Docker images installed upon conclusion.
该脚本列出了结束时安装的Docker镜像。

Look at the names for each image; these are the components that will ultimately comprise our Hyperledger Fabric network. You will also notice that you have two instances of the same image ID - one tagged as “amd64-1.x.x” and one tagged as “latest”. Prior to 1.2.0, the image being downloaded was determined by uname -m and showed as “x86_64-1.x.x”.
查看每个影像的名称;这些组件最终将构成我们的Hyperledger Fabric网络。你还会注意到,你有两个具有相同影像ID的实例 - 一个标记为“amd64-1.x.x”,另一个标记为“最新”。在1.2.0之前,下载的影像由uname -m确定,并显示为“x86_64-1.x.x”。

On different architectures, the x86_64/amd64 would be replaced with the string identifying your architecture.
在不同的体系结构中,x86_64/amd64将替换为标识你的体系结构的字符串。

On different architectures, the x86_64/amd64 would be replaced with the string identifying your architecture.
如果你有本文档未解决的问题,或遇到任何教程的问题,请访问仍有疑问?有关如何寻找其他帮助的一些提示的页面。

Hyperledger Fabric SDKs

Hyperledger Fabric offers a number of SDKs to support various programming languages. There are two officially released SDKs for Node.js and Java:
Hyperledger Fabric提供了许多SDK来支持各种编程语言。 有两个正式发布的Node.js和Java SDK:

Hyperledger Fabric Node SDK and Node SDK documentation.
Hyperledger Fabric Java SDK.
In addition, there are three more SDKs that have not yet been officially released (for Python, Go and REST), but they are still available for downloading and testing:
此外,还有三个尚未正式发布的SDK(适用于Python,Go和REST),但它们仍可供下载和测试:

Hyperledger Fabric Python SDK.
Hyperledger Fabric Go SDK.
Hyperledger Fabric REST SDK.

Hyperledger Fabric CA

Hyperledger Fabric provides an optional certificate authority service that you may choose to use to generate the certificates and key material to configure and manage identity in your blockchain network. However, any CA that can generate ECDSA certificates may be used.
Hyperledger Fabric提供可选的证书颁发机构服务,你可以选择使用它来生成证书和密钥材料,以配置和管理区块链网络中的身份。但是,可以使用任何可以生成ECDSA证书的CA。

你可能感兴趣的:(区块链)