<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>运达&#039;s  blog &#187; fabric</title>
	<atom:link href="https://www.yunda51.com/?cat=178&#038;feed=rss2" rel="self" type="application/rss+xml" />
	<link>https://www.yunda51.com</link>
	<description>运达的博客</description>
	<lastBuildDate>Wed, 12 Nov 2025 07:58:26 +0000</lastBuildDate>
	<language>zh-CN</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=4.0.19</generator>
	<item>
		<title>MacOs下fabric2.4搭建部署</title>
		<link>https://www.yunda51.com/?p=1951</link>
		<comments>https://www.yunda51.com/?p=1951#comments</comments>
		<pubDate>Thu, 27 Oct 2022 02:53:37 +0000</pubDate>
		<dc:creator><![CDATA[运达]]></dc:creator>
				<category><![CDATA[docker]]></category>
		<category><![CDATA[fabric]]></category>
		<category><![CDATA[Go]]></category>
		<category><![CDATA[golang]]></category>
		<category><![CDATA[MacOs]]></category>

		<guid isPermaLink="false">http://www.yunda51.com/?p=1951</guid>
		<description><![CDATA[一、环境准备 安装git brew install git 安装vim brew install vim 安装<a href="https://www.yunda51.com/?p=1951" class="read-more">Continue Reading</a>]]></description>
				<content:encoded><![CDATA[<p><strong>一、环境准备</strong></p>
<pre class="wp-code-highlight prettyprint">
安装git brew install git
安装vim brew install vim
安装curl brew install curl
安装wget brew install wget
安装go1.14 以及以上版本
安装docker 17.06.2-ce 以及以上版本
安装docker-compose 1.14.0 以及以上版本
git 拉下 fabric 项目
下载docker image镜像
</pre>
<p>具体操作：<br />
1.go安装<br />
下载压缩包 无法翻墙 可以去这个网站：https://studygolang.com/dl<br />
下载好之后依次执行以下命令：</p>
<pre class="wp-code-highlight prettyprint">tar -xzf go1. 17.7 darwin -amd64.tar.gz // 解压你下载的go包
sudo mv go /usr/local    	//移动
cd /Users/liuyunda		//进入自己账户目录下
mkdir -p workspace/go/	    //建立go工作空间
cd /Users/ liuyunda /workspace/go
mkdir src bin pkg			//建立go工作空间
cd src				//存放源码的地方mkdir github.com/hyperledger 	//一定要这样建立目录，然后在这目录下拉fabric源码，不然报错
</pre>
<p><strong>路径配置：</strong><br />
执行 vim ~/.bash_profile ,然后把下面路径配置到其中,具体路径要按照你电脑的来，我这里是我自己的路径<br />
编辑完成后记得 source ~/.bash_profile<br />
<a href="http://www.yunda51.com/wp-content/uploads/2022/10/1.png"><img src="http://www.yunda51.com/wp-content/uploads/2022/10/1.png" alt="1" width="864" height="140" class="alignnone size-full wp-image-1952" /></a><br />
到此GO语言部分准备完毕</p>
<p><strong>二、docker安装：</strong><br />
mac用户 直接 brew install docker 即可，或者去docker官网下载安装<br />
mac 安装docker就自动安装了docker-compose<br />
然后 docker version 、docker-compose version 看版本<br />
像这样就没问题：<br />
<a href="http://www.yunda51.com/wp-content/uploads/2022/10/2.png"><img src="http://www.yunda51.com/wp-content/uploads/2022/10/2.png" alt="2" width="864" height="636" class="alignnone size-full wp-image-1953" /></a><br />
<strong>三、docker镜像下载：</strong></p>
<pre class="wp-code-highlight prettyprint">
cd /users/apple/privatespace/go/src/github.com/hyperledger  //进入源码存放目录
git clone https://github.com/hyperledger/fabric.git  		//下载fabric源码
cd fabric/scripts		//进入这个目录，里面有一个 bootstrap.sh 文件
sudo ./bootstrap.sh 	//执行这个文件 会下载fabric-samples 和 镜像
</pre>
<p>镜像下载有这些如图：<br />
<a href="http://www.yunda51.com/wp-content/uploads/2022/10/3.png"><img src="http://www.yunda51.com/wp-content/uploads/2022/10/3.png" alt="3" width="862" height="640" class="alignnone size-full wp-image-1954" /></a><br />
上面的工作完成后，当前目录多了一个fabric-samples文件夹，我们进去该目录下的test-network目录测试下搭建的环境是否成功：</p>
<pre class="wp-code-highlight prettyprint">
cd fabric-samples/
cd test-network/
</pre>
<p>由于国内被墙，修改go代理</p>
<pre class="wp-code-highlight prettyprint">
go env -w GOPROXY=https://goproxy.cn,direct
</pre>
<p>然后启动我们的测试网络：</p>
<pre class="wp-code-highlight prettyprint">
sudo ./network.sh up
</pre>
<p>记得加sudo保平安哦。开始了一堆代码之后出现（如下图所示，表示启动成功）:<br />
<a href="http://www.yunda51.com/wp-content/uploads/2022/10/5.png"><img src="http://www.yunda51.com/wp-content/uploads/2022/10/5.png" alt="5" width="864" height="394" class="alignnone size-full wp-image-1955" /></a><br />
同样道理：</p>
<pre class="wp-code-highlight prettyprint">
sudo ./network.sh down  // 关闭
</pre>
<p>如果出现权限不够的情况</p>
<pre class="wp-code-highlight prettyprint">
直接 cd /users/liuyunda /go/src/github.com/
然后 sudo chmod -R 777 hyperledger
</pre>
<p>到此基本没问题了</p>
<p>接下来开始跟着官网文档走<br />
一、使用fabric test network<br />
<strong>1.启动:</strong><br />
首先进入对应目录：cd fabric-samples/test-network<br />
然后启动： ./network.sh up<br />
出现这个代表成功<br />
<a href="http://www.yunda51.com/wp-content/uploads/2022/10/6.png"><img src="http://www.yunda51.com/wp-content/uploads/2022/10/6.png" alt="6" width="864" height="414" class="alignnone size-full wp-image-1956" /></a><br />
接着可以看看docker容器:docker ps -a<br />
应该有刚刚启动出来的order 和peer<br />
<a href="http://www.yunda51.com/wp-content/uploads/2022/10/7.png"><img src="http://www.yunda51.com/wp-content/uploads/2022/10/7.png" alt="7" width="864" height="478" class="alignnone size-full wp-image-1957" /></a><br />
<strong>2、创建通道:</strong><br />
./network.sh createChannel     默认名mychannel<br />
也可以自定义名字创建： ./network.sh createChannel -c channel2 自定义名字channel2<br />
<strong>3、测试:</strong><br />
首先执行：./network.sh deployCC<br />
可能会出现如下图所示的错误，别着急：<br />
<a href="http://www.yunda51.com/wp-content/uploads/2022/10/8.png"><img src="http://www.yunda51.com/wp-content/uploads/2022/10/8.png" alt="8" width="864" height="488" class="alignnone size-full wp-image-1958" /></a><br />
我们继续执行如下命令：
<pre class="wp-code-highlight prettyprint">
sudo ./network.sh deployCC -ccn basic -ccp ../asset-transfer-basic/chaincode-go -ccl go
</pre>
<p>这样就搞定了，如下图所示，表示执行成功。<br />
<a href="http://www.yunda51.com/wp-content/uploads/2022/10/9.png"><img src="http://www.yunda51.com/wp-content/uploads/2022/10/9.png" alt="9" width="864" height="484" class="alignnone size-full wp-image-1959" /></a><br />
<a href="http://www.yunda51.com/wp-content/uploads/2022/10/10.png"><img src="http://www.yunda51.com/wp-content/uploads/2022/10/10.png" alt="10" width="864" height="514" class="alignnone size-full wp-image-1960" /></a></p>
]]></content:encoded>
			<wfw:commentRss>https://www.yunda51.com/?feed=rss2&#038;p=1951</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
