如何在ubuntu上部署開發區塊鏈數字貨幣
最後更新:2018-07-24
來源:互聯網
上載者:User
區塊鏈愛好者(QQ:53016353)
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
#
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-
#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。