在ubuntu上部署OBC

等一轮残月 海盗王 船龄 9.2年 来源 CSDN
 31660  0
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!
  • 全部
  • 最佳
登录 账号发表你的看法,还没有账号?立即免费 注册
推荐教程
换一批