我在本地尝试过“ carauction-network”示例。但是,当我使用“ startFabric.sh”文件启动网络时,由于此旧数据丢失了,它正在删除Couch数据库并再次创建Couch DB。请提出我们如何在不清除数据的情况下启动结构服务器。
fabric-dev-servers下的[startFabric.sh
(以前称为fabric-tools)不仅可以启动Fabric,还可以删除现有的Fabric容器并从Docker镜像中重新创建新的Container。这样的影响是,您将从结构中丢失了所有数据和业务网络。现在,除PeerAdmin @ hlfv1之外的所有商务网卡都将无效。
docker-compose.yml
文件所在的目录(例如/home/<user>/fabric-tools/fabric-scripts/hlfv1/composer
)docker-compose stop
到织物容器的顶部docker-compose start
从上次中断的地方重新启动。 必要
版本更新
使用Composer v0.20.x(对于Fabric 1.2,文件夹的名称/版本已更改:/home/<user>/fabric-dev-servers/fabric-scripts/hlfv12/composer
使用Composer v0.19.x(对于Fabric v1.1为旧版本,文件夹名称/版本已更改:
/home/<user>/fabric-dev-servers/fabric-scripts/hlfv11/composer
#!/bin/bash
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Exit on first error, print all commands.
set -e
Usage() {
echo ""
echo "Usage: ./startFabric.sh [-d || --dev]"
echo ""
echo "Options:"
echo -e "\t-d or --dev: (Optional) enable fabric development mode"
echo ""
echo "Example: ./startFabric.sh"
echo ""
exit 1
}
Parse_Arguments() {
while [ $# -gt 0 ]; do
case $1 in
--help)
HELPINFO=true
;;
--dev | -d)
FABRIC_DEV_MODE=true
;;
esac
shift
done
}
Parse_Arguments $@
if [ "${HELPINFO}" == "true" ]; then
Usage
fi
#Detect architecture
ARCH=`uname -m`
# Grab the current directory
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
if [ "${FABRIC_DEV_MODE}" == "true" ]; then
DOCKER_FILE="${DIR}"/composer/docker-compose-dev.yml
else
DOCKER_FILE="${DIR}"/composer/docker-compose.yml
fi
ARCH=$ARCH docker-compose -f "${DOCKER_FILE}" stop
ARCH=$ARCH docker-compose -f "${DOCKER_FILE}" up -d
# wait for Hyperledger Fabric to start
# incase of errors when running later commands, issue export FABRIC_START_TIMEOUT=<larger number>
echo "sleeping for ${FABRIC_START_TIMEOUT} seconds to wait for fabric to complete start up"
sleep ${FABRIC_START_TIMEOUT}
# Create the channel
#docker exec peer0.org1.example.com peer channel create -o orderer.example.com:7050 -c composerchannel -f /etc/hyperledger/configtx/composer-channel.tx
# Join peer0.org1.example.com to the channel.
#docker exec -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/[email protected]/msp" peer0.org1.example.com peer channel join -b composerchannel.block
if [ "${FABRIC_DEV_MODE}" == "true" ]; then
echo "Fabric Network started in chaincode development mode"
fi
#!/bin/bash
cd ./fabric-scripts/hlfv1/composer
docker-compose stop
docker-compose start
似乎微不足道,并且没有为讨论增加太多,但节省了时间。