github代码地址:setupOnUbuntu
部署区块链的OBC及hyperledger/fabric项目程序比较复杂,首先先启动agrant下载一个irtualbox的镜像,之后在该box中安装docker,通过docker来编译项目。
这样会导致两个问题:
1、由于项目需要下载很多外面的依赖,国内墙略高,部署困难
2、使用irtualbox无法在Iass提供商如阿里云上直接部署。
为了解决上面两个问题,自己将官方部署翻译为ubuntu上的部署,代码如下:
#! /bin/bash
# Deelopment on Ubuntu is done on the natie OS, not in Vagrant. This script can be
# used to set up on Ubuntu, similar to deen/setup.sh which does the
# same for Vagrant.
# See https://github.com/hyperledger/fabric/blob/master/docs/de-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-de -y
apt-get install -y make build-essential libssl-de zlib1g-de libbz2-de libreadline-de libsqlite3-de llm
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 real just open a few ports..
iptables -I INPUT 1 -j ACCEPT
sysctl m.oERCommit_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:///ar/run/docker.sockAMPL
##################
# 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 lt;
export GOPATH=$HOME/go
export PATH=$PATH:$HOME/go/bin:/usr/local/go/bin
EOF
source ~/.bashrc
echo `go ersion`
rm go1.6.2.linux-amd64.tar.gz
################
#ROCKSDB BUILD
apt-get install -y libsnappy-de zlib1g-de libbz2-de
cd /tmp
git clone https://github.com/facebook/rocksdb.git
cd rocksdb
git checkout 4.1
PORTABLE=1 make shared_lib
INSTALL_PATH=/usr make install-shared AMPLAMPL ldconfig
################
#Install Pyen Python
cd /tmp
sudo apt-get install libc6-de gcc git -y
sudo apt-get install -y make build-essential libssl-de zlib1g-de libbz2-de libreadline-de libsqlite3-de llm
git clone git://github.com/yyuu/pyen.git ~/.pyen
echo ‘export PYENV_ROOT=”$HOME/.pyen”‘ ~/.bashrc
echo ‘export PATH=”$PYENV_ROOT/bin:$PATH”‘ ~/.bashrc
echo ‘eal “$(pyen init -)”‘ ~/.bashrc
source ~/.bashrc
pyen install 3.5.1 –
pyen rehash
pyen global 3.5.1
pip install –upgrade pip
pip install behae 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 ersion 4.1 and its dependencies
Docker
Pip
Set the maximum number of open files to 65535
pip的安装是先使用pyen安装python,再安装pip。
在脚本运行到末尾时,会自动运行单元测试,结果如下:、
欢迎star!