LINUX Ubuntu安装composer流程
The following are prerequisites for installing the required development tools:Operating Systems:
Ubuntu Linux 14.04/ 16.04 LTS (both 64-bit), or Mac OS 10.12
Docker Engine: Version 17.03 or higher
Docker-Compose: Version 1.8 or higher
Node: 8.9 or higher (note version 9 and higher is not supported)
npm: v5.x
git: 2.9.x or higher
Python: 2.7.x
1.安装虚拟机
虚拟机至少4G内存,双核或4核CPU.
系统Ubuntu Linux 16.04 LTS (64-bit)
官网提示在正式安装流程中,请使用普通用户登录并安装,尽量不要用root用户进行安装。尤其避免全局安装node时使用root用户。
If installing Hyperledger Composer using Linux, be aware of the following advice:
Login as a normal user, rather than root.
Do not su to root.
When installing prerequisites, use curl, then unzip using .
Run prereqs-ubuntu.sh as a normal user. It may prompt for root password as some of it’s actions are required to be run as root.
Do not use npm with or su to root to use it.
Avoid installing node globally as root.
在node和npm严格地不能使用root用户安装。其他软件可以用普通用户执行sudo命令安装。如果遇到需要root权限才能安装的软件,如docker,那么在提示说需要root权限的时候,升级到root权限去执行,没有问题。
2,安装Nodejs并升级到指定版本
Nodejs最好安装8.11.4,不能高不能低;npm 装5.6.0,也是不能高不能低
更新apt
sudo apt-get updat`e
安装nodejs
方法一,通过二进制文件安装(经测试可以成功运行)
这样通过官网下载二进制文件安装nodejs(这个步骤就避免了使用sudo)
首先到 NodeJS 的官网(https://nodejs.org/en/download/)下载对应的已经编译好的二进制包,我这里下载的是node-v8.11.4-linux-x64.tar.xz,
然后上传到虚拟机,
将node-v8.11.4-linux-x64.tar.xz复制到你想解压的目录下(这里/home/lxq/tools/nodejs为例,这里必须将文件移动到另一个目录下,否则直接解压就有可能出现问题了),
进入nodejs目录下 解压 tar xvJf node-v8.11.4-linux-x64.tar.xz(解压之后我将名字改为node)
进入bin目录 cd node/bin
查看版本号 ./node –v
看node版本号,显示版本号,证明包没问题
设置全局访问
vi ~/.profile
PATH="$HOME/tools/nodejs/node/bin:$PATH"
source ~/.profile
之后执行node –v和node –v看是否显示版本号,若显示说明成功了
方法二,用sudo apt命令安装(经测试也可以)
sudo apt-get install nodejs
sudo apt install nodejs-legacy
sudo apt install npm
更新npm的包镜像源,方便快速下载
npm config set registry https://registry.npm.taobao.org
npm config list
全局安装n管理器(用于管理nodejs版本)
npm install n -g
更新nodejs
n v8.11.4
更新npm
npm -g install npm@5.6.0
3.安装python2.7.X
sudo apt-get install python2.7 python2.7-dev
4.安装git
sudo apt-get install git
查看版本号
git--version
更新提示:
sudo add-apt-repository ppa:git-core/ppa
sudo apt-get update
sudo apt-get install git
(注: git最新版本是2.21.0,显然比要求的2.9.X高很多,这样就可以了)
5.安装docker
step 1: 安装必要的一些系统工具
sudo apt-get update
sudo apt-get -y install apt-transport-https ca-certificates curl software-properties-common
step 2: 安装GPG证书
sudo curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | apt-key add -
Step 3: 写入软件源信息
sudo add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
apt-get -y update
以上可能出现的错误:Ubuntu用 apt-get update出错:E: Problem executing scripts APT::Update::Post-Invoke-Success
解决方案:先删除libappstream3
apt remove libappstream3
然后再update
apt-get update
参考:https://blog.youkuaiyun.com/ljttianqin/article/details/78205145?locationNum=3&fps=1
如果还出错,则返回第3步选择Ubuntu的更新源为高速淘宝,再进行第6步。
Step 4: 更新并安装 Docker-CE
sudo apt-get -y install docker-ce
安装docker-ce可能会出错:
You might want to run ‘apt-get -f install’ to correct these:
The following packages have unmet dependencies:
docker-ce : Depends: docker-ce-cli but it is not going to be installed
Depends: containerd.io but it is not going to be installed
这说明相关依赖没有安装,为此先要安装依赖,执行下面的命令:
apt-get -f install
然后再执行一遍docker-ce安装命令
apt-get -y install docker-ce
Step 5:安装完成后需要修改当前用户(我使用的用户叫zhangdiwaa)权限:
sudo usermod -aG docker xxxxx
Step 6:添加镜像
注销并重新登录,然后添加阿里云的Docker Hub镜像:
mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://obou6wyb.mirror.aliyuncs.com"]
}
EOF
systemctl daemon-reload
systemctl restart docker
Step 7: Docker-Compose的安装(此处需要翻墙进行docker-compose的安装)
Docker-compose是支持通过模板脚本批量创建Docker容器的一个组件。
然后是安装docker-compose,我们从官方网站https://github.com/docker/compose/releases
下载,运行脚本(这一行有点长换行了):
sudo curl -L https://github.com/docker/compose/releases/download/1.23.2/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
step 8: 查看docker版本
docker --version
确定docker版本是:Docker 18.09.0
确定docker-compose版本是:docker-compose 1.23.2
这一步可能出现的错误:启动fabric网络时的 bus error,尝试降低docker-compose的版本到1.23.2解决这个问题
如果docker-compose版本不对,就要卸载重新安装,卸载方式很简单,就是全删除:
rm /usr/local/bin/docker-compose
6.npm安装hyperledger composer的三个软件
npm install-g composer-cli@0.19.13 composer-playground@0.19.13 composer-rest-server@0.19.13 --unsafe-perm
(换为淘宝镜像进行下载,出现遇到 npm ERR! fetch failed https://registry.taobao.org/xxx类似的问题,看前面docker安装的step#6的daemon.json文件创建成功了没和连接网了没)
安装完成后,检查一下。 运行 composer -v ,输出 v0.19.13 就成功。这一步一定要完成
这一步可能出现的错误:如果composer -v 无法正常显示,而且有类似endpoint的问题,主要是因为npm 无法找到 compser的cli.js。可以做一个软连接解决这个问题,执行下面的语句:
ln -s YOUR_COMPOSER_PATH/composer-cli/cli.js /user/local/bin/composer
- 导入deploy.tar.gz, 解压后运行./start
将deploy.tar.gz放到虚拟机里的任意目录下,解压缩:
tar -xzvf deploy.tar.gz
进入解压后的deploy目录,先执行
docker network create pershing
后运行./start(如果出现不是下面的错误,可以试着多运行几下./start)
这一步可能出现的错误:fabric网络启动之后,在join channel时候出错,这是因为等待时间太短有些设置还在初始化,把start批处理文件里的 sleep 60 改的长一些, 例如 sleep 120 或者更长就可以了
如果正确,应当能访问
composer playground web页面,地址是(虚拟机IP:8888)
composer rest server web页面,地址是(虚拟机IP:1111)
参考文档
https://hyperledger.github.io/composer/latest/installing/installing-index.html