mt logoMyToken
总市值:
0%
恐慌指数:
0%
币种:--
交易所 --
ETH Gas:--
EN
USD
APP
Ap Store QR Code

Scan Download

在ubuntu上部署OBC

收藏
分享
github代码地址: setupOnUbuntu
部署区块链的OBC及hyperledger/fabric项目程序比较复杂,首先先启动vagrant下载一个virtualbox的镜像,之后在该box中安装docker,通过docker来编译项目。
这样会导致两个问题:
1、由于项目需要下载很多外面的依赖,国内墙略高,部署困难
2、使用virtualbox无法在Iass提供商如阿里云上直接部署。

为了解决上面两个问题,自己将官方部署翻译为ubuntu上的部署,代码如下:

#! /bin/bash
# Development on Ubuntu is done on the native OS, not in Vagrant. This script can be
# used to set up on Ubuntu, similar to devenv/setup.sh which does the
# same for Vagrant.
# See https://github.com/hyperledger/fabric/blob/master/docs/dev-setup/install.md
#
if [ xroot != x$(whoami) ]
then
echo "You must run as root (Hint: sudo su)"
exit
fi
apt-get update
apt-get install git curl gcc g++ yum  wget libc6-dev -y
apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev llvm
apt-get upgrade gcc g++ -y
#Set the maximum number of open files to 10000 or greater for your OS
ulimit -n 65535
#TODO: should really just open a few ports..
iptables -I INPUT 1 -j ACCEPT
sysctl vm.overcommit_memory=1
##################
# Install Docker
mkdir $HOME/tmp
cd /tmp
wget -qO- https://get.docker.com/ | sh
#TODO: Install on boot
nohup docker daemon -g /data/docker -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock&
##################
# Install Golang
curl -O https://storage.googleapis.com/golang/go1.6.2.linux-amd64.tar.gz
tar -C /usr/local -xzf go1.6.2.linux-amd64.tar.gz
mkdir -p ~/go; echo "" >> ~/.bashrc
cat >> ~/.bashrc <
export GOPATH=$HOME/go
export PATH=$PATH:$HOME/go/bin:/usr/local/go/bin
EOF
source ~/.bashrc
echo `go version`
rm go1.6.2.linux-amd64.tar.gz
################
#ROCKSDB BUILD
apt-get install -y libsnappy-dev zlib1g-dev libbz2-dev
cd /tmp
git clone https://github.com/facebook/rocksdb.git
cd rocksdb
git checkout v4.1
PORTABLE=1 make shared_lib
INSTALL_PATH=/usr make install-shared && ldconfig
################
#Install Pyenv Python
cd /tmp
sudo apt-get install libc6-dev gcc git -y
sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev llvm
git clone git://github.com/yyuu/pyenv.git ~/.pyenv
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(pyenv init -)"' >> ~/.bashrc
source ~/.bashrc
pyenv install 3.5.1 -v
pyenv rehash
pyenv global 3.5.1
pip install --upgrade pip
pip install behave nose docker-compose
pip install -I flask==0.10.1 python-dateutil==2.2 pytz==2014.3 pyyaml==3.10 couchdb==1.0 flask-cors==2.0.1 requests==2.4.3
##################
# clone project
mkdir -p $HOME/go/src/github.com/hyperledger
cd $HOME/go/src/github.com/hyperledger
git clone https://github.com/hyperledger/fabric.git
cd fabric/
make peer unit-test

在上面的脚本中,主要做了下面几件事情:

Git client
Go - 1.6 or later
RocksDB version 4.1 and its dependencies
Docker
Pip
Set the maximum number of open files to 65535

pip的安装是先使用pyenv安装python,再安装pip。
在脚本运行到末尾时,会自动运行单元测试,结果如下:、
欢迎star!
免责声明:本文版权归原作者所有,不代表MyToken(www.mytokencap.com)观点和立场;如有关于内容、版权等问题,请与我们联系。
相关阅读