Hyperledger fabric1.1.0(一):基本环境整理

操作系统为:centos7。

整理包括:linux内核升级(若升级失败,可参考https://blog.csdn.net/tianshuhao521/article/details/84021064),jdk安装,docker(docker ce,docker-compose)安装,go语言环境安装。

1、Docker要求的linux内核版本最低为3.10,故需将linux内核升级到4.x,并更新本地依赖,一般执行以下命令即可:

<pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" cid="n5" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;" lang="">sudo yum update</pre>

20181109085750923.png

最后complete!表示更新成功。

2、安装jdk(我用的1.8):

(2.1)官网下载tar.gz安装包,上传至自己的目录,我这里是/home/develop/java/jdk

(2.2)进入/home/develop/java/jdk目录并解压安装包:

<pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" cid="n11" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;" lang=""> cd /home/develop/java/jdk

tar -zxvf jdk-8u181-linux-x64.tar.gz</pre>

(2.3)配置环境变量:

(2.3.1)输入命令:vim /etc/profile

(2.3.2)点击i或者o进入编辑模式

(2.3.3)在最后添加以下内容(JAVA_HOME为自己的安装目录):

<pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" cid="n16" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;" lang=""> java environment
export JAVA_HOME=/home/develop/java/jdk/jdk1.8.0_181
export CLASSPATH=.:{JAVA_HOME}/jre/lib/rt.jar:{JAVA_HOME}/lib/dt.jar:{JAVA_HOME}/lib/tools.jar export PATH=PATH:${JAVA_HOME}/bin</pre>

(2.3.4)按esc键进入命令模式,输入:wq保存并退出vim。

(2.3.5)输入命令source /etc/profile使文件生效。

(2.3.6)输入命令java -version查看jdk版本,如图:

20181109094446239.png

3、安装Docker

(3.1)如果以前安装过Docker,需要先卸载,命令如下:

<pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" cid="n23" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;" lang=""> sudo yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-selinux docker-engine-selinux docker-engine</pre>

(3.2)在线安装docker ce

(3.2.1)安装yum-utils提供的yum-config-manager,device-mapper-persistent-data和lvm2,命令如下:

<pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" cid="n26" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;" lang=""> sudo yum install -y yum-utils device-mapper-persistent-data lvm2</pre>

最后complete!

(3.2.2)设置稳定存储库:

20181109091638190.png

<pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" cid="n30" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;" lang=""> sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo</pre>

(3.2.3)可以选择性的启用edge和测试存储库,这些存储库包含在Docker中,默认是禁用的,命令如下:

<pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" cid="n32" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;" lang=""> sudo yum-config-manager --enable docker-ce-edge

sudo yum-config-manager --enable docker-ce-test</pre>

(3.2.4)以下命令为禁用edgecunc存储库:

<pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" cid="n34" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;" lang=""> sudo yum-config-manager --disable docker-ce-edge</pre>

(3.2.5)安装最新版的Docker CE:

<pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" cid="n36" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;" lang=""> sudo yum install docker-ce</pre>

20181109092258401.png

最后complete!

(3.2.6)查看docker版本,如图表示安装成功:

20181109092415265.png

<pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" cid="n41" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;" lang=""> docker --version</pre>

(3.2.7)启动docker:systemctl start docker (有些版本的启动命令为service docker start)

(3.2.8)设置docker开机自启:chkconfig docker on

(3.3)安装Docker-Compose(离线安装)

(3.3.1)若是在线安装docker-compose需要先安装curl,离线安装虽然这里用不到,但也可以安装一下,以后会有用,命令:

<pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" cid="n46" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;" lang=""> yum install curl</pre>

(3.3.2)下载最新版的docker-compose-Linux-x86_64,下载地址为https://github.com/docker/compose/releases。下载完后上传至/tmp/docker/docker-compose文件夹下,若无此文件夹,创建即可。

(3.3.3)进入文件所在目录:cd /tmp/docker/docker-compose

(3.3.4)将其移动至/usr/local/bin安装目录:mv docker-compose-Linux-x86_64 /usr/local/bin/docker-compose

(3.3.5)赋予可执行权限:chmod +x /usr/local/bin/docker-compose

(3.3.6)查看版本信息:docker-compose --version

20181109101112115.png

如图表示安装成功。

注意:若安装不成功,尝试一下以下命令:cp /usr/local/bin/docker-compose /usr/bin

4、安装Go语言环境

(4.1)下载go语言包:https://studygolang.com/dl

(4.2)将下载的语言包go1.11.linux-amd64.tar.gz上传至文件夹/tmp/docker

(4.3)进入/tmp/docker:cd /tmp/docker

(4.4)解压至/usr/local目录下:tar -C /usr/local -zxvf go1.11.linux-amd64.tar.gz

(4.5)配置go语言环境变量,参照配置jdk环境变量,在/etc/profile文件后加以下内容(别忘了使文件生效):

go环境变量 export PATH=$PATH:/usr/local/go/bin export GOPATH=/opt/gopath

(4.6)查看go版本:go version

20181109103402262.png

至此,hyperledger fabric所需的基本环境即整理完成。

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容