操作系統(tǒng)為:centos7距淫。
整理包括:linux內(nèi)核升級(若升級失敗月劈,可參考https://blog.csdn.net/tianshuhao521/article/details/84021064),jdk安裝,docker(docker ce,docker-compose)安裝,go語言環(huán)境安裝唇辨。
1、Docker要求的linux內(nèi)核版本最低為3.10能耻,故需將linux內(nèi)核升級到4.x赏枚,并更新本地依賴亡驰,一般執(zhí)行以下命令即可:
<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>
最后complete!表示更新成功。
2饿幅、安裝jdk(我用的1.8):
(2.1)官網(wǎng)下載tar.gz安裝包凡辱,上傳至自己的目錄,我這里是/home/develop/java/jdk
(2.2)進(jìn)入/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)配置環(huán)境變量:
(2.3.1)輸入命令:vim /etc/profile
(2.3.2)點擊i或者o進(jìn)入編輯模式
(2.3.3)在最后添加以下內(nèi)容(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}/lib/dt.jar:PATH:${JAVA_HOME}/bin</pre>
(2.3.4)按esc鍵進(jìn)入命令模式栗恩,輸入:wq保存并退出vim透乾。
(2.3.5)輸入命令source /etc/profile使文件生效。
(2.3.6)輸入命令java -version查看jdk版本磕秤,如圖:
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)設(shè)置穩(wěn)定存儲庫:
<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中磷瘤,默認(rèn)是禁用的,命令如下:
<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>
最后complete!
(3.2.6)查看docker版本癞己,如圖表示安裝成功:
<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)設(shè)置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文件夾下,若無此文件夾赂苗,創(chuàng)建即可愉耙。
(3.3.3)進(jìn)入文件所在目錄: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)賦予可執(zhí)行權(quán)限:chmod +x /usr/local/bin/docker-compose
(3.3.6)查看版本信息:docker-compose --version
如圖表示安裝成功。
注意:若安裝不成功拌滋,嘗試一下以下命令:cp /usr/local/bin/docker-compose /usr/bin
4朴沿、安裝Go語言環(huán)境
(4.1)下載go語言包:https://studygolang.com/dl
(4.2)將下載的語言包go1.11.linux-amd64.tar.gz上傳至文件夾/tmp/docker
(4.3)進(jìn)入/tmp/docker:cd /tmp/docker
(4.4)解壓至/usr/local目錄下:tar -C /usr/local -zxvf go1.11.linux-amd64.tar.gz
(4.5)配置go語言環(huán)境變量,參照配置jdk環(huán)境變量败砂,在/etc/profile文件后加以下內(nèi)容(別忘了使文件生效):
go環(huán)境變量 export PATH=$PATH:/usr/local/go/bin export GOPATH=/opt/gopath
(4.6)查看go版本:go version
至此赌渣,hyperledger fabric所需的基本環(huán)境即整理完成。