博客内容为Hyperledger-indy官方部署文档的中文翻译,翻译内容系原创,转载注明来源
【说明】
(1)【撰写目的】
Hyperledger-indy的中文资料较少,希望能为初次接触Hyperledger-indy的小伙伴提供一些参考。(2)【内容说明】
1.黑色中文为对上一行英文内容的翻译。蓝色中文为个人补充说明,用于对部署细节做进一步说明。
2.文档采用意译方式,与英文原文并不是逐字对应。
3.文档为indy-node开发环境部署官方文档的中文人工翻译。Hyperledger
indy-node支持的是indy链功能。
按照此文档部署indy-node开发环境之后,即具备对开源项目indy-node进行运行和开发的条件。(3)文章中如有错误,欢迎留言。Hyperledger-indy下的indy-node,indy-sdk ,aries-cloudagent-python等项目,本人均进行过部署搭建并在企业项目中进行过应用,目前的目标是可以深入了解Hyperledger-indy,挖掘更多应用实现,欢迎随时交流
英文官方文档原文地址:Dev Setup — Hyperledger Indy Node documentation
开发环境部署
There are scripts that can help in setting up environment and project for developers. The scripts are in dev-setup folder.
项目源代码目录下的[dev-setup]文件夹里面包含一些脚本,这些脚本的功能是部署indy-node集群
注:macOS里面是MAC OS系统中自动创建indy-node集群的脚本,ubentu里面是ubentu系统中自动创建indy-node集群的脚本,里面没有CentOS系统中自动创建indy-node集群的脚本
Note: as of now, we provide scripts for Ubuntu only. It’s not guaranteed that the code is working on Windows.
目前仅提供Ubuntu 系统中自动部署indy-node集群的脚本。windows系统中自动部署indy-node集群的方法还处在孵化状态,不提供正式使用
文档很久没更新了,目前提供macOS和Ubuntu平台的部署脚本
开源项目管理体系中,项目提交毕业申请,并经过认证之后,才会提供正式使用
One needs Python 3.5 to work with the code
使用Python3.5运行indy-node代码
We recommend using Python virtual environment for development
推荐使用“python虚拟环境”进行indy-node代码的运行
We use pytest for unit and integration testing
这个项目使用pytest模块实现indy-node项目的单元测试和集成测试
There are some dependencies that must be installed before being able to run the code
运行indy-node之前需要先安装一些依赖 需要的依赖会在下面具体介绍
介绍使用自动安装脚本在Ubuntu系统上部署indy-node
This is a Quick Setup for development on a clean Ubuntu 16.04 machine. You can also have a look at the scripts mentioned below to follow them and perform setup manually.
下面将介绍在Ubuntu 16.04系统机器上快速部署的方法。你也可以参考下面介绍的自动化脚本说明,手工进行开发环境的部署
Get scripts from dev-setup-ubuntu
脚本地址:https://github.com/hyperledger/indy-node/tree/master/dev-setup/ubuntu
Run setup-dev-python.sh
to setup Python3.5, pip and virtualenv
运行脚本setup-dev-python.sh,安装
Python3.5, pip以及virtualenv
注:此处
Run source ~/.bashrc
to apply virtual environment wrapper installation
执行source ~/.bashrc命令,让
virtualenv虚拟环境生效
Run setup-dev-depend-ubuntu16.sh
to setup dependencies (libindy, libindy-crypto, libsodium)
执行setup-dev-depend-ubuntu16.sh安装依赖(依赖包括:
libindy, libindy-crypto, libsodium)
Fork indy-plenum and indy-node
fork(下载 ) indy-plenum 和indy-node
Go to the destination folder for the project
进入到目标目录下
Run init-dev-project.sh
to clone indy-plenum and indy-node projects and create a virtualenv to work in
运行init-dev-project.sh脚本,这个脚本会将
indy-plenum 和indy-node克隆到本地,然后创建用于运行以上2个项目的虚拟环境
Activate new virtualenv workon
激活新的虚拟环境
[Optionally] Install Pycharm
该项为可选项,安装Pycharm
[Optionally] Open and configure projects in Pycharm:
该项为可选项,在Pycharm中打开项目,并做初始化配置
Open both indy-plenum and indy-node in one window
在同一个窗口中打开indy-plenum 和indy-node
Go to File -> Settings
点击File -> Settings
Configure Project Interpreter to use just created virtualenv
配置项目的Interpreter,让项目使用我们自己安装的Python virtualenv
Go to Project: -> Project Interpreter
点击Project: -> Project Interpreter
You’ll see indy-plenum and indy-node projects on the right side tab. For each of them:
在右侧的面板中会看到indy-plenum和indy-node工程,对于每个工程执行以下操作
Click on the project just beside “Project Interpreter” drop down, you’ll see one setting icon, click on it.
点击每个工程上的setting按钮
Select “Add Local”
选择“Add Local”
Select existing virtualenv path as below: /bin/python3.5 For example: /home/user_name/.virtualenvs/new-virtualenv-name>/bin/python3.5
选择已经存在虚拟环境
Configure Project Dependency
配置工程依赖
Go to Project: -> Project Dependencies
点击Project: -> Project Dependencies
Mark each project to be dependent on another one
工程依赖于另外一个工程
Configure pytest
配置pytest
Go to Configure Tools -> Python Integrated tools
点击Configure Tools -> Python Integrated tools
You’ll see indy-plenum and indy-node projects on the right side tab. For each of them:
右侧面板中的indy-plenum 和 indy-node工程
Select Py.test from the ‘Default test runner’
点击Py.test选项,执行Default test runner
Press Apply
点击执行
不使用自动部署脚本,如何部署indy-node集群
1.安装Python
2.安装Libsodium
3.安装Indy-Crypto
4.安装RocksDB
5.安装Libindy
6.配置python虚拟环境(非必要操作,直接用物理机上的python也是可以的)
7.部署indy-node并测试indy-node的部署效果
安装Python
One needs Python 3.5 to work with the code. You can use dev-setup/ubuntu/setup_dev_python.sh
script for quick installation of Python 3.5, pip and virtual environment on Ubuntu, or follow the detailed instructions below.
可以通过dev-setup/ubuntu/setup_dev_python.sh脚本在Ubuntu上快速安装
Python 3.5, pip and virtual environment,也可以根据下面的步骤手动进行安装
Ubuntu
如何在Ubuntu上安装Python3.5
Run sudo add-apt-repository ppa:deadsnakes/ppa
执行sudo add-apt-repository ppa:deadsnakes/ppa
Run sudo apt-get update
执行sudo apt-get update
On Ubuntu 14, run sudo apt-get install python3.5
(python3.5 is pre-installed on most Ubuntu 16 systems; if not, do it there as well.)
在Ubuntu 14中,使用sudo apt-get install python3.5
CentOS/Redhat
如何在CentOS或红帽上安装Python3.5
Run sudo yum install python3.5
执行sudo yum install python3.5
Mac
如何在macOS上安装Python3.5
Go to python.org and from the “Downloads” menu, download the Python 3.5.0 package (python-3.5.0-macosx10.6.pkg) or later.
Open the downloaded file to install it.
If you are a homebrew fan, you can install it using this brew command: brew install python3
To install homebrew package manager, see: brew.sh
Windows
如何在Windows上安装Python3.5
Download the latest build (pywin32-220.win-amd64-py3.5.exe is the latest build as of this writing) from here and run the downloaded executable.
安装Libsodium
Indy also depends on libsodium, an awesome crypto library. These need to be installed separately.
Ubuntu
如何在Ubuntu上安装Libsodium系统库
We need to install libsodium with the package manager. This typically requires a package repo that’s not active by default. Inspect /etc/apt/sources.list
file with your favorite editor (using sudo). On ubuntu 16, you are looking for a line that says deb http://us.archive.ubuntu.com/ubuntu xenial main universe
. On ubuntu 14, look for or add: deb http://ppa.launchpad.net/chris-lea/libsodium/ubuntu trusty main
and deb-src http://ppa.launchpad.net/chris-lea/libsodium/ubuntu trusty main
.
Run sudo apt-get update
. On ubuntu 14, if you get a GPG error about public key not available, run this command and then, after, retry apt-get update: sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys B9316A7BC7917B12
Install libsodium; the version depends on your distro version. On Ubuntu 14, run sudo apt-get install libsodium13
; on Ubuntu 16, run sudo apt-get install libsodium18
CentOS/Redhat
如何在CentOS或红帽上安装Libsodium系统库
Run sudo yum install libsodium-devel
Mac
如何在macOS上安装Libsodium系统库
Once you have homebrew installed, run brew install libsodium
to install libsodium.
Windows
如何在Windows上安装Libsodium系统库
Go to Index of /libsodium/releases/ and download the latest libsodium package (libsodium-1.0.8-mingw.tar.gz is the latest version as of this writing).
When you extract the contents of the downloaded tar file, you will see 2 folders with the names libsodium-win32 and libsodium-win64.
As the name suggests, use the libsodium-win32 if you are using 32-bit machine or libsodium-win64 if you are using a 64-bit operating system.
Copy the libsodium-x.dll from libsodium-win32\bin or libsodium-win64\bin to C:\Windows\System or System32 and rename it to libsodium.dll.
安装Indy-Crypto
这里只演示了如何在Ubuntu系统上安装Indy-Crypto,想要了解在其他系统中如何安装Indy-Crypto,需要看扩展文档,扩展文档地址GitHub - hyperledger-archives/indy-crypto: Archive of Indy Crypto library. Superseded by the Hyperledger Ursa Project.) on how it can b
Indy depends on Indy-Crypto.
There is a deb package of libindy-crypto that can be used on Ubuntu:
sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys CE7709D068DB5E88
sudo add-apt-repository "deb https://repo.sovrin.org/deb xenial master"
sudo apt-get update
sudo apt-get install libindy-crypto
See Indy-Crypto on how it can be installed on other platforms.
Indy depends on RocksDB, an embeddable persistent key-value store for fast storage.
Indy项目使用了RocksDB数据库,RocksDB数据库是一种嵌入式持久化的数据库,以k-v对形式存储数据,RocksDB具有快速存储的特点,
Currently Indy requires RocksDB version 5.8.8 or higher. There is a deb package of RocksDB-5.8.8 and related stuff that can be used on Ubuntu 16.04 (repository configuration steps may be skipped if Indy-Crypto installation steps have been done):
# Start of repository configuration steps
sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys CE7709D068DB5E88
sudo add-apt-repository "deb https://repo.sovrin.org/deb xenial master"
# End of repository configuration steps
sudo apt-get update
sudo apt-get install libbz2-dev \
zlib1g-dev \
liblz4-dev \
libsnappy-dev \
rocksdb=5.8.8
See RocksDB on how it can be installed on other platforms.
想查看如何在其他系统中安装RocksDB,请点击这个地址:GitHub - facebook/rocksdb: A library that provides an embeddable, persistent key-value store for fast storage.
Setup Libindy
Indy needs Libindy as a test dependency.
There is a deb package of libindy that can be used on Ubuntu:
sudo add-apt-repository "deb https://repo.sovrin.org/sdk/deb xenial stable"
sudo apt-get update
sudo apt-get install -y libindy
See Libindy on how it can be installed on other platforms. 想查看如何在其他系统中安装RocksDB,请点击这个地址GitHub - facebook/rocksdb: A library that provides an embeddable, persistent key-value store for fast storage.
We recommend creating a new Python virtual environment for trying out Indy. A virtual environment is a Python environment which is isolated from the system’s default Python environment (you can change that) and any other virtual environment you create.
You can create a new virtual environment by:
virtualenv -p python3.5 <name of virtual environment>
And activate it by:
source <name of virtual environment>/bin/activate
Optionally, you can install virtual environment wrapper as follows:
pip3 install virtualenvwrapper
echo '' >> ~/.bashrc
echo '# Python virtual environment wrapper' >> ~/.bashrc
echo 'export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3' >> ~/.bashrc
echo 'export WORKON_HOME=$HOME/.virtualenvs' >> ~/.bashrc
echo 'source /usr/local/bin/virtualenvwrapper.sh' >> ~/.bashrc
source ~/.bashrc
It allows to create a new virtual environment and activate it by using
mkvirtualenv -p python3.5 <env_name>
workon <env_name>
Activate the virtual environment.
启用Python虚拟环境
Navigate to the root directory of the source (for each project) and install required packages by
跳转到源码根目录下,安装必须的依赖包
下面的命令只是做了个命令示例,安装其他依赖包需要替换安装包名字
pip install -e .[tests]
If you are working with both indy-plenum and indy-node, then please make sure that both projects are installed with -e option, and not from pypi (have a look at the sequence at init-dev-project.sh
).
如果要同时使用indy-node和indy-plenum项目,那么安装这2个项目的时候一定要使用pip install -e进行源码安装,不要使用pipy在线安装
Go to the folder with tests (either indy-plenum
, indy-node/indy_node
, indy-node/indy_client
or indy-node/indy_common
) and run tests
跳转到目标文件夹下进行测试,先面下面展示的是测试命令 需要执行该命令的目录有: indy-plenum, indy-node/indy_node, indy-node/indy_clientor
indy-node/indy_common
pytest .